Skip to content

Commit

Permalink
Hide suggest reason when there is not one
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry committed Jun 9, 2018
1 parent 5bae191 commit 87646ae
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Composer/Installer/SuggestedPackagesReporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ public function output(RepositoryInterface $installedRepo = null)
}

$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'].')' : '')
));
}

Expand Down
14 changes: 14 additions & 0 deletions tests/Composer/Test/Installer/SuggestedPackagesReporterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,20 @@ public function testOutput()
$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
*/
Expand Down

0 comments on commit 87646ae

Please sign in to comment.