You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following code will cause an exception because function bar has defined a custom return type.
Example class: Foo.php
class Foo {
function bar($value): Swift_Message
{
return new Swift_Message();
}
}
Unit Test: FooTest.php
The below code causes the following exception: InvalidArgumentException: Return values of type 'Swift_Message' must be explicitly specified.
public function setUp()
{
$message = Phony::mock(Swift_Message::class);
$foo = Phony::mock(Foo::class);
$foo->bar('x')->returns($message->mock()); // Causes InvalidArgumentException
}
But adding this line (bar method without parameters) will make the above code work.
public function setUp()
{
$message = Phony::mock(Swift_Message::class);
$foo = Phony::mock(Foo::class);
$foo->bar->returns($message->mock()); // stubbing will now work
$foo->bar('x')->returns($message->mock()); // no longer causes exception
}
The following code will cause an exception because function bar has defined a custom return type.
Example class: Foo.php
Unit Test: FooTest.php
The below code causes the following exception:
InvalidArgumentException: Return values of type 'Swift_Message' must be explicitly specified.But adding this line (bar method without parameters) will make the above code work.