mageekguy\atoum\tests\units\mock\generator::testGetMockedClassCodeForAbstractClassWithConstructorInInterface PHP Метод

testGetMockedClassCodeForAbstractClassWithConstructorInInterface() публичный Метод

    public function testGetMockedClassCodeForAbstractClassWithConstructorInInterface()
    {
        $this->if($generator = new testedClass())->and($publicMethodController = new mock\controller())->and($publicMethodController->__construct = function () {
        })->and($publicMethodController->getName = '__construct')->and($publicMethodController->isConstructor = true)->and($publicMethodController->getParameters = array())->and($publicMethodController->isPublic = true)->and($publicMethodController->isProtected = false)->and($publicMethodController->isPrivate = false)->and($publicMethodController->isFinal = false)->and($publicMethodController->isStatic = false)->and($publicMethodController->isAbstract = true)->and($publicMethodController->returnsReference = false)->and($publicMethod = new \mock\reflectionMethod(null, null))->and($classController = new mock\controller())->and($classController->__construct = function () {
        })->and($classController->getName = $className = uniqid())->and($classController->isFinal = false)->and($classController->isInterface = false)->and($classController->isAbstract = true)->and($classController->getMethods = array($publicMethod))->and($classController->getConstructor = $publicMethod)->and($class = new \mock\reflectionClass(null))->and($generator->setReflectionClassFactory(function () use($class) {
            return $class;
        }))->and($adapter = new atoum\test\adapter())->and($adapter->class_exists = function ($class) use($className) {
            return $class == '\\' . $className;
        })->and($generator->setAdapter($adapter))->then->string($generator->getMockedClassCode($className))->isEqualTo('namespace mock {' . PHP_EOL . 'final class ' . $className . ' extends \\' . $className . ' 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" . '$arguments = array_merge(array(), array_slice(func_get_args(), 0, -1));' . 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" . 'if (isset($this->getMockController()->__construct) === false)' . PHP_EOL . "\t\t" . '{' . PHP_EOL . "\t\t\t" . '$this->getMockController()->__construct = function() {};' . PHP_EOL . "\t\t" . '}' . PHP_EOL . "\t\t" . '$this->getMockController()->invoke(\'__construct\', $arguments);' . 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('__construct', '__call'), true) . ';' . PHP_EOL . "\t" . '}' . PHP_EOL . '}' . PHP_EOL . '}');
    }
generator