Skip to content

Instantly share code, notes, and snippets.

@guiled
Created July 3, 2012 21:59
Show Gist options
  • Save guiled/3043637 to your computer and use it in GitHub Desktop.
Save guiled/3043637 to your computer and use it in GitHub Desktop.
atoum and mock power! how to pass the same mocked method to different mocked classes
// code sample to instantiate a mock with the same method mocks from an other mocked class
function testMultiMock() {
$this
->if($test = new \mock\author\project\class)
->and($controller = $test->getMockController())
->and($test->getMockController()->instantiate = function () use ($controller) {
$instance = new \mock\author\project\class;
$instance->setMockController($controller);
return $instance;
})
->then
->assert
->object($obj = $test->instantiate())
->isInstanceOf('\author\project\class')
->object($obj->instantiate())
->isInstanceOf('\author\project\class');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment