Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ tests/Core/**/ export-ignore
phpcs.xml.dist export-ignore
phpstan.neon.dist export-ignore
phpunit.xml.dist export-ignore
phpunit-lte9.xml.dist export-ignore
tests/Core/ErrorSuppressionTest.php export-ignore

#
Expand Down
10 changes: 7 additions & 3 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,14 @@ To help you with this, a number of convenience scripts are available:
* `composer check-all` will run the `cs` + `test` checks in one go.
* `composer cs` will check for code style violations.
* `composer cbf` will run the autofixers for code style violations.
* `composer test` will run the unit tests.
* `composer coverage` will run the unit tests with code coverage and show a text summary.
* `composer test` will run the unit tests when using PHP 8.1+/PHPUnit 10+.
* `composer test-lte9` will run the unit tests when using PHP < 8.1/PHPUnit <= 9.
* `composer coverage` will run the unit tests with code coverage and show a text summary (PHP 8.1+/PHPUnit 10+).
* `composer coverage-lte9` will run the unit tests with code coverage and show a text summary (PHP < 8.1/PHPUnit <= 9).
* `composer coverage-local` will run the unit tests with code coverage and generate an HTML coverage report,
which will be placed in a `build/coverage-html` subdirectory.
which will be placed in a `build/coverage-html` subdirectory (PHP 8.1+/PHPUnit 10+).
* `composer coverage-lte9-local` will run the unit tests with code coverage and generate an HTML coverage report,
which will be placed in a `build/coverage-html` subdirectory (PHP < 8.1/PHPUnit <= 9).
* `composer build` will build the phpcs.phar and phpcbf.phar files.


Expand Down
31 changes: 28 additions & 3 deletions .github/workflows/quicktest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,44 @@ jobs:
# Bust the cache at least once a month - output format: YYYY-MM.
custom-cache-suffix: $(date -u "+%Y-%m")

- name: Grab PHPUnit version
id: phpunit_version
shell: bash
# yamllint disable-line rule:line-length
run: echo "VERSION=$(php "vendor/bin/phpunit" --version | grep --only-matching --max-count=1 --extended-regexp '\b[0-9]+\.[0-9]+')" >> "$GITHUB_OUTPUT"

- name: "DEBUG: Show grabbed version"
run: echo ${{ steps.phpunit_version.outputs.VERSION }}

- name: Determine PHPUnit config file to use
id: phpunit_config
shell: bash
run: |
if [ "${{ startsWith( steps.phpunit_version.outputs.VERSION, '11.' ) }}" == "true" ]; then
echo 'FILE=phpunit.xml.dist' >> "$GITHUB_OUTPUT"
elif [ "${{ startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }}" == "true" ]; then
echo 'FILE=phpunit.xml.dist' >> "$GITHUB_OUTPUT"
else
echo 'FILE=phpunit-lte9.xml.dist' >> "$GITHUB_OUTPUT"
fi

- name: 'PHPCS: set the path to PHP'
run: php "bin/phpcs" --config-set php_path php

- name: 'PHPUnit: run the full test suite'
if: ${{ matrix.os != 'windows-latest' }}
run: php "vendor/bin/phpunit" --no-coverage
run: php "vendor/bin/phpunit" -c ${{ steps.phpunit_config.outputs.FILE }} --no-coverage

- name: 'PHPUnit: run tests which may have different outcomes on Windows'
if: ${{ matrix.os == 'windows-latest' }}
run: php "vendor/bin/phpunit" --group Windows --no-coverage
run: >
php "vendor/bin/phpunit" -c ${{ steps.phpunit_config.outputs.FILE }} --no-coverage
--group Windows

- name: 'PHPUnit: run select tests in CBF mode'
run: php "vendor/bin/phpunit" --group CBF --exclude-group nothing --no-coverage
run: >
php "vendor/bin/phpunit" -c ${{ steps.phpunit_config.outputs.FILE }} --no-coverage
--group CBF --exclude-group nothing
env:
PHP_CODESNIFFER_CBF: '1'

Expand Down
50 changes: 44 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -197,18 +197,41 @@ jobs:
composer-options: ${{ matrix.php == '8.5' && '--ignore-platform-req=php+' || '' }}
custom-cache-suffix: $(date -u "+%Y-%m")

