From 514f7087ed65af67440eada1924de1b165960534 Mon Sep 17 00:00:00 2001 From: Franck RANAIVO-HARISOA Date: Thu, 21 Dec 2023 18:13:49 +0100 Subject: [PATCH] Add Global Command tests --- .../Test/Command/GlobalCommandTest.php | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tests/Composer/Test/Command/GlobalCommandTest.php diff --git a/tests/Composer/Test/Command/GlobalCommandTest.php b/tests/Composer/Test/Command/GlobalCommandTest.php new file mode 100644 index 000000000..9313893ca --- /dev/null +++ b/tests/Composer/Test/Command/GlobalCommandTest.php @@ -0,0 +1,39 @@ + + * 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; +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Exception\InvalidArgumentException; +use Symfony\Component\Console\Exception\RuntimeException; + +class GlobalCommandTest extends TestCase +{ + public function testExceptionRunningWithNoSubcommand(): void + { + $this->expectException(RuntimeException::class); + $this->expectExceptionMessage('Not enough arguments (missing: "command-name").'); + + $appTester = $this->getApplicationTester(); + $this->assertEquals(Command::FAILURE, $appTester->run(['command' => 'global'])); + } + + public function testExceptionRunningWithIncompleteSubcommand(): void + { + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('Not enough arguments (missing: "packages").'); + + $appTester = $this->getApplicationTester(); + $this->assertEquals(Command::FAILURE, $appTester->run(['command' => 'global', 'command-name' => 'remove'] )); + } +}