diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6d5ae3102a..9e4b5f2a33 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -222,8 +222,6 @@ jobs: composer-options: ${{ matrix.php == '8.5' && '--ignore-platform-req=php+' || '' }} custom-cache-suffix: $(date -u "+%Y-%m") - # Note: The code style check is run multiple times against every PHP version - # as it also acts as an integration test. - name: 'PHPCS: set the path to PHP' run: php "bin/phpcs" --config-set php_path php @@ -231,12 +229,21 @@ jobs: if: ${{ matrix.skip_tests != true }} run: php "vendor/bin/phpunit" tests/AllTests.php --no-coverage + # Do one test run against the complete test suite in CBF mode to ensure all tests can run in CBF mode. + - name: 'PHPUnit: run the full test suite without code coverage in CBF mode (PHP 8.3 only)' + if: ${{ matrix.php == '8.3' }} + run: php "vendor/bin/phpunit" tests/AllTests.php --exclude-group nothing --no-coverage + env: + PHP_CODESNIFFER_CBF: '1' + - name: 'PHPUnit: run select tests in CBF mode' - if: ${{ matrix.skip_tests != true }} + if: ${{ matrix.skip_tests != true && matrix.php != '8.3' }} run: php "vendor/bin/phpunit" tests/AllTests.php --group CBF --exclude-group nothing --no-coverage env: PHP_CODESNIFFER_CBF: '1' + # Note: The code style check is run multiple times against every PHP version + # as it also acts as an integration test. - name: 'PHPCS: check code style without cache, no parallel' if: ${{ matrix.custom_ini == false }} run: php "bin/phpcs" --no-cache --parallel=1 diff --git a/tests/Core/Config/GeneratorArgTest.php b/tests/Core/Config/GeneratorArgTest.php index 5def5f68f8..12fe1c66f2 100644 --- a/tests/Core/Config/GeneratorArgTest.php +++ b/tests/Core/Config/GeneratorArgTest.php @@ -20,6 +20,22 @@ final class GeneratorArgTest extends TestCase { + /** + * Skip these tests when in CBF mode. + * + * @before + * + * @return void + */ + protected function maybeSkipTests() + { + if (PHP_CODESNIFFER_CBF === true) { + $this->markTestSkipped('The `--generator` CLI flag is only supported for the `phpcs` command'); + } + + }//end maybeSkipTests() + + /** * Ensure that the generator property is set when the parameter is passed a valid value. * diff --git a/tests/Core/Config/SniffsExcludeArgsTest.php b/tests/Core/Config/SniffsExcludeArgsTest.php index 59aabecc19..18b877c423 100644 --- a/tests/Core/Config/SniffsExcludeArgsTest.php +++ b/tests/Core/Config/SniffsExcludeArgsTest.php @@ -34,6 +34,11 @@ final class SniffsExcludeArgsTest extends TestCase */ public function testInvalid($argument, $value, $errors, $suggestion) { + $cmd = 'phpcs'; + if (PHP_CODESNIFFER_CBF === true) { + $cmd = 'phpcbf'; + } + $exception = 'PHP_CodeSniffer\Exceptions\DeepExitException'; $message = 'ERROR: The --'.$argument.' option only supports sniff codes.'.PHP_EOL; $message .= 'Sniff codes are in the form "Standard.Category.Sniff".'.PHP_EOL; @@ -47,7 +52,7 @@ public function testInvalid($argument, $value, $errors, $suggestion) } $message .= PHP_EOL; - $message .= 'Run "phpcs --help" for usage information'.PHP_EOL; + $message .= "Run \"{$cmd} --help\" for usage information".PHP_EOL; $message .= PHP_EOL; if (method_exists($this, 'expectException') === true) { diff --git a/tests/Core/Ruleset/DisplayCachedMessagesTest.php b/tests/Core/Ruleset/DisplayCachedMessagesTest.php index 446bbfbcf6..55b0b7081b 100644 --- a/tests/Core/Ruleset/DisplayCachedMessagesTest.php +++ b/tests/Core/Ruleset/DisplayCachedMessagesTest.php @@ -229,18 +229,24 @@ public function testNonBlockingErrorsDoNotShowUnderSpecificCircumstances($config */ public static function dataSelectiveDisplayOfMessages() { - return [ - 'Explain mode' => [ + $data = [ + 'Explain mode' => [ 'configArgs' => ['-e'], ], - 'Quiet mode' => [ + 'Quiet mode' => [ 'configArgs' => ['-q'], ], - 'Documentation is requested' => [ - 'configArgs' => ['--generator=text'], - ], ]; + // Setting the `--generator` arg is only supported when running `phpcs`. + if (PHP_CODESNIFFER_CBF === false) { + $data['Documentation is requested'] = [ + 'configArgs' => ['--generator=text'], + ]; + } + + return $data; + }//end dataSelectiveDisplayOfMessages()