Skip to content

Commit fe1e5d3

Browse files
committed
Merge branch 'master' into 4.x
2 parents d9071b0 + 726bbc1 commit fe1e5d3

File tree

4 files changed

+42
-10
lines changed

4 files changed

+42
-10
lines changed

.github/workflows/test.yml

+10-3
Original file line numberDiff line numberDiff line change
@@ -227,23 +227,30 @@ jobs:
227227
echo 'FILE=phpunit-lte9.xml.dist' >> "$GITHUB_OUTPUT"
228228
fi
229229
230-
# Note: The code style check is run multiple times against every PHP version
231-
# as it also acts as an integration test.
232230
- name: 'PHPCS: set the path to PHP'
233231
run: php "bin/phpcs" --config-set php_path php
234232

235233
- name: 'PHPUnit: run the full test suite without code coverage'
236234
if: ${{ matrix.skip_tests != true }}
237235
run: php "vendor/bin/phpunit" -c ${{ steps.phpunit_config.outputs.FILE }} --no-coverage
238236

237+
# Do one test run against the complete test suite in CBF mode to ensure all tests can run in CBF mode.
238+
- name: 'PHPUnit: run the full test suite without code coverage in CBF mode (PHP 8.3 only)'
239+
if: ${{ matrix.php == '8.3' }}
240+
run: php "vendor/bin/phpunit" -c ${{ steps.phpunit_config.outputs.FILE }} --exclude-group nothing --no-coverage
241+
env:
242+
PHP_CODESNIFFER_CBF: '1'
243+
239244
- name: 'PHPUnit: run select tests in CBF mode'
240-
if: ${{ matrix.skip_tests != true }}
245+
if: ${{ matrix.skip_tests != true && matrix.php != '8.3' }}
241246
run: >
242247
php "vendor/bin/phpunit" -c ${{ steps.phpunit_config.outputs.FILE }} --no-coverage
243248
--group CBF --exclude-group nothing
244249
env:
245250
PHP_CODESNIFFER_CBF: '1'
246251

252+
# Note: The code style check is run multiple times against every PHP version
253+
# as it also acts as an integration test.
247254
- name: 'PHPCS: check code style without cache, no parallel'
248255
if: ${{ matrix.custom_ini == false }}
249256
run: php "bin/phpcs" --no-cache --parallel=1

tests/Core/Config/GeneratorArgTest.php

+14
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,20 @@ final class GeneratorArgTest extends TestCase
2020
{
2121

2222

23+
/**
24+
* Skip these tests when in CBF mode.
25+
*
26+
* @return void
27+
*/
28+
protected function setUp(): void
29+
{
30+
if (PHP_CODESNIFFER_CBF === true) {
31+
$this->markTestSkipped('This test needs CS mode to run');
32+
}
33+
34+
}//end setUp()
35+
36+
2337
/**
2438
* Ensure that the generator property is set when the parameter is passed a valid value.
2539
*

tests/Core/Config/SniffsExcludeArgsTest.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ final class SniffsExcludeArgsTest extends TestCase
3434
*/
3535
public function testInvalid($argument, $value, $errors, $suggestion)
3636
{
37+
$cmd = 'phpcs';
38+
if (PHP_CODESNIFFER_CBF === true) {
39+
$cmd = 'phpcbf';
40+
}
41+
3742
$exception = 'PHP_CodeSniffer\Exceptions\DeepExitException';
3843
$message = 'ERROR: The --'.$argument.' option only supports sniff codes.'.PHP_EOL;
3944
$message .= 'Sniff codes are in the form "Standard.Category.Sniff".'.PHP_EOL;
@@ -47,7 +52,7 @@ public function testInvalid($argument, $value, $errors, $suggestion)
4752
}
4853

4954
$message .= PHP_EOL;
50-
$message .= 'Run "phpcs --help" for usage information'.PHP_EOL;
55+
$message .= "Run \"{$cmd} --help\" for usage information".PHP_EOL;
5156
$message .= PHP_EOL;
5257

5358
$this->expectException($exception);

tests/Core/Ruleset/DisplayCachedMessagesTest.php

+12-6
Original file line numberDiff line numberDiff line change
@@ -237,18 +237,24 @@ public function testNonBlockingErrorsDoNotShowUnderSpecificCircumstances($config
237237
*/
238238
public static function dataSelectiveDisplayOfMessages()
239239
{
240-
return [
241-
'Explain mode' => [
240+
$data = [
241+
'Explain mode' => [
242242
'configArgs' => ['-e'],
243243
],
244-
'Quiet mode' => [
244+
'Quiet mode' => [
245245
'configArgs' => ['-q'],
246246
],
247-
'Documentation is requested' => [
248-
'configArgs' => ['--generator=text'],
249-
],
250247
];
251248

249+
// Setting the `--generator` arg is only supported when running `phpcs`.
250+
if (PHP_CODESNIFFER_CBF === false) {
251+
$data['Documentation is requested'] = [
252+
'configArgs' => ['--generator=text'],
253+
];
254+
}
255+
256+
return $data;
257+
252258
}//end dataSelectiveDisplayOfMessages()
253259

254260

0 commit comments

Comments
 (0)