Skip to content

Commit 543286f

Browse files
committed
Update ServiceProvider to be deferred
1 parent 5d590ed commit 543286f

File tree

1 file changed

+39
-4
lines changed

1 file changed

+39
-4
lines changed

tests/Integration/LaravelIdeHelperHookTranslatableServiceProviderTest.php

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,63 @@
44

55
namespace DanielDeWit\LaravelIdeHelperHookTranslatable\Tests\Integration;
66

7+
use Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider;
78
use DanielDeWit\LaravelIdeHelperHookTranslatable\Hooks\TranslatableHook;
89
use DanielDeWit\LaravelIdeHelperHookTranslatable\Providers\LaravelIdeHelperHookTranslatableServiceProvider;
10+
use Illuminate\Contracts\Config\Repository;
11+
use Illuminate\Foundation\Application;
912
use Orchestra\Testbench\TestCase;
1013

1114
class LaravelIdeHelperHookTranslatableServiceProviderTest extends TestCase
1215
{
1316
/**
14-
* @param \Illuminate\Foundation\Application $app
15-
* @return string[]
17+
* {@inheritDoc}
1618
*/
1719
protected function getPackageProviders($app): array
1820
{
1921
return [
22+
IdeHelperServiceProvider::class,
2023
LaravelIdeHelperHookTranslatableServiceProvider::class,
2124
];
2225
}
2326

2427
/**
2528
* @test
2629
*/
27-
public function it_adds_the_translatable_hook_to_the_config(): void
30+
public function it_auto_registers_model_hook(): void
2831
{
29-
static::assertContains(TranslatableHook::class, config('ide-helper.model_hooks'));
32+
/** @var Application $app */
33+
$app = $this->app;
34+
35+
$app->loadDeferredProvider(IdeHelperServiceProvider::class);
36+
$app->loadDeferredProvider(LaravelIdeHelperHookTranslatableServiceProvider::class);
37+
38+
/** @var Repository $config */
39+
$config = $app->get('config');
40+
41+
$this->assertContains(
42+
TranslatableHook::class,
43+
(array) $config->get('ide-helper.model_hooks', []),
44+
);
45+
}
46+
47+
/**
48+
* @test
49+
*/
50+
public function it_auto_registers_model_hook_with_wrong_service_provider_order(): void
51+
{
52+
/** @var Application $app */
53+
$app = $this->app;
54+
55+
$app->loadDeferredProvider(LaravelIdeHelperHookTranslatableServiceProvider::class);
56+
$app->loadDeferredProvider(IdeHelperServiceProvider::class);
57+
58+
/** @var Repository $config */
59+
$config = $app->get('config');
60+
61+
$this->assertContains(
62+
TranslatableHook::class,
63+
(array) $config->get('ide-helper.model_hooks', []),
64+
);
3065
}
3166
}

0 commit comments

Comments
 (0)