mageekguy\atoum\tests\units\mock\generator::testGetMockedClassCodeForUnknownClass PHP Method

testGetMockedClassCodeForUnknownClass() public method

    public function testGetMockedClassCodeForUnknownClass()
    {
        $this->if($generator = new testedClass())->and($adapter = new atoum\test\adapter())->and($adapter->class_exists = false)->and($generator->setAdapter($adapter))->then->string($generator->getMockedClassCode($unknownClass = uniqid()))->isEqualTo('namespace mock {' . PHP_EOL . 'final class ' . $unknownClass . ' implements \\mageekguy\\atoum\\mock\\aggregator' . PHP_EOL . '{' . PHP_EOL . $this->getMockControllerMethods() . "\t" . 'public function __construct(\\mageekguy\\atoum\\mock\\controller $mockController = null)' . PHP_EOL . "\t" . '{' . PHP_EOL . "\t\t" . 'if ($mockController === null)' . PHP_EOL . "\t\t" . '{' . PHP_EOL . "\t\t\t" . '$mockController = \\mageekguy\\atoum\\mock\\controller::get();' . PHP_EOL . "\t\t" . '}' . PHP_EOL . "\t\t" . 'if ($mockController !== null)' . PHP_EOL . "\t\t" . '{' . PHP_EOL . "\t\t\t" . '$this->setMockController($mockController);' . PHP_EOL . "\t\t" . '}' . PHP_EOL . "\t\t" . '$this->getMockController()->disableMethodChecking();' . PHP_EOL . "\t\t" . 'if (isset($this->getMockController()->__construct) === true)' . PHP_EOL . "\t\t" . '{' . PHP_EOL . "\t\t\t" . '$this->getMockController()->invoke(\'__construct\', func_get_args());' . PHP_EOL . "\t\t" . '}' . PHP_EOL . "\t" . '}' . PHP_EOL . "\t" . 'public function __call($methodName, $arguments)' . PHP_EOL . "\t" . '{' . PHP_EOL . "\t\t" . 'if (isset($this->getMockController()->{$methodName}) === true)' . PHP_EOL . "\t\t" . '{' . PHP_EOL . "\t\t\t" . '$return = $this->getMockController()->invoke($methodName, $arguments);' . PHP_EOL . "\t\t\t" . 'return $return;' . PHP_EOL . "\t\t" . '}' . PHP_EOL . "\t\t" . 'else' . PHP_EOL . "\t\t" . '{' . PHP_EOL . "\t\t\t" . '$this->getMockController()->addCall($methodName, $arguments);' . PHP_EOL . "\t\t" . '}' . PHP_EOL . "\t" . '}' . PHP_EOL . "\t" . 'public static function getMockedMethods()' . PHP_EOL . "\t" . '{' . PHP_EOL . "\t\t" . 'return ' . var_export(array('__call'), true) . ';' . PHP_EOL . "\t" . '}' . PHP_EOL . '}' . PHP_EOL . '}')->if($unknownClass = __NAMESPACE__ . '\\dummy')->and($generator->generate($unknownClass))->and($mockedUnknownClass = '\\mock\\' . $unknownClass)->and($dummy = new $mockedUnknownClass())->and($dummyController = new atoum\mock\controller())->and($dummyController->notControlNextNewMock())->and($calls = new \mock\mageekguy\atoum\test\adapter\calls())->and($dummyController->setCalls($calls))->and($dummyController->control($dummy))->then->when(function () use($dummy) {
            $dummy->bar();
        })->mock($calls)->call('addCall')->withArguments(new atoum\test\adapter\call('bar', array(), new decorators\addClass($dummy)))->once()->when(function () use($dummy) {
            $dummy->bar();
        })->mock($calls)->call('addCall')->withArguments(new atoum\test\adapter\call('bar', array(), new decorators\addClass($dummy)))->twice();
    }
generator