Skip to content

Commit e7bf5b6

Browse files
committed
CI/QA: prepare for adding additional tests
Update the test setup to allow for tests to be added for the Feature Complete tooling as well as the upcoming Docs XSD file. **PHPUnit config** * Rename the test suite to allow for adding additional test suites. * Add a second test suite for the upcoming Docs XSD tests and future "Feature Complete" tooling tests, both of which will be non-PHPCS dependent tests. **Composer** * Tweak the supported PHPUnit version to ensure the namespaced `TestCase` class is always available. * Add the PHPUnit Polyfills for use by those tests which need to use expectations/assertions which have changed over time. * Add autoloading for test files. * Add separate scripts to run the different test suites. * Rename the `run-tests` script (to run all tests) to `test` to be in line with the names of similar scripts in other repos in this organisation. **PHPUnit bootstrap** * Load the autoloader for the PHPUnit Polyfills. **GH Actions workflow** * Adjust the existing test run to run only the sniff test testsuite. * Add a second test run to run the tooling test suite which is only run once per PHP version. **.gitattributes** * Ignore the `Tests` directory for distribution archives. **PHPCS config** * Ignore long lines in test files as the "commands" to be passed can sometimes be quite long.
1 parent bfda1bd commit e7bf5b6

File tree

7 files changed

+38
-8
lines changed

7 files changed

+38
-8
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
/phpunit.xml.dist export-ignore
1313
/phpunit-bootstrap.php export-ignore
1414
/PHPCSDebug/Tests export-ignore
15+
/Tests export-ignore
1516

1617
#
1718
# Auto detect text files and perform LF normalization

.github/workflows/quicktest.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,9 @@ jobs:
8383
if: ${{ matrix.phpcs_version == 'dev-master' }}
8484
run: composer check-complete
8585

86-
- name: Run the unit tests
87-
run: composer run-tests
86+
- name: Run the unit tests for the PHPCSDebug sniff
87+
run: composer test-sniff
88+
89+
- name: Run the unit tests for the DevTools
90+
if: ${{ matrix.phpcs_version == 'dev-master' }}
91+
run: composer test-tools

.github/workflows/test.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,5 +124,9 @@ jobs:
124124
if: matrix.phpcs_version == 'dev-master'
125125
run: composer check-complete
126126

127-
- name: Run the unit tests
128-
run: composer run-tests
127+
- name: Run the unit tests for the PHPCSDebug sniff
128+
run: composer test-sniff
129+
130+
- name: Run the unit tests for the DevTools
131+
if: ${{ matrix.phpcs_version == 'dev-master' }}
132+
run: composer test-tools

composer.json

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,23 @@
2727
},
2828
"require-dev" : {
2929
"roave/security-advisories" : "dev-master",
30-
"phpunit/phpunit" : "^4.5 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0",
30+
"phpunit/phpunit" : "^4.8.36 || ^5.7.21 || ^6.0 || ^7.0 || ^8.0 || ^9.0",
3131
"php-parallel-lint/php-parallel-lint": "^1.3.2",
3232
"php-parallel-lint/php-console-highlighter": "^1.0.0",
3333
"phpcsstandards/phpcsdevcs": "^1.1.3",
34-
"phpcsstandards/phpcsutils" : "^1.0"
34+
"phpcsstandards/phpcsutils" : "^1.0",
35+
"yoast/phpunit-polyfills": "^1.0"
3536
},
3637
"config": {
3738
"allow-plugins": {
3839
"dealerdirect/phpcodesniffer-composer-installer": true
3940
}
4041
},
42+
"autoload-dev" : {
43+
"psr-4": {
44+
"PHPCSDevTools\\Tests\\": "Tests/"
45+
}
46+
},
4147
"bin": [
4248
"bin/phpcs-check-feature-completeness"
4349
],
@@ -56,9 +62,15 @@
5662
"fixcs": [
5763
"@php ./vendor/squizlabs/php_codesniffer/bin/phpcbf"
5864
],
59-
"run-tests": [
65+
"test": [
6066
"@php ./vendor/phpunit/phpunit/phpunit"
6167
],
68+
"test-sniff": [
69+
"@php ./vendor/phpunit/phpunit/phpunit --testsuite DebugSniff"
70+
],
71+
"test-tools": [
72+
"@php ./vendor/phpunit/phpunit/phpunit --testsuite DevTools"
73+
],
6274
"check-complete": [
6375
"@php ./bin/phpcs-check-feature-completeness ./PHPCSDebug"
6476
]

phpcs.xml.dist

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,8 @@
5656
<exclude-pattern>/phpunit-bootstrap\.php$</exclude-pattern>
5757
</rule>
5858

59+
<rule ref="Generic.Files.LineLength.TooLong">
60+
<exclude-pattern>/Tests/*\.php$</exclude-pattern>
61+
</rule>
62+
5963
</ruleset>

phpunit-bootstrap.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,5 +87,8 @@
8787
die(1);
8888
}
8989

90+
// Load test related autoloader.
91+
require_once __DIR__ . '/vendor/yoast/phpunit-polyfills/phpunitpolyfills-autoload.php';
92+
9093
// Clean up.
9194
unset($ds, $phpcsDir, $phpcsUtilsDir, $vendorDir);

phpunit.xml.dist

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
forceCoversAnnotation="true">
1414

1515
<testsuites>
16-
<testsuite name="PHPCSDevTools">
16+
<testsuite name="DebugSniff">
1717
<directory suffix="Test.php">./PHPCSDebug/Tests/</directory>
1818
</testsuite>
19+
<testsuite name="DevTools">
20+
</testsuite>
1921
</testsuites>
2022
</phpunit>

0 commit comments

Comments
 (0)