diff --git a/tests/Composer/Test/Command/ExecCommandTest.php b/tests/Composer/Test/Command/ExecCommandTest.php new file mode 100644 index 000000000..ee195c4b5 --- /dev/null +++ b/tests/Composer/Test/Command/ExecCommandTest.php @@ -0,0 +1,60 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Test\Command; + +use Composer\Test\TestCase; + +class ExecCommandTest extends TestCase +{ + public function testListThrowsIfNoBinariesExist(): void + { + $composerDir = $this->initTempComposer(); + + $composerBinDir = "$composerDir/vendor/bin"; + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage( + "No binaries found in composer.json or in bin-dir ($composerBinDir)" + ); + + $appTester = $this->getApplicationTester(); + $appTester->run(['command' => 'exec', '--list' => true]); + } + + public function testList(): void + { + $composerDir = $this->initTempComposer([ + 'bin' => [ + 'a' + ] + ]); + + $composerBinDir = "$composerDir/vendor/bin"; + mkdir($composerBinDir, 0777, true); + touch($composerBinDir . '/b'); + touch($composerBinDir . '/b.bat'); + touch($composerBinDir . '/c'); + + $appTester = $this->getApplicationTester(); + $appTester->run(['command' => 'exec', '--list' => true]); + + $output = $appTester->getDisplay(true); + + $this->assertSame( + 'Available binaries: +- b +- c +- a (local)', + trim($output) + ); + } +}