TestCase   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 3
dl 0
loc 58
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 6 1
A getPackageProviders() 0 6 1
A getEnvironmentSetUp() 0 9 1
A setUpDatabase() 0 16 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(): void
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->string('custom_column_sort');
48
            $table->integer('order_column');
49
        });
50
51
        collect(range(1, 20))->each(function (int $i) {
52
            Dummy::create([
53
                'name' => $i,
54
                'custom_column_sort' => rand(),
55
            ]);
56
        });
57
    }
58
59
    protected function setUpSoftDeletes()
60
    {
61
        $this->app['db']->connection()->getSchemaBuilder()->table('dummies', function (Blueprint $table) {
62
            $table->softDeletes();
63
        });
64
    }
65
}
66