diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3fb15b5..f29ed34 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -104,13 +104,13 @@ jobs: dependencies: highest - os: ubuntu-latest - php-version: "8.0" + php-version: "8.1" dependencies: highest codecov: true php-ini-values: assert.exception=1, zend.assertions=1, opcache.enable=1, opcache.enable_cli=1, opcache.optimization_level=-1, opcache.jit_buffer_size=4096M, opcache.jit=1205 - os: ubuntu-latest - php-version: "8.3" + php-version: "8.4" dependencies: highest codecov: true php-ini-values: assert.exception=1, zend.assertions=1, opcache.enable=1, opcache.enable_cli=1, opcache.optimization_level=-1, opcache.jit_buffer_size=4096M, opcache.jit=1205 diff --git a/tests/AnnotatedCommandFactoryTest.php b/tests/AnnotatedCommandFactoryTest.php index 574a669..6cd7ba9 100644 --- a/tests/AnnotatedCommandFactoryTest.php +++ b/tests/AnnotatedCommandFactoryTest.php @@ -667,14 +667,14 @@ function testCommandWithNoArguments() $this->assertInstanceOf('\Symfony\Component\Console\Command\Command', $command); $this->assertEquals('command:with-no-arguments', $command->getName()); $this->assertEquals('This command has no arguments--only options', $command->getDescription()); - $this->assertEquals("Return a result only if not silent.", $command->getHelp()); - $this->assertEquals('command:with-no-arguments [-s|--silent]', $command->getSynopsis()); + $this->assertEquals("Return a result only if not silence.", $command->getHelp()); + $this->assertEquals('command:with-no-arguments [-s|--silence]', $command->getSynopsis()); $input = new StringInput('command:with-no-arguments'); $this->assertRunCommandViaApplicationEquals($command, $input, 'Hello, world'); $input = new StringInput('command:with-no-arguments -s'); $this->assertRunCommandViaApplicationEquals($command, $input, ''); - $input = new StringInput('command:with-no-arguments --silent'); + $input = new StringInput('command:with-no-arguments --silence'); $this->assertRunCommandViaApplicationEquals($command, $input, ''); } @@ -690,13 +690,13 @@ function testCommandWithShortcutOnAnnotation() $this->assertEquals('shortcut:on-annotation', $command->getName()); $this->assertEquals('Shortcut on annotation', $command->getDescription()); $this->assertEquals("This command defines the option shortcut on the annotation instead of in the options array.", $command->getHelp()); - $this->assertEquals('shortcut:on-annotation [-s|--silent]', $command->getSynopsis()); + $this->assertEquals('shortcut:on-annotation [-s|--silence]', $command->getSynopsis()); $input = new StringInput('shortcut:on-annotation'); $this->assertRunCommandViaApplicationEquals($command, $input, 'Hello, world'); $input = new StringInput('shortcut:on-annotation -s'); $this->assertRunCommandViaApplicationEquals($command, $input, ''); - $input = new StringInput('shortcut:on-annotation --silent'); + $input = new StringInput('shortcut:on-annotation --silence'); $this->assertRunCommandViaApplicationEquals($command, $input, ''); } diff --git a/tests/HelpTest.php b/tests/HelpTest.php index 3174b0a..8dfd234 100644 --- a/tests/HelpTest.php +++ b/tests/HelpTest.php @@ -73,18 +73,18 @@ public function addDiscoveredCommands($factory, $commandFiles) { } } - function assertRunCommandViaApplicationEquals($cmd, $expectedOutput, $expectedStatusCode = 0) + function assertRunCommandViaApplicationContains($cmd, $containsList, $expectedStatusCode = 0) { $input = new StringInput($cmd); $output = new BufferedOutput(); $statusCode = $this->application->run($input, $output); - $commandOutput = trim($output->fetch()); + $commandOutput = $this->simplifyWhitespace($output->fetch()); - $expectedOutput = $this->simplifyWhitespace($expectedOutput); - $commandOutput = $this->simplifyWhitespace($commandOutput); - - $this->assertEquals($expectedOutput, $commandOutput); + foreach ($containsList as $contains) { + $contains = $this->simplifyWhitespace($contains); + $this->assertStringContainsString($contains, $commandOutput); + } $this->assertEquals($expectedStatusCode, $statusCode); } @@ -120,7 +120,7 @@ function testHelp() $expectedFieldMessage = "Select just one field, and force format to 'string'."; } - $expectedXML = << @@ -165,9 +165,9 @@ function testHelp() - +EOT; + + $expectedXMLEnd = << Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug @@ -194,14 +194,16 @@ function testHelp() EOT; - $this->assertRunCommandViaApplicationEquals('my-help --format=xml example:table', $expectedXML); + $expectedXML = [ $expectedXMLBeginning, $expectedXMLEnd ]; + + $this->assertRunCommandViaApplicationContains('my-help --format=xml example:table', $expectedXML); $encodedAnsiMessage = json_encode($expectedAnsiMessage); $encodedNoAnsiMessage = json_encode($expectedNoAnsiMessage); $encodedHelpMessage = json_encode(strip_tags($expectedHelpMessage)); $encodedFieldMessage = json_encode($expectedFieldMessage); - $expectedJSON = <<assertRunCommandViaApplicationEquals('my-help --format=json example:table', $expectedJSON); + $expectedJSON = [ $expectedJSONBeginning, $expectedJSONEnd ]; + + $this->assertRunCommandViaApplicationContains('my-help --format=json example:table', $expectedJSON); } } diff --git a/tests/src/ExampleCommandFile.php b/tests/src/ExampleCommandFile.php index 83b1e49..ee83681 100644 --- a/tests/src/ExampleCommandFile.php +++ b/tests/src/ExampleCommandFile.php @@ -273,13 +273,13 @@ public function commandWithIOParameters(InputInterface $input, OutputInterface $ /** * This command has no arguments--only options * - * Return a result only if not silent. + * Return a result only if not silence. * - * @option silent Supress output. + * @option silence Supress output. */ - public function commandWithNoArguments(array $opts = ['silent|s' => false]) + public function commandWithNoArguments(array $opts = ['silence|s' => false]) { - if (!$opts['silent']) { + if (!$opts['silence']) { return "Hello, world"; } } @@ -290,11 +290,11 @@ public function commandWithNoArguments(array $opts = ['silent|s' => false]) * This command defines the option shortcut on the annotation instead of in the options array. * * @param $opts The options - * @option silent|s Supress output. + * @option silence|s Supress output. */ - public function shortcutOnAnnotation(array $opts = ['silent' => false]) + public function shortcutOnAnnotation(array $opts = ['silence' => false]) { - if (!$opts['silent']) { + if (!$opts['silence']) { return "Hello, world"; } } diff --git a/tests/src/alpha/AlphaCommandFile.php b/tests/src/alpha/AlphaCommandFile.php index 051e1b8..8cd7573 100644 --- a/tests/src/alpha/AlphaCommandFile.php +++ b/tests/src/alpha/AlphaCommandFile.php @@ -294,11 +294,11 @@ public function withoutAnnotations() * * Return a result only if not silent. * - * @option silent Supress output. + * @option silence Supress output. */ - public function commandWithOneOptionalArgument($who = 'world', $opts = ['silent|s' => false]) + public function commandWithOneOptionalArgument($who = 'world', $opts = ['silence|s' => false]) { - if (!$opts['silent']) { + if (!$opts['silence']) { return "Hello, $who"; } }