Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 2 |
CRAP | |
33.33% |
2 / 6 |
| InstanceMockPass | |
0.00% |
0 / 1 |
|
0.00% |
0 / 2 |
5.67 | |
33.33% |
2 / 6 |
| apply($code, MockConfiguration $config) | |
0.00% |
0 / 1 |
2.15 | |
66.67% |
2 / 3 |
|||
| appendToClass($class, $code) | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 3 |
|||
| <?php | |
| namespace Mockery\Generator\StringManipulation\Pass; | |
| use Mockery\Generator\MockConfiguration; | |
| class InstanceMockPass | |
| { | |
| const INSTANCE_MOCK_CODE = <<<MOCK | |
| protected \$_mockery_ignoreVerification = true; | |
| public function __construct() | |
| { | |
| \$this->_mockery_ignoreVerification = false; | |
| \$associatedRealObject = \Mockery::fetchMock(__CLASS__); | |
| \$directors = \$associatedRealObject->mockery_getExpectations(); | |
| foreach (\$directors as \$method=>\$director) { | |
| \$expectations = \$director->getExpectations(); | |
| // get the director method needed | |
| \$existingDirector = \$this->mockery_getExpectationsFor(\$method); | |
| if (!\$existingDirector) { | |
| \$existingDirector = new \Mockery\ExpectationDirector(\$method, \$this); | |
| \$this->mockery_setExpectationsFor(\$method, \$existingDirector); | |
| } | |
| foreach (\$expectations as \$expectation) { | |
| \$clonedExpectation = clone \$expectation; | |
| \$existingDirector->addExpectation(\$clonedExpectation); | |
| } | |
| } | |
| \Mockery::getContainer()->rememberMock(\$this); | |
| } | |
| MOCK; | |
| public function apply($code, MockConfiguration $config) | |
| { | |
| if ($config->isInstanceMock()) { | |
| $code = $this->appendToClass($code, static::INSTANCE_MOCK_CODE); | |
| } | |
| return $code; | |
| } | |
| protected function appendToClass($class, $code) | |
| { | |
| $lastBrace = strrpos($class, "}"); | |
| $class = substr($class, 0, $lastBrace) . $code . "\n }\n"; | |
| return $class; | |
| } | |
| } |