Passed
Pull Request — master (#277)
by Kirill
03:11
created

ConfirmTest::testConfirmRollbackMigrateY()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 10
nc 1
nop 0
dl 0
loc 16
rs 9.9332
c 0
b 0
f 0
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\Command\Migrate\MigrateCommand;
15
use Spiral\Command\Migrate\ReplayCommand;
16
use Spiral\Command\Migrate\RollbackCommand;
17
use Spiral\Tests\Framework\ConsoleTest;
18
use Symfony\Component\Console\Tester\CommandTester;
19
20
class ConfirmTest extends ConsoleTest
21
{
22
    public function setUp(): void
23
    {
24
        $this->app = $this->makeApp([
25
            'SAFE_MIGRATIONS' => false
26
        ]);
27
    }
28
29
    public function testConfirmMigrate(): void
30
    {
31
        $this->runCommandDebug('migrate:init');
32
33
        $mc = $this->app->get(MigrateCommand::class);
34
        $mc->setContainer($this->app->getContainer());
35
36
        $ct = new CommandTester($mc);
0 ignored issues
show
Bug introduced by
It seems like $mc can also be of type null; however, parameter $command of Symfony\Component\Consol...ndTester::__construct() does only seem to accept Symfony\Component\Console\Command\Command, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

36
        $ct = new CommandTester(/** @scrutinizer ignore-type */ $mc);
Loading history...
37
        $ct->setInputs(['n']);
38
        $ct->execute([]);
39
40
        rewind($ct->getOutput()->getStream());
41
        $out = fread($ct->getOutput()->getStream(), 9000);
42
43
        $this->assertStringContainsString('Confirmation', $out);
44
        $this->assertStringNotContainsString('No outstanding', $out);
45
    }
46
47
    public function testConfirmMigrateY(): void
48
    {
49
        $this->runCommandDebug('migrate:init');
50
51
        $mc = $this->app->get(MigrateCommand::class);
52
        $mc->setContainer($this->app->getContainer());
53
54
        $ct = new CommandTester($mc);
0 ignored issues
show
Bug introduced by
It seems like $mc can also be of type null; however, parameter $command of Symfony\Component\Consol...ndTester::__construct() does only seem to accept Symfony\Component\Console\Command\Command, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

54
        $ct = new CommandTester(/** @scrutinizer ignore-type */ $mc);
Loading history...
55
        $ct->setInputs(['y']);
56
        $ct->execute([]);
57
58
        rewind($ct->getOutput()->getStream());
59
        $out = fread($ct->getOutput()->getStream(), 9000);
60
61
        $this->assertStringContainsString('Confirmation', $out);
62
        $this->assertStringContainsString('No outstanding', $out);
63
    }
64
65
    public function testConfirmRollbackMigrate(): void
66
    {
67
        $this->runCommandDebug('migrate:init');
68
69
        $mc = $this->app->get(RollbackCommand::class);
70
        $mc->setContainer($this->app->getContainer());
71
72
        $ct = new CommandTester($mc);
0 ignored issues
show
Bug introduced by
It seems like $mc can also be of type null; however, parameter $command of Symfony\Component\Consol...ndTester::__construct() does only seem to accept Symfony\Component\Console\Command\Command, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

72
        $ct = new CommandTester(/** @scrutinizer ignore-type */ $mc);
Loading history...
73
        $ct->setInputs(['n']);
74
        $ct->execute([]);
75
76
        rewind($ct->getOutput()->getStream());
77
        $out = fread($ct->getOutput()->getStream(), 9000);
78
79
        $this->assertStringContainsString('Confirmation', $out);
80
        $this->assertStringNotContainsString('No executed', $out);
81
    }
82
83
    public function testConfirmRollbackMigrateY(): void
84
    {
85
        $this->runCommandDebug('migrate:init');
86
87
        $mc = $this->app->get(RollbackCommand::class);
88
        $mc->setContainer($this->app->getContainer());
89
90
        $ct = new CommandTester($mc);
0 ignored issues
show
Bug introduced by
It seems like $mc can also be of type null; however, parameter $command of Symfony\Component\Consol...ndTester::__construct() does only seem to accept Symfony\Component\Console\Command\Command, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

90
        $ct = new CommandTester(/** @scrutinizer ignore-type */ $mc);
Loading history...
91
        $ct->setInputs(['y']);
92
        $ct->execute([]);
93
94
        rewind($ct->getOutput()->getStream());
95
        $out = fread($ct->getOutput()->getStream(), 9000);
96
97
        $this->assertStringContainsString('Confirmation', $out);
98
        $this->assertStringContainsString('No executed', $out);
99
    }
100
101
    public function testConfirmReplayMigrate(): void
102
    {
103
        $this->runCommandDebug('migrate:init');
104
105
        $mc = $this->app->get(ReplayCommand::class);
106
        $mc->setContainer($this->app->getContainer());
107
108
        $ct = new CommandTester($mc);
0 ignored issues
show
Bug introduced by
It seems like $mc can also be of type null; however, parameter $command of Symfony\Component\Consol...ndTester::__construct() does only seem to accept Symfony\Component\Console\Command\Command, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

108
        $ct = new CommandTester(/** @scrutinizer ignore-type */ $mc);
Loading history...
109
        $ct->setInputs(['n']);
110
        $ct->execute([]);
111
112
        rewind($ct->getOutput()->getStream());
113
        $out = fread($ct->getOutput()->getStream(), 9000);
114
115
        $this->assertStringContainsString('Confirmation', $out);
116
        $this->assertStringNotContainsString('No outstanding', $out);
117
    }
118
119
    public function testConfirmReplayMigrateY(): void
120
    {
121
        $this->runCommandDebug('migrate:init');
122
123
        $mc = $this->app->get(ReplayCommand::class);
124
        $mc->setContainer($this->app->getContainer());
125
126
        $ct = new CommandTester($mc);
0 ignored issues
show
Bug introduced by
It seems like $mc can also be of type null; however, parameter $command of Symfony\Component\Consol...ndTester::__construct() does only seem to accept Symfony\Component\Console\Command\Command, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

126
        $ct = new CommandTester(/** @scrutinizer ignore-type */ $mc);
Loading history...
127
        $ct->setInputs(['y']);
128
        $ct->execute([]);
129
130
        rewind($ct->getOutput()->getStream());
131
        $out = fread($ct->getOutput()->getStream(), 9000);
132
133
        $this->assertStringContainsString('Confirmation', $out);
134
        $this->assertStringContainsString('No outstanding', $out);
135
    }
136
}
137