Skip to content

Commit

Permalink
Merge pull request #26 from MacPaw/feat/orc-154-upgrade-doctrine-orm-…
Browse files Browse the repository at this point in the history
…3-version

feat(o10r-symfony-template-154): Upgrade doctrine/orm to 3.* version
  • Loading branch information
serhiidonii authored Jun 4, 2024
2 parents 1b8a69e + 6ca3745 commit b485886
Show file tree
Hide file tree
Showing 14 changed files with 93 additions and 46 deletions.
16 changes: 11 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,22 @@ jobs:
- '6.1.*'
- '6.2.*'
- '7.0.*'
doctrine-orm-versions:
- '^2.17'
- '^3.0'
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'
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
Expand Down Expand Up @@ -66,6 +72,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
Expand All @@ -80,9 +87,8 @@ jobs:
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/[email protected]
with:
file: './coverage.xml'
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
/package-lock.json
/node_modules/
/.idea/
/coverage
/clover.xml
8 changes: 5 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,23 @@
"require": {
"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/http-kernel": "^4.4 || ^5.4 || ^6.0 || ^7.0",
"doctrine/dbal": "^2.0 || ^3.0"
},
"require-dev": {
"phpstan/phpstan": "^1.2",
"phpunit/phpunit": "^9.5",
"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": {
Expand Down
2 changes: 2 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ parameters:
message: '#Offset (.*)? does not exist on array\{(.*)?\}.#'
count: 1
path: ./src/Database/Manager/SqliteDatabaseManager.php
-
identifier: missingType.iterableValue
1 change: 0 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ includes:

parameters:
level: max
checkMissingIterableValueType: false
paths:
- src/
6 changes: 3 additions & 3 deletions src/Database/Manager/SqliteDatabaseManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]
));
}
Expand Down
6 changes: 3 additions & 3 deletions tests/Functional/App/TestKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand All @@ -43,4 +43,4 @@ public function getProjectDir(): string
{
return __DIR__;
}
}
}
30 changes: 30 additions & 0 deletions tests/Functional/App/config/doctrine.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->extension('doctrine', [
'dbal' => [
'url' => 'sqlite:///%kernel.cache_dir%/data.db',
'options' => [
'collation' => 'utf8mb4_unicode_ci',
],
],
'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',
],
],
],
]);
};
14 changes: 0 additions & 14 deletions tests/Functional/App/config/doctrine.yml

This file was deleted.

13 changes: 13 additions & 0 deletions tests/Functional/App/config/doctrine_entity/BaseEntity.orm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="BehatDoctrineFixtures\Tests\Functional\App\Entity\BaseEntity" table="base_entity">
<id name="id" type="integer">
<generator strategy="AUTO"/>
<options>
<option name="collation">utf8_unicode_ci</option>
</options>
</id>
</entity>
</doctrine-mapping>

This file was deleted.

20 changes: 20 additions & 0 deletions tests/Functional/App/config/doctrine_migrations.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->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',
]);
};
8 changes: 0 additions & 8 deletions tests/Functional/App/config/doctrine_migrations.yml

This file was deleted.

7 changes: 4 additions & 3 deletions tests/Functional/Database/DatabaseHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b485886

Please sign in to comment.