Esempio n. 1
0
 public function testAddCommand()
 {
     $application = new Application();
     $application->addCommand($foo = new \FooCommand());
     $commands = $application->getCommands();
     $this->assertEquals($foo, $commands['foo:bar'], '->addCommand() registers a command');
     $application = new Application();
     $application->addCommands(array($foo = new \FooCommand(), $foo1 = new \Foo1Command()));
     $commands = $application->getCommands();
     $this->assertEquals(array($foo, $foo1), array($commands['foo:bar'], $commands['foo:bar1']), '->addCommands() registers an array of commands');
 }
Esempio n. 2
0
// ->register()
$t->diag('->register()');
$application = new Application();
$command = $application->register('foo');
$t->is($command->getName(), 'foo', '->register() regiters a new command');

// ->addCommand() ->addCommands()
$t->diag('->addCommand() ->addCommands()');
$application = new Application();
$application->addCommand($foo = new FooCommand());
$commands = $application->getCommands();
$t->is($commands['foo:bar'], $foo, '->addCommand() registers a command');

$application = new Application();
$application->addCommands(array($foo = new FooCommand(), $foo1 = new Foo1Command()));
$commands = $application->getCommands();
$t->is(array($commands['foo:bar'], $commands['foo:bar1']), array($foo, $foo1), '->addCommands() registers an array of commands');

// ->hasCommand() ->getCommand()
$t->diag('->hasCommand() ->getCommand()');
$application = new Application();
$t->ok($application->hasCommand('list'), '->hasCommand() returns true if a named command is registered');
$t->ok(!$application->hasCommand('afoobar'), '->hasCommand() returns false if a named command is not registered');

$application->addCommand($foo = new FooCommand());
$t->ok($application->hasCommand('afoobar'), '->hasCommand() returns true if an alias is registered');
$t->is($application->getCommand('foo:bar'), $foo, '->getCommand() returns a command by name');
$t->is($application->getCommand('afoobar'), $foo, '->getCommand() returns a command by alias');

try
{