-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathTestCase.php
58 lines (48 loc) · 2.12 KB
/
TestCase.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
namespace RalphJSmit\Filament\SEO\Tests;
use Filament\FilamentServiceProvider;
use Filament\Forms\FormsServiceProvider;
use Filament\Support\SupportServiceProvider;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\View;
use Livewire\LivewireServiceProvider;
use Orchestra\Testbench\TestCase as Orchestra;
use RalphJSmit\Filament\SEO\FilamentSEOServiceProvider;
use RalphJSmit\Laravel\SEO\LaravelSEOServiceProvider;
class TestCase extends Orchestra
{
use RefreshDatabase;
protected function setUp(): void
{
parent::setUp();
Factory::guessFactoryNamesUsing(fn (string $modelName) => 'RalphJSmit\\Filament\\SEO\\Database\\Factories\\' . class_basename($modelName) . 'Factory');
View::addLocation(__DIR__ . '/Fixtures/resources/views');
// Laravel 11 changed the way database migrations are loaded and removed the Doctrine DBAL dependency.
// That behaviour broke the previous way of running tests using `getEnvironmentSetUp()`.
if (version_compare(Application::VERSION, '11', '>=')) {
(include __DIR__ . '/Fixtures/migrations/create_test_tables.php')->up();
(include __DIR__ . '/../vendor/ralphjsmit/laravel-seo/database/migrations/create_seo_table.php.stub')->up();
}
}
protected function getPackageProviders($app): array
{
return [
LivewireServiceProvider::class,
FilamentServiceProvider::class,
FormsServiceProvider::class,
LaravelSEOServiceProvider::class,
FilamentSEOServiceProvider::class,
SupportServiceProvider::class,
];
}
protected function getEnvironmentSetUp($app): void
{
if (version_compare(Application::VERSION, '11', '<')) {
config()->set('database.default', 'testing');
(include __DIR__ . '/Fixtures/migrations/create_test_tables.php')->up();
(include __DIR__ . '/../vendor/ralphjsmit/laravel-seo/database/migrations/create_seo_table.php.stub')->up();
}
}
}