From d1f66073ca1a0a399c813fdff4210b5f88bc8e68 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sat, 14 Apr 2012 23:53:12 +0200 Subject: [PATCH] Update depends command --- src/Composer/Command/DependsCommand.php | 13 ++++++++----- .../Test/Installer/InstallationManagerTest.php | 1 - 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Composer/Command/DependsCommand.php b/src/Composer/Command/DependsCommand.php index 82ff5e02d..5c06e96f5 100644 --- a/src/Composer/Command/DependsCommand.php +++ b/src/Composer/Command/DependsCommand.php @@ -25,7 +25,10 @@ use Symfony\Component\Console\Output\OutputInterface; */ class DependsCommand extends Command { - protected $linkTypes = array('require', 'recommend', 'suggest'); + protected $linkTypes = array( + 'require' => 'requires', + 'require-dev' => 'devRequires', + ); protected function configure() { @@ -34,7 +37,7 @@ class DependsCommand extends Command ->setDescription('Shows which packages depend on the given package') ->setDefinition(array( new InputArgument('package', InputArgument::REQUIRED, 'Package to inspect'), - new InputOption('link-type', '', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Link types to show', $this->linkTypes) + new InputOption('link-type', '', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Link types to show (require, require-dev)', array_keys($this->linkTypes)) )) ->setHelp(<<getPackages() as $package) { foreach ($types as $type) { $type = rtrim($type, 's'); - if (!in_array($type, $this->linkTypes)) { - throw new \InvalidArgumentException('Unexpected link type: '.$type.', valid types: '.implode(', ', $this->linkTypes)); + if (!isset($this->linkTypes[$type])) { + throw new \InvalidArgumentException('Unexpected link type: '.$type.', valid types: '.implode(', ', array_keys($this->linkTypes))); } - foreach ($package->{'get'.$type.'s'}() as $link) { + foreach ($package->{'get'.$this->linkTypes[$type]}() as $link) { if ($link->getTarget() === $needle) { if ($verbose) { $references[] = array($type, $package, $link); diff --git a/tests/Composer/Test/Installer/InstallationManagerTest.php b/tests/Composer/Test/Installer/InstallationManagerTest.php index f14c08c84..a657ba948 100644 --- a/tests/Composer/Test/Installer/InstallationManagerTest.php +++ b/tests/Composer/Test/Installer/InstallationManagerTest.php @@ -72,7 +72,6 @@ class InstallationManagerTest extends \PHPUnit_Framework_TestCase $this->createPackageMock(), $this->createPackageMock() ); - $manager ->expects($this->once()) ->method('install')