Skip to content

Instantly share code, notes, and snippets.

@wodor
Last active February 2, 2019 21:39
Show Gist options
  • Save wodor/8089099 to your computer and use it in GitHub Desktop.
Save wodor/8089099 to your computer and use it in GitHub Desktop.
function testRepositoryUsage()
{
$id = 42;
$value = array('results');
$repo = $this->getMock('Repository\FindsStuffInCity');
$repo->expects($this->once())
->method('findByCityId')
->with($id)
->will($this->returnValue($value));
$sut = new Service($repo);
$this->assertEquals($value, $sut->getResultForCityId($id));
}
function it_uses_stuffrepository_to_find_stuff(FindsStuffInCity $repository)
{
$id = 42;
$value = array('result');
$repository->findByCityId($id)
->shouldBeCalled()
->willReturn($value);
$this->getResultForCityId($id)
->shouldBeEqualTo($value);
}
@ezra-obiwale
Copy link

A simple yet brilliant comparison.

@teddy-hoo
Copy link

so what is the difference in design?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment