Skip to content

Commit aa1f29c

Browse files
committed
Updated tests to include the MaintenanceModeEnabler
1 parent 7295017 commit aa1f29c

File tree

3 files changed

+24
-14
lines changed

3 files changed

+24
-14
lines changed

app/code/Magento/Theme/Test/Unit/Console/Command/ThemeUninstallCommandTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,9 +304,9 @@ public function testExecute()
304304
{
305305
$this->setUpExecute();
306306
$this->cleanupFiles->expects($this->never())->method('clearMaterializedViewFiles');
307+
$this->maintenanceMode->expects($this->once())->method('enableMaintenanceMode');
308+
$this->maintenanceMode->expects($this->once())->method('disableMaintenanceMode');
307309
$this->tester->execute(['theme' => ['area/vendor/test']]);
308-
$this->assertContains('Enabling maintenance mode', $this->tester->getDisplay());
309-
$this->assertContains('Disabling maintenance mode', $this->tester->getDisplay());
310310
$this->assertContains('Alert: Generated static view files were not cleared.', $this->tester->getDisplay());
311311
$this->assertNotContains('Generated static view files cleared successfully', $this->tester->getDisplay());
312312
}
@@ -315,9 +315,9 @@ public function testExecuteCleanStaticFiles()
315315
{
316316
$this->setUpExecute();
317317
$this->cleanupFiles->expects($this->once())->method('clearMaterializedViewFiles');
318+
$this->maintenanceMode->expects($this->once())->method('enableMaintenanceMode');
319+
$this->maintenanceMode->expects($this->once())->method('disableMaintenanceMode');
318320
$this->tester->execute(['theme' => ['area/vendor/test'], '-c' => true]);
319-
$this->assertContains('Enabling maintenance mode', $this->tester->getDisplay());
320-
$this->assertContains('Disabling maintenance mode', $this->tester->getDisplay());
321321
$this->assertNotContains('Alert: Generated static view files were not cleared.', $this->tester->getDisplay());
322322
$this->assertContains('Generated static view files cleared successfully', $this->tester->getDisplay());
323323
}

setup/src/Magento/Setup/Test/Unit/Console/Command/BackupCommandTest.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,14 @@ class BackupCommandTest extends \PHPUnit\Framework\TestCase
3535
*/
3636
private $deploymentConfig;
3737

38+
/**
39+
* @var \Magento\Framework\App\Console\MaintenanceModeEnabler|\PHPUnit_Framework_MockObject_MockObject
40+
*/
41+
private $maintenanceMode;
42+
3843
public function setUp()
3944
{
40-
$maintenanceMode = $this->createMock(\Magento\Framework\App\Console\MaintenanceModeEnabler::class);
45+
$this->maintenanceMode = $this->createMock(\Magento\Framework\App\Console\MaintenanceModeEnabler::class);
4146
$objectManagerProvider = $this->createMock(\Magento\Setup\Model\ObjectManagerProvider::class);
4247
$this->objectManager = $this->getMockForAbstractClass(
4348
\Magento\Framework\ObjectManagerInterface::class,
@@ -72,7 +77,7 @@ public function setUp()
7277
);
7378
$command = new BackupCommand(
7479
$objectManagerProvider,
75-
$maintenanceMode,
80+
$this->maintenanceMode,
7681
$this->deploymentConfig
7782
);
7883
$this->tester = new CommandTester($command);
@@ -128,10 +133,10 @@ public function testExecuteNoOptions()
128133
$this->deploymentConfig->expects($this->once())
129134
->method('isAvailable')
130135
->will($this->returnValue(false));
136+
$this->maintenanceMode->expects($this->once())->method('enableMaintenanceMode');
137+
$this->maintenanceMode->expects($this->once())->method('disableMaintenanceMode');
131138
$this->tester->execute([]);
132-
$expected = 'Enabling maintenance mode' . PHP_EOL
133-
. 'Not enough information provided to take backup.' . PHP_EOL
134-
. 'Disabling maintenance mode' . PHP_EOL;
139+
$expected = 'Not enough information provided to take backup.' . PHP_EOL;
135140
$this->assertSame($expected, $this->tester->getDisplay());
136141
}
137142
}

setup/src/Magento/Setup/Test/Unit/Console/Command/RollbackCommandTest.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,15 @@ class RollbackCommandTest extends \PHPUnit\Framework\TestCase
5050
*/
5151
private $command;
5252

53+
/**
54+
* @var \Magento\Framework\App\Console\MaintenanceModeEnabler|\PHPUnit_Framework_MockObject_MockObject
55+
*/
56+
private $maintenanceMode;
57+
5358
public function setUp()
5459
{
5560
$this->deploymentConfig = $this->createMock(\Magento\Framework\App\DeploymentConfig::class);
56-
$maintenanceMode = $this->createMock(\Magento\Framework\App\Console\MaintenanceModeEnabler::class);
61+
$this->maintenanceMode = $this->createMock(\Magento\Framework\App\Console\MaintenanceModeEnabler::class);
5762
$this->objectManager = $this->getMockForAbstractClass(
5863
\Magento\Framework\ObjectManagerInterface::class,
5964
[],
@@ -95,7 +100,7 @@ public function setUp()
95100
->will($this->returnValue($this->question));
96101
$this->command = new RollbackCommand(
97102
$objectManagerProvider,
98-
$maintenanceMode,
103+
$this->maintenanceMode,
99104
$this->deploymentConfig
100105
);
101106
$this->command->setHelperSet($this->helperSet);
@@ -152,10 +157,10 @@ public function testExecuteNoOptions()
152157
$this->deploymentConfig->expects($this->once())
153158
->method('isAvailable')
154159
->will($this->returnValue(true));
160+
$this->maintenanceMode->expects($this->once())->method('enableMaintenanceMode');
161+
$this->maintenanceMode->expects($this->once())->method('disableMaintenanceMode');
155162
$this->tester->execute([]);
156-
$expected = 'Enabling maintenance mode' . PHP_EOL
157-
. 'Not enough information provided to roll back.' . PHP_EOL
158-
. 'Disabling maintenance mode' . PHP_EOL;
163+
$expected = 'Not enough information provided to roll back.' . PHP_EOL;
159164
$this->assertSame($expected, $this->tester->getDisplay());
160165
}
161166

0 commit comments

Comments
 (0)