Skip to content

Commit 5ca7460

Browse files
committed
Integrate unit tests with github actions
1 parent 23b0c3b commit 5ca7460

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

.github/workflows/pull_request.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,21 @@ jobs:
3131
- name: Setup tmate session
3232
if: ${{ github.event.inputs.tmate_enabled == 1 }}
3333
uses: mxschmitt/action-tmate@v3
34+
35+
tests:
36+
name: Unit tests
37+
runs-on: ubuntu-latest
38+
strategy:
39+
matrix:
40+
php-version: [8.2, 8.3, 8.4]
41+
steps:
42+
- name: Checkout
43+
uses: actions/checkout@v5
44+
- name: Setup PHP
45+
uses: shivammathur/setup-php@v2
46+
with:
47+
php-version: ${{ matrix.php-version }}
48+
- name: Composer install
49+
run: composer install
50+
- name: Run tests
51+
run: vendor/bin/phpunit -c phpunit.xml

composer.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
},
2828
"require-dev": {
2929
"drupal/coder": "^8.3",
30-
"squizlabs/php_codesniffer": "^3.4"
30+
"squizlabs/php_codesniffer": "^3.4",
31+
"phpunit/phpunit": "^12.4"
3132
},
3233
"scripts": {
3334
"codesniff": [
@@ -39,6 +40,9 @@
3940
"vendor/bin/phpcbf . --ignore=vendor src"
4041
],
4142
"code:lint": "find src -name '*.php' -print0 | xargs -0 -n1 php -l",
43+
"code:test" : [
44+
"vendor/bin/phpunit -c ./phpunit.xml"
45+
],
4246
"pre-commit": [
4347
"composer validate --strict",
4448
"@codesniff",

phpunit.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<phpunit
2+
beStrictAboutTestsThatDoNotTestAnything="true"
3+
beStrictAboutOutputDuringTests="true"
4+
beStrictAboutChangesToGlobalState="true"
5+
failOnWarning="true"
6+
cacheResult="false">
7+
<testsuites>
8+
<testsuite name="unit">
9+
<directory>./tests/src/</directory>
10+
</testsuite>
11+
</testsuites>
12+
</phpunit>

0 commit comments

Comments
 (0)