- name: Grab PHPUnit version
id: phpunit_version
shell: bash
# yamllint disable-line rule:line-length
run: echo "VERSION=$(php "vendor/bin/phpunit" --version | grep --only-matching --max-count=1 --extended-regexp '\b[0-9]+\.[0-9]+')" >> "$GITHUB_OUTPUT"

- name: "DEBUG: Show grabbed version"
run: echo ${{ steps.phpunit_version.outputs.VERSION }}

- name: Determine PHPUnit config file to use
id: phpunit_config
shell: bash
run: |
if [ "${{ startsWith( steps.phpunit_version.outputs.VERSION, '11.' ) }}" == "true" ]; then
echo 'FILE=phpunit.xml.dist' >> "$GITHUB_OUTPUT"
elif [ "${{ startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }}" == "true" ]; then
echo 'FILE=phpunit.xml.dist' >> "$GITHUB_OUTPUT"
else
echo 'FILE=phpunit-lte9.xml.dist' >> "$GITHUB_OUTPUT"
fi

# 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

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

- name: 'PHPUnit: run select tests in CBF mode'
if: ${{ matrix.skip_tests != true }}
run: php "vendor/bin/phpunit" --group CBF --exclude-group nothing --no-coverage
run: >
php "vendor/bin/phpunit" -c ${{ steps.phpunit_config.outputs.FILE }} --no-coverage
--group CBF --exclude-group nothing
env:
PHP_CODESNIFFER_CBF: '1'

Expand Down Expand Up @@ -293,6 +316,18 @@ jobs:
- name: "DEBUG: Show grabbed version"
run: echo ${{ steps.phpunit_version.outputs.VERSION }}

- name: Determine PHPUnit config file to use
id: phpunit_config
shell: bash
run: |
if [ "${{ startsWith( steps.phpunit_version.outputs.VERSION, '11.' ) }}" == "true" ]; then
echo 'FILE=phpunit.xml.dist' >> "$GITHUB_OUTPUT"
elif [ "${{ startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }}" == "true" ]; then
echo 'FILE=phpunit.xml.dist' >> "$GITHUB_OUTPUT"
else
echo 'FILE=phpunit-lte9.xml.dist' >> "$GITHUB_OUTPUT"
fi

- name: 'PHPCS: set the path to PHP'
run: php "bin/phpcs" --config-set php_path php

Expand All @@ -302,18 +337,20 @@ jobs:
# Using that option prevents issues with PHP-Parser backfilling PHP tokens during our test runs.
- name: "Warm the PHPUnit cache (PHPUnit 9.3+)"
if: ${{ steps.phpunit_version.outputs.VERSION >= '9.3' }}
run: php "vendor/bin/phpunit" --coverage-cache ./build/phpunit-cache --warm-coverage-cache
run: >
php "vendor/bin/phpunit" -c ${{ steps.phpunit_config.outputs.FILE }}
--coverage-cache ./build/phpunit-cache --warm-coverage-cache

- name: "Run the unit tests with code coverage"
if: ${{ matrix.os != 'windows-latest' }}
run: >
php "vendor/bin/phpunit"
php "vendor/bin/phpunit" -c ${{ steps.phpunit_config.outputs.FILE }}
${{ steps.phpunit_version.outputs.VERSION >= '9.3' && '--coverage-cache ./build/phpunit-cache' || '' }}

- name: "Run select tests in CBF mode with code coverage"
if: ${{ matrix.os != 'windows-latest' }}
run: >
php "vendor/bin/phpunit"
php "vendor/bin/phpunit" -c ${{ steps.phpunit_config.outputs.FILE }}
${{ steps.phpunit_version.outputs.VERSION >= '9.3' && '--coverage-cache ./build/phpunit-cache' || '' }}
--group CBF --exclude-group nothing --coverage-clover build/logs/clover-cbf.xml
env:
Expand All @@ -322,8 +359,9 @@ jobs:
- name: "Run the unit tests which may have different outcomes on Windows with code coverage"
if: ${{ matrix.os == 'windows-latest' }}
run: >
php "vendor/bin/phpunit" --group Windows
php "vendor/bin/phpunit" -c ${{ steps.phpunit_config.outputs.FILE }}
${{ steps.phpunit_version.outputs.VERSION >= '9.3' && '--coverage-cache ./build/phpunit-cache' || '' }}
--group Windows

