$this->assertEquals('<info>foo</info> version <comment>bar</comment>',$application->getLongVersion(),'->getLongVersion() returns the long version of the application');
$this->assertStringEqualsFile(self::$fixturesPath.'/application_gethelp.txt',str_replace(PHP_EOL,"\n",$application->getHelp()),'->setHelp() returns a help message');
$this->assertInstanceOf('\InvalidArgumentException',$e,'->get() throws an \InvalidArgumentException if the command does not exist');
$this->assertEquals('The command "foofoo" does not exist.',$e->getMessage(),'->get() throws an \InvalidArgumentException if the command does not exist');
$this->assertEquals('Symfony\Component\Console\Command\HelpCommand',get_class($command),'->get() returns the help command if --help is provided as the input');
$this->assertInstanceOf('\InvalidArgumentException',$e,'->findNamespace() throws an \InvalidArgumentException if the abbreviation is ambiguous');
$this->assertEquals('The namespace "f" is ambiguous (foo, foo1).',$e->getMessage(),'->findNamespace() throws an \InvalidArgumentException if the abbreviation is ambiguous');
$this->assertInstanceOf('\InvalidArgumentException',$e,'->findNamespace() throws an \InvalidArgumentException if no command is in the given namespace');
$this->assertEquals('There are no commands defined in the "bar" namespace.',$e->getMessage(),'->findNamespace() throws an \InvalidArgumentException if no command is in the given namespace');
$this->assertEquals('FooCommand',get_class($application->find('foo:bar')),'->find() returns a command if its name exists');
$this->assertEquals('Symfony\Component\Console\Command\HelpCommand',get_class($application->find('h')),'->find() returns a command if its name exists');
$this->assertEquals('FooCommand',get_class($application->find('f:bar')),'->find() returns a command if the abbreviation for the namespace exists');
$this->assertEquals('FooCommand',get_class($application->find('f:b')),'->find() returns a command if the abbreviation for the namespace and the command name exist');
$this->assertEquals('FooCommand',get_class($application->find('a')),'->find() returns a command if the abbreviation exists for an alias');
$this->assertInstanceOf('\InvalidArgumentException',$e,'->find() throws an \InvalidArgumentException if the abbreviation is ambiguous for a namespace');
$this->assertRegExp('/Command "f" is not defined./',$e->getMessage(),'->find() throws an \InvalidArgumentException if the abbreviation is ambiguous for a namespace');
$this->assertInstanceOf('\InvalidArgumentException',$e,'->find() throws an \InvalidArgumentException if the abbreviation is ambiguous for an alias');
$this->assertEquals('Command "a" is ambiguous (afoobar, afoobar1 and 1 more).',$e->getMessage(),'->find() throws an \InvalidArgumentException if the abbreviation is ambiguous for an alias');
$this->assertInstanceOf('\InvalidArgumentException',$e,'->find() throws an \InvalidArgumentException if the abbreviation is ambiguous for a command');
$this->assertEquals('Command "foo:b" is ambiguous (foo:bar, foo:bar1).',$e->getMessage(),'->find() throws an \InvalidArgumentException if the abbreviation is ambiguous for a command');
$this->fail('->find() throws an \InvalidArgumentException if command does not exist');
}catch(\Exception$e){
$this->assertInstanceOf('\InvalidArgumentException',$e,'->find() throws an \InvalidArgumentException if command does not exist');
$this->assertEquals(sprintf('Command "%s" is not defined.',$commandName),$e->getMessage(),'->find() throws an \InvalidArgumentException if command does not exist, without alternatives');
}
try{
$application->find($commandName='foo');
$this->fail('->find() throws an \InvalidArgumentException if command does not exist');
}catch(\Exception$e){
$this->assertInstanceOf('\InvalidArgumentException',$e,'->find() throws an \InvalidArgumentException if command does not exist');
$this->assertRegExp(sprintf('/Command "%s" is not defined./',$commandName),$e->getMessage(),'->find() throws an \InvalidArgumentException if command does not exist, with alternatives');
$this->assertRegExp('/foo:bar/',$e->getMessage(),'->find() throws an \InvalidArgumentException if command does not exist, with alternative : "foo:bar"');
$this->assertRegExp('/foo1:bar/',$e->getMessage(),'->find() throws an \InvalidArgumentException if command does not exist, with alternative : "foo1:bar"');
$this->assertRegExp('/foo:bar1/',$e->getMessage(),'->find() throws an \InvalidArgumentException if command does not exist, with alternative : "foo:bar1"');
}
// Test if "foo1" command throw an "\InvalidArgumentException" and does not contain
// "foo:bar" as alternative because "foo1" is too far from "foo:bar"
try{
$application->find($commandName='foo1');
$this->fail('->find() throws an \InvalidArgumentException if command does not exist');
}catch(\Exception$e){
$this->assertInstanceOf('\InvalidArgumentException',$e,'->find() throws an \InvalidArgumentException if command does not exist');
$this->assertRegExp(sprintf('/Command "%s" is not defined./',$commandName),$e->getMessage(),'->find() throws an \InvalidArgumentException if command does not exist, with alternatives');
$this->assertFalse(strpos($e->getMessage(),'foo:bar'),'->find() throws an \InvalidArgumentException if command does not exist, without "foo:bar" alternative');
$this->assertStringEqualsFile(self::$fixturesPath.'/application_astext1.txt',str_replace(PHP_EOL,"\n",$application->asText()),'->asText() returns a text representation of the application');
$this->assertStringEqualsFile(self::$fixturesPath.'/application_astext2.txt',str_replace(PHP_EOL,"\n",$application->asText('foo')),'->asText() returns a text representation of the application');
$this->assertXmlStringEqualsXmlFile(self::$fixturesPath.'/application_asxml1.txt',$application->asXml(),'->asXml() returns an XML representation of the application');
$this->assertXmlStringEqualsXmlFile(self::$fixturesPath.'/application_asxml2.txt',$application->asXml('foo'),'->asXml() returns an XML representation of the application');
$this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception1.txt',$this->normalize($tester->getDisplay()),'->renderException() renders a pretty exception');
$this->assertRegExp('/Exception trace/',$this->normalize($tester->getDisplay()),'->renderException() renders a pretty exception with a stack trace when verbosity is verbose');
$this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception2.txt',$this->normalize($tester->getDisplay()),'->renderException() renders the command synopsis when an exception occurs in the context of a command');
$this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception3.txt',$this->normalize($tester->getDisplay()),'->renderException() renders a pretty exceptions with previous exceptions');
$this->assertEquals('Symfony\Component\Console\Input\ArgvInput',get_class($command->input),'->run() creates an ArgvInput by default if none is given');
$this->assertEquals('Symfony\Component\Console\Output\ConsoleOutput',get_class($command->output),'->run() creates a ConsoleOutput by default if none is given');
$this->assertStringEqualsFile(self::$fixturesPath.'/application_run1.txt',$this->normalize($tester->getDisplay()),'->run() runs the list command if no argument is passed');
$this->assertStringEqualsFile(self::$fixturesPath.'/application_run2.txt',$this->normalize($tester->getDisplay()),'->run() runs the help command if --help is passed');
$this->assertStringEqualsFile(self::$fixturesPath.'/application_run2.txt',$this->normalize($tester->getDisplay()),'->run() runs the help command if -h is passed');
$this->assertStringEqualsFile(self::$fixturesPath.'/application_run3.txt',$this->normalize($tester->getDisplay()),'->run() displays the help if --help is passed');
$this->assertStringEqualsFile(self::$fixturesPath.'/application_run3.txt',$this->normalize($tester->getDisplay()),'->run() displays the help if -h is passed');
$this->assertStringEqualsFile(self::$fixturesPath.'/application_run4.txt',$this->normalize($tester->getDisplay()),'->run() displays the program version if --version is passed');
$this->assertStringEqualsFile(self::$fixturesPath.'/application_run4.txt',$this->normalize($tester->getDisplay()),'->run() displays the program version if -v is passed');