$application =
new Application();
$application->
add(new \
FooCommand());
$application->
add(new \
Foo1Command());
$application->
add(new \
Foo2Command());
try { $application->
find($commandName = 'Unknown command'
);
$this->
fail('->find() throws a CommandNotFoundException if command does not exist'
);
} catch (\Exception
$e) { $this->
assertInstanceOf(CommandNotFoundException::
class,
$e, '->find() throws a CommandNotFoundException if command does not exist'
);
$this->
assertSame([],
$e->
getAlternatives());
$this->
assertEquals(sprintf('Command "%s" is not defined.',
$commandName),
$e->
getMessage(), '->find() throws a CommandNotFoundException if command does not exist, without alternatives'
);
} // Test if "bar1" command throw a "CommandNotFoundException" and does not contain
// "foo:bar" as alternative because "bar1" is too far from "foo:bar"
try { $application->
find($commandName = 'bar1'
);
$this->
fail('->find() throws a CommandNotFoundException if command does not exist'
);
} catch (\Exception
$e) { $this->
assertInstanceOf(CommandNotFoundException::
class,
$e, '->find() throws a CommandNotFoundException if command does not exist'
);
$this->
assertSame(['afoobar1', 'foo:bar1'
],
$e->
getAlternatives());