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

TestCase   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 5
c 2
b 0
f 0
lcom 1
cbo 4
dl 0
loc 54
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 6 1
A getEnvironmentSetUp() 0 9 1
A getPackageProviders() 0 6 1
A setUpDatabase() 0 12 1
A setUpSoftDeletes() 0 6 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