Completed
Pull Request — master (#32)
by Sébastien
01:58
created

TestCase::setUpSoftDeletes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
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