Skip to content

Commit

Permalink
feat: Add workflow for unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
paxuclus committed Oct 30, 2024
1 parent 19acc2d commit 5987dc8
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/unittests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: unittests

on: [ push, pull_request ]

jobs:
unittests:
name: '[PHP ${{ matrix.php-version }} | Flow ${{ matrix.flow-version }}] Unit Tests'
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
php-version: [ 8.1, 8.2, 8.3 ]
dbal-version: [ 2.13, 3.8 ]

env:
APP_ENV: true
TEST_DIR: test-dir

steps:
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, xml, json, zlib, iconv, intl, pdo_sqlite
ini-values: opcache.fast_shutdown=0

- name: Checkout code
uses: actions/checkout@v4
with:
path: ${{ env.TEST_DIR }}/dist/upsert

- name: "Create composer.json"
run: |
echo '{
"name": "netlogix/upsert-test",
"description": "",
"license": "GPL-3.0-or-later",
"require": {
"netlogix/doctrine-upsert": "@dev",
"doctrine/dbal": "^${{ matrix.dbal-version }}"
},
"require-dev": {
"phpunit/phpunit": "^10.5"
},
"repositories": [
{
"type": "path",
"url": "dist/upsert"
}
]
}' > composer.json
working-directory: ${{ env.TEST_DIR }}

- name: "Install project"
run: composer install
working-directory: ${{ env.TEST_DIR }}

- name: Run tests
run: vendor/bin/phpunit -c dist/upsert/phpunit.xml.dist --testsuite="Unit"
working-directory: ${{ env.TEST_DIR }}
30 changes: 30 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0"?>
<phpunit
beStrictAboutChangesToGlobalState="true"
beStrictAboutOutputDuringTests="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
timeoutForSmallTests="0">
<testsuites>
<testsuite name="Unit">
<directory>./test/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">./Classes</directory>
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="Build/Artifacts/Reports/PhpUnit/Coverage"/>
<log type="coverage-clover" target="Build/Artifacts/Reports/PhpUnit/clover.xml"/>
<log type="coverage-crap4j" target="Build/Artifacts/Reports/PhpUnit/crap4j.xml"/>
<log type="junit" target="Build/Artifacts/Reports/PhpUnit/junit.xml"/>
</logging>
<php>
<ini name="date.timezone" value="Europe/Berlin"/>
<ini name="error_reporting" value="E_ALL &amp; ~E_DEPRECATED"/>
<env name="FLOW_REWRITEURLS" value="1"/>
</php>
</phpunit>

0 comments on commit 5987dc8

Please sign in to comment.