diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index fe93ce9843..a8bb2ec3d0 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -580,6 +580,10 @@ class Application return $this->get($abbrevs[$searchName][0]); } + if (isset($abbrevs[$searchName]) && in_array($searchName, $abbrevs[$searchName])) { + return $this->get($searchName); + } + if (isset($abbrevs[$searchName]) && count($abbrevs[$searchName]) > 1) { $suggestions = $this->getAbbreviationSuggestions($abbrevs[$searchName]); diff --git a/src/Symfony/Component/Console/Tests/ApplicationTest.php b/src/Symfony/Component/Console/Tests/ApplicationTest.php index e106257a87..2d4f6c43be 100644 --- a/src/Symfony/Component/Console/Tests/ApplicationTest.php +++ b/src/Symfony/Component/Console/Tests/ApplicationTest.php @@ -219,6 +219,16 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase } } + public function testFindCommandEqualNamespace() + { + $application = new Application(); + $application->add(new \Foo3Command()); + $application->add(new \Foo4Command()); + + $this->assertInstanceOf('Foo3Command', $application->find('foo3:bar'), '->find() returns the good command even if a namespace has same name'); + $this->assertInstanceOf('Foo4Command', $application->find('foo3:bar:toh'), '->find() returns a command even if its namespace equals another command name'); + } + public function testFindAlternativeExceptionMessage() { $application = new Application();