From 8ed9c76258f597559bb99b0d7c04ede02ba99a2d Mon Sep 17 00:00:00 2001 From: Tom H Anderson Date: Tue, 29 Oct 2024 01:14:15 -0600 Subject: [PATCH 1/3] Translatable code coverage --- .../TranslatableExtensionTest.php | 21 +++---------------- 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/tests/Feature/Translatable/TranslatableExtensionTest.php b/tests/Feature/Translatable/TranslatableExtensionTest.php index 604af52..4d0ff7c 100644 --- a/tests/Feature/Translatable/TranslatableExtensionTest.php +++ b/tests/Feature/Translatable/TranslatableExtensionTest.php @@ -15,25 +15,10 @@ class TranslatableExtensionTest extends TestCase { public function testCanRegisterExtension(): void { - $app = m::mock(Application::class); - $app->shouldReceive('getLocale')->once()->andReturn('en'); + $extension = app(TranslatableExtension::class); + $extension->addSubscribers($this->evm, $this->em); - $config = m::mock(Repository::class); - $config->shouldReceive('get') - ->with('app.locale')->once() - ->andReturn('en'); - - $events = m::mock(Dispatcher::class); - $events->shouldReceive('listen') - ->with('locale.changed', m::type('callable')) - ->once(); - - $extension = new TranslatableExtension($app, $config, $events); - - $extension->addSubscribers( - $this->evm, - $this->em, - ); + $this->app['events']->dispatch('locale.changed', ['en']); $this->assertEmpty($extension->getFilters()); } From db5b7812a2cae65df1c6b69008ce1449cbbbcbe9 Mon Sep 17 00:00:00 2001 From: Tom H Anderson Date: Tue, 29 Oct 2024 01:18:56 -0600 Subject: [PATCH 2/3] Sortable test --- .../Sortable/SortableExtensionTest.php | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tests/Feature/Sortable/SortableExtensionTest.php diff --git a/tests/Feature/Sortable/SortableExtensionTest.php b/tests/Feature/Sortable/SortableExtensionTest.php new file mode 100644 index 0000000..520c361 --- /dev/null +++ b/tests/Feature/Sortable/SortableExtensionTest.php @@ -0,0 +1,24 @@ +addSubscribers( + $this->evm, + $this->em, + ); + + $this->assertEmpty($extension->getFilters()); + } +} From b42d360e46c407762a68e6e8a6bd7000a5d524a2 Mon Sep 17 00:00:00 2001 From: Tom H Anderson Date: Tue, 29 Oct 2024 01:20:22 -0600 Subject: [PATCH 3/3] phpcs --- tests/Feature/Sortable/SortableExtensionTest.php | 1 - tests/Feature/Translatable/TranslatableExtensionTest.php | 6 ++---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/tests/Feature/Sortable/SortableExtensionTest.php b/tests/Feature/Sortable/SortableExtensionTest.php index 520c361..b45ae6a 100644 --- a/tests/Feature/Sortable/SortableExtensionTest.php +++ b/tests/Feature/Sortable/SortableExtensionTest.php @@ -5,7 +5,6 @@ namespace LaravelDoctrineTest\Extensions\Feature\Sortable; use LaravelDoctrine\Extensions\Sortable\SortableExtension; -use LaravelDoctrine\Extensions\Timestamps\TimestampableExtension; use LaravelDoctrineTest\Extensions\Feature\TestCase; class SortableExtensionTest extends TestCase diff --git a/tests/Feature/Translatable/TranslatableExtensionTest.php b/tests/Feature/Translatable/TranslatableExtensionTest.php index 4d0ff7c..55dfb17 100644 --- a/tests/Feature/Translatable/TranslatableExtensionTest.php +++ b/tests/Feature/Translatable/TranslatableExtensionTest.php @@ -4,12 +4,10 @@ namespace LaravelDoctrineTest\Extensions\Feature\Translatable; -use Illuminate\Contracts\Config\Repository; -use Illuminate\Contracts\Events\Dispatcher; -use Illuminate\Contracts\Foundation\Application; use LaravelDoctrine\Extensions\Translatable\TranslatableExtension; use LaravelDoctrineTest\Extensions\Feature\TestCase; -use Mockery as m; + +use function app; class TranslatableExtensionTest extends TestCase {