10 use Symfony\Component\Console\Tester\CommandTester;
20 private $objectManager;
30 private $deploymentConfig;
35 private $backupRollback;
40 private $backupRollbackFactory;
59 $this->deploymentConfig = $this->createMock(\
Magento\Framework\
App\DeploymentConfig::class);
60 $maintenanceMode = $this->createMock(\
Magento\Framework\
App\MaintenanceMode::class);
61 $this->objectManager = $this->getMockForAbstractClass(
62 \
Magento\Framework\ObjectManagerInterface::class,
67 $objectManagerProvider = $this->createMock(\
Magento\Setup\Model\ObjectManagerProvider::class);
68 $objectManagerProvider->expects($this->any())->method(
'get')->willReturn($this->objectManager);
69 $this->backupRollback = $this->createMock(\
Magento\Framework\Setup\BackupRollback::class);
70 $this->backupRollbackFactory = $this->createMock(\
Magento\Framework\Setup\BackupRollbackFactory::class);
71 $this->backupRollbackFactory->expects($this->any())
73 ->willReturn($this->backupRollback);
74 $appState = $this->createMock(\
Magento\Framework\
App\State::class);
75 $configLoader = $this->getMockForAbstractClass(
81 $configLoader->expects($this->any())->method(
'load')->willReturn([]);
82 $this->objectManager->expects($this->any())
84 ->will($this->returnValueMap([
85 [\
Magento\Framework\Setup\BackupRollbackFactory::class, $this->backupRollbackFactory],
86 [\
Magento\Framework\
App\State::class, $appState],
89 $this->helperSet = $this->createMock(\Symfony\Component\Console\Helper\HelperSet::class);
90 $this->question = $this->createMock(\Symfony\Component\Console\Helper\QuestionHelper::class);
92 ->expects($this->any())
94 ->will($this->returnValue(
true));
96 ->expects($this->any())
99 ->will($this->returnValue($this->question));
101 $objectManagerProvider,
103 $this->deploymentConfig,
106 $this->command->setHelperSet($this->helperSet);
107 $this->tester =
new CommandTester($this->command);
112 $this->deploymentConfig->expects($this->once())
113 ->method(
'isAvailable')
114 ->will($this->returnValue(
true));
115 $this->backupRollback->expects($this->once())
116 ->method(
'codeRollback')
117 ->willReturn($this->backupRollback);
118 $this->tester->execute([
'--code-file' =>
'A.tgz']);
123 $this->deploymentConfig->expects($this->once())
124 ->method(
'isAvailable')
125 ->will($this->returnValue(
true));
126 $this->backupRollback->expects($this->once())
127 ->method(
'codeRollback')
128 ->willReturn($this->backupRollback);
129 $this->tester->execute([
'--media-file' =>
'A.tgz']);
134 $this->deploymentConfig->expects($this->once())
135 ->method(
'isAvailable')
136 ->will($this->returnValue(
true));
137 $this->backupRollback->expects($this->once())
138 ->method(
'dbRollback')
139 ->willReturn($this->backupRollback);
140 $this->tester->execute([
'--db-file' =>
'C.gz']);
145 $this->deploymentConfig->expects($this->once())
146 ->method(
'isAvailable')
147 ->will($this->returnValue(
false));
148 $this->tester->execute([
'--db-file' =>
'C.gz']);
149 $this->assertStringMatchesFormat(
150 'No information is available: the Magento application is not installed.%w',
151 $this->tester->getDisplay()
157 $this->deploymentConfig->expects($this->once())
158 ->method(
'isAvailable')
159 ->will($this->returnValue(
true));
160 $this->tester->execute([]);
161 $expected =
'Enabling maintenance mode' . PHP_EOL
162 .
'Not enough information provided to roll back.' . PHP_EOL
163 .
'Disabling maintenance mode' . PHP_EOL;
164 $this->assertSame($expected, $this->tester->getDisplay());
169 $this->deploymentConfig->expects($this->once())
170 ->method(
'isAvailable')
171 ->will($this->returnValue(
true));
173 ->expects($this->atLeast(2))
175 ->will($this->returnValue(
false));
177 ->expects($this->once())
180 ->will($this->returnValue($this->question));
181 $this->command->setHelperSet($this->helperSet);
182 $this->tester =
new CommandTester($this->command);
183 $this->tester->execute([
'--db-file' =>
'C.gz']);
testExecuteMediaRollback()
testExecuteNotInstalled()
testExecuteCodeRollback()