|
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); |
|
|
|
|
|
|
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); |
|
|
|
|
|
|
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); |
|
|
|
|
|
|
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); |
|
|
|
|
|
|
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); |
|
|
|
|
|
|
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); |
|
|
|
|
|
|
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
|
|
|
|