Skip to content

Commit 438fb45

Browse files
authored
Merge pull request #111 from Yoast/feature/tests-add-separate-testconfig-for-phpunit-10
Tests: add separate configuration file for PHPUnit 10
2 parents 3eeec05 + a361745 commit 438fb45

File tree

5 files changed

+56
-5
lines changed

5 files changed

+56
-5
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
/.remarkignore export-ignore
1515
/.remarkrc export-ignore
1616
/phpunit.xml.dist export-ignore
17+
/phpunit10.xml.dist export-ignore
1718
/tests/ export-ignore
1819

1920
#

.github/workflows/test.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,18 @@ jobs:
108108
# Bust the cache at least once a month - output format: YYYY-MM.
109109
custom-cache-suffix: $(date -u "+%Y-%m")
110110

111-
- name: Run the unit tests
112-
if: ${{ matrix.phpunit != '^10.0' }}
111+
- name: Grab PHPUnit version
112+
id: phpunit_version
113+
run: echo "VERSION=$(vendor/bin/phpunit --version | grep --only-matching --max-count=1 --extended-regexp '\b[0-9]+\.[0-9]+')" >> $GITHUB_OUTPUT
114+
115+
- name: "DEBUG: Show grabbed version"
116+
run: echo ${{ steps.phpunit_version.outputs.VERSION }}
117+
118+
- name: "Run the unit tests (PHPUnit < 10)"
119+
if: ${{ ! startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }}
113120
run: composer test
114121

115-
- name: Trial run the unit tests against PHPUnit 10.0
116-
if: ${{ matrix.phpunit == '^10.0' }}
122+
- name: "Trial run the unit tests against PHPUnit 10.0"
123+
if: ${{ startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }}
117124
continue-on-error: true
118-
run: composer test
125+
run: composer test10

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ vendor/
55
/phpcs.xml
66
.cache/phpcs.cache
77
/phpunit.xml
8+
/phpunit10.xml
89
/.phpunit.result.cache
910
/build/

composer.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@
6868
],
6969
"coverage": [
7070
"@php ./vendor/phpunit/phpunit/phpunit"
71+
],
72+
"test10": [
73+
"@php ./vendor/phpunit/phpunit/phpunit -c phpunit10.xml.dist --no-coverage"
74+
],
75+
"coverage10": [
76+
"@php ./vendor/phpunit/phpunit/phpunit -c phpunit10.xml.dist"
7177
]
7278
}
7379
}

phpunit10.xml.dist

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
5+
backupGlobals="true"
6+
bootstrap="./tests/bootstrap.php"
7+
beStrictAboutOutputDuringTests="true"
8+
beStrictAboutTestsThatDoNotTestAnything="true"
9+
colors="true"
10+
cacheDirectory=".cache/phpcs.cache"
11+
requireCoverageMetadata="true"
12+
displayDetailsOnTestsThatTriggerErrors="true"
13+
displayDetailsOnTestsThatTriggerWarnings="true"
14+
displayDetailsOnTestsThatTriggerNotices="true"
15+
displayDetailsOnTestsThatTriggerDeprecations="true"
16+
>
17+
18+
<testsuites>
19+
<testsuite name="PHPUnitPolyfills">
20+
<directory suffix="Test.php">./tests/</directory>
21+
</testsuite>
22+
</testsuites>
23+
24+
<coverage includeUncoveredFiles="true">
25+
<include>
26+
<directory suffix=".php">./src/</directory>
27+
</include>
28+
<exclude>
29+
<file>src/Polyfills/AssertClosedResource_Empty.php</file>
30+
</exclude>
31+
<report>
32+
<clover outputFile="build/logs/clover.xml"/>
33+
</report>
34+
</coverage>
35+
36+
</phpunit>

0 commit comments

Comments
 (0)