Created
November 18, 2015 06:34
-
-
Save and1truong/369b929fd1d67753b4b5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use PHPUnit_Framework_MockObject_MockObject as Mock; | |
class FooTest extends PHPUnit_Framework_Testcase { | |
public function getFoo() { | |
$service = $this->getService(function(Mock $service) { | |
$service->expects($this->once())->method('foo'); | |
}); | |
$service->doFoo(); | |
} | |
public function getBar() { | |
$service = $this->getService(function(Mock $service) { | |
$service->expects($this->at(2))->method('foo'); | |
}); | |
$this->doBar(); | |
} | |
public function getService(callable $callback) { | |
$service = $this->getMock(MyService::class); | |
$callback($service); | |
return $service; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment