Skip to content

Commit 960ac59

Browse files
committed
MAGETWO-53474: [Github] Caches Aren't Enabled by Default on RC1 with Composer when Upgrading via CLI
- Updating tests.
1 parent 503643c commit 960ac59

File tree

3 files changed

+21
-33
lines changed

3 files changed

+21
-33
lines changed

setup/src/Magento/Setup/Console/Command/UpgradeCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
9999
}
100100

101101
//TODO: to be removed in scope of MAGETWO-53476
102-
$writeFactory = $objectManager->get('\Magento\Framework\Filesystem\Directory\WriteFactory');
102+
$writeFactory = $objectManager->get('Magento\Framework\Filesystem\Directory\WriteFactory');
103103
$write = $writeFactory->create(BP);
104104
/** @var \Magento\Framework\App\Filesystem\DirectoryList $dirList */
105-
$dirList = $objectManager->get('\Magento\Framework\App\Filesystem\DirectoryList');
105+
$dirList = $objectManager->get('Magento\Framework\App\Filesystem\DirectoryList');
106106

107107
$pathToCacheStatus = $write->getRelativePath($dirList->getPath(DirectoryList::VAR_DIR) . '/.cachestates.json');
108108

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

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,31 @@ public function testExecute()
2020
$state = $this->getMock('Magento\Framework\App\State', [], [], '', false);
2121
$state->expects($this->once())->method('setAreaCode')->with('setup');
2222
$objectManagerProvider->expects($this->once())->method('get')->willReturn($objectManager);
23-
$objectManager->expects($this->exactly(2))
24-
->method('get')
25-
->will($this->returnValueMap([
26-
['Magento\Framework\App\State', $state],
27-
['Magento\Framework\ObjectManager\ConfigLoaderInterface', $configLoader],
28-
]));
2923
$objectManager->expects($this->once())->method('configure');
3024
$state->expects($this->once())->method('setAreaCode')->with('setup');
3125
$installer = $this->getMock('Magento\Setup\Model\Installer', [], [], '', false);
3226
$installer->expects($this->at(0))->method('updateModulesSequence');
3327
$installer->expects($this->at(1))->method('installSchema');
3428
$installer->expects($this->at(2))->method('installDataFixtures');
3529
$installerFactory->expects($this->once())->method('create')->willReturn($installer);
30+
31+
$pathToCacheStatus = '/path/to/cachefile';
32+
$writeFactory = $this->getMock('\Magento\Framework\Filesystem\Directory\WriteFactory', [], [], '', false);
33+
$write = $this->getMock('\Magento\Framework\Filesystem\Directory\Write', [], [], '', false);
34+
$write->expects($this->once())->method('isExist')->with('/path/to/cachefile')->willReturn(false);
35+
$write->expects($this->once())->method('getRelativePath')->willReturn($pathToCacheStatus);
36+
37+
$writeFactory->expects($this->once())->method('create')->willReturn($write);
38+
$directoryList = $this->getMock('\Magento\Framework\App\Filesystem\DirectoryList', [], [], '', false);
39+
$objectManager->expects($this->exactly(4))
40+
->method('get')
41+
->will($this->returnValueMap([
42+
['Magento\Framework\App\State', $state],
43+
['Magento\Framework\ObjectManager\ConfigLoaderInterface', $configLoader],
44+
['Magento\Framework\Filesystem\Directory\WriteFactory', $writeFactory],
45+
['Magento\Framework\App\Filesystem\DirectoryList', $directoryList],
46+
]));
47+
3648
$commandTester = new CommandTester(new UpgradeCommand($installerFactory, $objectManagerProvider));
3749
$commandTester->execute([]);
3850
}

setup/src/Magento/Setup/Test/Unit/Model/Cron/JobUpgradeTest.php

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class JobUpgradeTest extends \PHPUnit_Framework_TestCase
1212
public function testExecute()
1313
{
1414
$queue = $this->getMock('Magento\Setup\Model\Cron\Queue', [], [], '', false);
15-
$queue->expects($this->exactly(3))->method('addJobs');
15+
$queue->expects($this->exactly(2))->method('addJobs');
1616
$command = $this->getMock('Magento\Setup\Console\Command\UpgradeCommand', [], [], '', false);
1717
$command->expects($this->once())->method('run');
1818
$status = $this->getMock('Magento\Setup\Model\Cron\Status', [], [], '', false);
@@ -21,30 +21,6 @@ public function testExecute()
2121
$objectManagerProvider = $this->getMock('Magento\Setup\Model\ObjectManagerProvider', ['get'], [], '', false);
2222
$objectManagerProvider->expects($this->once())->method('get')->willReturn($objectManager);
2323

24-
$cleanupFiles = $this->getMock('\Magento\Framework\App\State\CleanupFiles', [], [], '', false);
25-
$cache = $this->getMock('\Magento\Framework\App\Cache', [], [], '', false);
26-
27-
$pathToCacheStatus = '/path/to/cachefile';
28-
$writeFactory = $this->getMock('\Magento\Framework\Filesystem\Directory\WriteFactory', [], [], '', false);
29-
$write = $this->getMock('\Magento\Framework\Filesystem\Directory\Write', [], [], '', false);
30-
$write->expects($this->once())->method('isExist')->with('/path/to/cachefile')->willReturn(true);
31-
$write->expects($this->once())->method('readFile')->with('/path/to/cachefile')->willReturn(
32-
'{"cacheOne":1,"cacheTwo":1,"cacheThree":1}'
33-
);
34-
$write->expects($this->once())->method('delete')->with('/path/to/cachefile')->willReturn(true);
35-
$write->expects($this->once())->method('getRelativePath')->willReturn($pathToCacheStatus);
36-
37-
$writeFactory->expects($this->once())->method('create')->willReturn($write);
38-
$directoryList = $this->getMock('\Magento\Framework\App\Filesystem\DirectoryList', [], [], '', false);
39-
$directoryList->expects($this->once())->method('getPath')->willReturn('/some/full/path' . $pathToCacheStatus);
40-
41-
$objectManager->expects($this->any())->method('get')->will($this->returnValueMap([
42-
['\Magento\Framework\Filesystem\Directory\WriteFactory', $writeFactory],
43-
['\Magento\Framework\App\Filesystem\DirectoryList', $directoryList],
44-
['\Magento\Framework\App\State\CleanupFiles', $cleanupFiles],
45-
['\Magento\Framework\App\Cache', $cache],
46-
]));
47-
4824
$jobUpgrade = new JobUpgrade(
4925
$command,
5026
$objectManagerProvider,

0 commit comments

Comments
 (0)