public addNewArgument ( string $name, string $dataType = 'string', boolean $isRequired = true, mixed $defaultValue = null ) : |
||
$name | string | Name of the argument |
$dataType | string | Name of one of the built-in data types |
$isRequired | boolean | TRUE if this argument should be marked as required |
$defaultValue | mixed | Default value of the argument. Only makes sense if $isRequired==FALSE |
return | The new argument |
public function addNewArgument($name, $dataType = 'string', $isRequired = true, $defaultValue = null)
{
$argument = new Argument($name, $dataType);
$argument->setRequired($isRequired);
$argument->setDefaultValue($defaultValue);
$this->addArgument($argument);
return $argument;
}
/** * @test */ public function processRequestResetsCommandMethodArguments() { $mockRequest = $this->getMockBuilder(Request::class)->disableOriginalConstructor()->getMock(); $mockResponse = $this->getMockBuilder(Mvc\ResponseInterface::class)->getMock(); $mockArguments = new Arguments(); $mockArguments->addNewArgument('foo'); $this->inject($this->commandController, 'arguments', $mockArguments); $this->assertCount(1, $this->commandController->_get('arguments')); $this->commandController->processRequest($mockRequest, $mockResponse); $this->assertCount(0, $this->commandController->_get('arguments')); }