Skip to content

Commit 96584ae

Browse files
committed
MAGETWO-52000: [Github][PR]impossible to see what is wrong with cron - unhelpful error message #3189
- updating tests
1 parent cf4bf08 commit 96584ae

File tree

3 files changed

+42
-8
lines changed

3 files changed

+42
-8
lines changed

lib/internal/Magento/Framework/Code/Test/Unit/GeneratedFilesTest.php

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,16 @@ public function testRegenerate($getPathMap, $isDirectoryMap, $deleteMap)
5151
{
5252

5353
$this->writeInterface
54-
->expects($this->once())
54+
->expects($this->any())
5555
->method('isExist')
56-
->with(GeneratedFiles::REGENERATE_FLAG)
57-
->willReturn(true);
58-
$this->directoryList->expects($this->exactly(2))->method('getPath')->willReturnMap($getPathMap);
59-
$this->writeInterface->expects($this->exactly(2))->method('getRelativePath')->willReturnMap($getPathMap);
60-
$this->writeInterface->expects($this->exactly(2))->method('isDirectory')->willReturnMap($isDirectoryMap);
56+
->with()
57+
->willReturnMap([
58+
[GeneratedFiles::REGENERATE_FLAG, true],
59+
['path/to/di', false]
60+
]);
61+
$this->directoryList->expects($this->any())->method('getPath')->willReturnMap($getPathMap);
62+
$this->writeInterface->expects($this->any())->method('getRelativePath')->willReturnMap($getPathMap);
63+
$this->writeInterface->expects($this->any())->method('isDirectory')->willReturnMap($isDirectoryMap);
6164
$this->writeInterface->expects($this->exactly(1))->method('delete')->willReturnMap($deleteMap);
6265
$this->model->regenerate();
6366
}
@@ -69,9 +72,15 @@ public function regenerateDataProvider()
6972
{
7073
$pathToGeneration = 'path/to/generation';
7174
$pathToDi = 'path/to/di';
75+
$pathToCache = 'path/to/di';
76+
$pathToConfig = 'path/to/config';
7277

7378
$getPathMap = [[DirectoryList::GENERATION, $pathToGeneration],
74-
[DirectoryList::DI, $pathToDi]];
79+
[DirectoryList::DI, $pathToDi],
80+
[DirectoryList::CACHE, $pathToCache],
81+
[DirectoryList::CONFIG, $pathToConfig],
82+
];
83+
7584
$deleteMap = [[BP . '/' . $pathToGeneration, true],
7685
[BP . '/' . $pathToDi, true],
7786
[BP . GeneratedFiles::REGENERATE_FLAG, true],

setup/src/Magento/Setup/Model/Cron/JobUpgrade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function execute()
7676
/**
7777
* @var \Magento\Framework\Filesystem\Directory\WriteFactory $writeFactory
7878
*/
79-
$writeFactory = $this->objectManager->get('\\Magento\Framework\Filesystem\Directory\WriteFactory');
79+
$writeFactory = $this->objectManager->get('\Magento\Framework\Filesystem\Directory\WriteFactory');
8080
$write = $writeFactory->create(BP);
8181
$dirList = $this->objectManager->get('\Magento\Framework\App\Filesystem\DirectoryList');
8282
$pathToCacheStatus = $write->getRelativePath(

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +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');
1516
$command = $this->getMock('Magento\Setup\Console\Command\UpgradeCommand', [], [], '', false);
1617
$command->expects($this->once())->method('run');
1718
$status = $this->getMock('Magento\Setup\Model\Cron\Status', [], [], '', false);
@@ -20,6 +21,30 @@ public function testExecute()
2021
$objectManagerProvider = $this->getMock('Magento\Setup\Model\ObjectManagerProvider', ['get'], [], '', false);
2122
$objectManagerProvider->expects($this->once())->method('get')->willReturn($objectManager);
2223

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+
2348
$jobUpgrade = new JobUpgrade(
2449
$command,
2550
$objectManagerProvider,

0 commit comments

Comments
 (0)