diff --git a/DependencyInjection/DoctrineExtension.php b/DependencyInjection/DoctrineExtension.php index 816a9363..faa0d6c3 100644 --- a/DependencyInjection/DoctrineExtension.php +++ b/DependencyInjection/DoctrineExtension.php @@ -1095,19 +1095,6 @@ private function loadValidatorLoader(string $entityManagerName, ContainerBuilder $validatorLoaderDefinition->addTag('validator.auto_mapper', ['priority' => -100]); } - /** - * @param array $objectManager - * @param string $cacheName - * - * @return void - * - * @psalm-suppress MoreSpecificImplementedParamType - */ - public function loadObjectManagerCacheDriver(array $objectManager, ContainerBuilder $container, $cacheName) - { - $this->loadCacheDriver($cacheName, $objectManager['name'], $objectManager[$cacheName . '_driver'], $container); - } - public function getXsdValidationBasePath(): string { return __DIR__ . '/../Resources/config/schema'; diff --git a/Tests/DataCollector/DoctrineDataCollectorTest.php b/Tests/DataCollector/DoctrineDataCollectorTest.php index 63da6c20..f4f2aa00 100644 --- a/Tests/DataCollector/DoctrineDataCollectorTest.php +++ b/Tests/DataCollector/DoctrineDataCollectorTest.php @@ -15,6 +15,7 @@ use Symfony\Bridge\Doctrine\Middleware\Debug\DebugDataHolder; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\Kernel; use function interface_exists; @@ -132,6 +133,10 @@ public function testGetGroupedQueries(): void /** @group legacy */ public function testGetGroupedQueriesWithDeprecatedDebugStackLogger(): void { + if (Kernel::VERSION_ID >= 70000) { + $this->markTestSkipped('This test requires symfony < 7.0'); + } + $logger = $this->getMockBuilder(DebugStack::class)->getMock(); $logger->queries = []; $logger->queries[] = [ diff --git a/Tests/RegistryTest.php b/Tests/RegistryTest.php index db3da966..d8ae8d87 100644 --- a/Tests/RegistryTest.php +++ b/Tests/RegistryTest.php @@ -11,9 +11,10 @@ use Fixtures\Bundles\RepositoryServiceBundle\Entity\TestCustomClassRepoEntity; use Fixtures\Bundles\RepositoryServiceBundle\Repository\TestCustomClassRepoRepository; use InvalidArgumentException; +use PHPUnit\Framework\MockObject\MockObject; use ProxyManager\Proxy\ProxyInterface; use stdClass; -use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\DependencyInjection\Container; use Symfony\Component\VarExporter\LazyObjectInterface; use function assert; @@ -24,54 +25,57 @@ class RegistryTest extends TestCase { + /** @var MockObject&Container */ + private MockObject $container; + + protected function setUp(): void + { + $this->container = $this->createMock(Container::class); + } + public function testGetDefaultConnectionName(): void { - $container = $this->getMockBuilder(ContainerInterface::class)->getMock(); - $registry = new Registry($container, [], [], 'default', 'default'); + $registry = new Registry($this->container, [], [], 'default', 'default'); $this->assertEquals('default', $registry->getDefaultConnectionName()); } public function testGetDefaultEntityManagerName(): void { - $container = $this->getMockBuilder(ContainerInterface::class)->getMock(); - $registry = new Registry($container, [], [], 'default', 'default'); + $registry = new Registry($this->container, [], [], 'default', 'default'); $this->assertEquals('default', $registry->getDefaultManagerName()); } public function testGetDefaultConnection(): void { - $conn = $this->getMockBuilder(Connection::class)->disableOriginalConstructor()->getMock(); - $container = $this->getMockBuilder(ContainerInterface::class)->getMock(); - $container->expects($this->once()) + $conn = $this->getMockBuilder(Connection::class)->disableOriginalConstructor()->getMock(); + $this->container->expects($this->once()) ->method('get') ->with($this->equalTo('doctrine.dbal.default_connection')) ->will($this->returnValue($conn)); - $registry = new Registry($container, ['default' => 'doctrine.dbal.default_connection'], [], 'default', 'default'); + $registry = new Registry($this->container, ['default' => 'doctrine.dbal.default_connection'], [], 'default', 'default'); $this->assertSame($conn, $registry->getConnection()); } public function testGetConnection(): void { - $conn = $this->getMockBuilder(Connection::class)->disableOriginalConstructor()->getMock(); - $container = $this->getMockBuilder(ContainerInterface::class)->getMock(); - $container->expects($this->once()) + $conn = $this->getMockBuilder(Connection::class)->disableOriginalConstructor()->getMock(); + $this->container->expects($this->once()) ->method('get') ->with($this->equalTo('doctrine.dbal.default_connection')) ->will($this->returnValue($conn)); - $registry = new Registry($container, ['default' => 'doctrine.dbal.default_connection'], [], 'default', 'default'); + $registry = new Registry($this->container, ['default' => 'doctrine.dbal.default_connection'], [], 'default', 'default'); $this->assertSame($conn, $registry->getConnection('default')); } public function testGetUnknownConnection(): void { - $container = $this->getMockBuilder(ContainerInterface::class)->getMock(); - $registry = new Registry($container, [], [], 'default', 'default'); + $registry = new Registry($this->container, [], [], 'default', 'default'); $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Doctrine ORM Connection named "default" does not exist.'); @@ -80,44 +84,40 @@ public function testGetUnknownConnection(): void public function testGetConnectionNames(): void { - $container = $this->getMockBuilder(ContainerInterface::class)->getMock(); - $registry = new Registry($container, ['default' => 'doctrine.dbal.default_connection'], [], 'default', 'default'); + $registry = new Registry($this->container, ['default' => 'doctrine.dbal.default_connection'], [], 'default', 'default'); $this->assertEquals(['default' => 'doctrine.dbal.default_connection'], $registry->getConnectionNames()); } public function testGetDefaultEntityManager(): void { - $em = new stdClass(); - $container = $this->getMockBuilder(ContainerInterface::class)->getMock(); - $container->expects($this->once()) + $em = new stdClass(); + $this->container->expects($this->once()) ->method('get') ->with($this->equalTo('doctrine.orm.default_entity_manager')) ->will($this->returnValue($em)); - $registry = new Registry($container, [], ['default' => 'doctrine.orm.default_entity_manager'], 'default', 'default'); + $registry = new Registry($this->container, [], ['default' => 'doctrine.orm.default_entity_manager'], 'default', 'default'); $this->assertSame($em, $registry->getManager()); } public function testGetEntityManager(): void { - $em = new stdClass(); - $container = $this->getMockBuilder(ContainerInterface::class)->getMock(); - $container->expects($this->once()) + $em = new stdClass(); + $this->container->expects($this->once()) ->method('get') ->with($this->equalTo('doctrine.orm.default_entity_manager')) ->will($this->returnValue($em)); - $registry = new Registry($container, [], ['default' => 'doctrine.orm.default_entity_manager'], 'default', 'default'); + $registry = new Registry($this->container, [], ['default' => 'doctrine.orm.default_entity_manager'], 'default', 'default'); $this->assertSame($em, $registry->getManager('default')); } public function testGetUnknownEntityManager(): void { - $container = $this->getMockBuilder(ContainerInterface::class)->getMock(); - $registry = new Registry($container, [], [], 'default', 'default'); + $registry = new Registry($this->container, [], [], 'default', 'default'); $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage( @@ -128,8 +128,7 @@ public function testGetUnknownEntityManager(): void public function testResetUnknownEntityManager(): void { - $container = $this->getMockBuilder(ContainerInterface::class)->getMock(); - $registry = new Registry($container, [], [], 'default', 'default'); + $registry = new Registry($this->container, [], [], 'default', 'default'); $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage( @@ -153,13 +152,12 @@ public function testReset(): void ->method('setProxyInitializer') ->with($this->isInstanceOf(Closure::class)); - $container = $this->getMockBuilder(ContainerInterface::class)->getMock(); - $container->expects($this->any()) + $this->container->expects($this->any()) ->method('initialized') ->withConsecutive(['doctrine.orm.uninitialized_entity_manager'], ['doctrine.orm.noproxy_entity_manager'], ['doctrine.orm.proxy_entity_manager']) ->willReturnOnConsecutiveCalls(false, true, true, true); - $container->expects($this->any()) + $this->container->expects($this->any()) ->method('get') ->withConsecutive(['doctrine.orm.noproxy_entity_manager'], ['doctrine.orm.proxy_entity_manager'], ['doctrine.orm.proxy_entity_manager'], ['doctrine.orm.proxy_entity_manager']) ->willReturnOnConsecutiveCalls($noProxyManager, $proxyManager, $proxyManager, $proxyManager); @@ -170,7 +168,7 @@ public function testReset(): void 'proxy' => 'doctrine.orm.proxy_entity_manager', ]; - $registry = new Registry($container, [], $entityManagers, 'default', 'default'); + $registry = new Registry($this->container, [], $entityManagers, 'default', 'default'); $registry->reset(); } @@ -185,11 +183,10 @@ public function testResetLazyObject(): void /** @psalm-suppress MissingDependency https://github.com/vimeo/psalm/issues/8258 */ $ghostManager->expects($this->once())->method('resetLazyObject')->willReturn(true); - $container = $this->createMock(ContainerInterface::class); - $container->method('initialized') + $this->container->method('initialized') ->withConsecutive(['doctrine.orm.uninitialized_entity_manager'], ['doctrine.orm.ghost_entity_manager']) ->willReturnOnConsecutiveCalls(false, true, true); - $container->method('get') + $this->container->method('get') ->withConsecutive(['doctrine.orm.ghost_entity_manager'], ['doctrine.orm.ghost_entity_manager'], ['doctrine.orm.ghost_entity_manager']) ->willReturnOnConsecutiveCalls($ghostManager, $ghostManager, $ghostManager); @@ -198,7 +195,7 @@ public function testResetLazyObject(): void 'ghost' => 'doctrine.orm.ghost_entity_manager', ]; - (new Registry($container, [], $entityManagers, 'default', 'default'))->reset(); + (new Registry($this->container, [], $entityManagers, 'default', 'default'))->reset(); } public function testIdentityMapsStayConsistentAfterReset(): void diff --git a/composer.json b/composer.json index 269c4c27..40a30de1 100644 --- a/composer.json +++ b/composer.json @@ -34,13 +34,13 @@ "doctrine/dbal": "^3.6.0", "doctrine/persistence": "^2.2 || ^3", "doctrine/sql-formatter": "^1.0.1", - "symfony/cache": "^5.4 || ^6.0", - "symfony/config": "^5.4 || ^6.0", - "symfony/console": "^5.4 || ^6.0", - "symfony/dependency-injection": "^5.4 || ^6.0", + "symfony/cache": "^5.4 || ^6.0 || ^7.0", + "symfony/config": "^5.4 || ^6.0 || ^7.0", + "symfony/console": "^5.4 || ^6.0 || ^7.0", + "symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0", "symfony/deprecation-contracts": "^2.1 || ^3", - "symfony/doctrine-bridge": "^5.4.19 || ^6.0.7", - "symfony/framework-bundle": "^5.4 || ^6.0", + "symfony/doctrine-bridge": "^5.4.19 || ^6.0.7 || ^7.0", + "symfony/framework-bundle": "^5.4 || ^6.0 || ^7.0", "symfony/service-contracts": "^1.1.1 || ^2.0 || ^3" }, "require-dev": { @@ -53,15 +53,15 @@ "psalm/plugin-phpunit": "^0.18.4", "psalm/plugin-symfony": "^4", "psr/log": "^1.1.4 || ^2.0 || ^3.0", - "symfony/phpunit-bridge": "^6.1", - "symfony/property-info": "^5.4 || ^6.0", - "symfony/proxy-manager-bridge": "^5.4 || ^6.0", - "symfony/security-bundle": "^5.4 || ^6.0", - "symfony/string": "^5.4 || ^6.0", - "symfony/twig-bridge": "^5.4 || ^6.0", - "symfony/validator": "^5.4 || ^6.0", - "symfony/web-profiler-bundle": "^5.4 || ^6.0", - "symfony/yaml": "^5.4 || ^6.0", + "symfony/phpunit-bridge": "^6.1 || ^7.0", + "symfony/property-info": "^5.4 || ^6.0 || ^7.0", + "symfony/proxy-manager-bridge": "^5.4 || ^6.0 || ^7.0", + "symfony/security-bundle": "^5.4 || ^6.0 || ^7.0", + "symfony/string": "^5.4 || ^6.0 || ^7.0", + "symfony/twig-bridge": "^5.4 || ^6.0 || ^7.0", + "symfony/validator": "^5.4 || ^6.0 || ^7.0", + "symfony/web-profiler-bundle": "^5.4 || ^6.0 || ^7.0", + "symfony/yaml": "^5.4 || ^6.0 || ^7.0", "twig/twig": "^1.34 || ^2.12 || ^3.0", "vimeo/psalm": "^4.30" },