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

testGetMockedClassCodeWithProtectedAbstractMethod() public method

    public function testGetMockedClassCodeWithProtectedAbstractMethod()
    {
        $this->if($generator = new testedClass())->and($parameterController1 = new mock\controller())->and($parameterController1->__construct = function () {
        })->and($parameterController1->isArray = false)->and($parameterController1->isCallable = false)->and($parameterController1->getClass = null)->and($parameterController1->getName = 'arg1')->and($parameterController1->isPassedByReference = false)->and($parameterController1->isDefaultValueAvailable = false)->and($parameterController1->isOptional = false)->and($parameter1 = new \mock\reflectionParameter(null, null))->and($parameterController2 = new mock\controller())->and($parameterController2->__construct = function () {
        })->and($parameterController2->isArray = true)->and($parameterController2->isCallable = false)->and($parameterController2->getClass = null)->and($parameterController2->getName = 'arg2')->and($parameterController2->isPassedByReference = true)->and($parameterController2->isDefaultValueAvailable = false)->and($parameterController2->isOptional = false)->and($parameter2 = new \mock\reflectionParameter(null, null))->and($publicMethodController = new mock\controller())->and($publicMethodController->__construct = function () {
        })->and($publicMethodController->getName = $publicMethodName = uniqid())->and($publicMethodController->isConstructor = false)->and($publicMethodController->getParameters = array($parameter1, $parameter2))->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($protectedMethodController = new mock\controller())->and($protectedMethodController->__construct = function () {
        })->and($protectedMethodController->getName = $protectedMethodName = uniqid())->and($protectedMethodController->isConstructor = false)->and($protectedMethodController->getParameters = array())->and($protectedMethodController->isPublic = false)->and($protectedMethodController->isProtected = true)->and($protectedMethodController->isPrivate = false)->and($protectedMethodController->isFinal = false)->and($protectedMethodController->isStatic = false)->and($protectedMethodController->isAbstract = true)->and($protectedMethodController->returnsReference = false)->and($protectedMethod = 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->getMethods = array($publicMethod, $protectedMethod))->and($classController->getConstructor = null)->and($classController->isAbstract = false)->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" . '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) === 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 ' . $publicMethodName . '($arg1, array & $arg2)' . PHP_EOL . "\t" . '{' . PHP_EOL . "\t\t" . '$arguments = array_merge(array($arg1, & $arg2), array_slice(func_get_args(), 2));' . PHP_EOL . "\t\t" . 'if (isset($this->getMockController()->' . $publicMethodName . ') === false)' . PHP_EOL . "\t\t" . '{' . PHP_EOL . "\t\t\t" . '$this->getMockController()->' . $publicMethodName . ' = function() {};' . PHP_EOL . "\t\t" . '}' . PHP_EOL . "\t\t" . '$return = $this->getMockController()->invoke(\'' . $publicMethodName . '\', $arguments);' . PHP_EOL . "\t\t" . 'return $return;' . PHP_EOL . "\t" . '}' . PHP_EOL . "\t" . 'protected function ' . $protectedMethodName . '()' . PHP_EOL . "\t" . '{' . PHP_EOL . "\t\t" . '$arguments = array_merge(array(), array_slice(func_get_args(), 0));' . PHP_EOL . "\t\t" . 'if (isset($this->getMockController()->' . $protectedMethodName . ') === false)' . PHP_EOL . "\t\t" . '{' . PHP_EOL . "\t\t\t" . '$this->getMockController()->' . $protectedMethodName . ' = function() {};' . PHP_EOL . "\t\t" . '}' . PHP_EOL . "\t\t" . '$return = $this->getMockController()->invoke(\'' . $protectedMethodName . '\', $arguments);' . PHP_EOL . "\t\t" . 'return $return;' . PHP_EOL . "\t" . '}' . PHP_EOL . "\t" . 'public static function getMockedMethods()' . PHP_EOL . "\t" . '{' . PHP_EOL . "\t\t" . 'return ' . var_export(array('__construct', $publicMethodName, $protectedMethodName), true) . ';' . PHP_EOL . "\t" . '}' . PHP_EOL . '}' . PHP_EOL . '}');
    }
generator