Passed
Push — chore/add-feature-tests ( 36c2df...e56562 )
by Bas
04:12 queued 19s
created

DatabaseTruncation   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
c 1
b 0
f 0
dl 0
loc 43
ccs 18
cts 18
cp 1
rs 10
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setMigrationPaths() 0 13 3
A migrateFreshUsing() 0 14 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LaravelFreelancerNL\Aranguent\Testing;
6
7
use Illuminate\Foundation\Testing\DatabaseTruncation as IlluminateDatabaseTruncation;
8
9
trait DatabaseTruncation
10
{
11
    use IlluminateDatabaseTruncation;
12
13
    /**
14
     * The parameters that should be used when running "migrate:fresh".
15
     *
16
     * @return array
17
     */
18 1
    protected function migrateFreshUsing()
19
    {
20 1
        $seeder = $this->seeder();
21
22 1
        $results =  array_merge(
23 1
            [
24 1
                '--drop-views' => $this->shouldDropViews(),
25 1
                '--drop-types' => $this->shouldDropTypes(),
26 1
            ],
27 1
            $seeder ? ['--seeder' => $seeder] : ['--seed' => $this->shouldSeed()],
28 1
            $this->setMigrationPaths(),
29 1
        );
30
31 1
        return $results;
32
    }
33
34
    /**
35
     * Determine if types should be dropped when refreshing the database.
36
     *
37
     * @return array<string, array<string>|string>
38
     */
39 1
    protected function setMigrationPaths()
40
    {
41 1
        $migrationSettings = [];
42
43 1
        if(property_exists($this, 'realPath')) {
44 1
            $migrationSettings['--realpath'] = $this->realPath ?? false;
45
        }
46
47 1
        if (property_exists($this, 'migrationPaths')) {
48 1
            $migrationSettings['--path'] = $this->migrationPaths;
49
        }
50
51 1
        return $migrationSettings;
52
    }
53
}
54