$application =
new Application();
$application->
addCommands([$foo =
new \
FooCommand(),
$foo1 =
new \
Foo1Command()]);
$commands =
$application->
all();
$this->
assertEquals([$foo,
$foo1],
[$commands['foo:bar'
],
$commands['foo:bar1'
]], '->addCommands() registers an array of commands'
);
} public function testAddCommandWithEmptyConstructor() { $this->
expectException(\LogicException::
class);
$this->
expectExceptionMessage('Command class "Foo5Command" is not correctly initialized. You probably forgot to call the parent constructor.'
);
$application =
new Application();
$application->
add(new \
Foo5Command());
} public function testHasGet() { $application =
new Application();
$this->
assertTrue($application->
has('list'
), '->has() returns true if a named command is registered'
);
$this->
assertFalse($application->
has('afoobar'
), '->has() returns false if a named command is not registered'
);
$application->
add($foo =
new \
FooCommand());
$this->
assertTrue($application->
has('afoobar'
), '->has() returns true if an alias is registered'
);
$this->
assertEquals($foo,
$application->
get('foo:bar'
), '->get() returns a command by name'
);