|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Modules\Tag\Tests; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Contracts\Console\Kernel; |
|
6
|
|
|
use Illuminate\View\ViewServiceProvider; |
|
7
|
|
|
use Modules\Core\Providers\CoreServiceProvider; |
|
8
|
|
|
use Modules\Page\Providers\PageServiceProvider; |
|
9
|
|
|
use Modules\Tag\Providers\TagServiceProvider; |
|
10
|
|
|
use Nwidart\Modules\LaravelModulesServiceProvider; |
|
11
|
|
|
use Orchestra\Testbench\TestCase; |
|
12
|
|
|
|
|
13
|
|
|
abstract class BaseTestCase extends TestCase |
|
14
|
|
|
{ |
|
15
|
|
|
public function setUp() |
|
16
|
|
|
{ |
|
17
|
|
|
parent::setUp(); |
|
18
|
|
|
|
|
19
|
|
|
$this->resetDatabase(); |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
protected function getPackageProviders($app) |
|
23
|
|
|
{ |
|
24
|
|
|
return [ |
|
25
|
|
|
ViewServiceProvider::class, |
|
26
|
|
|
LaravelModulesServiceProvider::class, |
|
27
|
|
|
CoreServiceProvider::class, |
|
28
|
|
|
PageServiceProvider::class, |
|
29
|
|
|
TagServiceProvider::class, |
|
30
|
|
|
]; |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
protected function getEnvironmentSetUp($app) |
|
34
|
|
|
{ |
|
35
|
|
|
$app['path.base'] = __DIR__ . '/..'; |
|
36
|
|
|
$app['config']->set('database.default', 'sqlite'); |
|
37
|
|
|
$app['config']->set('database.connections.sqlite', array( |
|
38
|
|
|
'driver' => 'sqlite', |
|
39
|
|
|
'database' => ':memory:', |
|
40
|
|
|
'prefix' => '', |
|
41
|
|
|
)); |
|
42
|
|
|
$app['config']->set('translatable.locales', ['en', 'fr']); |
|
43
|
|
|
$app['config']->set('modules.paths.modules', __DIR__ . '/../Modules'); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
private function resetDatabase() |
|
47
|
|
|
{ |
|
48
|
|
|
// Relative to the testbench app folder: vendors/orchestra/testbench/src/fixture |
|
49
|
|
|
$migrationsPath = 'Database/Migrations'; |
|
50
|
|
|
$artisan = $this->app->make(Kernel::class); |
|
51
|
|
|
// Makes sure the migrations table is created |
|
52
|
|
|
$artisan->call('migrate', [ |
|
53
|
|
|
'--database' => 'sqlite', |
|
54
|
|
|
'--path' => $migrationsPath, |
|
55
|
|
|
]); |
|
56
|
|
|
// We empty all tables |
|
57
|
|
|
$artisan->call('migrate:reset', [ |
|
58
|
|
|
'--database' => 'sqlite', |
|
59
|
|
|
]); |
|
60
|
|
|
// Migrate |
|
61
|
|
|
$artisan->call('migrate', [ |
|
62
|
|
|
'--database' => 'sqlite', |
|
63
|
|
|
'--path' => $migrationsPath, |
|
64
|
|
|
]); |
|
65
|
|
|
$artisan->call('migrate', [ |
|
66
|
|
|
'--database' => 'sqlite', |
|
67
|
|
|
'--path' => 'Modules/Page/Database/Migrations', |
|
68
|
|
|
]); |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
|