Created
July 3, 2012 21:59
-
-
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
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
// 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