added a unit test
This commit is contained in:
parent
b925b44c87
commit
77fd70bc9d
@ -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()
|
||||
|
11
src/Symfony/Component/Console/Tests/Fixtures/Foo4Command.php
Normal file
11
src/Symfony/Component/Console/Tests/Fixtures/Foo4Command.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
|
||||
class Foo4Command extends Command
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('foo3:bar:toh');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user