diff --git a/src/PackageDiff.php b/src/PackageDiff.php index fc4691f..301b490 100644 --- a/src/PackageDiff.php +++ b/src/PackageDiff.php @@ -130,11 +130,12 @@ private function getFileContents($path) $output = array(); @exec(sprintf('git show %s 2>&1', escapeshellarg($path)), $output, $exit); + $outputString = implode("\n", $output); if (0 !== $exit) { - throw new \RuntimeException(sprintf('Could not open file %s or find it in git as %s', $originalPath, $path)); + throw new \RuntimeException(sprintf('Could not open file %s or find it in git as %s: %s', $originalPath, $path, $outputString)); } - return implode("\n", $output); + return $outputString; } } diff --git a/src/Url/GitGenerator.php b/src/Url/GitGenerator.php index 5aa4b68..5b0f722 100644 --- a/src/Url/GitGenerator.php +++ b/src/Url/GitGenerator.php @@ -11,7 +11,7 @@ abstract class GitGenerator implements UrlGenerator */ public function supportsPackage(PackageInterface $package) { - return false !== strpos($package->getSourceUrl(), $this->getDomain()); + return false !== strpos((string) $package->getSourceUrl(), $this->getDomain()); } /** diff --git a/tests/Command/DiffCommandTest.php b/tests/Command/DiffCommandTest.php index f672348..ad40b31 100644 --- a/tests/Command/DiffCommandTest.php +++ b/tests/Command/DiffCommandTest.php @@ -7,6 +7,7 @@ use Composer\DependencyResolver\Operation\UninstallOperation; use Composer\DependencyResolver\Operation\UpdateOperation; use IonBazan\ComposerDiff\Command\DiffCommand; +use IonBazan\ComposerDiff\Tests\Integration\ComposerApplication; use IonBazan\ComposerDiff\Tests\TestCase; use Symfony\Component\Console\Tester\CommandTester; @@ -20,7 +21,10 @@ class DiffCommandTest extends TestCase public function testItGeneratesReportInGivenFormat($expectedOutput, array $options) { $diff = $this->getMockBuilder('IonBazan\ComposerDiff\PackageDiff')->getMock(); - $tester = new CommandTester(new DiffCommand($diff, array('gitlab2.org'))); + $application = new ComposerApplication(); + $command = new DiffCommand($diff, array('gitlab2.org')); + $command->setApplication($application); + $tester = new CommandTester($command); $diff->expects($this->once()) ->method('getPackageDiff') ->with($this->isType('string'), $this->isType('string'), false, false) @@ -49,7 +53,10 @@ public function testItGeneratesReportInGivenFormat($expectedOutput, array $optio public function testStrictMode($exitCode, array $prodOperations, array $devOperations) { $diff = $this->getMockBuilder('IonBazan\ComposerDiff\PackageDiff')->getMock(); - $tester = new CommandTester(new DiffCommand($diff, array('gitlab2.org'))); + $application = new ComposerApplication(); + $command = new DiffCommand($diff, array('gitlab2.org')); + $command->setApplication($application); + $tester = new CommandTester($command); $diff->expects($this->exactly(2)) ->method('getPackageDiff') ->with($this->isType('string'), $this->isType('string'), $this->isType('boolean'), false) diff --git a/tests/Integration/DiffCommandTest.php b/tests/Integration/DiffCommandTest.php index 43bacc6..71e6cc3 100644 --- a/tests/Integration/DiffCommandTest.php +++ b/tests/Integration/DiffCommandTest.php @@ -24,7 +24,10 @@ class DiffCommandTest extends TestCase */ public function testCommand($expectedOutput, array $input) { - $tester = new CommandTester(new DiffCommand(new PackageDiff())); + $application = new ComposerApplication(); + $command = new DiffCommand(new PackageDiff()); + $command->setApplication($application); + $tester = new CommandTester($command); $result = $tester->execute($input); $this->assertSame(0, $result); $this->assertSame($expectedOutput, $tester->getDisplay());