1 | <?php |
||
17 | abstract class BasePageTest extends TestCase |
||
18 | { |
||
19 | /** |
||
20 | * @var PageRepository |
||
21 | */ |
||
22 | protected $page; |
||
23 | |||
24 | public function setUp() |
||
25 | { |
||
26 | parent::setUp(); |
||
27 | |||
28 | $this->resetDatabase(); |
||
29 | |||
30 | $this->page = app(PageRepository::class); |
||
31 | } |
||
32 | |||
33 | protected function getPackageProviders($app) |
||
34 | { |
||
35 | return [ |
||
36 | LaravelModulesServiceProvider::class, |
||
37 | CoreServiceProvider::class, |
||
38 | TagServiceProvider::class, |
||
39 | PageServiceProvider::class, |
||
40 | LaravelLocalizationServiceProvider::class, |
||
41 | SidebarServiceProvider::class, |
||
42 | ]; |
||
43 | } |
||
44 | |||
45 | protected function getPackageAliases($app) |
||
46 | { |
||
47 | return [ |
||
48 | 'Eloquent' => Model::class, |
||
49 | 'LaravelLocalization' => LaravelLocalization::class, |
||
50 | ]; |
||
51 | } |
||
52 | |||
53 | protected function getEnvironmentSetUp($app) |
||
54 | { |
||
55 | $app['path.base'] = __DIR__ . '/..'; |
||
56 | $app['config']->set('database.default', 'sqlite'); |
||
57 | $app['config']->set('database.connections.sqlite', array( |
||
58 | 'driver' => 'sqlite', |
||
59 | 'database' => ':memory:', |
||
60 | 'prefix' => '', |
||
61 | )); |
||
62 | $app['config']->set('translatable.locales', ['en', 'fr']); |
||
63 | } |
||
64 | |||
65 | private function resetDatabase() |
||
66 | { |
||
67 | // Relative to the testbench app folder: vendors/orchestra/testbench/src/fixture |
||
68 | $migrationsPath = 'Database/Migrations'; |
||
69 | $artisan = $this->app->make(Kernel::class); |
||
70 | // Makes sure the migrations table is created |
||
71 | $artisan->call('migrate', [ |
||
72 | '--database' => 'sqlite', |
||
73 | '--path' => $migrationsPath, |
||
74 | ]); |
||
75 | // We empty all tables |
||
76 | $artisan->call('migrate:reset', [ |
||
77 | '--database' => 'sqlite', |
||
78 | ]); |
||
79 | // Migrate |
||
80 | $artisan->call('migrate', [ |
||
81 | '--database' => 'sqlite', |
||
82 | '--path' => $migrationsPath, |
||
83 | ]); |
||
84 | $artisan->call('migrate', [ |
||
85 | '--database' => 'sqlite', |
||
86 | '--path' => 'Modules/Tag/Database/Migrations', |
||
87 | ]); |
||
88 | } |
||
89 | } |
||
90 |