From 5ca74600c2daa4cf27d55182b6d9093734b8a28d Mon Sep 17 00:00:00 2001 From: Roshny Kunjappan Date: Thu, 23 Oct 2025 14:20:04 -0400 Subject: [PATCH 1/3] Integrate unit tests with github actions --- .github/workflows/pull_request.yml | 18 ++++++++++++++++++ composer.json | 6 +++++- phpunit.xml | 12 ++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 phpunit.xml diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 4b91bff..cbf1d4c 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -31,3 +31,21 @@ jobs: - name: Setup tmate session if: ${{ github.event.inputs.tmate_enabled == 1 }} uses: mxschmitt/action-tmate@v3 + + tests: + name: Unit tests + runs-on: ubuntu-latest + strategy: + matrix: + php-version: [8.2, 8.3, 8.4] + steps: + - name: Checkout + uses: actions/checkout@v5 + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + - name: Composer install + run: composer install + - name: Run tests + run: vendor/bin/phpunit -c phpunit.xml diff --git a/composer.json b/composer.json index af708ce..08c6ccd 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,8 @@ }, "require-dev": { "drupal/coder": "^8.3", - "squizlabs/php_codesniffer": "^3.4" + "squizlabs/php_codesniffer": "^3.4", + "phpunit/phpunit": "^12.4" }, "scripts": { "codesniff": [ @@ -39,6 +40,9 @@ "vendor/bin/phpcbf . --ignore=vendor src" ], "code:lint": "find src -name '*.php' -print0 | xargs -0 -n1 php -l", + "code:test" : [ + "vendor/bin/phpunit -c ./phpunit.xml" + ], "pre-commit": [ "composer validate --strict", "@codesniff", diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..5bb870d --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,12 @@ + + + + ./tests/src/ + + + From e9de387a6488d1aafafb075a74e185eba13c1faf Mon Sep 17 00:00:00 2001 From: Roshny Kunjappan Date: Thu, 23 Oct 2025 14:24:48 -0400 Subject: [PATCH 2/3] Change unit test command to use composer script --- .github/workflows/pull_request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index cbf1d4c..3341a40 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -48,4 +48,4 @@ jobs: - name: Composer install run: composer install - name: Run tests - run: vendor/bin/phpunit -c phpunit.xml + run: composer run-script code:test From cb9147b32f7622fd949397863e92bdd5a81ecf7e Mon Sep 17 00:00:00 2001 From: Roshny Kunjappan Date: Thu, 23 Oct 2025 14:33:24 -0400 Subject: [PATCH 3/3] Update phpunit requirement to stable version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 08c6ccd..8777724 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "require-dev": { "drupal/coder": "^8.3", "squizlabs/php_codesniffer": "^3.4", - "phpunit/phpunit": "^12.4" + "phpunit/phpunit": "@stable" }, "scripts": { "codesniff": [