소스 검색

Merge pull request #7399 from theofidry/bugfix/fix-suggest-reporter

Hide suggest reason when there is not one
Jordi Boggiano 6 년 전
부모
커밋
f92e15b032
2개의 변경된 파일16개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 2
      src/Composer/Installer/SuggestedPackagesReporter.php
  2. 14 0
      tests/Composer/Test/Installer/SuggestedPackagesReporterTest.php

+ 2 - 2
src/Composer/Installer/SuggestedPackagesReporter.php

@@ -115,10 +115,10 @@ class SuggestedPackagesReporter
             }
 
             $this->io->writeError(sprintf(
-                '%s suggests installing %s (%s)',
+                '%s suggests installing %s%s',
                 $suggestion['source'],
                 $this->escapeOutput($suggestion['target']),
-                $this->escapeOutput($suggestion['reason'])
+                $this->escapeOutput('' !== $suggestion['reason'] ? ' ('.$suggestion['reason'].')' : '')
             ));
         }
 

+ 14 - 0
tests/Composer/Test/Installer/SuggestedPackagesReporterTest.php

@@ -142,6 +142,20 @@ class SuggestedPackagesReporterTest extends TestCase
         $this->suggestedPackagesReporter->output();
     }
 
+    /**
+     * @covers ::output
+     */
+    public function testOutputWithNoSuggestedPackage()
+    {
+        $this->suggestedPackagesReporter->addPackage('a', 'b', '');
+
+        $this->io->expects($this->once())
+            ->method('writeError')
+            ->with('a suggests installing b');
+
+        $this->suggestedPackagesReporter->output();
+    }
+
     /**
      * @covers ::output
      */