|
1
|
|
|
<?php namespace Modules\Setting\Tests; |
|
2
|
|
|
|
|
3
|
|
|
use Illuminate\Contracts\Console\Kernel; |
|
4
|
|
|
use Illuminate\Database\Eloquent\Model; |
|
5
|
|
|
use Maatwebsite\Sidebar\SidebarServiceProvider; |
|
6
|
|
|
use Modules\Setting\Providers\SettingServiceProvider; |
|
7
|
|
|
use Modules\Setting\Repositories\SettingRepository; |
|
8
|
|
|
use Orchestra\Testbench\TestCase; |
|
9
|
|
|
|
|
10
|
|
|
abstract class BaseSettingTest extends TestCase |
|
11
|
|
|
{ |
|
12
|
|
|
/** |
|
13
|
|
|
* @var SettingRepository |
|
14
|
|
|
*/ |
|
15
|
|
|
protected $settingRepository; |
|
16
|
|
|
|
|
17
|
|
|
public function setUp() |
|
18
|
|
|
{ |
|
19
|
|
|
parent::setUp(); |
|
20
|
|
|
|
|
21
|
|
|
$this->resetDatabase(); |
|
22
|
|
|
|
|
23
|
|
|
$this->settingRepository = app(SettingRepository::class); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
protected function getPackageProviders($app) |
|
27
|
|
|
{ |
|
28
|
|
|
return [ |
|
29
|
|
|
SettingServiceProvider::class, |
|
30
|
|
|
SidebarServiceProvider::class, |
|
31
|
|
|
]; |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
protected function getEnvironmentSetUp($app) |
|
35
|
|
|
{ |
|
36
|
|
|
$app['path.base'] = __DIR__ . '/..'; |
|
37
|
|
|
$app['config']->set('database.default', 'sqlite'); |
|
38
|
|
|
$app['config']->set('database.connections.sqlite', array( |
|
39
|
|
|
'driver' => 'sqlite', |
|
40
|
|
|
'database' => ':memory:', |
|
41
|
|
|
'prefix' => '', |
|
42
|
|
|
)); |
|
43
|
|
|
$app['config']->set('asgard.core.settings', [ |
|
44
|
|
|
'site-name' => [ |
|
45
|
|
|
'description' => 'core::settings.site-name', |
|
46
|
|
|
'view' => 'text', |
|
47
|
|
|
'translatable' => true, |
|
48
|
|
|
], |
|
49
|
|
|
'template' => [ |
|
50
|
|
|
'description' => 'core::settings.template', |
|
51
|
|
|
'view' => 'core::fields.select-theme', |
|
52
|
|
|
], |
|
53
|
|
|
'locales' => [ |
|
54
|
|
|
'description' => 'core::settings.locales', |
|
55
|
|
|
'view' => 'core::fields.select-locales', |
|
56
|
|
|
'translatable' => false, |
|
57
|
|
|
], |
|
58
|
|
|
]); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
protected function getPackageAliases($app) |
|
62
|
|
|
{ |
|
63
|
|
|
return ['Eloquent' => Model::class]; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
private function resetDatabase() |
|
67
|
|
|
{ |
|
68
|
|
|
// Relative to the testbench app folder: vendors/orchestra/testbench/src/fixture |
|
69
|
|
|
$migrationsPath = 'Database/Migrations'; |
|
70
|
|
|
$artisan = $this->app->make(Kernel::class); |
|
71
|
|
|
// Makes sure the migrations table is created |
|
72
|
|
|
$artisan->call('migrate', [ |
|
73
|
|
|
'--database' => 'sqlite', |
|
74
|
|
|
'--path' => $migrationsPath, |
|
75
|
|
|
]); |
|
76
|
|
|
// We empty all tables |
|
77
|
|
|
$artisan->call('migrate:reset', [ |
|
78
|
|
|
'--database' => 'sqlite', |
|
79
|
|
|
]); |
|
80
|
|
|
// Migrate |
|
81
|
|
|
$artisan->call('migrate', [ |
|
82
|
|
|
'--database' => 'sqlite', |
|
83
|
|
|
'--path' => $migrationsPath, |
|
84
|
|
|
]); |
|
85
|
|
|
} |
|
86
|
|
|
} |
|
87
|
|
|
|