From d57fa40268d9cf778768f577d5ae4b1741e7eb5d Mon Sep 17 00:00:00 2001 From: Tom H Anderson Date: Tue, 29 Oct 2024 00:28:08 -0600 Subject: [PATCH] Added tests for GedmoExtensionsServiceProvider --- src/GedmoExtensionsServiceProvider.php | 7 +++++ ...tensionsServiceProviderAllMappingsTest.php | 27 +++++++++++++++++++ .../GedmoExtensionsServiceProviderTest.php | 18 +++++++++++++ .../Uploadable/UploadableExtensionTest.php | 3 +++ 4 files changed, 55 insertions(+) create mode 100644 tests/Feature/GedmoExtensionsServiceProviderAllMappingsTest.php create mode 100644 tests/Feature/GedmoExtensionsServiceProviderTest.php diff --git a/src/GedmoExtensionsServiceProvider.php b/src/GedmoExtensionsServiceProvider.php index ff6a476..bc259aa 100644 --- a/src/GedmoExtensionsServiceProvider.php +++ b/src/GedmoExtensionsServiceProvider.php @@ -4,6 +4,7 @@ namespace LaravelDoctrine\Extensions; +use Gedmo\DoctrineExtensions; use Illuminate\Support\ServiceProvider; class GedmoExtensionsServiceProvider extends ServiceProvider @@ -18,6 +19,12 @@ public function register(): void foreach ($registry->getManagers() as $manager) { $chain = $manager->getConfiguration()->getMetadataDriverImpl(); + + if ($this->needsAllMappings()) { + DoctrineExtensions::registerMappingIntoDriverChainORM($chain); + } else { + DoctrineExtensions::registerAbstractMappingIntoDriverChainORM($chain); + } } }); } diff --git a/tests/Feature/GedmoExtensionsServiceProviderAllMappingsTest.php b/tests/Feature/GedmoExtensionsServiceProviderAllMappingsTest.php new file mode 100644 index 0000000..1171abd --- /dev/null +++ b/tests/Feature/GedmoExtensionsServiceProviderAllMappingsTest.php @@ -0,0 +1,27 @@ +set('doctrine.gedmo.all_mappings', true); + }); + } + + public function testCustomExtensionsCanBeRegistered(): void + { + $this->app['events']->dispatch('doctrine.extensions.booting'); + + $this->assertTrue(true); + } +} diff --git a/tests/Feature/GedmoExtensionsServiceProviderTest.php b/tests/Feature/GedmoExtensionsServiceProviderTest.php new file mode 100644 index 0000000..092b49d --- /dev/null +++ b/tests/Feature/GedmoExtensionsServiceProviderTest.php @@ -0,0 +1,18 @@ +app['events']->dispatch('doctrine.extensions.booting'); + + $this->assertTrue(true); + } +} diff --git a/tests/Feature/Uploadable/UploadableExtensionTest.php b/tests/Feature/Uploadable/UploadableExtensionTest.php index 879b698..cb06d5a 100644 --- a/tests/Feature/Uploadable/UploadableExtensionTest.php +++ b/tests/Feature/Uploadable/UploadableExtensionTest.php @@ -6,6 +6,7 @@ use Gedmo\Uploadable\UploadableListener; use LaravelDoctrine\Extensions\Uploadable\UploadableExtension; +use LaravelDoctrine\Extensions\Uploadable\UploadableFacade; use LaravelDoctrineTest\Extensions\Feature\TestCase; use Mockery as m; @@ -13,6 +14,8 @@ class UploadableExtensionTest extends TestCase { public function testCanRegisterExtension(): void { + $this->assertFalse(UploadableFacade::isFake()); + $listener = m::mock(UploadableListener::class); $extension = new UploadableExtension(