Passed
Push — master ( 77392d...e0a3bd )
by Kirill
08:16 queued 11s
created

StatusTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
eloc 3
c 1
b 1
f 0
nc 1
nop 0
dl 0
loc 6
rs 10
1
<?php
2
3
/**
4
 * Spiral Framework.
5
 *
6
 * @license   MIT
7
 * @author    Anton Titov (Wolfy-J)
8
 */
9
10
declare(strict_types=1);
11
12
namespace Spiral\Tests\Framework\Migrate;
13
14
use Spiral\Database\Database;
15
use Spiral\Tests\Framework\ConsoleTest;
16
17
class StatusTest extends ConsoleTest
18
{
19
    public function setUp(): void
20
    {
21
        parent::setUp();
22
23
        $this->app = $this->makeApp([
24
            'SAFE_MIGRATIONS' => true
25
        ]);
26
    }
27
28
    public function testMigrate(): void
29
    {
30
        /** @var Database $db */
31
        $db = $this->app->get(Database::class);
32
        $this->assertSame([], $db->getTables());
33
34
        $out = $this->runCommandDebug('migrate:status');
35
        $this->assertStringContainsString('No migrations', $out);
36
37
        $this->runCommandDebug('migrate:init');
38
39
        $out = $this->runCommandDebug('migrate:status');
40
        $this->assertStringContainsString('No migrations', $out);
41
42
        $this->runCommandDebug('cycle:migrate');
43
        $this->assertCount(0, $db->getTables());
44
45
        $out = $this->runCommandDebug('migrate:status');
46
        $this->assertStringContainsString('not executed yet', $out);
47
48
        $this->runCommandDebug('migrate');
49
        $this->assertCount(3, $db->getTables());
50
51
        $out2 = $this->runCommandDebug('migrate:status');
52
        $this->assertNotSame($out, $out2);
53
    }
54
}
55