From 4ab8a629b7a0857c8f5a326a31f049d39f6935ea Mon Sep 17 00:00:00 2001 From: Serhii Donii Date: Mon, 3 Jun 2024 23:37:52 +0300 Subject: [PATCH 01/10] feat(o10r-symfony-template-154): Upgrade doctrine/orm to 3.* version --- composer.json | 12 +++++---- phpstan-baseline.neon | 2 ++ phpstan.neon | 1 - .../Manager/SqliteDatabaseManager.php | 6 ++--- tests/Functional/App/TestKernel.php | 6 ++--- tests/Functional/App/config/doctrine.php | 27 +++++++++++++++++++ tests/Functional/App/config/doctrine.yml | 14 ---------- .../config/doctrine_entity/BaseEntity.orm.xml | 10 +++++++ .../config/doctrine_entity/BaseEntity.orm.yml | 6 ----- .../App/config/doctrine_migrations.php | 20 ++++++++++++++ .../App/config/doctrine_migrations.yml | 8 ------ 11 files changed, 72 insertions(+), 40 deletions(-) create mode 100644 tests/Functional/App/config/doctrine.php delete mode 100644 tests/Functional/App/config/doctrine.yml create mode 100644 tests/Functional/App/config/doctrine_entity/BaseEntity.orm.xml delete mode 100644 tests/Functional/App/config/doctrine_entity/BaseEntity.orm.yml create mode 100644 tests/Functional/App/config/doctrine_migrations.php delete mode 100644 tests/Functional/App/config/doctrine_migrations.yml diff --git a/composer.json b/composer.json index 88eb34a..6f2a419 100644 --- a/composer.json +++ b/composer.json @@ -27,15 +27,16 @@ ], "license": "MIT", "require": { - "php": "^7.4 || ^8.0", + "php": "^7.4 | ^8.0", "behat/behat": "^3.0", - "doctrine/orm": "^2.0", + "doctrine/orm": "^2.0 | ^3.0", "doctrine/doctrine-bundle": "^2.0", "doctrine/doctrine-fixtures-bundle": "^3.0", "doctrine/doctrine-migrations-bundle": "^3.0", "theofidry/alice-data-fixtures": "^1.0", - "symfony/dependency-injection": "^4.4 || ^5.4 || ^6.0 || ^7.0", - "symfony/http-kernel": "^4.4 || ^5.4 || ^6.0 || ^7.0" + "symfony/dependency-injection": "^4.4 | ^5.4 | ^6.0 | ^7.0", + "symfony/http-kernel": "^4.4 | ^5.4 | ^6.0 | ^7.0", + "doctrine/dbal": "^2.0 | ^3.0" }, "require-dev": { "phpstan/phpstan": "^1.2", @@ -43,7 +44,8 @@ "slevomat/coding-standard": "^7.0", "squizlabs/php_codesniffer": "^3.6", "symfony/console": "^4.4 || ^5.4 || ^6.0 || ^7.0", - "symfony/property-access": "^4.4 || ^5.4 || ^6.0 || ^7.0" + "symfony/property-access": "^4.4 || ^5.4 || ^6.0 || ^7.0", + "symplify/config-transformer": "^12.3" }, "autoload": { "psr-4": { diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 0c5931e..d2204fc 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -12,3 +12,5 @@ parameters: message: '#Offset (.*)? does not exist on array\{(.*)?\}.#' count: 1 path: ./src/Database/Manager/SqliteDatabaseManager.php + - + identifier: missingType.iterableValue diff --git a/phpstan.neon b/phpstan.neon index 4d27dd7..cb64689 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -3,6 +3,5 @@ includes: parameters: level: max - checkMissingIterableValueType: false paths: - src/ diff --git a/src/Database/Manager/SqliteDatabaseManager.php b/src/Database/Manager/SqliteDatabaseManager.php index 2360415..4bc1baf 100644 --- a/src/Database/Manager/SqliteDatabaseManager.php +++ b/src/Database/Manager/SqliteDatabaseManager.php @@ -108,9 +108,9 @@ private function adaptDatabaseSchemaToSqlite(Schema $schema): void { foreach ($schema->getTables() as $table) { foreach ($table->getColumns() as $column) { - if ($column->hasCustomSchemaOption('collation')) { - $column->setCustomSchemaOptions(array_diff_key( - $column->getCustomSchemaOptions(), + if ($column->hasPlatformOption('collation')) { + $column->setPlatformOptions(array_diff_key( + $column->getPlatformOptions(), ['collation' => true] )); } diff --git a/tests/Functional/App/TestKernel.php b/tests/Functional/App/TestKernel.php index b817ca8..760cdab 100644 --- a/tests/Functional/App/TestKernel.php +++ b/tests/Functional/App/TestKernel.php @@ -29,8 +29,8 @@ public function registerBundles(): iterable public function registerContainerConfiguration(LoaderInterface $loader): void { - $loader->load(__DIR__ . '/config/doctrine.yml'); - $loader->load(__DIR__ . '/config/doctrine_migrations.yml'); + $loader->load(__DIR__ . '/config/doctrine.php'); + $loader->load(__DIR__ . '/config/doctrine_migrations.php'); $loader->load(__DIR__ . '/config/behat_doctrine_fixtures.yml'); } @@ -43,4 +43,4 @@ public function getProjectDir(): string { return __DIR__; } -} \ No newline at end of file +} diff --git a/tests/Functional/App/config/doctrine.php b/tests/Functional/App/config/doctrine.php new file mode 100644 index 0000000..f8bb149 --- /dev/null +++ b/tests/Functional/App/config/doctrine.php @@ -0,0 +1,27 @@ +extension('doctrine', [ + 'dbal' => [ + 'url' => 'sqlite:///%kernel.cache_dir%/data.db', + ], + 'orm' => [ + 'auto_generate_proxy_classes' => true, + 'naming_strategy' => 'doctrine.orm.naming_strategy.underscore_number_aware', + 'auto_mapping' => true, + 'mappings' => [ + 'App' => [ + 'is_bundle' => false, + 'type' => 'xml', + 'dir' => '%kernel.project_dir%/config/doctrine_entity', + 'prefix' => 'BehatDoctrineFixtures\Tests\Functional\App\Entity', + 'alias' => 'App', + ], + ], + ], + ]); +}; diff --git a/tests/Functional/App/config/doctrine.yml b/tests/Functional/App/config/doctrine.yml deleted file mode 100644 index 13fae18..0000000 --- a/tests/Functional/App/config/doctrine.yml +++ /dev/null @@ -1,14 +0,0 @@ -doctrine: - dbal: - url: 'sqlite:///%kernel.cache_dir%/data.db' - orm: - auto_generate_proxy_classes: true - naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware - auto_mapping: true - mappings: - App: - is_bundle: false - type: yml - dir: '%kernel.project_dir%/config/doctrine_entity' - prefix: 'BehatDoctrineFixtures\Tests\Functional\App\Entity' - alias: App diff --git a/tests/Functional/App/config/doctrine_entity/BaseEntity.orm.xml b/tests/Functional/App/config/doctrine_entity/BaseEntity.orm.xml new file mode 100644 index 0000000..a1d1b2c --- /dev/null +++ b/tests/Functional/App/config/doctrine_entity/BaseEntity.orm.xml @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/tests/Functional/App/config/doctrine_entity/BaseEntity.orm.yml b/tests/Functional/App/config/doctrine_entity/BaseEntity.orm.yml deleted file mode 100644 index 5529bba..0000000 --- a/tests/Functional/App/config/doctrine_entity/BaseEntity.orm.yml +++ /dev/null @@ -1,6 +0,0 @@ -BehatDoctrineFixtures\Tests\Functional\App\Entity\BaseEntity: - type: entity - table: base_entity - id: - id: - type: integer diff --git a/tests/Functional/App/config/doctrine_migrations.php b/tests/Functional/App/config/doctrine_migrations.php new file mode 100644 index 0000000..ff2997e --- /dev/null +++ b/tests/Functional/App/config/doctrine_migrations.php @@ -0,0 +1,20 @@ +extension('doctrine_migrations', [ + 'storage' => [ + 'table_storage' => [ + 'table_name' => 'migration_versions', + ], + ], + 'migrations_paths' => [ + 'BehatDoctrineFixtures\Tests\Functional\App\Migrations' => '%kernel.project_dir%/Migrations', + ], + 'organize_migrations' => 'BY_YEAR', + 'custom_template' => '%kernel.project_dir%/config/doctrine_migrations.template', + ]); +}; diff --git a/tests/Functional/App/config/doctrine_migrations.yml b/tests/Functional/App/config/doctrine_migrations.yml deleted file mode 100644 index 853703d..0000000 --- a/tests/Functional/App/config/doctrine_migrations.yml +++ /dev/null @@ -1,8 +0,0 @@ -doctrine_migrations: - storage: - table_storage: - table_name: 'migration_versions' - migrations_paths: - DoctrineMigrations: '%kernel.project_dir%/Migrations' - organize_migrations: BY_YEAR - custom_template: '%kernel.project_dir%/config/doctrine_migrations.template' From c26e70df309d87f5a09015b00ea2e1891852a4f4 Mon Sep 17 00:00:00 2001 From: Yozhef Date: Tue, 4 Jun 2024 11:19:49 +0300 Subject: [PATCH 02/10] update Codecov upload --- .github/workflows/ci.yaml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0e9d5ba..c984538 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -79,10 +79,9 @@ jobs: - name: PHPUnit tests and Log Code coverage run: vendor/bin/phpunit --coverage-clover=coverage.xml if: matrix.coverage == 'xdebug' - - - name: Run codecov - uses: codecov/codecov-action@v1 + + - name: Upload coverage reports to Codecov if: matrix.coverage == 'xdebug' + uses: codecov/codecov-action@v4.0.1 with: - file: './coverage.xml' - fail_ci_if_error: true + token: ${{ secrets.CODECOV_TOKEN }} From 96b3d569f03df07b01b83df114e25e981f735bd8 Mon Sep 17 00:00:00 2001 From: Serhii Donii Date: Tue, 4 Jun 2024 12:39:49 +0300 Subject: [PATCH 03/10] feat(o10r-symfony-template-154): Upgrade doctrine/orm to 3.* version --- .github/workflows/ci.yaml | 7 ++++++- composer.json | 8 ++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c984538..abc76dc 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -22,6 +22,9 @@ jobs: - '6.1.*' - '6.2.*' - '7.0.*' + doctrine-orm-versions: + - '^2.17' + - '^3.0' exclude: - php: '8.1' symfony-versions: '7.0.*' @@ -29,9 +32,10 @@ jobs: - description: 'Log Code Coverage' php: '8.2' coverage: 'xdebug' + doctrine-orm-versions: '^3.0' symfony-versions: '^7.0' - name: PHP ${{ matrix.php }} ${{ matrix.description }} + name: PHP ${{ matrix.php }} Symfony ${{ matrix.symfony-versions }} Doctrine ${{ matrix.doctrine-orm-versions }} ${{ matrix.description }} steps: - name: Checkout uses: actions/checkout@v2 @@ -66,6 +70,7 @@ jobs: run: | composer require symfony/dependency-injection:${{ matrix.symfony-versions }} --no-update --no-scripts composer require symfony/http-kernel:${{ matrix.symfony-versions }} --no-update --no-scripts + composer require doctrine/orm:${{ matrix.doctrine-orm-versions }} --no-update --no-scripts composer require --dev symfony/console:${{ matrix.symfony-versions }} --no-update --no-scripts composer require --dev symfony/property-access:${{ matrix.symfony-versions }} --no-update --no-scripts diff --git a/composer.json b/composer.json index 6f2a419..8ad060c 100644 --- a/composer.json +++ b/composer.json @@ -27,16 +27,16 @@ ], "license": "MIT", "require": { - "php": "^7.4 | ^8.0", + "php": "^7.4 || ^8.0", "behat/behat": "^3.0", - "doctrine/orm": "^2.0 | ^3.0", + "doctrine/orm": "^2.0 || ^3.0", "doctrine/doctrine-bundle": "^2.0", "doctrine/doctrine-fixtures-bundle": "^3.0", "doctrine/doctrine-migrations-bundle": "^3.0", "theofidry/alice-data-fixtures": "^1.0", - "symfony/dependency-injection": "^4.4 | ^5.4 | ^6.0 | ^7.0", + "symfony/dependency-injection": "^4.4 || ^5.4 || ^6.0 || ^7.0", "symfony/http-kernel": "^4.4 | ^5.4 | ^6.0 | ^7.0", - "doctrine/dbal": "^2.0 | ^3.0" + "doctrine/dbal": "^2.0 || ^3.0" }, "require-dev": { "phpstan/phpstan": "^1.2", From 3e687e04161dc9f3e69f9737011f3f7cdd4abd2e Mon Sep 17 00:00:00 2001 From: Serhii Donii Date: Tue, 4 Jun 2024 12:41:57 +0300 Subject: [PATCH 04/10] feat(o10r-symfony-template-154): Upgrade doctrine/orm to 3.* version --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index abc76dc..cb57678 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -84,7 +84,7 @@ jobs: - name: PHPUnit tests and Log Code coverage run: vendor/bin/phpunit --coverage-clover=coverage.xml if: matrix.coverage == 'xdebug' - + - name: Upload coverage reports to Codecov if: matrix.coverage == 'xdebug' uses: codecov/codecov-action@v4.0.1 From 05a6674b0a4b8a4dbc1dcaaece978911c27f7eed Mon Sep 17 00:00:00 2001 From: Serhii Donii Date: Tue, 4 Jun 2024 12:44:05 +0300 Subject: [PATCH 05/10] feat(o10r-symfony-template-154): Upgrade doctrine/orm to 3.* version --- .github/workflows/ci.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index cb57678..cbb81ae 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -28,6 +28,8 @@ jobs: exclude: - php: '8.1' symfony-versions: '7.0.*' + - doctrine-orm-versions: '^3.0' + symfony-versions: '4.4.*' include: - description: 'Log Code Coverage' php: '8.2' From b698efa3971e77e23004252f9dfcf43d2a29fc08 Mon Sep 17 00:00:00 2001 From: Serhii Donii Date: Tue, 4 Jun 2024 13:13:22 +0300 Subject: [PATCH 06/10] feat(o10r-symfony-template-154): Upgrade doctrine/orm to 3.* version --- .gitignore | 2 ++ tests/Functional/Database/DatabaseHelperTest.php | 7 ++++--- .../Database/DatabaseManager/SqliteDatabaseManagerTest.php | 3 +++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index c652d80..99eed3e 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ /package-lock.json /node_modules/ /.idea/ +/coverage +/clover.xml diff --git a/tests/Functional/Database/DatabaseHelperTest.php b/tests/Functional/Database/DatabaseHelperTest.php index 0f85cb4..a5c142c 100644 --- a/tests/Functional/Database/DatabaseHelperTest.php +++ b/tests/Functional/Database/DatabaseHelperTest.php @@ -17,15 +17,16 @@ protected function setUp(): void { parent::setUp(); - exec('tests/Functional/App/bin/console doctrine:database:create --no-interaction'); - exec('tests/Functional/App/bin/console d:mi:mi --no-interaction'); + exec('XDEBUG_MODE=off tests/Functional/App/bin/console doctrine:database:create --no-interaction'); + exec('XDEBUG_MODE=off tests/Functional/App/bin/console d:mi:mi --no-interaction'); + exec('rm -rf tests/Functional/App/var/cache/*'); } protected function tearDown(): void { parent::setUp(); - exec('tests/Functional/App/bin/console d:d:d --force --no-interaction'); + exec('XDEBUG_MODE=off tests/Functional/App/bin/console d:d:d --force --no-interaction'); } public function testLoadFixtures(): void diff --git a/tests/Unit/Database/DatabaseManager/SqliteDatabaseManagerTest.php b/tests/Unit/Database/DatabaseManager/SqliteDatabaseManagerTest.php index 0296929..1d4fef4 100644 --- a/tests/Unit/Database/DatabaseManager/SqliteDatabaseManagerTest.php +++ b/tests/Unit/Database/DatabaseManager/SqliteDatabaseManagerTest.php @@ -4,10 +4,13 @@ namespace BehatDoctrineFixtures\Tests\Unit\Database\DatabaseManager; +use BehatDoctrineFixtures\Database\DatabaseHelper; use BehatDoctrineFixtures\Database\Manager\ConsoleManager\SqliteConsoleManager; use BehatDoctrineFixtures\Database\Manager\SqliteDatabaseManager; +use BehatDoctrineFixtures\Tests\Functional\App\Entity\BaseEntity; use BehatDoctrineFixtures\Tests\Unit\Database\AbstractDatabaseManagerTest; use Doctrine\DBAL\Platforms\PostgreSQL100Platform; +use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; From e6bb1b8535898050f2351342e6be4efe3c63cf99 Mon Sep 17 00:00:00 2001 From: Serhii Donii Date: Tue, 4 Jun 2024 13:13:57 +0300 Subject: [PATCH 07/10] feat(o10r-symfony-template-154): Upgrade doctrine/orm to 3.* version --- .../Database/DatabaseManager/SqliteDatabaseManagerTest.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/Unit/Database/DatabaseManager/SqliteDatabaseManagerTest.php b/tests/Unit/Database/DatabaseManager/SqliteDatabaseManagerTest.php index 1d4fef4..0296929 100644 --- a/tests/Unit/Database/DatabaseManager/SqliteDatabaseManagerTest.php +++ b/tests/Unit/Database/DatabaseManager/SqliteDatabaseManagerTest.php @@ -4,13 +4,10 @@ namespace BehatDoctrineFixtures\Tests\Unit\Database\DatabaseManager; -use BehatDoctrineFixtures\Database\DatabaseHelper; use BehatDoctrineFixtures\Database\Manager\ConsoleManager\SqliteConsoleManager; use BehatDoctrineFixtures\Database\Manager\SqliteDatabaseManager; -use BehatDoctrineFixtures\Tests\Functional\App\Entity\BaseEntity; use BehatDoctrineFixtures\Tests\Unit\Database\AbstractDatabaseManagerTest; use Doctrine\DBAL\Platforms\PostgreSQL100Platform; -use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; From 8ee306491b8b4f5ca6a505afee772a4fcf4697e5 Mon Sep 17 00:00:00 2001 From: Serhii Donii Date: Tue, 4 Jun 2024 13:15:17 +0300 Subject: [PATCH 08/10] feat(o10r-symfony-template-154): Upgrade doctrine/orm to 3.* version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 8ad060c..88f31ca 100644 --- a/composer.json +++ b/composer.json @@ -35,7 +35,7 @@ "doctrine/doctrine-migrations-bundle": "^3.0", "theofidry/alice-data-fixtures": "^1.0", "symfony/dependency-injection": "^4.4 || ^5.4 || ^6.0 || ^7.0", - "symfony/http-kernel": "^4.4 | ^5.4 | ^6.0 | ^7.0", + "symfony/http-kernel": "^4.4 || ^5.4 || ^6.0 || ^7.0", "doctrine/dbal": "^2.0 || ^3.0" }, "require-dev": { From 8ec5b10f73ae44e8db03df99af0319fcd5222108 Mon Sep 17 00:00:00 2001 From: Serhii Donii Date: Tue, 4 Jun 2024 13:23:08 +0300 Subject: [PATCH 09/10] feat(o10r-symfony-template-154): Upgrade doctrine/orm to 3.* version --- src/Database/Manager/SqliteDatabaseManager.php | 2 +- tests/Functional/App/config/doctrine.php | 3 +++ tests/Functional/App/config/doctrine_entity/BaseEntity.orm.xml | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Database/Manager/SqliteDatabaseManager.php b/src/Database/Manager/SqliteDatabaseManager.php index 4bc1baf..24889ab 100644 --- a/src/Database/Manager/SqliteDatabaseManager.php +++ b/src/Database/Manager/SqliteDatabaseManager.php @@ -111,7 +111,7 @@ private function adaptDatabaseSchemaToSqlite(Schema $schema): void if ($column->hasPlatformOption('collation')) { $column->setPlatformOptions(array_diff_key( $column->getPlatformOptions(), - ['collation' => true] + ['collation' => 'utf8_unicode_ci'] )); } } diff --git a/tests/Functional/App/config/doctrine.php b/tests/Functional/App/config/doctrine.php index f8bb149..6509371 100644 --- a/tests/Functional/App/config/doctrine.php +++ b/tests/Functional/App/config/doctrine.php @@ -8,6 +8,9 @@ $containerConfigurator->extension('doctrine', [ 'dbal' => [ 'url' => 'sqlite:///%kernel.cache_dir%/data.db', + 'options' => [ + 'collation' => 'utf8mb4_unicode_ci', + ], ], 'orm' => [ 'auto_generate_proxy_classes' => true, diff --git a/tests/Functional/App/config/doctrine_entity/BaseEntity.orm.xml b/tests/Functional/App/config/doctrine_entity/BaseEntity.orm.xml index a1d1b2c..e6aa963 100644 --- a/tests/Functional/App/config/doctrine_entity/BaseEntity.orm.xml +++ b/tests/Functional/App/config/doctrine_entity/BaseEntity.orm.xml @@ -5,6 +5,9 @@ + + + From 6ca37454b281e0ad5a33661e5d136173880b9243 Mon Sep 17 00:00:00 2001 From: Serhii Donii Date: Tue, 4 Jun 2024 13:30:12 +0300 Subject: [PATCH 10/10] feat(o10r-symfony-template-154): Upgrade doctrine/orm to 3.* version --- src/Database/Manager/SqliteDatabaseManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Database/Manager/SqliteDatabaseManager.php b/src/Database/Manager/SqliteDatabaseManager.php index 24889ab..4bc1baf 100644 --- a/src/Database/Manager/SqliteDatabaseManager.php +++ b/src/Database/Manager/SqliteDatabaseManager.php @@ -111,7 +111,7 @@ private function adaptDatabaseSchemaToSqlite(Schema $schema): void if ($column->hasPlatformOption('collation')) { $column->setPlatformOptions(array_diff_key( $column->getPlatformOptions(), - ['collation' => 'utf8_unicode_ci'] + ['collation' => true] )); } }