1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Author: Nil Portugués Calderó <[email protected]> |
4
|
|
|
* Date: 12/9/15 |
5
|
|
|
* Time: 5:24 PM. |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace NilPortugues\Tests\Laravel5\JsonApi; |
12
|
|
|
|
13
|
|
|
use Illuminate\Filesystem\ClassFinder; |
14
|
|
|
use Illuminate\Filesystem\Filesystem; |
15
|
|
|
use NilPortugues\Laravel5\JsonApi\Laravel5JsonApiServiceProvider; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Class LaravelTestCase. |
19
|
|
|
*/ |
20
|
|
|
class LaravelTestCase extends \Illuminate\Foundation\Testing\TestCase |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* Setup DB before each test. |
24
|
|
|
*/ |
25
|
|
|
public function setUp() |
26
|
|
|
{ |
27
|
|
|
parent::setUp(); |
28
|
|
|
|
29
|
|
|
$this->app['config']->set('database.default', 'sqlite'); |
30
|
|
|
$this->app['config']->set('database.connections.sqlite.database', ':memory:'); |
31
|
|
|
|
32
|
|
|
$this->app->boot(); |
33
|
|
|
$this->migrate(); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* run package database migrations. |
38
|
|
|
*/ |
39
|
|
|
public function migrate() |
40
|
|
|
{ |
41
|
|
|
$fileSystem = new Filesystem(); |
42
|
|
|
$classFinder = new ClassFinder(); |
43
|
|
|
|
44
|
|
|
foreach ($fileSystem->files(__DIR__.'/../../../../tests/NilPortugues/Laravel5/JsonApi/Migrations') as $file) { |
45
|
|
|
$fileSystem->requireOnce($file); |
46
|
|
|
$migrationClass = $classFinder->findClass($file); |
47
|
|
|
(new $migrationClass())->down(); |
48
|
|
|
(new $migrationClass())->up(); |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Boots the application. |
54
|
|
|
* |
55
|
|
|
* @return \Illuminate\Foundation\Application |
56
|
|
|
*/ |
57
|
|
|
public function createApplication() |
58
|
|
|
{ |
59
|
|
|
|
60
|
|
|
$app = require __DIR__.'/../../../../vendor/laravel/laravel/bootstrap/app.php'; |
61
|
|
|
|
62
|
|
|
$app->make('Illuminate\Contracts\Console\Kernel')->bootstrap(); |
63
|
|
|
$app->register(\Illuminate\Database\DatabaseServiceProvider::class); |
64
|
|
|
$app->register(Laravel5JsonApiServiceProvider::class); |
65
|
|
|
|
66
|
|
|
return $app; |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|