Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
MONGO_URL="mongodb://127.0.0.1:27018/dbName?compressors=disabled&gssapiServiceName=mongodb"

USE_DAMA_DOCTRINE_TEST_BUNDLE="0"
USE_FOUNDRY_PHPUNIT_EXTENSION="0"
USE_PHP_84_LAZY_OBJECTS="0"
PHPUNIT_VERSION="13" # allowed values: 9, 10, 11, 12, 13
USE_PHP_84_LAZY_OBJECTS="1"

# Only relevant for "reset-database" testsuite
DATABASE_RESET_MODE="schema" # allowed values: schema, migrate
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ jobs:
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' || '' }}
MONGO_URL: ${{ contains(matrix.database, 'mongo') && 'mongodb://127.0.0.1:27017/dbName?compressors=disabled&gssapiServiceName=mongodb' || '' }}
USE_DAMA_DOCTRINE_TEST_BUNDLE: ${{ matrix.with-dama }}
USE_FOUNDRY_PHPUNIT_EXTENSION: 1
PHPUNIT_VERSION: ${{ matrix.phpunit }}

services:
mongo:
Expand Down
90 changes: 28 additions & 62 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,67 +21,45 @@ concurrency:

jobs:
tests:
name: P:${{ matrix.php }}, S:${{ matrix.symfony }}, D:${{ matrix.database }}, PU:${{ matrix.phpunit }}${{ matrix.deps == 'lowest' && ' (lowest)' || '' }}${{ matrix.use-phpunit-extension != 1 && ' (no phpunit extension)' || '' }}${{ (matrix.use-php-84-lazy-objects != 1 || matrix.php != '8.4') && ' (legacy proxy)' || '' }}${{ matrix.no-dama == 1 && ' (no dama)' || '' }}
name: P:${{ matrix.php }}, S:${{ matrix.symfony }}, D:${{ matrix.database }}${{ matrix.deps == 'lowest' && ' (lowest)' || '' }}${{ matrix.no-dama == 1 && ' (no dama)' || '' }}${{ matrix.disable-php-84-lazy-objects == 1 && ' (no lazy objects)' || '' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [ 8.4, 8.5 ]
symfony: [ 6.4.*, 7.4.*, 8.0.* ]
symfony: [ 8.0.* ]
database: [ mysql|mongo ]
phpunit: [ 13 ]
use-phpunit-extension: [ 1 ]
use-php-84-lazy-objects: [ 1 ]
deps: [ highest ]

include:
# old php versions
- {php: 8.1, symfony: 6.4.*, phpunit: 9, database: mysql, use-phpunit-extension: 0}
- {php: 8.2, symfony: 6.4.*, phpunit: 9, database: mysql, use-phpunit-extension: 0}

# old PHPUnit versions
- {php: 8.3, symfony: 7.4.*, phpunit: 9, database: mysql, use-phpunit-extension: 0}
- {php: 8.4, symfony: 7.4.*, phpunit: 10, database: mysql, use-phpunit-extension: 0}
- {php: 8.4, symfony: 7.4.*, phpunit: 11, database: mysql, use-phpunit-extension: 0}
- {php: 8.4, symfony: 7.4.*, phpunit: 11, database: mysql}
- {php: 8.4, symfony: 7.4.*, phpunit: 12, database: mysql, use-phpunit-extension: 0}
- {php: 8.4, symfony: 7.4.*, phpunit: 12, database: mysql}

# test with no database (PHPUnit 9 is used to prevent some problems with empty data providers)
- {php: 8.3, symfony: 7.4.*, phpunit: 9, database: none, use-phpunit-extension: 0}
- {php: 8.3, symfony: 7.4.*, phpunit: 9, database: none, deps: lowest, use-phpunit-extension: 0}

# One permutation per DBMS
- {php: 8.4, symfony: 7.4.*, phpunit: 13, database: mongo}
- {php: 8.4, symfony: 7.4.*, phpunit: 13, database: pgsql}
- {php: 8.4, symfony: 7.4.*, phpunit: 13, database: sqlite}
- {php: 8.4, symfony: 7.4.*, phpunit: 13, database: mysql}
- {php: 8.5, symfony: 8.0.*, database: mongo}
- {php: 8.5, symfony: 8.0.*, database: pgsql}
- {php: 8.5, symfony: 8.0.*, database: sqlite}
- {php: 8.5, symfony: 8.0.*, database: mysql}

# lowest deps (one per DBMS)
- {php: 8.3, symfony: 6.4.*, phpunit: 9, database: mysql|mongo, deps: lowest, use-phpunit-extension: 0}
- {php: 8.3, symfony: 6.4.*, phpunit: 9, database: mongo, deps: lowest, use-phpunit-extension: 0}
- {php: 8.3, symfony: 6.4.*, phpunit: 9, database: pgsql, deps: lowest, use-phpunit-extension: 0}
- {php: 8.3, symfony: 6.4.*, phpunit: 9, database: sqlite, deps: lowest, use-phpunit-extension: 0}
- {php: 8.3, symfony: 6.4.*, phpunit: 9, database: mysql, deps: lowest, use-phpunit-extension: 0}
# test with no database
- {php: 8.5, symfony: 8.0.*, database: none}
- {php: 8.5, symfony: 8.0.*, database: none, deps: lowest}

# Lowest deps with PHP 8.4 & lazy objects
- {php: 8.4, symfony: 6.4.*, phpunit: 13, database: mysql|mongo, deps: lowest}
# lowest deps (one per DBMS)
- {php: 8.4, symfony: 8.0.*, database: mysql|mongo, deps: lowest}
- {php: 8.4, symfony: 8.0.*, database: mongo, deps: lowest}
- {php: 8.4, symfony: 8.0.*, database: pgsql, deps: lowest}
- {php: 8.4, symfony: 8.0.*, database: sqlite, deps: lowest}
- {php: 8.4, symfony: 8.0.*, database: mysql, deps: lowest}

# Disable Foundry's PHPUnit extension and/or dama
- {php: 8.4, symfony: 7.4.*, phpunit: 13, database: mysql|mongo, use-phpunit-extension: 0}
- {php: 8.4, symfony: 7.4.*, phpunit: 13, database: mysql, use-phpunit-extension: 0, no-dama: 1}
- {php: 8.4, symfony: 7.4.*, phpunit: 13, database: mysql, no-dama: 1}
# Disable dama
- {php: 8.5, symfony: 8.0.*, database: mysql, no-dama: 1}

# disable lazy objects in PHP 8.4
- {php: 8.4, symfony: 7.4.*, phpunit: 13, database: mysql|mongo, use-php-84-lazy-objects: 0}
- { php: 8.4, symfony: 8.0.*, database: mysql|mongo, disable-php-84-lazy-objects: 1 }
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' || '' }}
MONGO_URL: ${{ contains(matrix.database, 'mongo') && 'mongodb://127.0.0.1:27017/dbName?compressors=disabled&gssapiServiceName=mongodb' || '' }}
USE_DAMA_DOCTRINE_TEST_BUNDLE: ${{ contains(matrix.database, 'sql') && matrix.no-dama != 1 && 1 || 0 }}
USE_FOUNDRY_PHPUNIT_EXTENSION: ${{ matrix.use-phpunit-extension || 0 }}
USE_PHP_84_LAZY_OBJECTS: ${{ matrix.use-php-84-lazy-objects }}
PHPUNIT_VERSION: ${{ matrix.phpunit }}
WITH_LOWEST_DEPENDENCIES: ${{ matrix.deps == 'lowest' && 1 || 0 }}
USE_PHP_84_LAZY_OBJECTS: ${{ matrix.disable-php-84-lazy-objects != 1 && 1 || 0}}
services:
postgres:
image: ${{ contains(matrix.database, 'pgsql') && 'postgres:15' || '' }}
Expand Down Expand Up @@ -111,18 +89,14 @@ jobs:
coverage: none
tools: flex

- name: Add the polyfill compatible with Doctrine ^2.16
if: ${{ matrix.deps == 'lowest' }}
shell: bash
run: composer require --dev symfony/polyfill-php80:^1.16 --no-update

- name: Install dependencies
uses: ramsey/composer-install@v2
with:
dependency-versions: ${{ matrix.deps }}
composer-options: --prefer-dist
env:
SYMFONY_REQUIRE: ${{ matrix.symfony }}

- name: Set up MySQL
if: contains(matrix.database, 'mysql')
run: sudo /etc/init.d/mysql start
Expand All @@ -134,7 +108,7 @@ jobs:
SYMFONY_REQUIRE: ${{ matrix.symfony }}

test-reset-database:
name: Reset DB - D:${{ matrix.database }} ${{ matrix.use-dama == 1 && ' (dama)' || '' }} ${{ matrix.reset-database-mode == 'migrate' && ' (migrate)' || '' }} ${{ contains(matrix.with-migration-configuration-file, 'transactional') && '(configuration file transactional)' || contains(matrix.with-migration-configuration-file, 'configuration') && '(configuration file)' || '' }}${{ matrix.deps == 'lowest' && ' (lowest)' || '' }}${{ matrix.use-phpunit-extension == 0 && ' (no phpunit extension)' || '' }}
name: Reset DB - D:${{ matrix.database }}${{ matrix.use-dama == 1 && ' (dama)' || '' }}${{ matrix.reset-database-mode == 'migrate' && ' (migrate)' || '' }}${{ contains(matrix.with-migration-configuration-file, 'transactional') && '(configuration file transactional)' || contains(matrix.with-migration-configuration-file, 'configuration') && '(configuration file)' || '' }}${{ matrix.deps == 'lowest' && ' (lowest)' || '' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -144,22 +118,18 @@ jobs:
reset-database-mode: [ schema, migrate ]
migration-configuration-file: ['no']
deps: [ highest, lowest ]
use-phpunit-extension: [ 1 ]
include:
- { database: mongo, use-dama: 0, reset-database-mode: schema, use-phpunit-extension: 1 }
- { database: pgsql, use-dama: 1, reset-database-mode: schema, use-phpunit-extension: 0 }
- { database: pgsql, use-dama: 0, reset-database-mode: schema, use-phpunit-extension: 0 }
- { database: pgsql, migration-configuration-file: 'migration-configuration', use-dama: 0, reset-database-mode: migration, use-phpunit-extension: 1 }
- { database: pgsql, migration-configuration-file: 'migration-configuration-transactional', use-dama: 0, reset-database-mode: migration, use-phpunit-extension: 1 }
- { database: mongo, use-dama: 0, reset-database-mode: schema }
- { database: pgsql, migration-configuration-file: 'migration-configuration', use-dama: 0, reset-database-mode: migration }
- { database: pgsql, migration-configuration-file: 'migration-configuration-transactional', use-dama: 0, reset-database-mode: migration }
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: ${{ contains(matrix.database, 'mongo') && 'mongodb://127.0.0.1:27017/dbName?compressors=disabled&gssapiServiceName=mongodb' || '' }}
USE_DAMA_DOCTRINE_TEST_BUNDLE: ${{ matrix.use-dama == 1 && 1 || 0 }}
DATABASE_RESET_MODE: ${{ matrix.reset-database-mode == 1 && 1 || 0 }}
MIGRATION_CONFIGURATION_FILE: ${{ matrix.migration-configuration-file == 'no' && '' || format('tests/Fixture/MigrationTests/configs/{0}.php', matrix.migration-configuration-file) }}
PHPUNIT_VERSION: 13
WITH_LOWEST_DEPENDENCIES: ${{ matrix.deps == 'lowest' && 1 || 0 }}
USE_FOUNDRY_PHPUNIT_EXTENSION: ${{ matrix.use-phpunit-extension }}
USE_PHP_84_LAZY_OBJECTS: 1
services:
postgres:
image: ${{ contains(matrix.database, 'pgsql') && 'postgres:15' || '' }}
Expand Down Expand Up @@ -195,7 +165,7 @@ jobs:
dependency-versions: ${{ matrix.deps }}
composer-options: --prefer-dist
env:
SYMFONY_REQUIRE: 7.4.*
SYMFONY_REQUIRE: 8.0.*

- name: Set up MySQL
if: contains(matrix.database, 'mysql')
Expand All @@ -210,15 +180,15 @@ jobs:
./phpunit --testsuite reset-database --bootstrap tests/bootstrap-reset-database.php
shell: bash
env:
SYMFONY_REQUIRE: 7.4.*
SYMFONY_REQUIRE: 8.0.*

test-no-framework:
name: No framework - PHP${{ matrix.php }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [ 8.3, 8.4, 8.5 ]
php: [ 8.4, 8.5 ]
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand Down Expand Up @@ -299,9 +269,6 @@ jobs:
DATABASE_URL: postgresql://root:root@localhost:5432/foundry?serverVersion=15
MONGO_URL: mongodb://127.0.0.1:27017/dbName?compressors=disabled&gssapiServiceName=mongodb
USE_DAMA_DOCTRINE_TEST_BUNDLE: 1
USE_FOUNDRY_PHPUNIT_EXTENSION: 1
USE_PHP_84_LAZY_OBJECTS: 1
PHPUNIT_VERSION: 13
FOUNDRY_FAKER_SEED: 1234
services:
mongo:
Expand Down Expand Up @@ -350,4 +317,3 @@ jobs:
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml

51 changes: 23 additions & 28 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,42 +16,41 @@
}
],
"require": {
"php": ">=8.1",
"php": ">=8.4",
"fakerphp/faker": "^1.24",
"symfony/deprecation-contracts": "^2.2|^3.0",
"symfony/polyfill-php84": "^1.32",
"symfony/polyfill-php85": "^1.33",
"symfony/property-access": "^6.4|^7.0|^8.0",
"symfony/property-info": "^6.4|^7.0|^8.0",
"symfony/var-exporter": "^6.4.9|~7.0.9|^7.1.2|^8.0",
"symfony/property-access": "^8.0",
"symfony/property-info": "^8.0",
"symfony/var-exporter": "^8.0",
"zenstruck/assert": "^1.4"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.8",
"dama/doctrine-test-bundle": "^8.0",
"doctrine/collections": "^1.7|^2.0",
"doctrine/collections": "^2.0",
"doctrine/common": "^3.2.2",
"doctrine/doctrine-bundle": "^2.10|^3.0",
"doctrine/doctrine-migrations-bundle": "^2.2|^3.0",
"doctrine/mongodb-odm": "^2.4",
"doctrine/mongodb-odm-bundle": "^4.6|^5.0",
"doctrine/orm": "^2.16|^3.0",
"doctrine/persistence": "^2.0|^3.0|^4.0",
"phpunit/phpunit": "^9.5.0 || ^10.0 || ^11.0 || ^12.0 || ^13.0",
"symfony/browser-kit": "^6.4|^7.0|^8.0",
"symfony/console": "^6.4|^7.0|^8.0",
"symfony/dotenv": "^6.4|^7.0|^8.0",
"symfony/event-dispatcher": "^6.4|^7.0|^8.0",
"doctrine/doctrine-bundle": "^3.0",
"doctrine/doctrine-migrations-bundle": "^3.0",
"doctrine/mongodb-odm": "^2.16",
"doctrine/mongodb-odm-bundle": "^5.6",
"doctrine/orm": "^3.0",
"doctrine/persistence": "^3.3.1|^4.0",
"phpunit/phpunit": "^13.0",
"symfony/browser-kit": "^8.0",
"symfony/console": "^8.0",
"symfony/dotenv": "^8.0",
"symfony/event-dispatcher": "^8.0",
"symfony/flex": "^2.10",
"symfony/framework-bundle": "^6.4|^7.0|^8.0",
"symfony/framework-bundle": "^8.0",
"symfony/maker-bundle": "^1.55",
"symfony/phpunit-bridge": "^6.4.26|^7.0|^8.0",
"symfony/routing": "^6.4|^7.0|^8.0",
"symfony/runtime": "^6.4|^7.0|^8.0",
"symfony/phpunit-bridge": "^8.0",
"symfony/routing": "^8.0",
"symfony/runtime": "^8.0",
"symfony/translation-contracts": "^3.4",
"symfony/uid": "^6.4|^7.0|^8.0",
"symfony/var-dumper": "^6.4|^7.0|^8.0",
"symfony/yaml": "^6.4|^7.0|^8.0",
"symfony/uid": "^8.0",
"symfony/var-dumper": "^8.0",
"symfony/yaml": "^8.0",
"webmozart/assert": "^1.11"
},
"autoload": {
Expand Down Expand Up @@ -84,10 +83,6 @@
"symfony/runtime": false
}
},
"conflict": {
"doctrine/persistence": "<2.0",
"doctrine/cache": "<1.12.1"
},
"extra": {
"bamarni-bin": {
"target-directory": "bin/tools",
Expand Down
4 changes: 2 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ parameters:

- tests/Fixture/Maker/expected/can_create_factory_with_auto_activated_not_persisted_option.php
- tests/Fixture/Maker/expected/can_create_factory_interactively.php
- tests/Fixture/Maker/expected/can_create_factory_with_embeddable_with_data_set_odm.php
- tests/Fixture/Maker/expected/can_create_factory_with_embeddable_with_data_set_orm.php
- tests/Fixture/Maker/expected/can_create_factory_with_embeddable_odm.php
- tests/Fixture/Maker/expected/can_create_factory_with_embeddable_orm.php

# phpstan runs with orm 3 - there are too many failures in these files which are compatible with orm 2
- ./src/Maker/Factory/LegacyORMDefaultPropertiesGuesser.php
Expand Down
69 changes: 9 additions & 60 deletions phpunit
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,6 @@
set -o errexit
set -o nounset

COMPOSER_BIN="php -d xdebug.mode=off $(which composer)"

check_phpunit_version() {
INSTALLED_PHPUNIT_VERSION=$(${COMPOSER_BIN} info phpunit/phpunit | grep versions | cut -c 14-)

REQUIRED_PHPUNIT_VERSION="${1?}"

if [[ "${INSTALLED_PHPUNIT_VERSION}" == "${REQUIRED_PHPUNIT_VERSION}"* ]]; then
echo 1;
else
echo 0;
fi
}

### >> load env vars from .env files if not in CI and not from a composer script
if [ -z "${CI:-}" ] ; then
source .env
Expand All @@ -27,59 +13,22 @@ if [ -z "${CI:-}" ] ; then
fi
### <<

### >> update PHPUnit if needed
if [[ " 9 10 11 12 13 " != *" ${PHPUNIT_VERSION-9} "* ]]; then
echo "❌ PHPUNIT_VERSION should be one of 9, 10, 11, 12, 13";
exit 1;
fi

SHOULD_UPDATE_PHPUNIT=$(check_phpunit_version "${PHPUNIT_VERSION}")

if [ "${SHOULD_UPDATE_PHPUNIT}" = "0" ]; then
echo "ℹ️ Upgrading PHPUnit to ${PHPUNIT_VERSION}"
${COMPOSER_BIN} update dama/doctrine-test-bundle "phpunit/phpunit:^${PHPUNIT_VERSION}" -W
fi
### <<

### >> actually execute PHPUnit with the right options
DAMA_EXTENSION="DAMA\DoctrineTestBundle\PHPUnit\PHPUnitExtension"
FOUNDRY_EXTENSION="Zenstruck\Foundry\PHPUnit\FoundryExtension"

if [ "${USE_FOUNDRY_PHPUNIT_EXTENSION:-0}" = "1" ] && [ "${PHPUNIT_VERSION}" = "9" ]; then
echo "❌ USE_FOUNDRY_PHPUNIT_EXTENSION cannot be used with PHPUNIT_VERSION=10";
exit 1;
fi

PHPUNIT_EXEC="vendor/bin/phpunit"
case ${PHPUNIT_VERSION} in
"9")
PHPUNIT_EXEC="${PHPUNIT_EXEC} -c phpunit-9.xml.dist"
if [ "${USE_DAMA_DOCTRINE_TEST_BUNDLE:-0}" = "1" ]; then
PHPUNIT_EXEC="${PHPUNIT_EXEC} --extensions ${DAMA_EXTENSION}"
fi
;;
PHPUNIT_EXEC="vendor/bin/phpunit -c phpunit.xml.dist"
PHPUNIT_EXEC="${PHPUNIT_EXEC} --extension Zenstruck\Foundry\Tests\Fixture\DoctrineCascadeRelationship\PhpUnitTestExtension"

"10")
# PHPUnit 10 does not have a --extension option
PHPUNIT_EXEC="${PHPUNIT_EXEC} -c phpunit.xml.dist"
;;

"11"|"12"|"13")
PHPUNIT_EXEC="${PHPUNIT_EXEC} -c phpunit.xml.dist --extension Zenstruck\Foundry\Tests\Fixture\DoctrineCascadeRelationship\PhpUnitTestExtension"

if [ "${USE_DAMA_DOCTRINE_TEST_BUNDLE:-0}" = "1" ]; then
PHPUNIT_EXEC="${PHPUNIT_EXEC} --extension "${DAMA_EXTENSION}""
fi
if [ "${USE_DAMA_DOCTRINE_TEST_BUNDLE:-0}" = "1" ]; then
PHPUNIT_EXEC="${PHPUNIT_EXEC} --extension ${DAMA_EXTENSION}"
fi

if [ "${USE_FOUNDRY_PHPUNIT_EXTENSION:-0}" = "1" ]; then
PHPUNIT_EXEC="${PHPUNIT_EXEC} --extension "${FOUNDRY_EXTENSION}""
fi
PHPUNIT_EXEC="${PHPUNIT_EXEC} --extension ${FOUNDRY_EXTENSION}"

if [ "${WITH_LOWEST_DEPENDENCIES:-0}" = "1" ]; then
PHPUNIT_EXEC="${PHPUNIT_EXEC} --do-not-fail-on-deprecation --do-not-fail-on-phpunit-deprecation"
fi
;;
esac
if [ "${WITH_LOWEST_DEPENDENCIES:-0}" = "1" ]; then
PHPUNIT_EXEC="${PHPUNIT_EXEC} --do-not-fail-on-deprecation --do-not-fail-on-phpunit-deprecation"
fi

PHPUNIT_EXEC="${PHPUNIT_EXEC} $*"

Expand Down
Loading
Loading