10 use Symfony\Component\Console\Tester\CommandTester;
17 private $objectManager;
22 private $backupRollback;
32 private $backupRollbackFactory;
37 private $deploymentConfig;
41 $maintenanceMode = $this->createMock(\
Magento\Framework\
App\MaintenanceMode::class);
42 $objectManagerProvider = $this->createMock(\
Magento\Setup\Model\ObjectManagerProvider::class);
43 $this->objectManager = $this->getMockForAbstractClass(
44 \
Magento\Framework\ObjectManagerInterface::class,
49 $objectManagerProvider->expects($this->any())->method(
'get')->willReturn($this->objectManager);
50 $this->backupRollback = $this->createMock(\
Magento\Framework\Setup\BackupRollback::class);
51 $this->backupRollbackFactory = $this->createMock(\
Magento\Framework\Setup\BackupRollbackFactory::class);
52 $this->backupRollbackFactory->expects($this->any())
54 ->willReturn($this->backupRollback);
55 $this->deploymentConfig = $this->createMock(\
Magento\Framework\
App\DeploymentConfig::class);
56 $appState = $this->createMock(\
Magento\Framework\
App\State::class);
57 $configLoader = $this->getMockForAbstractClass(
63 $configLoader->expects($this->any())->method(
'load')->willReturn([]);
65 $this->objectManager->expects($this->any())
68 $this->returnValueMap([
69 [\
Magento\Framework\Setup\BackupRollbackFactory::class, $this->backupRollbackFactory],
70 [\
Magento\Framework\
App\State::class, $appState],
75 $objectManagerProvider,
77 $this->deploymentConfig,
80 $this->tester =
new CommandTester($command);
85 $this->deploymentConfig->expects($this->once())
86 ->method(
'isAvailable')
87 ->will($this->returnValue(
true));
88 $this->backupRollback->expects($this->once())
89 ->method(
'codeBackup')
90 ->willReturn($this->backupRollback);
91 $this->tester->execute([
'--code' =>
true]);
96 $this->deploymentConfig->expects($this->once())
97 ->method(
'isAvailable')
98 ->will($this->returnValue(
true));
99 $this->backupRollback->expects($this->once())
100 ->method(
'codeBackup')
101 ->willReturn($this->backupRollback);
102 $this->tester->execute([
'--media' =>
true]);
107 $this->deploymentConfig->expects($this->once())
108 ->method(
'isAvailable')
109 ->will($this->returnValue(
true));
110 $this->backupRollback->expects($this->once())
112 ->willReturn($this->backupRollback);
113 $this->tester->execute([
'--db' =>
true]);
118 $this->deploymentConfig->expects($this->once())
119 ->method(
'isAvailable')
120 ->will($this->returnValue(
false));
121 $this->tester->execute([
'--db' =>
true]);
122 $this->assertStringMatchesFormat(
123 'No information is available: the Magento application is not installed.%w',
124 $this->tester->getDisplay()
130 $this->deploymentConfig->expects($this->once())
131 ->method(
'isAvailable')
132 ->will($this->returnValue(
false));
133 $this->tester->execute([]);
134 $expected =
'Enabling maintenance mode' . PHP_EOL
135 .
'Not enough information provided to take backup.' . PHP_EOL
136 .
'Disabling maintenance mode' . PHP_EOL;
137 $this->assertSame($expected, $this->tester->getDisplay());
testExecuteNotInstalled()