Skip to content

Commit

Permalink
add a phpunit config for postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
mszulik committed Dec 12, 2024
1 parent c06da56 commit 40336dd
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
9 changes: 8 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ on:
env:
MYSQL_IMAGE: mysql:8.0
MYSQL_DB_OPTIONS: "--health-cmd=\"mysqladmin ping\" --health-interval=10s --health-timeout=5s --health-retries=3"
MYSQL_PHPUNIT_CONFIG: "phpunit-ci-mysql.xml.dist"
POSTGRES_IMAGE: postgres:17
POSTGRES_DB_OPTIONS: "--health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3"
POSTGRES_PHPUNIT_CONFIG: "phpunit-ci-postgres.xml.dist"

jobs:
# Environment variables are not available in the matrix context, so we have to define them as outputs.
Expand All @@ -22,8 +24,10 @@ jobs:
outputs:
MYSQL_IMAGE: ${{ env.MYSQL_IMAGE }}
MYSQL_DB_OPTIONS: ${{ env.MYSQL_DB_OPTIONS }}
MYSQL_PHPUNIT_CONFIG: ${{ env.MYSQL_PHPUNIT_CONFIG }}
POSTGRES_IMAGE: ${{ env.POSTGRES_IMAGE }}
POSTGRES_DB_OPTIONS: ${{ env.POSTGRES_DB_OPTIONS }}
POSTGRES_PHPUNIT_CONFIG: ${{ env.POSTGRES_PHPUNIT_CONFIG }}
steps:
# Placeholder because a job needs a step.
- run: echo "null"
Expand All @@ -37,6 +41,7 @@ jobs:
matrix:
db-image: [ "${{ needs.prepare.outputs.MYSQL_IMAGE }}", "${{ needs.prepare.outputs.POSTGRES_IMAGE }}" ]
db-options: [ "${{ needs.prepare.outputs.MYSQL_DB_OPTIONS }}", "${{ needs.prepare.outputs.POSTGRES_DB_OPTIONS }}" ]
phpunit-config: [ "${{ needs.prepare.outputs.MYSQL_PHPUNIT_CONFIG }}", "${{ needs.prepare.outputs.POSTGRES_PHPUNIT_CONFIG }}" ]
php: [ 8.1, 8.2, 8.3 ]
laravel: [ 9.*, 10.*, 11.* ]
dependency-version: [ prefer-stable ]
Expand All @@ -47,13 +52,15 @@ jobs:
laravel: 11.*
- db-image: "${{ needs.prepare.outputs.MYSQL_IMAGE }}"
db-options: "${{ needs.prepare.outputs.POSTGRES_DB_OPTIONS }}"
phpunit-config: "${{ needs.prepare.outputs.POSTGRES_PHPUNIT_CONFIG }}"
- db-image: "${{ needs.prepare.outputs.POSTGRES_IMAGE }}"
db-options: "${{ needs.prepare.outputs.MYSQL_DB_OPTIONS }}"
phpunit-config: "${{ needs.prepare.outputs.MYSQL_PHPUNIT_CONFIG }}"
with:
DATABASE_IMAGE: ${{ matrix.db-image }}
DATABASE_NAME: protector_test
DATABASE_OPTIONS: ${{ matrix.db-options }}
PHP_VERSION: ${{ matrix.php }}
LARAVEL_VERSION: ${{ matrix.laravel }}
DEPENDENCY_VERSION: ${{ matrix.dependency-version }}
TEST_COMMANDS: vendor/bin/phpunit -c phpunit-ci.xml.dist
TEST_COMMANDS: vendor/bin/phpunit -c ${{ matrix.phpunit-config }}
File renamed without changes.
26 changes: 26 additions & 0 deletions phpunit-ci-postgres.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" colors="true" testdox="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd">
<testsuites>
<testsuite name="Feature">
<directory>tests/feature</directory>
</testsuite>
</testsuites>
<php>
<env name="PROTECTOR_PRIVATE_KEY" value="e195f1252346e31fe7b87e899f69a87d6fe99f38bd6e7c3cbdde411fcd9cc93e2c1d0ea6e0f8e207b38bef11bfcd5c0615c3cf4695876631b1da523a552b6022"/>
<env name="PROTECTOR_PUBLIC_KEY" value="2c1d0ea6e0f8e207b38bef11bfcd5c0615c3cf4695876631b1da523a552b6022"/>
<env name="PROTECTOR_ENCRYPTED_MESSAGE" value="c93e1c30857b0a5a36dddd11237ff65ef153144e0c400304cc80501da7e9b41a99c568fb34491629577ba4b5c0ec632e50067d61cf1ece27e1eabc"/>
<env name="PROTECTOR_DECRYPTED_MESSAGE" value="hello world"/>
<env name="PROTECTOR_AUTH_TOKEN" value="1|bxa5BBNo7lXxgtRY4DN775JdAtQSAlN4UfgRnFhz"/>
<env name="DB_CONNECTION" value="pgsql"/>
<env name="DB_HOST" value="127.0.0.1"/>
<env name="DB_DATABASE" value="protector_test"/>
<env name="DB_USERNAME" value="root"/>
<env name="DB_PASSWORD" value=""/>
<env name="APP_URL" value="http://protector.invalid"/>
</php>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
</phpunit>

0 comments on commit 40336dd

Please sign in to comment.