$this->assertTrue($command->getDefinition()->hasArgument('foo'),'->setDefinition() also takes an array of InputArguments and InputOptions as an argument');
$this->assertTrue($command->getDefinition()->hasOption('bar'),'->setDefinition() also takes an array of InputArguments and InputOptions as an argument');
$command->setDefinition(newInputDefinition());
}
publicfunctiontestAddArgument()
{
$command=new\TestCommand();
$ret=$command->addArgument('foo');
$this->assertEquals($command,$ret,'->addArgument() implements a fluent interface');
$this->assertTrue($command->getDefinition()->hasArgument('foo'),'->addArgument() adds an argument to the command');
}
publicfunctiontestAddOption()
{
$command=new\TestCommand();
$ret=$command->addOption('foo');
$this->assertEquals($command,$ret,'->addOption() implements a fluent interface');
$this->assertTrue($command->getDefinition()->hasOption('foo'),'->addOption() adds an option to the command');
}
publicfunctiontestGetNamespaceGetNameSetName()
{
$command=new\TestCommand();
$this->assertEquals('namespace:name',$command->getName(),'->getName() returns the command name');
$command->setName('foo');
$this->assertEquals('foo',$command->getName(),'->setName() sets the command name');
$ret=$command->setName('foobar:bar');
$this->assertEquals($command,$ret,'->setName() implements a fluent interface');
$this->assertEquals('foobar:bar',$command->getName(),'->setName() sets the command name');
}
/**
*@dataProviderprovideInvalidCommandNames
*/
publicfunctiontestInvalidCommandNames($name)
{
$this->setExpectedException('InvalidArgumentException',sprintf('Command name "%s" is invalid.',$name));
$command=new\TestCommand();
$command->setName($name);
}
publicfunctionprovideInvalidCommandNames()
{
returnarray(
array(''),
array('foo:'),
);
}
publicfunctiontestGetSetDescription()
{
$command=new\TestCommand();
$this->assertEquals('description',$command->getDescription(),'->getDescription() returns the description');
$ret=$command->setDescription('description1');
$this->assertEquals($command,$ret,'->setDescription() implements a fluent interface');
$this->assertEquals('description1',$command->getDescription(),'->setDescription() sets the description');
}
publicfunctiontestGetSetHelp()
{
$command=new\TestCommand();
$this->assertEquals('help',$command->getHelp(),'->getHelp() returns the help');
$ret=$command->setHelp('help1');
$this->assertEquals($command,$ret,'->setHelp() implements a fluent interface');
$this->assertEquals('help1',$command->getHelp(),'->setHelp() sets the help');
$this->assertTrue($command->getDefinition()->hasArgument('foo'),'->mergeApplicationDefinition() merges the application arguments and the command arguments');
$this->assertTrue($command->getDefinition()->hasArgument('bar'),'->mergeApplicationDefinition() merges the application arguments and the command arguments');
$this->assertTrue($command->getDefinition()->hasOption('foo'),'->mergeApplicationDefinition() merges the application options and the command options');
$this->assertTrue($command->getDefinition()->hasOption('bar'),'->mergeApplicationDefinition() merges the application options and the command options');
$m->invoke($command);
$this->assertEquals(3,$command->getDefinition()->getArgumentCount(),'->mergeApplicationDefinition() does not try to merge twice the application arguments and options');
$this->assertTrue($command->getDefinition()->hasOption('bar'),'->mergeApplicationDefinition(false) merges the application and the command options');
$this->assertFalse($command->getDefinition()->hasArgument('foo'),'->mergeApplicationDefinition(false) does not merge the application arguments');
$m->invoke($command,true);
$this->assertTrue($command->getDefinition()->hasArgument('foo'),'->mergeApplicationDefinition(true) merges the application arguments and the command arguments');
$m->invoke($command);
$this->assertEquals(2,$command->getDefinition()->getArgumentCount(),'->mergeApplicationDefinition() does not try to merge twice the application arguments');
$this->assertEquals('interact called'.PHP_EOL.'execute called'.PHP_EOL,$tester->getDisplay(),'->run() calls the interact() method if the input is interactive');
$this->assertXmlStringEqualsXmlFile(self::$fixturesPath.'/command_asxml.txt',$command->asXml(),'->asXml() returns an XML representation of the command');