1
|
|
|
<?php namespace Tests; |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Simplifies the creation of tests creating a full application, running migrations and loading multiple Service Providers |
5
|
|
|
*/ |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class TestCase |
9
|
|
|
* @codeCoverageIgnore |
10
|
|
|
*/ |
11
|
|
|
class TestCase extends \Orchestra\Testbench\TestCase |
|
|
|
|
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* Setup the test environment. |
15
|
|
|
* |
16
|
|
|
* @return void |
17
|
|
|
*/ |
18
|
|
|
public function setUp(): void |
19
|
|
|
{ |
20
|
|
|
if (!$this->app) { |
21
|
|
|
$this->refreshApplication(); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
$this->artisan('vendor:publish', [ '--all' => true ]); |
25
|
|
|
|
26
|
|
|
//refresh configuration values |
27
|
|
|
$this->refreshApplication(); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Clean up the testing environment before the next test. |
32
|
|
|
* |
33
|
|
|
* @return void |
34
|
|
|
*/ |
35
|
|
|
public function tearDown(): void |
36
|
|
|
{ |
37
|
|
|
parent::tearDown(); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Define environment setup. |
42
|
|
|
* |
43
|
|
|
* @param \Illuminate\Foundation\Application $app |
44
|
|
|
* @return void |
45
|
|
|
*/ |
46
|
|
|
protected function getEnvironmentSetUp($app) |
47
|
|
|
{ |
48
|
|
|
// reset base path to point to our package's src directory |
49
|
|
|
$app['path.base'] = realpath(__DIR__ . '/..'); |
50
|
|
|
|
51
|
|
|
$app['config']->set( |
52
|
|
|
'database.connections', |
53
|
|
|
[ |
54
|
|
|
'sqlite' => [ |
55
|
|
|
'driver' => 'sqlite', |
56
|
|
|
'database' => ':memory:', |
57
|
|
|
'prefix' => '', |
58
|
|
|
//'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), |
59
|
|
|
], |
60
|
|
|
'mysql' => [ |
61
|
|
|
'driver' => 'mysql', |
62
|
|
|
'url' => env('DATABASE_URL'), |
63
|
|
|
'host' => env('DB_HOST', '127.0.0.1'), |
64
|
|
|
'port' => env('DB_PORT', '3306'), |
65
|
|
|
'database' => env('DB_DATABASE', 'forge'), |
66
|
|
|
'username' => env('DB_USERNAME', 'forge'), |
67
|
|
|
'password' => env('DB_PASSWORD', ''), |
68
|
|
|
'unix_socket' => env('DB_SOCKET', ''), |
69
|
|
|
'charset' => 'utf8mb4', |
70
|
|
|
'collation' => 'utf8mb4_unicode_ci', |
71
|
|
|
'prefix' => '', |
72
|
|
|
'prefix_indexes' => true, |
73
|
|
|
'strict' => true, |
74
|
|
|
'engine' => null, |
75
|
|
|
'options' => extension_loaded('pdo_mysql') ? array_filter([ |
76
|
|
|
\PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), |
77
|
|
|
]) : [], |
78
|
|
|
], |
79
|
|
|
'pgsql' => [ |
80
|
|
|
'driver' => 'pgsql', |
81
|
|
|
'url' => env('DATABASE_URL'), |
82
|
|
|
'host' => env('DB_HOST', '127.0.0.1'), |
83
|
|
|
'port' => env('DB_PORT', '5432'), |
84
|
|
|
'database' => env('DB_DATABASE', 'forge'), |
85
|
|
|
'username' => env('DB_USERNAME', 'forge'), |
86
|
|
|
'password' => env('DB_PASSWORD', ''), |
87
|
|
|
'charset' => 'utf8', |
88
|
|
|
'prefix' => '', |
89
|
|
|
'prefix_indexes' => true, |
90
|
|
|
'schema' => 'public', |
91
|
|
|
'sslmode' => 'prefer', |
92
|
|
|
], |
93
|
|
|
] |
94
|
|
|
); |
95
|
|
|
|
96
|
|
|
$app['config']->set('database.default', env('DB_CONNECTION', 'sqlite')); |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|