Skip to content

Commit

Permalink
CI: Fix deprecation failures with Symfony 6.4 and ORM
Browse files Browse the repository at this point in the history
  • Loading branch information
ostrolucky committed Sep 2, 2023
1 parent f28b1f7 commit 7c615a3
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 13 deletions.
1 change: 1 addition & 0 deletions Resources/config/schema/doctrine-1.0.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@
<xsd:attribute name="proxy-dir" type="xsd:string" />
<xsd:attribute name="proxy-namespace" type="xsd:string" />
<xsd:attribute name="auto-generate-proxy-classes" type="xsd:string" default="false" />
<xsd:attribute name="enable-lazy-ghost-objects" type="xsd:boolean" />
<xsd:attributeGroup ref="entity-manager-config" />
</xsd:complexType>

Expand Down
9 changes: 7 additions & 2 deletions Tests/DependencyInjection/Compiler/IdGeneratorPassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ public function testRepositoryServiceWiring(): void
'annotations' => [
'enabled' => class_exists(AnnotationReader::class) && Kernel::VERSION_ID < 64000,
],
],
'php_errors' => ['log' => true],
] + (Kernel::VERSION_ID >= 62000 ? ['handle_all_throwables' => true] : []),
], $container);

$extension = new DoctrineExtension();
Expand All @@ -107,7 +108,11 @@ public function testRepositoryServiceWiring(): void
'charset' => 'UTF8',
'schema_manager_factory' => 'doctrine.dbal.default_schema_manager_factory',
],
'orm' => ['mappings' => $mappings, 'report_fields_where_declared' => true],
'orm' => [
'mappings' => $mappings,
'report_fields_where_declared' => true,
'enable_lazy_ghost_objects' => true,
],
],
], $container);

Expand Down
9 changes: 4 additions & 5 deletions Tests/DependencyInjection/Fixtures/TestKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,9 @@ public function registerContainerConfiguration(LoaderInterface $loader): void
$container->loadFromExtension('framework', [
'secret' => 'F00',
'http_method_override' => false,
'annotations' => [
'enabled' => class_exists(Annotation::class) && Kernel::VERSION_ID <= 64000,
],
]);

'annotations' => class_exists(Annotation::class) && Kernel::VERSION_ID <= 64000,
'php_errors' => ['log' => true],
] + (Kernel::VERSION_ID >= 62000 ? ['handle_all_throwables' => true] : []));
$container->loadFromExtension('doctrine', [
'dbal' => [
'driver' => 'pdo_sqlite',
Expand All @@ -55,6 +53,7 @@ public function registerContainerConfiguration(LoaderInterface $loader): void
'orm' => [
'report_fields_where_declared' => true,
'auto_generate_proxy_classes' => true,
'enable_lazy_ghost_objects' => true,
'mappings' => [
'RepositoryServiceBundle' => [
'type' => PHP_VERSION_ID >= 80000 ? 'attribute' : 'annotation',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<connection name="default" dbname="db" />
</dbal>

<orm>
<orm enable-lazy-ghost-objects="true">
<filter name="soft_delete" enabled="true" >Doctrine\Bundle\DoctrineBundle\Tests\DependencyInjection\TestFilter</filter>
<filter name="myFilter" enabled="true" class="Doctrine\Bundle\DoctrineBundle\Tests\DependencyInjection\TestFilter">
<parameter name="myParameter">myValue</parameter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ doctrine:
dbname: db

orm:
enable_lazy_ghost_objects: true
filters:
soft_delete:
class: Doctrine\Bundle\DoctrineBundle\Tests\DependencyInjection\TestFilter
Expand Down
11 changes: 9 additions & 2 deletions Tests/LockStoreSchemaListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
use Symfony\Component\HttpKernel\Kernel;

use function class_exists;
use function interface_exists;
Expand Down Expand Up @@ -51,11 +52,17 @@ public function testLockStoreSchemaSubscriberWiring(array $config, int $expected

$extension = new FrameworkExtension();
$container->registerExtension($extension);
$extension->load(['framework' => ['http_method_override' => false] + $config], $container);
$extension->load(
[
'framework' => ['http_method_override' => false, 'php_errors' => ['log' => true]]
+ (Kernel::VERSION_ID >= 62000 ? ['handle_all_throwables' => true] : []) + $config,
],
$container
);

$extension = new DoctrineExtension();
$container->registerExtension($extension);
$extension->load([['dbal' => [], 'orm' => []]], $container);
$extension->load([['dbal' => [], 'orm' => ['enable_lazy_ghost_objects' => true]]], $container);

$container->setAlias(
'test_subscriber_lock_alias',
Expand Down
6 changes: 4 additions & 2 deletions Tests/ServiceRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,11 @@ public function testRepositoryServiceWiring(): void
$extension->load([
'framework' => [
'http_method_override' => false,
'php_errors' => ['log' => true],
'annotations' => [
'enabled' => class_exists(AnnotationReader::class) && Kernel::VERSION_ID < 64000,
],
],
] + (Kernel::VERSION_ID >= 62000 ? ['handle_all_throwables' => true] : []),
], $container);

$extension = new DoctrineExtension();
Expand All @@ -89,6 +90,7 @@ public function testRepositoryServiceWiring(): void
],
'orm' => [
'report_fields_where_declared' => true,
'enable_lazy_ghost_objects' => true,
'mappings' => [
'RepositoryServiceBundle' => [
'type' => PHP_VERSION_ID >= 80000 ? 'attribute' : 'annotation',
Expand All @@ -102,7 +104,7 @@ public function testRepositoryServiceWiring(): void

$def = $container->register(TestCustomServiceRepoRepository::class, TestCustomServiceRepoRepository::class)
->setPublic(false);
// create a public alias so we can use it below for testing
// create a public alias, so we can use it below for testing
$container->setAlias('test_alias__' . TestCustomServiceRepoRepository::class, new Alias(TestCustomServiceRepoRepository::class, true));

$def->setAutowired(true);
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"doctrine/annotations": "^1 || ^2",
"doctrine/coding-standard": "^9.0",
"doctrine/deprecations": "^1.0",
"doctrine/orm": "^2.11 || ^3.0",
"doctrine/orm": "^2.14 || ^3.0",
"friendsofphp/proxy-manager-lts": "^1.0",
"phpunit/phpunit": "^9.5.26 || ^10.0",
"psalm/plugin-phpunit": "^0.18.4",
Expand Down

0 comments on commit 7c615a3

Please sign in to comment.