diff --git a/app/code/Magento/Backend/Test/Unit/Console/Command/CacheDisableCommandTest.php b/app/code/Magento/Backend/Test/Unit/Console/Command/CacheDisableCommandTest.php
index f3e3311d4b8a0a1a25777d5a042f0acc72f93027..4446b1b992e03b44bb3602adbab2c16cda301106 100644
--- a/app/code/Magento/Backend/Test/Unit/Console/Command/CacheDisableCommandTest.php
+++ b/app/code/Magento/Backend/Test/Unit/Console/Command/CacheDisableCommandTest.php
@@ -26,8 +26,13 @@ class CacheDisableCommandTest extends AbstractCacheSetCommandTest
      */
     public function testExecute($param, $enable, $result, $output)
     {
-        $this->cacheManagerMock->expects($this->once())->method('getAvailableTypes')->willReturn(['A', 'B', 'C']);
-        $this->cacheManagerMock->expects($this->once())->method('setEnabled')->with($enable, false)->willReturn($result);
+        $this->cacheManagerMock->expects($this->once())
+            ->method('getAvailableTypes')
+            ->willReturn(['A', 'B', 'C']);
+        $this->cacheManagerMock->expects($this->once())
+            ->method('setEnabled')
+            ->with($enable, false)
+            ->willReturn($result);
 
         $commandTester = new CommandTester($this->command);
         $commandTester->execute($param);
diff --git a/app/code/Magento/Backend/Test/Unit/Console/Command/CacheEnableCommandTest.php b/app/code/Magento/Backend/Test/Unit/Console/Command/CacheEnableCommandTest.php
index 8690d4295ecf295f57610bde7fadb782a13b48f5..e44b71d06f9fdc9a624959b50a32521c2db479eb 100644
--- a/app/code/Magento/Backend/Test/Unit/Console/Command/CacheEnableCommandTest.php
+++ b/app/code/Magento/Backend/Test/Unit/Console/Command/CacheEnableCommandTest.php
@@ -27,8 +27,14 @@ class CacheEnableCommandTest extends AbstractCacheSetCommandTest
     public function testExecute($param, $enable, $result, $output)
     {
         $this->cacheManagerMock->expects($this->once())->method('getAvailableTypes')->willReturn(['A', 'B', 'C']);
-        $this->cacheManagerMock->expects($this->once())->method('setEnabled')->with($enable, true)->willReturn($result);
-        $this->cacheManagerMock->expects($result === [] ? $this->never() : $this->once())->method('clean')->with($enable);
+        $this->cacheManagerMock->expects($this->once())
+            ->method('setEnabled')
+            ->with($enable, true)
+            ->willReturn($result);
+        $cleanInvocationCount = $result === [] ? 0 : 1;
+        $this->cacheManagerMock->expects($this->exactly($cleanInvocationCount))
+            ->method('clean')
+            ->with($enable);
 
         $commandTester = new CommandTester($this->command);
         $commandTester->execute($param);