DBTestCase   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 39
rs 10
c 0
b 0
f 0
wmc 7
lcom 1
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 7 1
A debugSQL() 0 11 5
A tearDown() 0 6 1
1
<?php namespace Tests;
2
3
/**
4
 * Simplifies the creation of tests creating a full application, running migrations and loading multiple Service Providers
5
 */
6
7
/**
8
 * Class TestCase
9
 * @codeCoverageIgnore
10
 */
11
class DBTestCase extends TestCase
0 ignored issues
show
Bug introduced by
There is at least one abstract method in this class. Maybe declare it as abstract, or implement the remaining methods: artisan, be, call, seed
Loading history...
12
{
13
    /**
14
     * Setup the test environment.
15
     *
16
     * @return void
17
     */
18
    public function setUp(): void
19
    {
20
        parent::setUp();
21
22
        $this->artisan('migrate');
23
        //echo $artisan->output();
24
    }
25
26
    public function debugSQL() {
27
        echo "\n";
28
        $i = 0;
29
        $this->app['db']->listen(function($sql) use (&$i) {
30
            if (strpos($sql->sql, "drop") === 0 || strpos($sql->sql, "create") === 0 || strpos($sql->sql, "migrations") !== false || strpos($sql->sql, "sqlite_master") !== false) {
31
                return;
32
            }
33
34
            echo "-> (" . ++$i . ") " . $sql->sql . ": " . print_r(implode(", ", $sql->bindings), true) . "\n";
35
        });
36
    }
37
38
    /**
39
     * Clean up the testing environment before the next test.
40
     *
41
     * @return void
42
     */
43
    public function tearDown(): void
44
    {
45
        $this->artisan('migrate:reset');
46
47
        parent::tearDown();
48
    }
49
}
50