diff --git a/.env b/.env
index da52e373..a27200d4 100644
--- a/.env
+++ b/.env
@@ -1,5 +1,4 @@
DATABASE_URL="mysql://root:1234@127.0.0.1:3307/foundry_test?serverVersion=5.7.42"
MONGO_URL="mongodb://127.0.0.1:27018/dbName?compressors=disabled&gssapiServiceName=mongodb"
-DATABASE_RESET_MODE="schema"
USE_DAMA_DOCTRINE_TEST_BUNDLE="0"
PHPUNIT_VERSION="9"
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 0d5bced4..3bc50982 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -8,7 +8,7 @@ on:
jobs:
tests:
- name: P:${{ matrix.php }}, S:${{ matrix.symfony }}, D:${{ matrix.database }}, PU:${{ matrix.phpunit }}${{ matrix.deps == 'lowest' && ' (lowest)' || '' }}${{ matrix.use-dama == 1 && contains(matrix.database, 'sql') && ' (dama)' || '' }}${{ !contains(matrix.database, 'sql') && '' || matrix.use-migrate == 1 && ' (migrate)' || ' (schema)' }}
+ name: P:${{ matrix.php }}, S:${{ matrix.symfony }}, D:${{ matrix.database }}, PU:${{ matrix.phpunit }}${{ matrix.deps == 'lowest' && ' (lowest)' || '' }}${{ matrix.use-dama == 1 && contains(matrix.database, 'sql') && ' (dama)' || '' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
@@ -18,7 +18,6 @@ jobs:
symfony: [ 6.4.*, 7.0.*, 7.1.* ]
database: [ mysql, mongo ]
use-dama: [ 1 ]
- use-migrate: [ 0 ]
phpunit: [ 9 ]
exclude:
- php: 8.1
@@ -31,70 +30,60 @@ jobs:
symfony: '*'
database: none
use-dama: 1
- use-migrate: 0
phpunit: 9
- php: 8.3
deps: highest
symfony: '*'
database: mysql|mongo
use-dama: 1
- use-migrate: 0
phpunit: 9
- php: 8.3
deps: highest
symfony: '*'
database: pgsql|mongo
use-dama: 1
- use-migrate: 0
phpunit: 9
- php: 8.3
deps: highest
symfony: '*'
database: pgsql
use-dama: 0
- use-migrate: 0
phpunit: 9
- php: 8.3
deps: highest
symfony: '*'
database: sqlite
use-dama: 0
- use-migrate: 0
phpunit: 9
- php: 8.3
deps: lowest
symfony: '*'
database: sqlite
use-dama: 0
- use-migrate: 0
phpunit: 9
- php: 8.3
deps: lowest
symfony: '*'
database: mysql
use-dama: 1
- use-migrate: 0
phpunit: 9
- php: 8.3
deps: highest
symfony: '*'
database: mysql
use-dama: 1
- use-migrate: 1
phpunit: 9
- php: 8.3
deps: highest
symfony: '*'
database: mysql|mongo
use-dama: 1
- use-migrate: 0
phpunit: 10
- php: 8.3
deps: highest
symfony: '*'
database: mysql|mongo
use-dama: 1
- use-migrate: 0
phpunit: 11
env:
DATABASE_URL: ${{ contains(matrix.database, 'mysql') && 'mysql://root:root@localhost:3306/foundry?serverVersion=5.7.42' || contains(matrix.database, 'pgsql') && 'postgresql://root:root@localhost:5432/foundry?serverVersion=15' || contains(matrix.database, 'sqlite') && 'sqlite:///%kernel.project_dir%/var/data.db' || '' }}
@@ -145,8 +134,68 @@ jobs:
- name: Test
run: ./phpunit
shell: bash
+
+ test-reset-database-with-migration:
+ name: Test migration - D:${{ matrix.database }}, ${{ matrix.use-dama == 1 && ' (dama)' || '' }}
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ database: [ mysql, pgsql, sqlite ]
+ use-dama: [ 0, 1 ]
+ with-migration-configuration-file:
+ - ''
+ - 'tests/Fixture/MigrationTests/configs/migration-configuration.php'
+ - 'tests/Fixture/MigrationTests/configs/migration-configuration-transactional.php'
+ exclude:
+ - database: mysql
+ with-migration-configuration-file: 'tests/Fixture/MigrationTests/configs/migration-configuration-transactional.php'
+ env:
+ DATABASE_URL: ${{ contains(matrix.database, 'mysql') && 'mysql://root:root@localhost:3306/foundry?serverVersion=5.7.42' || contains(matrix.database, 'pgsql') && 'postgresql://root:root@localhost:5432/foundry?serverVersion=15' || 'sqlite:///%kernel.project_dir%/var/data.db' }}
+ MONGO_URL: ''
+ USE_DAMA_DOCTRINE_TEST_BUNDLE: ${{ matrix.use-dama == 1 && 1 || 0 }}
+ WITH_MIGRATION_CONFIGURATION_FILE: ${{ matrix.with-migration-configuration-file }}
+ PHPUNIT_VERSION: 9
+ services:
+ postgres:
+ image: ${{ contains(matrix.database, 'pgsql') && 'postgres:15' || '' }}
+ env:
+ POSTGRES_USER: root
+ POSTGRES_PASSWORD: root
+ POSTGRES_DB: foundry
+ ports:
+ - 5432:5432
+ options: >-
+ --health-cmd pg_isready
+ --health-interval 10s
+ --health-timeout 5s
+ --health-retries 5
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v3
+
+ - name: Setup PHP
+ uses: shivammathur/setup-php@v2
+ with:
+ php-version: 8.3
+ coverage: none
+ tools: flex
+
+ - name: Install dependencies
+ uses: ramsey/composer-install@v2
+ with:
+ dependency-versions: highest
+ composer-options: --prefer-dist
env:
- DATABASE_RESET_MODE: ${{ matrix.use-migrate == 1 && 'migrate' || 'schema' }}
+ SYMFONY_REQUIRE: 7.1.*
+
+ - name: Set up MySQL
+ if: contains(matrix.database, 'mysql')
+ run: sudo /etc/init.d/mysql start
+
+ - name: Test
+ run: ./phpunit --testsuite migrate --bootstrap tests/bootstrap-migrate.php
+ shell: bash
code-coverage:
name: Code Coverage
diff --git a/.gitignore b/.gitignore
index ee9e61fd..6d5aba94 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,5 +14,5 @@
/docker/.makefile
/.env.local
/docker-compose.override.yaml
-/tests/Fixture/Migrations/
+/tests/Fixture/MigrationTests/Migrations/
/tests/Fixture/Maker/tmp/
diff --git a/README.md b/README.md
index 4472e279..ba954bc3 100644
--- a/README.md
+++ b/README.md
@@ -47,20 +47,15 @@ $ docker compose up --detach
# install dependencies
$ composer update
-# run test suite with all available permutations
-$ composer test
-
-# run only one permutation
+# run main testsuite (with "schema" reset database strategy)
+$ composer test-schema
+# or
$ ./phpunit
-# run test suite with dama/doctrine-test-bundle
-$ USE_DAMA_DOCTRINE_TEST_BUNDLE=1 vendor/bin/phpunit
-
-# run test suite with postgreSQL instead of MySQL
-$ DATABASE_URL="postgresql://zenstruck:zenstruck@127.0.0.1:5433/zenstruck_foundry?serverVersion=15" vendor/bin/phpunit
-
-# run test suite with another PHPUnit version
-$ PHPUNIT_VERSION=10 vendor/bin/phpunit
+# run "migrate" testsuite (with "migrate" reset database strategy)
+$ composer test-migrate
+# or
+$ ./phpunit --testsuite migrate --bootstrap tests/bootstrap-migrate.php
```
### Overriding the default configuration
@@ -69,11 +64,20 @@ You can override default environment variables by creating a `.env.local` file,
```bash
# .env.local
-DATABASE_URL="postgresql://zenstruck:zenstruck@127.0.0.1:5433/zenstruck_foundry?serverVersion=15" # enables postgreSQL instead of MySQL
+
+# change the database to postgreSQL...
+DATABASE_URL="postgresql://zenstruck:zenstruck@127.0.0.1:5433/zenstruck_foundry?serverVersion=15"
+# ...or to SQLite
+DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
+
MONGO_URL="" # disables Mongo
USE_DAMA_DOCTRINE_TEST_BUNDLE="1" # enables dama/doctrine-test-bundle
PHPUNIT_VERSION="11" # possible values: 9, 10, 11, 11.4
+# test reset database with configuration migration,
+# only relevant for "migrate" testsuite
+WITH_MIGRATION_CONFIGURATION_FILE="tests/Fixture/MigrationTests/configs/migration-configuration.php"
+
# run test suite with postgreSQL
$ vendor/bin/phpunit
```
diff --git a/composer.json b/composer.json
index aec2e99e..3a6b8ad5 100644
--- a/composer.json
+++ b/composer.json
@@ -48,7 +48,12 @@
"Zenstruck\\Foundry\\": "src/",
"Zenstruck\\Foundry\\Psalm\\": "utils/psalm"
},
- "files": ["src/functions.php", "src/Persistence/functions.php", "src/phpunit_helper.php"]
+ "files": [
+ "src/functions.php",
+ "src/Persistence/functions.php",
+ "src/phpunit_helper.php",
+ "src/symfony_console.php"
+ ]
},
"autoload-dev": {
"psr-4": {
@@ -77,22 +82,15 @@
},
"scripts": {
"test": [
- "@test-schema-no-dama",
- "@test-migrate-no-dama",
- "@test-schema-dama",
- "@test-migrate-dama"
+ "@test-schema",
+ "@test-migrate"
],
- "test-schema-no-dama": "DATABASE_RESET_MODE=schema USE_DAMA_DOCTRINE_TEST_BUNDLE=0 ./phpunit",
- "test-migrate-no-dama": "DATABASE_RESET_MODE=migrate USE_DAMA_DOCTRINE_TEST_BUNDLE=0 ./phpunit",
- "test-schema-dama": "DATABASE_RESET_MODE=schema USE_DAMA_DOCTRINE_TEST_BUNDLE=1 ./phpunit",
- "test-migrate-dama": "DATABASE_RESET_MODE=migrate USE_DAMA_DOCTRINE_TEST_BUNDLE=1 ./phpunit"
+ "test-schema": "./phpunit",
+ "test-migrate": "./phpunit --testsuite migrate --bootstrap tests/bootstrap-migrate.php"
},
"scripts-descriptions": {
- "test": "Run all test permutations",
- "test-schema-no-dama": "Test with schema reset (no dama/doctrine-test-bundle)",
- "test-migrate-no-dama": "Test with migrations reset (no dama/doctrine-test-bundle)",
- "test-schema-dama": "Test with schema reset and dama/doctrine-test-bundle",
- "test-migrate-dama": "Test with migrations reset and dama/doctrine-test-bundle"
+ "test-schema": "Test with schema reset",
+ "test-migrate": "Test with migrations reset"
},
"minimum-stability": "dev",
"prefer-stable": true
diff --git a/phpunit-10.xml.dist b/phpunit-10.xml.dist
index 1727f9b8..5af371de 100644
--- a/phpunit-10.xml.dist
+++ b/phpunit-10.xml.dist
@@ -14,8 +14,12 @@
-
+
tests
+ tests/Integration/Migration/ResetDatabaseWithMigrationTest.php
+
+
+ tests/Integration/Migration/ResetDatabaseWithMigrationTest.php