|
4 | 4 |
|
5 | 5 | namespace DanielDeWit\LaravelIdeHelperHookTranslatable\Tests\Integration; |
6 | 6 |
|
| 7 | +use Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider; |
7 | 8 | use DanielDeWit\LaravelIdeHelperHookTranslatable\Hooks\TranslatableHook; |
8 | 9 | use DanielDeWit\LaravelIdeHelperHookTranslatable\Providers\LaravelIdeHelperHookTranslatableServiceProvider; |
| 10 | +use Illuminate\Contracts\Config\Repository; |
| 11 | +use Illuminate\Foundation\Application; |
9 | 12 | use Orchestra\Testbench\TestCase; |
10 | 13 |
|
11 | 14 | class LaravelIdeHelperHookTranslatableServiceProviderTest extends TestCase |
12 | 15 | { |
13 | 16 | /** |
14 | | - * @param \Illuminate\Foundation\Application $app |
15 | | - * @return string[] |
| 17 | + * {@inheritDoc} |
16 | 18 | */ |
17 | 19 | protected function getPackageProviders($app): array |
18 | 20 | { |
19 | 21 | return [ |
| 22 | + IdeHelperServiceProvider::class, |
20 | 23 | LaravelIdeHelperHookTranslatableServiceProvider::class, |
21 | 24 | ]; |
22 | 25 | } |
23 | 26 |
|
24 | 27 | /** |
25 | 28 | * @test |
26 | 29 | */ |
27 | | - public function it_adds_the_translatable_hook_to_the_config(): void |
| 30 | + public function it_auto_registers_model_hook(): void |
28 | 31 | { |
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 | + ); |
30 | 65 | } |
31 | 66 | } |
0 commit comments