/** * @test * @author Sebastian Kurfürst <*****@*****.**> */ public function callActionMethodPassesDefaultValuesAsArguments() { $mockRequest = $this->getMock('Tx_Extbase_MVC_RequestInterface', array(), array(), '', FALSE); $mockResponse = $this->getMock('Tx_Extbase_MVC_ResponseInterface', array(), array(), '', FALSE); $arguments = new ArrayObject(); $optionalArgument = new Tx_Extbase_MVC_Controller_Argument('name1', 'Text'); $optionalArgument->setDefaultValue('Default value'); $arguments[] = $optionalArgument; $mockArgumentMappingResults = $this->getMock('Tx_Extbase_Property_MappingResults', array(), array(), '', FALSE); $mockArgumentMappingResults->expects($this->once())->method('hasErrors')->will($this->returnValue(FALSE)); $mockController = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_MVC_Controller_ActionController'), array('fooAction', 'initializeAction'), array(), '', FALSE); $mockController->expects($this->once())->method('fooAction')->with('Default value'); $mockController->_set('request', $mockRequest); $mockController->_set('response', $mockResponse); $mockController->_set('arguments', $arguments); $mockController->_set('actionMethodName', 'fooAction'); $mockController->_set('argumentsMappingResults', $mockArgumentMappingResults); $mockController->_call('callActionMethod'); }
/** * @test */ public function settingDefaultValueReallySetsDefaultValue() { $argument = new Tx_Extbase_MVC_Controller_Argument('dummy', 'Text'); $argument->setDefaultValue(42); $this->assertEquals(42, $argument->getValue(), 'The default value was not stored in the Argument.'); }
/** * Creates a new argument. This is a replacement for $this->objectFactory->create() of FLOW3. * * @param string $name Name of the argument * @param string $dataType Name of one of the built-in data types * @return Tx_Extbase_MVC_Controller_Argument The created argument */ protected function createArgument($name, $dataType) { $argument = new Tx_Extbase_MVC_Controller_Argument($name, $dataType); $argument->injectPersistenceManager($this->persistenceManager); $argument->injectQueryFactory($this->queryFactory); $argument->initializeObject(); return $argument; }