TestCase.php
1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
use App\Access\Model\Role\Role;
use App\Access\Model\User\User;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Foundation\Testing\DatabaseTransactions;
/**
* Class TestCase.
*/
abstract class TestCase extends Illuminate\Foundation\Testing\TestCase
{
use DatabaseTransactions;
/**
* The base URL to use while testing the application.
*
* @var string
*/
protected $baseUrl = 'http://l5boilerplate.dev';
/**
* @var
*/
protected $admin;
/**
* @var
*/
protected $executive;
/**
* @var
*/
protected $user;
/**
* @var
*/
protected $adminRole;
/**
* @var
*/
protected $executiveRole;
/**
* @var
*/
protected $userRole;
/**
* Creates the application.
*
* @return \Illuminate\Foundation\Application
*/
public function createApplication()
{
$app = require __DIR__.'/../bootstrap/app.php';
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
return $app;
}
/**
* Set up tests.
*/
public function setUp()
{
parent::setUp();
// Set up the database
Artisan::call('migrate:refresh');
Artisan::call('db:seed');
// Run the tests in English
App::setLocale('en');
/*
* Create class properties to be used in tests
*/
$this->admin = User::find(1);
$this->executive = User::find(2);
$this->user = User::find(3);
$this->adminRole = Role::find(1);
$this->executiveRole = Role::find(2);
$this->userRole = Role::find(3);
}
public function tearDown()
{
$this->beforeApplicationDestroyed(function () {
DB::disconnect();
});
parent::tearDown();
}
}