|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
use Illuminate\Filesystem\Filesystem; |
|
4
|
|
|
use Illuminate\Support\Arr; |
|
5
|
|
|
use Illuminate\Support\Facades\DB; |
|
6
|
|
|
use Illuminate\Support\Facades\Schema; |
|
7
|
|
|
use Laravel\BrowserKitTesting\TestCase as BaseTestCase; |
|
8
|
|
|
|
|
9
|
|
|
class TestCase extends BaseTestCase |
|
10
|
|
|
{ |
|
11
|
|
|
protected $baseUrl = 'http://localhost:8000'; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Boots the application. |
|
15
|
|
|
* |
|
16
|
|
|
* @return \Illuminate\Foundation\Application |
|
17
|
|
|
*/ |
|
18
|
|
|
public function createApplication() |
|
19
|
|
|
{ |
|
20
|
|
|
$app = require __DIR__.'/../vendor/laravel/laravel/bootstrap/app.php'; |
|
21
|
|
|
|
|
22
|
|
|
$app->booting(function () { |
|
23
|
|
|
$loader = \Illuminate\Foundation\AliasLoader::getInstance(); |
|
24
|
|
|
$loader->alias('Admin', \Encore\Admin\Facades\Admin::class); |
|
25
|
|
|
}); |
|
26
|
|
|
|
|
27
|
|
|
$app->make('Illuminate\Contracts\Console\Kernel')->bootstrap(); |
|
28
|
|
|
|
|
29
|
|
|
$app->register('Encore\Admin\AdminServiceProvider'); |
|
30
|
|
|
|
|
31
|
|
|
return $app; |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
public function setUp() |
|
35
|
|
|
{ |
|
36
|
|
|
parent::setUp(); |
|
37
|
|
|
|
|
38
|
|
|
$adminConfig = require __DIR__.'/config/admin.php'; |
|
39
|
|
|
|
|
40
|
|
|
$this->app['config']->set('database.default', 'mysql'); |
|
41
|
|
|
$this->app['config']->set('database.connections.mysql.host', env('MYSQL_HOST', 'localhost')); |
|
42
|
|
|
$this->app['config']->set('database.connections.mysql.database', 'laravel_admin_test'); |
|
43
|
|
|
$this->app['config']->set('database.connections.mysql.username', 'root'); |
|
44
|
|
|
$this->app['config']->set('database.connections.mysql.password', ''); |
|
45
|
|
|
$this->app['config']->set('app.key', 'AckfSECXIvnK5r28GVIWUAxmbBSjTsmF'); |
|
46
|
|
|
$this->app['config']->set('filesystems', require __DIR__.'/config/filesystems.php'); |
|
47
|
|
|
$this->app['config']->set('admin', $adminConfig); |
|
48
|
|
|
|
|
49
|
|
|
foreach (Arr::dot(Arr::get($adminConfig, 'auth'), 'auth.') as $key => $value) { |
|
50
|
|
|
$this->app['config']->set($key, $value); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
$this->artisan('vendor:publish', ['--provider' => 'Encore\Admin\AdminServiceProvider']); |
|
54
|
|
|
|
|
55
|
|
|
Schema::defaultStringLength(191); |
|
56
|
|
|
|
|
57
|
|
|
$this->artisan('admin:install'); |
|
58
|
|
|
|
|
59
|
|
|
$this->migrateTestTables(); |
|
60
|
|
|
|
|
61
|
|
|
if (file_exists($routes = admin_path('routes.php'))) { |
|
62
|
|
|
require $routes; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
require __DIR__.'/routes.php'; |
|
66
|
|
|
|
|
67
|
|
|
require __DIR__.'/seeds/factory.php'; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
public function tearDown() |
|
71
|
|
|
{ |
|
72
|
|
|
(new CreateAdminTables())->down(); |
|
73
|
|
|
|
|
74
|
|
|
(new CreateTestTables())->down(); |
|
75
|
|
|
|
|
76
|
|
|
DB::select("delete from `migrations` where `migration` = '2016_01_04_173148_create_admin_tables'"); |
|
77
|
|
|
|
|
78
|
|
|
parent::tearDown(); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* run package database migrations. |
|
83
|
|
|
* |
|
84
|
|
|
* @return void |
|
85
|
|
|
*/ |
|
86
|
|
|
public function migrateTestTables() |
|
87
|
|
|
{ |
|
88
|
|
|
$fileSystem = new Filesystem(); |
|
89
|
|
|
|
|
90
|
|
|
$fileSystem->requireOnce(__DIR__.'/migrations/2016_11_22_093148_create_test_tables.php'); |
|
91
|
|
|
|
|
92
|
|
|
(new CreateTestTables())->up(); |
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
|