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

testGetMockedClassCodeForClassWithVariadicArgumentsInConstruct() public method

    public function testGetMockedClassCodeForClassWithVariadicArgumentsInConstruct()
    {
        $this->if($generator = new testedClass())->and($reflectionParameterController = new mock\controller())->and($reflectionParameterController->__construct = function () {
        })->and($reflectionParameterController->isArray = false)->and($reflectionParameterController->isCallable = false)->and($reflectionParameterController->getName = 'variadic')->and($reflectionParameterController->isPassedByReference = false)->and($reflectionParameterController->isDefaultValueAvailable = false)->and($reflectionParameterController->isOptional = false)->and($reflectionParameterController->isVariadic = true)->and($reflectionParameterController->getClass = null)->and($reflectionParameter = new \mock\reflectionParameter(null, null))->and($reflectionMethodController = new mock\controller())->and($reflectionMethodController->__construct = function () {
        })->and($reflectionMethodController->getName = '__construct')->and($reflectionMethodController->isConstructor = true)->and($reflectionMethodController->getParameters = array($reflectionParameter))->and($reflectionMethodController->isPublic = true)->and($reflectionMethodController->isProtected = false)->and($reflectionMethodController->isPrivate = false)->and($reflectionMethodController->isFinal = false)->and($reflectionMethodController->isStatic = false)->and($reflectionMethodController->isAbstract = false)->and($reflectionMethodController->returnsReference = false)->and($reflectionMethod = new \mock\reflectionMethod(null, null))->and($reflectionClassController = new mock\controller())->and($reflectionClassController->__construct = function () {
        })->and($reflectionClassController->getName = function () use(&$realClass) {
            return $realClass;
        })->and($reflectionClassController->isFinal = false)->and($reflectionClassController->isInterface = false)->and($reflectionClassController->getMethods = array($reflectionMethod))->and($reflectionClassController->getConstructor = $reflectionMethod)->and($reflectionClassController->isAbstract = false)->and($reflectionClass = new \mock\reflectionClass(null))->and($generator->setReflectionClassFactory(function () use($reflectionClass) {
            return $reflectionClass;
        }))->and($adapter = new atoum\test\adapter())->and($adapter->class_exists = function ($class) use(&$realClass) {
            return $class == '\\' . $realClass;
        })->and($generator->setAdapter($adapter))->then->string($generator->getMockedClassCode($realClass = uniqid()))->isEqualTo('namespace mock {' . PHP_EOL . 'final class ' . $realClass . ' extends \\' . $realClass . ' implements \\mageekguy\\atoum\\mock\\aggregator' . PHP_EOL . '{' . PHP_EOL . $this->getMockControllerMethods() . "\t" . 'public function __construct(... $variadic)' . PHP_EOL . "\t" . '{' . PHP_EOL . "\t\t" . '$arguments = func_get_args();' . PHP_EOL . "\t\t" . '$mockController = \\mageekguy\\atoum\\mock\\controller::get();' . 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\', $arguments);' . PHP_EOL . "\t\t" . '}' . PHP_EOL . "\t\t" . 'else' . PHP_EOL . "\t\t" . '{' . PHP_EOL . "\t\t\t" . '$this->getMockController()->addCall(\'__construct\', $arguments);' . PHP_EOL . "\t\t\t" . 'call_user_func_array(\'parent::__construct\', $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'), true) . ';' . PHP_EOL . "\t" . '}' . PHP_EOL . '}' . PHP_EOL . '}');
    }
generator