Answer the question
In order to leave comments, you need to log in
How to properly test interfaces using PHPUnit?
There is a certain library, it has a class:
class Foo
{
public static function bar(MyInterface $example)
{
//some actions
return 1;
}
}
class FooTest extends \PHPUnit_Framework_TestCase
{
public function testFoo()
{
//...create $object for testing
self::assertEquals(1, Foo::bar($object));
}
}
Answer the question
In order to leave comments, you need to log in
Strange, it should work
. This is how a class is created with an empty implementation of the interface, i.e. There can be no type mismatch. The only problem that may arise is methods that by default do not return anything, for example, you have a chain of calls like this in your code:
$obj->setId(1)
->setName("name");
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question