From e65f03307d46e7af9c5af6324c7fe8409428df07 Mon Sep 17 00:00:00 2001 From: Tom H Anderson Date: Mon, 28 Oct 2024 19:50:59 -0600 Subject: [PATCH 1/2] Test DoctrineServiceProvider --- src/DoctrineServiceProvider.php | 2 +- tests/Feature/DoctrineServiceProviderTest.php | 40 +++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 tests/Feature/DoctrineServiceProviderTest.php diff --git a/src/DoctrineServiceProvider.php b/src/DoctrineServiceProvider.php index d6ef931b..f03bee38 100644 --- a/src/DoctrineServiceProvider.php +++ b/src/DoctrineServiceProvider.php @@ -311,6 +311,6 @@ protected function registerConsoleCommands(): void protected function shouldRegisterDoctrinePresenceValidator(): bool { - return $this->app['config']->get('doctrine.doctrine_presence_verifier', true); + return config('doctrine.doctrine_presence_verifier', true); } } diff --git a/tests/Feature/DoctrineServiceProviderTest.php b/tests/Feature/DoctrineServiceProviderTest.php new file mode 100644 index 00000000..998f986e --- /dev/null +++ b/tests/Feature/DoctrineServiceProviderTest.php @@ -0,0 +1,40 @@ +app->get('registry'); + + $this->assertInstanceOf( + ManagerRegistry::class, + $registry + ); + } + + public function testEntityManagerSingleton(): void + { + $em1 = $this->app->get('em'); + $em2 = $this->app->get('em'); + + $this->assertSame($em1, $em2); + } + + public function testMetaDataFactory(): void + { + $metaDataFactory = $this->app->get(ClassMetadataFactory::class); + + $this->assertInstanceOf( + ClassMetadataFactory::class, + $metaDataFactory + ); + } +} From 7d9938bb4780e952865c24933b0b3c20bd15074b Mon Sep 17 00:00:00 2001 From: Tom H Anderson Date: Mon, 28 Oct 2024 19:53:57 -0600 Subject: [PATCH 2/2] phpcs --- src/DoctrineServiceProvider.php | 1 + tests/Feature/DoctrineServiceProviderTest.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/DoctrineServiceProvider.php b/src/DoctrineServiceProvider.php index f03bee38..e048bdfd 100644 --- a/src/DoctrineServiceProvider.php +++ b/src/DoctrineServiceProvider.php @@ -35,6 +35,7 @@ use function assert; use function class_exists; +use function config; use function config_path; class DoctrineServiceProvider extends ServiceProvider diff --git a/tests/Feature/DoctrineServiceProviderTest.php b/tests/Feature/DoctrineServiceProviderTest.php index 998f986e..0c013cfd 100644 --- a/tests/Feature/DoctrineServiceProviderTest.php +++ b/tests/Feature/DoctrineServiceProviderTest.php @@ -16,7 +16,7 @@ public function testRegistryIsRegistered(): void $this->assertInstanceOf( ManagerRegistry::class, - $registry + $registry, ); } @@ -34,7 +34,7 @@ public function testMetaDataFactory(): void $this->assertInstanceOf( ClassMetadataFactory::class, - $metaDataFactory + $metaDataFactory, ); } }