public function testExecuteDoesNotAlterCodeWhenControllerFoundIsDeclaredAbstract() { $baseUrl = 'http://nowhere.mysite.com'; $controllerClass = 'MyNamespace/ProjectBundle/Controller/DataController'; $inputMock = $this->getMock(ArrayInput::class, ['getArgument'], [], '', false); $inputMock->expects($this->once())->method('getArgument')->with($this->equalTo('url'))->will($this->returnValue($baseUrl)); $commandUtilityMock = $this->getMock(CommandUtility::class, ['exec']); $commandUtilityMock->expects($this->at(0))->method('exec')->will($this->returnCallback(function ($command, &$output, &$returnVar = 0) { $output[] = 'src/MyNamespace/ProjectBundle/Controller'; })); $commandUtilityMock->expects($this->at(1))->method('exec')->will($this->returnCallback(function ($command, &$output, &$returnVar = 0) { $output[] = 'src/MyNamespace/ProjectBundle/Controller/DataController.php'; })); $classInfoMock = $this->getMock(SymfonyClassInfo::class, ['getClassPath']); $classInfoMock->expects($this->once())->method('getClassPath')->with($this->equalTo('controller'))->will($this->returnValue($controllerClass)); $reflectionMock = $this->getMock(ReflectionClass::class, ['isAbstract'], [], '', false); $reflectionMock->expects($this->once())->method('isAbstract')->will($this->returnValue(true)); Factory::injectObject(CommandUtility::class, $commandUtilityMock); Factory::injectObject(SymfonyClassInfo::class, $classInfoMock); Factory::injectObject(ReflectionClass::class, $reflectionMock); $command = $this->getMock(GenerateJSClassesCommandMock::class, ['writeCode']); $command->expects($this->once())->method('writeCode'); $command->publicExecute($inputMock, new NullOutput()); $testUtility = new TestUtility(); $this->assertEquals('', $testUtility->getProtectedProperty($command, 'code')); }
public function testTokenReturnsBypassTokenValue() { $token = 'aaasdf'; $bypassTokenMock = $this->getMock(BypassToken::class, ['getToken']); $bypassTokenMock->expects($this->any())->method('getToken')->willReturn($token); $signupMock = $this->getMock(Signup::class, ['getBypassToken']); $signupMock->expects($this->any())->method('getBypassToken')->willReturn($bypassTokenMock); $testUtility = new TestUtility(); $notification = new SignupConfirmation($signupMock); $tokens = $testUtility->getProtectedProperty($notification, 'tokenDefinitions'); $tokenCallback = $tokens['TOKEN']; $this->assertEquals($token, $tokenCallback()); }