Completed
Push — master ( a0b016...728b96 )
by Stéphane
24:07
created

DBTestCase::tearDown()   A

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
        $artisan = $this->app->make('Illuminate\Contracts\Console\Kernel');
23
        $artisan->call('migrate');
24
        //echo $artisan->output();
25
    }
26
27
    public function debugSQL() {
28
        echo "\n";
29
        $i = 0;
30
        $this->app['db']->listen(function($sql) use (&$i) {
31
            if (strpos($sql->sql, "drop") === 0 || strpos($sql->sql, "create") === 0 || strpos($sql->sql, "migrations") !== false || strpos($sql->sql, "sqlite_master") !== false) {
32
                return;
33
            }
34
35
            echo "-> (" . ++$i . ") " . $sql->sql . ": " . print_r(implode(", ", $sql->bindings), true) . "\n";
36
        });
37
    }
38
39
    /**
40
     * Clean up the testing environment before the next test.
41
     *
42
     * @return void
43
     */
44
    public function tearDown(): void
45
    {
46
        $artisan = $this->app->make('Illuminate\Contracts\Console\Kernel');
47
        $artisan->call('migrate:reset');
48
49
        parent::tearDown();
50
    }
51
}
52