From 52e1a558d2cc4c8dadc54549457174a907eb5fab Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Sun, 4 Feb 2024 21:37:13 +0100 Subject: [PATCH 1/2] feat: allow doctrine/orm 3 for tests --- composer.json | 158 +++++++++++++++++++++++++------------------------- 1 file changed, 79 insertions(+), 79 deletions(-) diff --git a/composer.json b/composer.json index b3557fa6..0afafc7e 100644 --- a/composer.json +++ b/composer.json @@ -1,83 +1,83 @@ { - "name": "liip/test-fixtures-bundle", - "description": "This bundles enables efficient loading of Doctrine fixtures in functional test-cases for Symfony applications", - "keywords": ["symfony", "testing", "fixtures"], - "type": "symfony-bundle", - "license": "MIT", - "authors": [ - { - "name": "Liip AG", - "homepage": "http://www.liip.ch/" - }, - { - "name": "Community contributions", - "homepage": "https://github.com/liip/LiipTestFixturesBundle/contributors" - } - ], - "require": { - "php": "^7.4 || ^8.0", - "doctrine/common": "^2.13 || ^3.0", - "doctrine/persistence": "^1.3.3 || ^2.0 || ^3.0", - "symfony/deprecation-contracts": "^2.1 || ^3.0", - "symfony/event-dispatcher": "^5.4 || ^6.3 || ^7.0", - "symfony/event-dispatcher-contracts": "^1 || ^2 || ^3", - "symfony/framework-bundle": "^5.4 || ^6.3 || ^7.0", - "symfony/yaml": "^5.4 || ^6.3 || ^7.0" + "name": "liip/test-fixtures-bundle", + "description": "This bundles enables efficient loading of Doctrine fixtures in functional test-cases for Symfony applications", + "keywords": ["symfony", "testing", "fixtures"], + "type": "symfony-bundle", + "license": "MIT", + "authors": [ + { + "name": "Liip AG", + "homepage": "http://www.liip.ch/" }, - "require-dev": { - "doctrine/annotations": "^1.13.1 || ^2.0", - "doctrine/data-fixtures": "^1.4.4", - "doctrine/dbal": "^2.13.1 || ^3.1", - "doctrine/doctrine-bundle": "^2.2", - "doctrine/doctrine-fixtures-bundle": "^3.4.4 || ^4.0", - "doctrine/mongodb-odm": "^2.2", - "doctrine/mongodb-odm-bundle": "^4.2.1 || ^5.0", - "doctrine/orm": "^2.14 || ^3.0", - "doctrine/phpcr-bundle": "^2.4.3 || ^3.0", - "doctrine/phpcr-odm": "^1.7.2 || ^2.0", - "jackalope/jackalope-doctrine-dbal": "^1.10.1 || ^2.0", - "monolog/monolog": "^1.25.1 || ^2.0 || ^3.0", - "phpunit/phpunit": "^9.6.17 || ^10.5.11 || ^11.0.4", - "symfony/doctrine-bridge": "^5.4 || ^6.3 || ^7.0", - "symfony/monolog-bridge": "^5.4 || ^6.3 || ^7.0", - "symfony/monolog-bundle": "^3.2", - "symfony/phpunit-bridge": "^7.0", - "theofidry/alice-data-fixtures": "^1.5.2" - }, - "conflict": { - "doctrine/annotations": "<1.13.1 || >=3.0", - "doctrine/dbal": "<2.13.1 || ~3.0.0 || >=4.0", - "doctrine/mongodb-odm": "<2.2 || >=3.0", - "doctrine/orm": "<2.14 || >=4.0" - }, - "suggest": { - "doctrine/dbal": "Required when using the fixture loading functionality with an ORM and SQLite", - "doctrine/doctrine-fixtures-bundle": "Required when using the fixture loading functionality", - "doctrine/orm": "Required when using the fixture loading functionality with an ORM and SQLite", - "hautelook/alice-bundle": "Required when using loadFixtureFiles functionality with custom providers", - "theofidry/alice-data-fixtures": "Required when using loadFixtureFiles functionality" - }, - "autoload": { - "psr-4": { - "Liip\\TestFixturesBundle\\": "src/" - } - }, - "autoload-dev": { - "psr-4": { - "Liip\\Acme\\Tests\\": "tests/" - } - }, - "config": { - "sort-packages": true, - "allow-plugins": { - "composer/package-versions-deprecated": true, - "symfony/flex": true, - "ocramius/package-versions": true - } - }, - "extra": { - "branch-alias": { - "dev-master": "2.x-dev" - } + { + "name": "Community contributions", + "homepage": "https://github.com/liip/LiipTestFixturesBundle/contributors" + } + ], + "require": { + "php": "^7.4 || ^8.0", + "doctrine/common": "^2.13 || ^3.0", + "doctrine/persistence": "^1.3.3 || ^2.0 || ^3.0", + "symfony/deprecation-contracts": "^2.1 || ^3.0", + "symfony/event-dispatcher": "^5.4 || ^6.3 || ^7.0", + "symfony/event-dispatcher-contracts": "^1 || ^2 || ^3", + "symfony/framework-bundle": "^5.4 || ^6.3 || ^7.0", + "symfony/yaml": "^5.4 || ^6.3 || ^7.0" + }, + "require-dev": { + "doctrine/annotations": "^1.13.1 || ^2.0", + "doctrine/data-fixtures": "^1.4.4", + "doctrine/dbal": "^2.13.1 || ^3.1", + "doctrine/doctrine-bundle": "^2.2", + "doctrine/doctrine-fixtures-bundle": "^3.4.4 || ^4.0", + "doctrine/mongodb-odm": "^2.2", + "doctrine/mongodb-odm-bundle": "^4.2.1 || ^5.0", + "doctrine/orm": "^2.14 || ^3.0", + "doctrine/phpcr-bundle": "^2.4.3 || ^3.0", + "doctrine/phpcr-odm": "^1.7.2 || ^2.0", + "jackalope/jackalope-doctrine-dbal": "^1.10.1 || ^2.0", + "monolog/monolog": "^1.25.1 || ^2.0 || ^3.0", + "phpunit/phpunit": "^9.6.17 || ^10.5.11 || ^11.0.4", + "symfony/doctrine-bridge": "^5.4 || ^6.3 || ^7.0", + "symfony/monolog-bridge": "^5.4 || ^6.3 || ^7.0", + "symfony/monolog-bundle": "^3.2", + "symfony/phpunit-bridge": "^7.0", + "theofidry/alice-data-fixtures": "^1.5.2" + }, + "conflict": { + "doctrine/annotations": "<1.13.1 || >=3.0", + "doctrine/dbal": "<2.13.1 || ~3.0.0 || >=4.0", + "doctrine/mongodb-odm": "<2.2 || >=3.0", + "doctrine/orm": "<2.14 || >=4.0" + }, + "suggest": { + "doctrine/dbal": "Required when using the fixture loading functionality with an ORM and SQLite", + "doctrine/doctrine-fixtures-bundle": "Required when using the fixture loading functionality", + "doctrine/orm": "Required when using the fixture loading functionality with an ORM and SQLite", + "hautelook/alice-bundle": "Required when using loadFixtureFiles functionality with custom providers", + "theofidry/alice-data-fixtures": "Required when using loadFixtureFiles functionality" + }, + "autoload": { + "psr-4": { + "Liip\\TestFixturesBundle\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Liip\\Acme\\Tests\\": "tests/" + } + }, + "config": { + "sort-packages": true, + "allow-plugins": { + "composer/package-versions-deprecated": true, + "symfony/flex": true, + "ocramius/package-versions": true + } + }, + "extra": { + "branch-alias": { + "dev-master": "2.x-dev" } + } } From a70ede3a2cb325a4faf9c540a246e96f5ad89e7b Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Sat, 17 Feb 2024 11:33:31 +0100 Subject: [PATCH 2/2] feat: allow doctrine/orm 3 and doctrine/dbal 4 (WIP) --- .../DatabaseTools/ORMSqliteDatabaseTool.php | 3 + tests/App/Entity/User.php | 2 +- tests/App/config.yml | 64 +++++++++---------- 3 files changed, 36 insertions(+), 33 deletions(-) diff --git a/src/Services/DatabaseTools/ORMSqliteDatabaseTool.php b/src/Services/DatabaseTools/ORMSqliteDatabaseTool.php index 9b3f4f54..be665ab5 100644 --- a/src/Services/DatabaseTools/ORMSqliteDatabaseTool.php +++ b/src/Services/DatabaseTools/ORMSqliteDatabaseTool.php @@ -53,6 +53,7 @@ public function loadFixtures(array $classNames = [], bool $append = false): Abst $cacheDriver->clear(); } } else { + # legacy $cacheDriver = $config->getMetadataCacheImpl(); if ($cacheDriver) { @@ -139,6 +140,7 @@ protected function disableForeignKeyChecksIfApplicable(): void if (method_exists($this->connection, 'executeQuery')) { $this->connection->executeQuery('PRAGMA foreign_keys = 0'); } else { + # legacy $this->connection->query('PRAGMA foreign_keys = 0'); } @@ -158,6 +160,7 @@ protected function enableForeignKeyChecksIfApplicable(): void if (method_exists($this->connection, 'executeQuery')) { $this->connection->executeQuery('PRAGMA foreign_keys = 1'); } else { + # legacy $this->connection->query('PRAGMA foreign_keys = 1'); } diff --git a/tests/App/Entity/User.php b/tests/App/Entity/User.php index a77b4632..b8e79b4c 100644 --- a/tests/App/Entity/User.php +++ b/tests/App/Entity/User.php @@ -61,7 +61,7 @@ class User public function __construct() { $this->salt = sha1( - // http://php.net/manual/fr/function.openssl-random-pseudo-bytes.php + // http://php.net/manual/fr/function.openssl-random-pseudo-bytes.php bin2hex(openssl_random_pseudo_bytes(100)) ); } diff --git a/tests/App/config.yml b/tests/App/config.yml index 7b40a2db..7c75344d 100644 --- a/tests/App/config.yml +++ b/tests/App/config.yml @@ -2,45 +2,45 @@ # Tests/App/config.yml framework: - secret: secret - test: ~ - profiler: - collect: false - property_access: ~ + secret: secret + test: ~ + profiler: + collect: false + property_access: ~ monolog: - handlers: - main: - type: fingers_crossed - action_level: error - handler: nested - nested: - type: stream - path: "%kernel.logs_dir%/%kernel.environment%.log" - level: debug + handlers: + main: + type: fingers_crossed + action_level: error + handler: nested + nested: + type: stream + path: "%kernel.logs_dir%/%kernel.environment%.log" + level: debug liip_test_fixtures: ~ doctrine: - orm: - default_entity_manager: default - entity_managers: - default: - connection: default - mappings: - LiipAcme: - dir: "%kernel.project_dir%/Entity" - prefix: 'Liip\Acme\Tests\App\Entity' - is_bundle: false + orm: + default_entity_manager: default + entity_managers: + default: + connection: default + mappings: + LiipAcme: + dir: "%kernel.project_dir%/Entity" + prefix: 'Liip\Acme\Tests\App\Entity' + is_bundle: false services: - _defaults: - autowire: true - autoconfigure: true + _defaults: + autowire: true + autoconfigure: true - Liip\Acme\Tests\App\DataFixtures\ORM\: - resource: 'DataFixtures/ORM/*' - tags: ['doctrine.fixture.orm'] + Liip\Acme\Tests\App\DataFixtures\ORM\: + resource: 'DataFixtures/ORM/*' + tags: ['doctrine.fixture.orm'] - Liip\Acme\Tests\App\Service\: - resource: './Service/' + Liip\Acme\Tests\App\Service\: + resource: './Service/'