diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index 52b7ea770..8e159f1d5 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -26,6 +26,6 @@ on: jobs: coding-standards: name: "Coding Standards" - uses: "doctrine/.github/.github/workflows/coding-standards.yml@8.0.0" + uses: "doctrine/.github/.github/workflows/coding-standards.yml@v12.2.0" with: composer-options: "--prefer-dist --prefer-stable" diff --git a/.github/workflows/composer-lint.yml b/.github/workflows/composer-lint.yml index d679fb032..a9876185a 100644 --- a/.github/workflows/composer-lint.yml +++ b/.github/workflows/composer-lint.yml @@ -17,4 +17,4 @@ on: jobs: composer-lint: name: "Composer Lint" - uses: "doctrine/.github/.github/workflows/composer-lint.yml@8.0.0" + uses: "doctrine/.github/.github/workflows/composer-lint.yml@v12.2.0" diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 63a89fe5b..1c95434ec 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -115,7 +115,7 @@ jobs: run: "vendor/bin/phpunit --coverage-clover=coverage.xml" - name: "Upload coverage file" - uses: "actions/upload-artifact@v4" + uses: "actions/upload-artifact@v5" with: name: "phpunit-${{ matrix.php-version }}-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}.coverage" path: "coverage.xml" @@ -135,7 +135,7 @@ jobs: fetch-depth: 2 - name: "Download coverage files" - uses: "actions/download-artifact@v5" + uses: "actions/download-artifact@v6" with: path: "reports" diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 1a6b13918..7722f764f 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -17,4 +17,4 @@ on: jobs: documentation: name: "Documentation" - uses: "doctrine/.github/.github/workflows/documentation.yml@8.0.0" \ No newline at end of file + uses: "doctrine/.github/.github/workflows/documentation.yml@v12.2.0" \ No newline at end of file diff --git a/.github/workflows/release-on-milestone-closed.yml b/.github/workflows/release-on-milestone-closed.yml index 29770e22e..634210120 100644 --- a/.github/workflows/release-on-milestone-closed.yml +++ b/.github/workflows/release-on-milestone-closed.yml @@ -8,7 +8,7 @@ on: jobs: release: name: "Git tag, release & create merge-up PR" - uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@8.0.0" + uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@v12.2.0" secrets: GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }} GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }} diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index a951d95be..19cd93448 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -26,4 +26,4 @@ on: jobs: static-analysis: name: "Static Analysis" - uses: "doctrine/.github/.github/workflows/phpstan.yml@8.0.0" + uses: "doctrine/.github/.github/workflows/phpstan.yml@v12.2.0" diff --git a/.github/workflows/website-schema.yml b/.github/workflows/website-schema.yml index e7c8e15bb..80312010a 100644 --- a/.github/workflows/website-schema.yml +++ b/.github/workflows/website-schema.yml @@ -18,4 +18,4 @@ on: jobs: json-validate: name: "Validate JSON schema" - uses: "doctrine/.github/.github/workflows/website-schema.yml@8.0.0" + uses: "doctrine/.github/.github/workflows/website-schema.yml@v12.2.0" diff --git a/docs/composer.json b/docs/composer.json new file mode 100644 index 000000000..5072d501c --- /dev/null +++ b/docs/composer.json @@ -0,0 +1,8 @@ +{ + "require-dev": { + "doctrine/docs-builder": "^1.0" + }, + "config": { + "sort-packages": true + } +} diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 3f7796717..0b3cc38b8 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -4,8 +4,7 @@ parameters: - config - src - tests - scanFiles: - - vendor/symfony/dependency-injection/Loader/Configurator/functions.php + excludePaths: - src/Command/Proxy/ConvertMappingDoctrineCommand.php - src/Command/Proxy/EnsureProductionSettingsDoctrineCommand.php diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index bf402bf16..196c8e942 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -714,7 +714,7 @@ private function getOrmEntityManagersNode(): ArrayNodeDefinition ->thenInvalid('The setting "report_fields_where_declared" cannot be disabled for ORM 3.') ->end() ->end() - ->booleanNode('validate_xml_mapping')->defaultFalse()->info('Set to "true" to opt-in to the new mapping driver mode that was added in Doctrine ORM 2.14 and will be mandatory in ORM 3.0. See https://github.com/doctrine/orm/pull/6728.')->end() + ->booleanNode('validate_xml_mapping')->defaultFalse()->info('Set to "true" to opt-in to the new mapping driver mode that was added in Doctrine ORM 2.14. See https://github.com/doctrine/orm/pull/6728.')->end() ->end() ->children() ->arrayNode('second_level_cache') diff --git a/src/DependencyInjection/DoctrineExtension.php b/src/DependencyInjection/DoctrineExtension.php index 6a461a906..8d3e40283 100644 --- a/src/DependencyInjection/DoctrineExtension.php +++ b/src/DependencyInjection/DoctrineExtension.php @@ -427,8 +427,8 @@ private function detectMappingType(string $directory, ContainerBuilder $containe } if ( - preg_match('/^(?: \*|\/\*\*) @.*' . $quotedMappingObjectName . '\b/m', $content) - || preg_match('/^(?: \*|\/\*\*) @.*Embeddable\b/m', $content) + self::textContainsAnnotation($quotedMappingObjectName, $content) + || self::textContainsAnnotation('Embeddable', $content) ) { $type = 'annotation'; break; @@ -438,6 +438,21 @@ private function detectMappingType(string $directory, ContainerBuilder $containe return $type; } + /** + * Check if the file content contains a class-like annotation + * + * @internal + */ + public static function textContainsAnnotation(string $quotedMappingObjectName, string $content): bool + { + return preg_match('/^(?:[ ]\*|\/\*\*)[ ]@ # Match phpdoc start or line with an at + \\\\? # Can start with antislash + ([a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*\\\\)* # Match namespace components ending with antislash + ' . $quotedMappingObjectName . ' # The target class + \b # Match word boundary + /mx', $content) === 1; + } + /** * Returns a modified version of $managerConfigs. * diff --git a/tests/CacheSchemaSubscriberTest.php b/tests/CacheSchemaSubscriberTest.php index 3c4d4df69..96d825b0e 100644 --- a/tests/CacheSchemaSubscriberTest.php +++ b/tests/CacheSchemaSubscriberTest.php @@ -32,8 +32,10 @@ public function testSchemaSubscriberWiring(): void 'kernel.build_dir' => sys_get_temp_dir(), 'kernel.environment' => 'test', 'kernel.runtime_environment' => '%%env(default:kernel.environment:APP_RUNTIME_ENV)%%', + 'kernel.runtime_mode.web' => false, 'kernel.root_dir' => __DIR__ . '/../../../../', // src dir 'kernel.project_dir' => __DIR__ . '/../../../../', // src dir + 'kernel.share_dir' => sys_get_temp_dir(), 'kernel.bundles_metadata' => [], 'kernel.charset' => 'UTF-8', 'kernel.container_class' => ContainerBuilder::class, diff --git a/tests/Command/CreateDatabaseDoctrineTest.php b/tests/Command/CreateDatabaseDoctrineTest.php index 849c4e061..113ee347e 100644 --- a/tests/Command/CreateDatabaseDoctrineTest.php +++ b/tests/Command/CreateDatabaseDoctrineTest.php @@ -11,7 +11,7 @@ use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\Schema\SchemaManagerFactory; use Doctrine\Persistence\ManagerRegistry; -use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\MockObject\Stub; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Tester\CommandTester; use Symfony\Component\DependencyInjection\Container; @@ -59,25 +59,23 @@ public function testExecute(): void * @param mixed[]|null $params Connection parameters * @psalm-param Params $params * - * @return MockObject&Container + * @return Stub&Container */ - private function getMockContainer(string $connectionName, array|null $params = null): MockObject + private function getMockContainer(string $connectionName, array|null $params = null): Stub { // Mock the container and everything you'll need here $mockDoctrine = $this->createStub(ManagerRegistry::class); $mockDoctrine->method('getDefaultConnectionName')->willReturn($connectionName); - $config = (new Configuration())->setSchemaManagerFactory($this->createMock(SchemaManagerFactory::class)); + $config = (new Configuration())->setSchemaManagerFactory($this->createStub(SchemaManagerFactory::class)); $mockConnection = $this->createStub(Connection::class); $mockConnection->method('getConfiguration')->willReturn($config); $mockConnection->method('getParams')->willReturn($params); $mockDoctrine->method('getConnection')->willReturn($mockConnection); - $mockContainer = $this->getMockBuilder(Container::class) - ->onlyMethods(['get']) - ->getMock(); + $mockContainer = $this->createStub(Container::class); $mockContainer->method('get')->with('doctrine')->willReturn($mockDoctrine); diff --git a/tests/Command/DropDatabaseDoctrineTest.php b/tests/Command/DropDatabaseDoctrineTest.php index f7176499d..c691867ef 100644 --- a/tests/Command/DropDatabaseDoctrineTest.php +++ b/tests/Command/DropDatabaseDoctrineTest.php @@ -14,7 +14,7 @@ use Doctrine\Persistence\ManagerRegistry; use Generator; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\MockObject\Stub; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Tester\CommandTester; use Symfony\Component\DependencyInjection\Container; @@ -137,9 +137,9 @@ public static function provideIncompatibleDriverOptions(): Generator * @param list $params Connection parameters * @psalm-param Params $params * - * @return MockObject&Container + * @return Stub&Container */ - private function getMockContainer(string $connectionName, array $params): MockObject + private function getMockContainer(string $connectionName, array $params): Stub { // Mock the container and everything you'll need here $mockDoctrine = $this->createStub(ManagerRegistry::class); @@ -148,18 +148,16 @@ private function getMockContainer(string $connectionName, array $params): MockOb $config = (new Configuration())->setSchemaManagerFactory(new DefaultSchemaManagerFactory()); - $mockConnection = $this->createMock(Connection::class); + $mockConnection = $this->createStub(Connection::class); $mockConnection->method('getConfiguration')->willReturn($config); $mockConnection->method('getParams')->willReturn($params); $mockDoctrine->method('getConnection')->willReturn($mockConnection); - $mockContainer = $this->getMockBuilder(Container::class) - ->onlyMethods(['get']) - ->getMock(); + $mockContainer = $this->createStub(Container::class); $mockContainer->method('get') - ->with('doctrine') - ->willReturn($mockDoctrine); + ->with('doctrine') + ->willReturn($mockDoctrine); return $mockContainer; } diff --git a/tests/DataCollector/DoctrineDataCollectorTest.php b/tests/DataCollector/DoctrineDataCollectorTest.php index 43a41d195..3112f1f42 100644 --- a/tests/DataCollector/DoctrineDataCollectorTest.php +++ b/tests/DataCollector/DoctrineDataCollectorTest.php @@ -35,8 +35,8 @@ public function testCollectEntities(): void $manager = $this->createStub(EntityManagerInterface::class); $config = $this->createMock(Configuration::class); $factory = $this->createMock(ClassMetadataFactory::class); - $collector = $this->createCollector(['default' => $manager], true, $this->createMock(DebugDataHolder::class)); - $unitOfWork = $this->createMock(UnitOfWork::class); + $collector = $this->createCollector(['default' => $manager], true, $this->createStub(DebugDataHolder::class)); + $unitOfWork = $this->createStub(UnitOfWork::class); $manager->method('getMetadataFactory')->willReturn($factory); $manager->method('getConfiguration')->willReturn($config); @@ -74,8 +74,8 @@ public function testDoesNotCollectEntities(): void } $manager = $this->createMock(EntityManager::class); - $config = $this->createMock(Configuration::class); - $collector = $this->createCollector(['default' => $manager], false, $this->createMock(DebugDataHolder::class)); + $config = $this->createStub(Configuration::class); + $collector = $this->createCollector(['default' => $manager], false, $this->createStub(DebugDataHolder::class)); $unitOfWork = $this->createStub(UnitOfWork::class); $manager->expects($this->never())->method('getMetadataFactory'); @@ -91,7 +91,7 @@ public function testDoesNotCollectEntities(): void public function testGetGroupedQueries(): void { - $debugDataHolder = $this->createMock(DebugDataHolder::class); + $debugDataHolder = $this->createStub(DebugDataHolder::class); $queries = [ 'default' => [ diff --git a/tests/DependencyInjection/Compiler/IdGeneratorPassTest.php b/tests/DependencyInjection/Compiler/IdGeneratorPassTest.php index 14177f5fc..9f40c8e1f 100644 --- a/tests/DependencyInjection/Compiler/IdGeneratorPassTest.php +++ b/tests/DependencyInjection/Compiler/IdGeneratorPassTest.php @@ -50,8 +50,10 @@ public function testRepositoryServiceWiring(): void 'kernel.bundles' => $bundles, 'kernel.cache_dir' => sys_get_temp_dir(), 'kernel.build_dir' => sys_get_temp_dir(), + 'kernel.share_dir' => sys_get_temp_dir(), 'kernel.environment' => 'test', 'kernel.runtime_environment' => '%%env(default:kernel.environment:APP_RUNTIME_ENV)%%', + 'kernel.runtime_mode.web' => false, 'kernel.root_dir' => __DIR__ . '/../../../../', // src dir 'kernel.project_dir' => __DIR__ . '/../../../../', // src dir 'kernel.bundles_metadata' => [], diff --git a/tests/DependencyInjection/DoctrineExtensionTest.php b/tests/DependencyInjection/DoctrineExtensionTest.php index 3fd421fd6..1407e9f48 100644 --- a/tests/DependencyInjection/DoctrineExtensionTest.php +++ b/tests/DependencyInjection/DoctrineExtensionTest.php @@ -1507,6 +1507,71 @@ public function testControllerResolver(bool $simpleEntityManagerConfig): void $this->assertEquals(new MapEntity(null, null, null, [], null, null, null, true, true), $container->get('controller_resolver_defaults')); } + #[TestWith(['AnnotationsBundle', 'attribute', 'Vendor'], 'Bundle without anything')] + #[TestWith(['AttributesBundle', 'attribute'], 'Bundle with attributes')] + #[TestWith(['RepositoryServiceBundle', 'attribute'], 'Bundle with both')] + #[TestWith(['AnnotationsBundle', 'annotation'], 'Bundle with annotations')] + #[TestWith(['AttributesWithPackageBundle', 'attribute'], 'Bundle with attributes and @package')] + public function testDetectMappingType(string $bundle, string $expectedType, string $vendor = '') + { + if (! interface_exists(EntityManagerInterface::class)) { + self::markTestSkipped('This test requires ORM'); + } + + $container = $this->getContainer([$bundle], $vendor); + $extension = new DoctrineExtension(); + + $config = BundleConfigurationBuilder::createBuilder() + ->addBaseConnection() + ->addEntityManager([ + 'default_entity_manager' => 'default', + 'entity_managers' => [ + 'default' => [ + 'mappings' => [ + $bundle => [], + ], + ], + ], + ]) + ->build(); + + if (! class_exists(AnnotationDriver::class) && $expectedType === 'annotation') { + $this->expectException(LogicException::class); + $this->expectExceptionMessage('The annotation driver is only available in doctrine/orm v2.'); + } + + $extension->load([$config], $container); + + $calls = $container->getDefinition('doctrine.orm.default_metadata_driver')->getMethodCalls(); + $this->assertEquals( + sprintf('doctrine.orm.default_%s_metadata_driver', $expectedType), + (string) $calls[0][1][0], + ); + } + + #[TestWith([' * @Mapping\\Entity', true], 'Using the namespace without alias')] + #[TestWith([' * @ORM\\Entity', true], 'Using the namespace with alias')] + #[TestWith([' * @\\Doctrine\\ORM\\Mapping\\Entity', true], 'Complete namespace with starting slash')] + #[TestWith([' * @Doctrine\\ORM\\Mapping\\Entity', true], 'Complete namespace without starting slash')] + #[TestWith([' * @Entity', true], 'Use of the class')] + #[TestWith([' * @Entity()', true], 'With parentheses')] + #[TestWith(['/** @Entity */', true], 'Comment start')] + #[TestWith(["/**\n * @Entity\n */", true], 'Multiline phpdoc')] + #[TestWith([' * @orm\\Entity', true], 'namespace can start with lowercase')] + #[TestWith([' * @_ORM\\Entity', true], 'namespace can start with underscore')] + #[TestWith([" * @\x80ORM\\Entity", true], 'namespace can start with char from x80-Xff')] + #[TestWith([" * @orm0_\x80\\Entity", true], 'namespace can contain number, underscore and char from x80-Xff')] + #[TestWith([' * @ORMEntity', false], 'Use of the class with prefix')] + #[TestWith([' * @EntityORM', false], 'Use of the class with suffix')] + #[TestWith([' * @package testEntity', false], 'Annotation with Entity as value')] + #[TestWith([' * @entity', false], 'Lowercase use of the class')] + #[TestWith([' * @1ORMEntity', false], 'namespace can\'t start with number')] + #[TestWith([' * @extend', false], 'The Entity is used inside < and >')] + public function testTextContainsAnnotation(string $input, bool $expected): void + { + self::assertEquals($expected, DoctrineExtension::textContainsAnnotation('Entity', $input)); + } + /** @param list $bundles */ private static function getContainer(array $bundles = ['XmlBundle'], string $vendor = ''): ContainerBuilder { diff --git a/tests/DependencyInjection/Fixtures/Bundles/AnnotationsBundle/AnnotationsBundle.php b/tests/DependencyInjection/Fixtures/Bundles/AnnotationsBundle/AnnotationsBundle.php new file mode 100644 index 000000000..27f395278 --- /dev/null +++ b/tests/DependencyInjection/Fixtures/Bundles/AnnotationsBundle/AnnotationsBundle.php @@ -0,0 +1,11 @@ + [], 'kernel.cache_dir' => sys_get_temp_dir(), 'kernel.build_dir' => sys_get_temp_dir(), + 'kernel.share_dir' => sys_get_temp_dir(), 'kernel.environment' => 'test', 'kernel.runtime_environment' => '%%env(default:kernel.environment:APP_RUNTIME_ENV)%%', + 'kernel.runtime_mode.web' => false, 'kernel.root_dir' => __DIR__ . '/../../../../', // src dir 'kernel.project_dir' => __DIR__ . '/../../../../', // src dir 'kernel.bundles_metadata' => [], diff --git a/tests/Mapping/DisconnectedMetadataFactoryTest.php b/tests/Mapping/DisconnectedMetadataFactoryTest.php index 3c13605ad..e6cb9d728 100644 --- a/tests/Mapping/DisconnectedMetadataFactoryTest.php +++ b/tests/Mapping/DisconnectedMetadataFactoryTest.php @@ -30,7 +30,7 @@ public function testCannotFindNamespaceAndPathForMetadata(): void $class = new ClassMetadata(self::class); $collection = new ClassMetadataCollection([$class]); - $registry = $this->getMockBuilder(ManagerRegistry::class)->getMock(); + $registry = $this->createStub(ManagerRegistry::class); $factory = new DisconnectedMetadataFactory($registry); $this->expectException(RuntimeException::class); diff --git a/tests/Middleware/IdleConnectionMiddlewareTest.php b/tests/Middleware/IdleConnectionMiddlewareTest.php index 25e64c0f7..fc4b0d166 100644 --- a/tests/Middleware/IdleConnectionMiddlewareTest.php +++ b/tests/Middleware/IdleConnectionMiddlewareTest.php @@ -25,7 +25,7 @@ public function testWrap() $middleware = new IdleConnectionMiddleware($connectionExpiries, $ttlByConnection); $middleware->setConnectionName('connectionone'); - $driverMock = $this->createMock(Driver::class); + $driverMock = $this->createStub(Driver::class); $wrappedDriver = $middleware->wrap($driverMock); $this->assertInstanceOf(IdleConnectionDriver::class, $wrappedDriver); diff --git a/tests/ProfilerTest.php b/tests/ProfilerTest.php index 3e9e30318..ae2cbcad1 100644 --- a/tests/ProfilerTest.php +++ b/tests/ProfilerTest.php @@ -43,7 +43,7 @@ class ProfilerTest extends BaseTestCase public function setUp(): void { $this->debugDataHolder = new DebugDataHolder(); - $registry = $this->getMockBuilder(ManagerRegistry::class)->getMock(); + $registry = $this->createStub(ManagerRegistry::class); $registry->method('getConnectionNames')->willReturn([]); $registry->method('getManagerNames')->willReturn([]); $registry->method('getManagers')->willReturn([]); @@ -53,14 +53,12 @@ public function setUp(): void $twigLoaderFilesystem->addPath(__DIR__ . '/../vendor/symfony/web-profiler-bundle/Resources/views', 'WebProfiler'); $this->twig = new Environment($twigLoaderFilesystem, ['debug' => true, 'strict_variables' => true]); - $fragmentHandler = $this->getMockBuilder(FragmentHandler::class); - $fragmentHandler->disableOriginalConstructor(); - $fragmentHandler = $fragmentHandler->getMock(); + $fragmentHandler = $this->createStub(FragmentHandler::class); $fragmentHandler->method('render')->willReturn(''); $kernelRuntime = new HttpKernelRuntime($fragmentHandler); - $urlGenerator = $this->getMockBuilder(UrlGeneratorInterface::class)->getMock(); + $urlGenerator = $this->createStub(UrlGeneratorInterface::class); $urlGenerator->method('generate')->willReturn(''); if (class_exists(CodeExtension::class)) { diff --git a/tests/RegistryTest.php b/tests/RegistryTest.php index 59ee8098d..728419419 100644 --- a/tests/RegistryTest.php +++ b/tests/RegistryTest.php @@ -43,7 +43,7 @@ public function testGetDefaultEntityManagerName(): void public function testGetDefaultConnection(): void { - $conn = $this->getMockBuilder(Connection::class)->disableOriginalConstructor()->getMock(); + $conn = $this->createStub(Connection::class); $container = new Container(); $container->set('doctrine.dbal.default_connection', $conn); @@ -54,7 +54,7 @@ public function testGetDefaultConnection(): void public function testGetConnection(): void { - $conn = $this->getMockBuilder(Connection::class)->disableOriginalConstructor()->getMock(); + $conn = $this->createStub(Connection::class); $container = new Container(); $container->set('doctrine.dbal.default_connection', $conn); @@ -81,7 +81,7 @@ public function testGetConnectionNames(): void public function testGetDefaultEntityManager(): void { - $em = $this->createMock(ObjectManager::class); + $em = $this->createStub(ObjectManager::class); $container = new Container(); $container->set('doctrine.orm.default_entity_manager', $em); @@ -92,7 +92,7 @@ public function testGetDefaultEntityManager(): void public function testGetEntityManager(): void { - $em = $this->createMock(ObjectManager::class); + $em = $this->createStub(ObjectManager::class); $container = new Container(); $container->set('doctrine.orm.default_entity_manager', $em); diff --git a/tests/Repository/ServiceEntityRepositoryTest.php b/tests/Repository/ServiceEntityRepositoryTest.php index b39188c46..43ca68d4f 100644 --- a/tests/Repository/ServiceEntityRepositoryTest.php +++ b/tests/Repository/ServiceEntityRepositoryTest.php @@ -31,7 +31,7 @@ public static function setUpBeforeClass(): void public function testConstructorThrowsExceptionWhenNoManagerFound(): void { - $registry = $this->getMockBuilder(ManagerRegistry::class)->getMock(); + $registry = $this->createStub(ManagerRegistry::class); $this->expectException(LogicException::class); $this->expectExceptionMessage(<<<'EXCEPTION' Could not find the entity manager for class "Doctrine\Bundle\DoctrineBundle\Tests\Repository\TestEntity". Check your Doctrine configuration to make sure it is configured to load this entity’s metadata. @@ -46,7 +46,7 @@ public function testConstructorThrowsExceptionWhenNoManagerFound(): void #[RequiresPhp('>= 8.4')] public function testConstructInitializesWhenImplementingLazyObjectInterface(): void { - $registry = $this->getMockBuilder(ManagerRegistry::class)->getMock(); + $registry = $this->createStub(ManagerRegistry::class); $this->expectException(LogicException::class); /* @phpstan-ignore class.notFound, expr.resultUnused */ diff --git a/tests/ServiceRepositoryTest.php b/tests/ServiceRepositoryTest.php index f60d26609..318efddcf 100644 --- a/tests/ServiceRepositoryTest.php +++ b/tests/ServiceRepositoryTest.php @@ -48,8 +48,10 @@ public function testRepositoryServiceWiring(): void 'kernel.build_dir' => sys_get_temp_dir(), 'kernel.environment' => 'test', 'kernel.runtime_environment' => '%%env(default:kernel.environment:APP_RUNTIME_ENV)%%', + 'kernel.runtime_mode.web' => false, 'kernel.root_dir' => __DIR__ . '/../../../../', // src dir 'kernel.project_dir' => __DIR__ . '/../../../../', // src dir + 'kernel.share_dir' => sys_get_temp_dir(), 'kernel.bundles_metadata' => [], 'kernel.charset' => 'UTF-8', 'kernel.container_class' => ContainerBuilder::class,