Skip to content

Commit

Permalink
[Console] find command even if its name is a namespace too (closes #7860
Browse files Browse the repository at this point in the history
)
  • Loading branch information
pborreli committed Apr 26, 2013
1 parent 609b5ff commit be34917
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Symfony/Component/Console/Application.php
Expand Up @@ -580,6 +580,10 @@ public function find($name)
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]);

Expand Down
10 changes: 10 additions & 0 deletions src/Symfony/Component/Console/Tests/ApplicationTest.php
Expand Up @@ -219,6 +219,16 @@ public function testFind()
}
}

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();
Expand Down

0 comments on commit be34917

Please sign in to comment.