1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Gabievi\Promocodes\Tests; |
4
|
|
|
|
5
|
|
|
use Gabievi\Promocodes\Tests\Models\User; |
6
|
|
|
use Orchestra\Testbench\TestCase as Orchestra; |
7
|
|
|
|
8
|
|
|
abstract class TestCase extends Orchestra |
9
|
|
|
{ |
10
|
|
|
// |
11
|
|
|
public function setUp(): void |
12
|
|
|
{ |
13
|
|
|
parent::setUp(); |
14
|
|
|
|
15
|
|
|
$this->loadLaravelMigrations(['--database' => 'sqlite']); |
16
|
|
|
|
17
|
|
|
$this->seedUsers(); |
18
|
|
|
|
19
|
|
|
$this->setUpDatabase(); |
20
|
|
|
|
21
|
|
|
$this->updateConfig(); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
// |
25
|
|
|
protected function getPackageProviders($app) |
26
|
|
|
{ |
27
|
|
|
return [ |
28
|
|
|
\Gabievi\Promocodes\PromocodesServiceProvider::class |
29
|
|
|
]; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
// |
33
|
|
|
protected function getPackageAliases($app) |
34
|
|
|
{ |
35
|
|
|
return [ |
36
|
|
|
'Promocodes' => \Gabievi\Promocodes\Facades\Promocodes::class, |
37
|
|
|
]; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
// |
41
|
|
|
protected function getEnvironmentSetUp($app) |
42
|
|
|
{ |
43
|
|
|
$app['config']->set('database.default', 'sqlite'); |
44
|
|
|
$app['config']->set('database.connections.sqlite', [ |
45
|
|
|
'driver' => 'sqlite', |
46
|
|
|
'database' => ':memory:', |
47
|
|
|
'prefix' => '', |
48
|
|
|
]); |
49
|
|
|
|
50
|
|
|
|
51
|
|
|
$app['config']->set('app.key', 'dwFcFNf8J3fJ3RYADQbWMHyNx8YK'); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
// |
55
|
|
|
protected function setUpDatabase() |
56
|
|
|
{ |
57
|
|
|
include_once __DIR__.'/../migrations/2016_05_17_221000_create_promocodes_table.php'; |
58
|
|
|
|
59
|
|
|
(new \CreatePromocodesTable)->up(); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
// |
63
|
|
|
protected function seedUsers() |
64
|
|
|
{ |
65
|
|
|
User::create([ |
66
|
|
|
'name' => 'user #1', |
67
|
|
|
'email' => '[email protected]', |
68
|
|
|
'password' => 'secret' |
69
|
|
|
]); |
70
|
|
|
|
71
|
|
|
User::create([ |
72
|
|
|
'name' => 'user #2', |
73
|
|
|
'email' => '[email protected]', |
74
|
|
|
'password' => 'secret' |
75
|
|
|
]); |
76
|
|
|
|
77
|
|
|
User::create([ |
78
|
|
|
'name' => 'user #3', |
79
|
|
|
'email' => '[email protected]', |
80
|
|
|
'password' => 'secret' |
81
|
|
|
]); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
// |
85
|
|
|
protected function updateConfig() |
86
|
|
|
{ |
87
|
|
|
$this->app['config']->set('promocodes.user_model', User::class); |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|