Completed
Pull Request — master (#56)
by
unknown
01:46
created

TestCase::getPackageProviders()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Spatie\EloquentSortable\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 function setUp()
11
    {
12
        parent::setUp();
13
14
        $this->setUpDatabase();
15
    }
16
17
    /**
18
     * @param \Illuminate\Foundation\Application $app
19
     *
20
     * @return array
21
     */
22
    protected function getPackageProviders($app)
23
    {
24
        return [
25
26
        ];
27
    }
28
29
    /**
30
     * @param \Illuminate\Foundation\Application $app
31
     */
32
    protected function getEnvironmentSetUp($app)
33
    {
34
        $app['config']->set('database.default', 'sqlite');
35
        $app['config']->set('database.connections.sqlite', [
36
            'driver' => 'sqlite',
37
            'database' => ':memory:',
38
            'prefix' => '',
39
        ]);
40
    }
41
42
    protected function setUpDatabase()
43
    {
44
        $this->app['db']->connection()->getSchemaBuilder()->create('dummies', function (Blueprint $table) {
45
            $table->increments('id');
46
            $table->string('name');
47
            $table->integer('order_column');
48
        });
49
50
        collect(range(1, 20))->each(function (int $i) {
51
            Dummy::create(['name' => $i]);
52
        });
53
    }
54
55
    protected function setUpSoftDeletes()
56
    {
57
        $this->app['db']->connection()->getSchemaBuilder()->table('dummies', function (Blueprint $table) {
58
            $table->softDeletes();
59
        });
60
    }
61
62
    protected function setUpGroupColumn()
63
    {
64
        $this->app['db']->connection()->getSchemaBuilder()->table('dummies', function (Blueprint $table) {
65
            $table->integer('group_column')->nullable();
66
        });
67
68
        Dummy::truncate();
69
70
        collect(range(1, 20))->each(function (int $i) {
71
            DummyWithGroupColumn::create(['name' => $i, 'group_column' => 1]);
72
        });
73
74
        collect(range(1, 20))->each(function (int $i) {
75
            DummyWithGroupColumn::create(['name' => $i, 'group_column' => 2]);
76
        });
77
    }
78
}
79