Skip to content

Instantly share code, notes, and snippets.

@brollypop
Last active July 7, 2016 12:20
Show Gist options
  • Save brollypop/bce905920078a11abe552220dc69aa19 to your computer and use it in GitHub Desktop.
Save brollypop/bce905920078a11abe552220dc69aa19 to your computer and use it in GitHub Desktop.
class Foo
{
/**
* @param VO $vo
*/
public function handle(VO $vo)
{
$vo->bar->doSth();
}
}
class VO
{
/** @var Bar */
public $bar;
}
class Bar
{
public function doSth()
{
echo 'sth';
}
}
class FooSpec extends ObjectBehavior
{
function it_should_call_do_sth(Bar $bar)
{
$vo = new VO();
$vo->bar = $bar;
$this->handle($vo);
$bar->doSth()->shouldHaveBeenCalled();
}
}
Test fails with:
- it should call do sth
no calls have been made that match:
Double\Bar\P90->doSth()
but expected at least one.
0 vendor/phpspec/prophecy/src/Prophecy/Prediction/CallPrediction.php:76
throw new Prophecy\Exception\Prediction\NoCallsException("No calls have been made t...")
1 vendor/phpspec/prophecy/src/Prophecy/Prophecy/MethodProphecy.php:295
Prophecy\Prediction\CallPrediction->check([array:0], [obj:Prophecy\Prophecy\ObjectProphecy], [obj:Prophecy\Prophecy\MethodProphecy])
2 vendor/phpspec/prophecy/src/Prophecy/Prophecy/MethodProphecy.php:315
Prophecy\Prophecy\MethodProphecy->shouldHave([obj:Prophecy\Prediction\CallPrediction])
3 spec/FooSpec.php:24
Prophecy\Prophecy\MethodProphecy->shouldHaveBeenCalled()
4 [internal]
spec\FooSpec->it_should_call_do_sth([obj:PhpSpec\Wrapper\Collaborator])
5 vendor/phpspec/phpspec/src/PhpSpec/Runner/ExampleRunner.php:143
ReflectionMethod->invokeArgs([obj:spec\FooSpec], [array:1])
6 vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:831
Symfony\Component\Console\Command\Command->run([obj:Symfony\Component\Console\Input\ArgvInput], [obj:Symfony\Component\Console\Output\ConsoleOutput])
7 vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:186
Symfony\Component\Console\Application->doRunCommand([obj:PhpSpec\Console\Command\RunCommand], [obj:Symfony\Component\Console\Input\ArgvInput], [obj:Symfony\Component\Console\Output\ConsoleOutput])
8 vendor/phpspec/phpspec/src/PhpSpec/Console/Application.php:97
Symfony\Component\Console\Application->doRun([obj:Symfony\Component\Console\Input\ArgvInput], [obj:Symfony\Component\Console\Output\ConsoleOutput])
9 vendor/phpspec/phpspec/bin/phpspec:26
Symfony\Component\Console\Application->run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment