Skip to content

Commit 590ff36

Browse files
committed
ci(Unit Tests): add support for phpunit <=9 and add a specific xml file.
1 parent 0151cc3 commit 590ff36

File tree

2 files changed

+51
-4
lines changed

2 files changed

+51
-4
lines changed

.github/workflows/unit-tests.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,21 @@ jobs:
131131
- name: Composer info
132132
run: composer info
133133

134-
- name: Grab PHPCS version
135-
id: phpcs_version
136-
run: echo "VERSION=$(vendor/bin/phpcs --version | grep --only-matching --max-count=1 --extended-regexp '\b[0-9]+\.[0-9]+')" >> "$GITHUB_OUTPUT"
134+
- name: Grab PHPUnit version
135+
id: phpunit_version
136+
run: echo "VERSION=$(vendor/bin/phpunit --version | grep --only-matching --max-count=1 --extended-regexp '\b[0-9]+\.[0-9]+')" >> "$GITHUB_OUTPUT"
137+
138+
- name: Determine PHPUnit config file to use
139+
id: phpunit_config
140+
shell: bash
141+
run: |
142+
if [ "${{ startsWith( steps.phpunit_version.outputs.VERSION, '11.' ) }}" == "true" ]; then
143+
echo 'FILE=phpunit.xml' >> "$GITHUB_OUTPUT"
144+
else
145+
echo 'FILE=phpunit-lte9.xml' >> "$GITHUB_OUTPUT"
146+
fi
137147
138148
- name: Run the unit tests
139-
run: composer test
149+
run: composer test -- -c ${{ steps.phpunit_config.outputs.FILE }}
140150
env:
141151
PHPCS_VERSION: ${{ matrix.phpcs_version }}

phpunit-lte9.xml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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/9.2/phpunit.xsd"
5+
backupGlobals="true"
6+
beStrictAboutOutputDuringTests="true"
7+
beStrictAboutTestsThatDoNotTestAnything="false"
8+
bootstrap="./vendor/squizlabs/php_codesniffer/tests/bootstrap.php"
9+
convertErrorsToExceptions="true"
10+
convertWarningsToExceptions="true"
11+
convertNoticesToExceptions="true"
12+
convertDeprecationsToExceptions="true"
13+
forceCoversAnnotation="true"
14+
>
15+
<testsuites>
16+
<testsuite name="yCodeTech_Sniffs">
17+
<directory>./yCodeTech/Tests/</directory>
18+
</testsuite>
19+
</testsuites>
20+
21+
<groups>
22+
<exclude>
23+
<group>CBF</group>
24+
</exclude>
25+
</groups>
26+
27+
<filter>
28+
<whitelist addUncoveredFilesFromWhitelist="true" processUncoveredFilesFromWhitelist="false">
29+
<directory suffix=".php">./yCodeTech/</directory>
30+
</whitelist>
31+
</filter>
32+
33+
<logging>
34+
<log type="coverage-text" target="php://stdout" showOnlySummary="true"/>
35+
<log type="coverage-clover" target="build/logs/clover.xml"/>
36+
</logging>
37+
</phpunit>

0 commit comments

Comments
 (0)