DBTestCase::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

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