public function testSetApplication() { $application = new Application(); $command = new \TestCommand(); $command->setApplication($application); $this->assertEquals($application, $command->getApplication(), '->setApplication() sets the current application'); }
{ $command = new Command(); $t->fail('__construct() throws a \LogicException if the name is null'); } catch (\LogicException $e) { $t->pass('__construct() throws a \LogicException if the name is null'); } $command = new Command('foo:bar'); $t->is($command->getFullName(), 'foo:bar', '__construct() takes the command name as its first argument'); // ->setApplication() $t->diag('->setApplication()'); $command = new TestCommand(); $command->setApplication($application); $t->is($command->getApplication(), $application, '->setApplication() sets the current application'); // ->setDefinition() ->getDefinition() $t->diag('->setDefinition() ->getDefinition()'); $ret = $command->setDefinition($definition = new InputDefinition()); $t->is($ret, $command, '->setDefinition() implements a fluent interface'); $t->is($command->getDefinition(), $definition, '->setDefinition() sets the current InputDefinition instance'); $command->setDefinition(array(new InputArgument('foo'), new InputOption('bar'))); $t->ok($command->getDefinition()->hasArgument('foo'), '->setDefinition() also takes an array of InputArguments and InputOptions as an argument'); $t->ok($command->getDefinition()->hasOption('bar'), '->setDefinition() also takes an array of InputArguments and InputOptions as an argument'); $command->setDefinition(new InputDefinition()); // ->addArgument() $t->diag('->addArgument()'); $ret = $command->addArgument('foo'); $t->is($ret, $command, '->addArgument() implements a fluent interface');