Passed
Push — master ( af1948...fa5d33 )
by Anton
02:45
created

ConfirmTest::testConfirmCycleSync()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 14
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * Spiral Framework.
4
 *
5
 * @license   MIT
6
 * @author    Anton Titov (Wolfy-J)
7
 */
8
declare(strict_types=1);
9
10
11
namespace Spiral\Framework\Migrate;
12
13
use Spiral\Command\Migrate\MigrateCommand;
14
use Spiral\Command\Migrate\ReplayCommand;
15
use Spiral\Command\Migrate\RollbackCommand;
16
use Spiral\Framework\ConsoleTest;
17
use Symfony\Component\Console\Tester\CommandTester;
18
19
class ConfirmTest extends ConsoleTest
20
{
21
    public function setUp()
22
    {
23
        $this->app = $this->makeApp([
24
            'SAFE_MIGRATIONS' => false
25
        ]);
26
    }
27
28
    public function testConfirmMigrate()
29
    {
30
        $this->runCommandDebug('migrate:init');
31
32
        $mc = $this->app->get(MigrateCommand::class);
33
        $mc->setContainer($this->app->getContainer());
34
35
        $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

35
        $ct = new CommandTester(/** @scrutinizer ignore-type */ $mc);
Loading history...
36
        $ct->setInputs(['n']);
37
        $ct->execute([]);
38
39
        rewind($ct->getOutput()->getStream());
40
        $out = fread($ct->getOutput()->getStream(), 9000);
41
42
        $this->assertContains('Confirmation', $out);
43
        $this->assertNotContains('No outstanding', $out);
44
    }
45
46
    public function testConfirmMigrateY()
47
    {
48
        $this->runCommandDebug('migrate:init');
49
50
        $mc = $this->app->get(MigrateCommand::class);
51
        $mc->setContainer($this->app->getContainer());
52
53
        $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

53
        $ct = new CommandTester(/** @scrutinizer ignore-type */ $mc);
Loading history...
54
        $ct->setInputs(['y']);
55
        $ct->execute([]);
56
57
        rewind($ct->getOutput()->getStream());
58
        $out = fread($ct->getOutput()->getStream(), 9000);
59
60
        $this->assertContains('Confirmation', $out);
61
        $this->assertContains('No outstanding', $out);
62
    }
63
64
    public function testConfirmRollbackMigrate()
65
    {
66
        $this->runCommandDebug('migrate:init');
67
68
        $mc = $this->app->get(RollbackCommand::class);
69
        $mc->setContainer($this->app->getContainer());
70
71
        $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

71
        $ct = new CommandTester(/** @scrutinizer ignore-type */ $mc);
Loading history...
72
        $ct->setInputs(['n']);
73
        $ct->execute([]);
74
75
        rewind($ct->getOutput()->getStream());
76
        $out = fread($ct->getOutput()->getStream(), 9000);
77
78
        $this->assertContains('Confirmation', $out);
79
        $this->assertNotContains('No executed', $out);
80
    }
81
82
    public function testConfirmRollbackMigrateY()
83
    {
84
        $this->runCommandDebug('migrate:init');
85
86
        $mc = $this->app->get(RollbackCommand::class);
87
        $mc->setContainer($this->app->getContainer());
88
89
        $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

89
        $ct = new CommandTester(/** @scrutinizer ignore-type */ $mc);
Loading history...
90
        $ct->setInputs(['y']);
91
        $ct->execute([]);
92
93
        rewind($ct->getOutput()->getStream());
94
        $out = fread($ct->getOutput()->getStream(), 9000);
95
96
        $this->assertContains('Confirmation', $out);
97
        $this->assertContains('No executed', $out);
98
    }
99
100
    public function testConfirmReplayMigrate()
101
    {
102
        $this->runCommandDebug('migrate:init');
103
104
        $mc = $this->app->get(ReplayCommand::class);
105
        $mc->setContainer($this->app->getContainer());
106
107
        $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

107
        $ct = new CommandTester(/** @scrutinizer ignore-type */ $mc);
Loading history...
108
        $ct->setInputs(['n']);
109
        $ct->execute([]);
110
111
        rewind($ct->getOutput()->getStream());
112
        $out = fread($ct->getOutput()->getStream(), 9000);
113
114
        $this->assertContains('Confirmation', $out);
115
        $this->assertNotContains('No outstanding', $out);
116
    }
117
118
    public function testConfirmReplayMigrateY()
119
    {
120
        $this->runCommandDebug('migrate:init');
121
122
        $mc = $this->app->get(ReplayCommand::class);
123
        $mc->setContainer($this->app->getContainer());
124
125
        $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

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