- name: "Upload coverage results to Coveralls (normal run)"
if: ${{ success() }}
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ jobs:
pattern: "phpcs.xml.dist"
xsd-file: "phpcs.xsd"

- name: "Validate PHPUnit config for well-formedness"
- name: "Validate PHPUnit <= 9 config for well-formedness"
uses: phpcsstandards/xmllint-validate@v1
with:
pattern: "phpunit-lte9.xml.dist"

- name: "Validate PHPUnit 10+ config for well-formedness"
uses: phpcsstandards/xmllint-validate@v1
with:
pattern: "phpunit.xml.dist"
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/CodeSniffer.conf
/phpcs.xml
/phpunit.xml
/phpunitlte9.xml
/phpunit-lte9.xml
.phpunit.result.cache
/build/
.idea/*
Expand Down
23 changes: 19 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"ext-xmlwriter": "*"
},
"require-dev": {
"phpunit/phpunit": "^8.0 || ^9.3.4"
"phpunit/phpunit": "^8.0 || ^9.3.4 || ^10.5.32 || ^11.3.3"
},
"bin": [
"bin/phpcbf",
Expand All @@ -61,14 +61,26 @@
"Composer\\Config::disableProcessTimeout",
"@php ./vendor/phpunit/phpunit/phpunit --no-coverage"
],
"test-lte9": [
"Composer\\Config::disableProcessTimeout",
"@php ./vendor/phpunit/phpunit/phpunit -c phpunit-lte9.xml.dist --no-coverage"
],
"coverage": [
"Composer\\Config::disableProcessTimeout",
"@php ./vendor/phpunit/phpunit/phpunit -d max_execution_time=0"
],
"coverage-lte9": [
"Composer\\Config::disableProcessTimeout",
"@php ./vendor/phpunit/phpunit/phpunit -c phpunit-lte9.xml.dist -d max_execution_time=0"
],
"coverage-local": [
"Composer\\Config::disableProcessTimeout",
"@php ./vendor/phpunit/phpunit/phpunit --coverage-html ./build/coverage-html -d max_execution_time=0"
],
"coverage-lte9-local": [
"Composer\\Config::disableProcessTimeout",
"@php ./vendor/phpunit/phpunit/phpunit -c phpunit-lte9.xml.dist --coverage-html ./build/coverage-html -d max_execution_time=0"
],
"build": [
"Composer\\Config::disableProcessTimeout",
"@php -d phar.readonly=0 -f ./scripts/build-phar.php"
Expand All @@ -81,9 +93,12 @@
"scripts-descriptions": {
"cs": "Check for code style violations.",
"cbf": "Fix code style violations.",
"test": "Run the unit tests without code coverage.",
"coverage": "Run the unit tests with code coverage.",
"coverage-local": "Run the unit tests with code coverage and generate an HTML report in a 'build' directory.",
"test": "PHPUnit 10+: Run the unit tests without code coverage.",
"test-lte9": "PHPUnit <= 9: Run the unit tests without code coverage.",
"coverage": "PHPUnit 10+: Run the unit tests with code coverage.",
"coverage-lte9": "PHPUnit <= 9: Run the unit tests with code coverage.",
"coverage-local": "PHPUnit 10+: Run the unit tests with code coverage and generate an HTML report in a 'build' directory.",
"coverage-lte9-local": "PHPUnit <= 9: Run the unit tests with code coverage and generate an HTML report in a 'build' directory.",
"build": "Create PHAR files for PHPCS and PHPCBF.",
"check-all": "Run all checks (phpcs, tests)."
}
Expand Down
8 changes: 8 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ parameters:
paths:
- requirements.php
- src
excludePaths:
- src/Standards/Generic/Tests/*
- src/Standards/PEAR/Tests/*
- src/Standards/PSR1/Tests/*
- src/Standards/PSR2/Tests/*
- src/Standards/PSR12/Tests/*
- src/Standards/Squiz/Tests/*
- src/Standards/Zend/Tests/*
bootstrapFiles:
- tests/bootstrap.php

Expand Down
54 changes: 54 additions & 0 deletions phpunit-lte9.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.2/phpunit.xsd"
backupGlobals="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTestsThatDoNotTestAnything="false"
bootstrap="tests/bootstrap.php"
convertErrorsToExceptions="true"
convertWarningsToExceptions="true"
convertNoticesToExceptions="true"
convertDeprecationsToExceptions="true"
forceCoversAnnotation="true"
>
<testsuites>
<testsuite name="PHPCS_Core">
<directory>./tests/Core/</directory>
</testsuite>
<testsuite name="PHPCS_Sniffs">
<directory>./src/Standards/Generic/Tests/</directory>
<directory>./src/Standards/PEAR/Tests/</directory>
<directory>./src/Standards/PSR1/Tests/</directory>
<directory>./src/Standards/PSR2/Tests/</directory>
<directory>./src/Standards/PSR12/Tests/</directory>
<directory>./src/Standards/Squiz/Tests/</directory>
<directory>./src/Standards/Zend/Tests/</directory>
</testsuite>
</testsuites>

<groups>
<exclude>
<group>CBF</group>
</exclude>
</groups>

<filter>
<whitelist addUncoveredFilesFromWhitelist="true" processUncoveredFilesFromWhitelist="false">
<directory suffix=".php">./src</directory>
<file>./autoload.php</file>
<exclude>
<directory suffix="UnitTest.php">./src/Standards</directory>
</exclude>
</whitelist>
</filter>

<logging>
<log type="coverage-text" target="php://stdout" showOnlySummary="true"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>

<php>
<env name="PHP_CODESNIFFER_CBF" value="0"/>
</php>
</phpunit>
42 changes: 25 additions & 17 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.2/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
backupGlobals="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTestsThatDoNotTestAnything="false"
bootstrap="tests/bootstrap.php"
convertErrorsToExceptions="true"
convertWarningsToExceptions="true"
convertNoticesToExceptions="true"
convertDeprecationsToExceptions="true"
forceCoversAnnotation="true"
cacheDirectory="build/phpunit-cache"
displayDetailsOnTestsThatTriggerErrors="true"
displayDetailsOnTestsThatTriggerWarnings="true"
displayDetailsOnTestsThatTriggerNotices="true"
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnPhpunitDeprecations="false"
failOnWarning="true"
failOnNotice="true"
failOnDeprecation="true"
failOnPhpunitDeprecation="false"
requireCoverageMetadata="true"
>
<testsuites>
<testsuite name="PHPCS_Core">
Expand All @@ -33,20 +39,22 @@
</exclude>
</groups>

<filter>
<whitelist addUncoveredFilesFromWhitelist="true" processUncoveredFilesFromWhitelist="false">
<source>
<include>
<directory suffix=".php">./src</directory>
<file>./autoload.php</file>
<exclude>
<directory suffix="UnitTest.php">./src/Standards</directory>
</exclude>
</whitelist>
</filter>
</include>
<exclude>
<directory suffix="UnitTest.php">./src/Standards</directory>
</exclude>
</source>

<logging>
<log type="coverage-text" target="php://stdout" showOnlySummary="true"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
<coverage includeUncoveredFiles="true">
<report>
<clover outputFile="build/logs/clover.xml"/>
<text outputFile="php://stdout" showOnlySummary="true"/>
</report>
</coverage>

<php>
<env name="PHP_CODESNIFFER_CBF" value="0"/>
Expand Down
4 changes: 2 additions & 2 deletions src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@

namespace PHP_CodeSniffer\Standards\Generic\Tests\Arrays;

use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest;
use PHP_CodeSniffer\Tests\Standards\AbstractSniffTestCase;

/**
* Unit test class for the ArrayIndent sniff.
*
* @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Arrays\ArrayIndentSniff
*/
final class ArrayIndentUnitTest extends AbstractSniffUnitTest
final class ArrayIndentUnitTest extends AbstractSniffTestCase
{


Expand Down
Loading