added a unit test

This commit is contained in:
Bilal Amarni 2012-10-09 23:27:04 +02:00 committed by Fabien Potencier
parent b925b44c87
commit 77fd70bc9d
2 changed files with 25 additions and 0 deletions

View File

@ -30,6 +30,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
require_once self::$fixturesPath.'/Foo1Command.php';
require_once self::$fixturesPath.'/Foo2Command.php';
require_once self::$fixturesPath.'/Foo3Command.php';
require_once self::$fixturesPath.'/Foo4Command.php';
}
protected function normalizeLineBreaks($text)
@ -259,6 +260,19 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
$this->assertInstanceOf('\InvalidArgumentException', $e, '->find() throws an \InvalidArgumentException if command does not exist, with alternatives');
$this->assertRegExp('/Did you mean one of these/', $e->getMessage(), '->find() throws an \InvalidArgumentException if command does not exist, with alternatives');
}
$application->add(new \Foo3Command());
$application->add(new \Foo4Command());
// Subnamespace + plural
try {
$a = $application->find('foo3:');
$this->fail('->find() should throw an \InvalidArgumentException if a command is ambiguous because of a subnamespace, with alternatives');
} catch (\Exception $e) {
$this->assertInstanceOf('\InvalidArgumentException', $e);
$this->assertRegExp('/foo3:bar/', $e->getMessage());
$this->assertRegExp('/foo3:bar:toh/', $e->getMessage());
}
}
public function testFindAlternativeCommands()

View File

@ -0,0 +1,11 @@
<?php
use Symfony\Component\Console\Command\Command;
class Foo4Command extends Command
{
protected function configure()
{
$this->setName('foo3:bar:toh');
}
}