TestCase::getEnvironmentSetUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 1
Metric Value
c 2
b 1
f 1
dl 0
loc 11
rs 9.4285
cc 1
eloc 7
nc 1
nop 1
1
<?php
2
3
namespace LarsJanssen\IncrementDecrement\Test;
4
5
use Illuminate\Database\Schema\Blueprint;
6
use Orchestra\Testbench\TestCase as Orchestra;
7
8
abstract class TestCase extends Orchestra
9
{
10
    public $order;
11
12
    public function setUp()
13
    {
14
        parent::setUp();
15
        $this->setUpDatabase($this->app);
16
        $this->order = $this->app->make('order');
17
    }
18
19
    /**
20
     * @param \Illuminate\Foundation\Application $app
21
     *
22
     * @return array
23
     */
24
    protected function getPackageProviders($app)
25
    {
26
        return [
27
            \LarsJanssen\IncrementDecrement\IncrementDecrementServiceProvider::class,
28
        ];
29
    }
30
31
    /**
32
     * @param \Illuminate\Foundation\Application $app
33
     */
34
    protected function getEnvironmentSetUp($app)
35
    {
36
        $app['config']->set('database.default', 'sqlite');
37
        $app['config']->set('database.connections.sqlite', [
38
            'driver'   => 'sqlite',
39
            'database' => ':memory:',
40
            'prefix'   => '',
41
        ]);
42
43
        $app['config']->set('app.key', '6rE9Nz59bGRbeMATftriyQjrpF7DcOQm');
44
    }
45
46
    /**
47
     * @param \Illuminate\Foundation\Application $app
48
     */
49
    protected function setUpDatabase($app)
50
    {
51
        $app['db']->connection()->getSchemaBuilder()->create('forum', function (Blueprint $table) {
52
            $table->increments('id');
53
            $table->string('name');
54
            $table->integer('order');
55
            $table->rememberToken();
56
            $table->timestamps();
57
        });
58
59
        TestModel::create(['name' => 'food',        'order' => 1]);
60
        TestModel::create(['name' => 'work',        'order' => 2]);
61
        TestModel::create(['name' => 'children',    'order' => 3]);
62
        TestModel::create(['name' => 'ict',         'order' => 4]);
63
        TestModel::create(['name' => 'people',      'order' => 5]);
64
    }
65
}
66