Skip to content

Commit d435078

Browse files
Updated tests
1 parent 5453043 commit d435078

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

lib/internal/Magento/Framework/Crontab/Test/Unit/CrontabManagerTest.php

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,17 @@ public function getTasksDataProvider()
8787
return [
8888
[
8989
'content' => '* * * * * /bin/php /var/www/cron.php' . PHP_EOL
90-
. CrontabManagerInterface::TASKS_BLOCK_START . PHP_EOL
90+
. CrontabManagerInterface::TASKS_BLOCK_START . ' ' . md5(BP) . PHP_EOL
9191
. '* * * * * /bin/php /var/www/magento/bin/magento cron:run' . PHP_EOL
92-
. CrontabManagerInterface::TASKS_BLOCK_END . PHP_EOL,
92+
. CrontabManagerInterface::TASKS_BLOCK_END . ' ' . md5(BP) . PHP_EOL,
9393
'tasks' => ['* * * * * /bin/php /var/www/magento/bin/magento cron:run'],
9494
],
9595
[
9696
'content' => '* * * * * /bin/php /var/www/cron.php' . PHP_EOL
97-
. CrontabManagerInterface::TASKS_BLOCK_START . PHP_EOL
97+
. CrontabManagerInterface::TASKS_BLOCK_START . ' ' . md5(BP) . PHP_EOL
9898
. '* * * * * /bin/php /var/www/magento/bin/magento cron:run' . PHP_EOL
9999
. '* * * * * /bin/php /var/www/magento/bin/magento setup:cron:run' . PHP_EOL
100-
. CrontabManagerInterface::TASKS_BLOCK_END . PHP_EOL,
100+
. CrontabManagerInterface::TASKS_BLOCK_END . ' ' . md5(BP) . PHP_EOL,
101101
'tasks' => [
102102
'* * * * * /bin/php /var/www/magento/bin/magento cron:run',
103103
'* * * * * /bin/php /var/www/magento/bin/magento setup:cron:run',
@@ -165,17 +165,17 @@ public function removeTasksDataProvider()
165165
return [
166166
[
167167
'contentBefore' => '* * * * * /bin/php /var/www/cron.php' . PHP_EOL
168-
. CrontabManagerInterface::TASKS_BLOCK_START . PHP_EOL
168+
. CrontabManagerInterface::TASKS_BLOCK_START . ' ' . md5(BP) . PHP_EOL
169169
. '* * * * * /bin/php /var/www/magento/bin/magento cron:run' . PHP_EOL
170-
. CrontabManagerInterface::TASKS_BLOCK_END . PHP_EOL,
170+
. CrontabManagerInterface::TASKS_BLOCK_END . ' ' . md5(BP) . PHP_EOL,
171171
'contentAfter' => '* * * * * /bin/php /var/www/cron.php' . PHP_EOL
172172
],
173173
[
174174
'contentBefore' => '* * * * * /bin/php /var/www/cron.php' . PHP_EOL
175-
. CrontabManagerInterface::TASKS_BLOCK_START . PHP_EOL
175+
. CrontabManagerInterface::TASKS_BLOCK_START . ' ' . md5(BP) . PHP_EOL
176176
. '* * * * * /bin/php /var/www/magento/bin/magento cron:run' . PHP_EOL
177177
. '* * * * * /bin/php /var/www/magento/bin/magento setup:cron:run' . PHP_EOL
178-
. CrontabManagerInterface::TASKS_BLOCK_END . PHP_EOL,
178+
. CrontabManagerInterface::TASKS_BLOCK_END . ' ' . md5(BP) . PHP_EOL,
179179
'contentAfter' => '* * * * * /bin/php /var/www/cron.php' . PHP_EOL
180180
],
181181
[
@@ -198,14 +198,13 @@ public function testSaveTasksWithEmptyTasksList()
198198
{
199199
$baseDirMock = $this->getMockBuilder(ReadInterface::class)
200200
->getMockForAbstractClass();
201-
$baseDirMock->expects($this->once())
201+
$baseDirMock->expects($this->never())
202202
->method('getAbsolutePath')
203203
->willReturn('/var/www/magento2/');
204204
$logDirMock = $this->getMockBuilder(ReadInterface::class)
205205
->getMockForAbstractClass();
206-
$logDirMock->expects($this->once())
207-
->method('getAbsolutePath')
208-
->willReturn('/var/www/magento2/var/log/');
206+
$logDirMock->expects($this->never())
207+
->method('getAbsolutePath');
209208

210209
$this->filesystemMock->expects($this->any())
211210
->method('getDirectoryRead')
@@ -292,9 +291,9 @@ public function testSaveTasks($tasks, $content, $contentToSave)
292291
public function saveTasksDataProvider()
293292
{
294293
$content = '* * * * * /bin/php /var/www/cron.php' . PHP_EOL
295-
. CrontabManagerInterface::TASKS_BLOCK_START . PHP_EOL
294+
. CrontabManagerInterface::TASKS_BLOCK_START . ' ' . md5(BP) . PHP_EOL
296295
. '* * * * * /bin/php /var/www/magento/bin/magento cron:run' . PHP_EOL
297-
. CrontabManagerInterface::TASKS_BLOCK_END . PHP_EOL;
296+
. CrontabManagerInterface::TASKS_BLOCK_END . ' ' . md5(BP) . PHP_EOL;
298297

299298
return [
300299
[
@@ -303,41 +302,41 @@ public function saveTasksDataProvider()
303302
],
304303
'content' => $content,
305304
'contentToSave' => '* * * * * /bin/php /var/www/cron.php' . PHP_EOL
306-
. CrontabManagerInterface::TASKS_BLOCK_START . PHP_EOL
305+
. CrontabManagerInterface::TASKS_BLOCK_START . ' ' . md5(BP) . PHP_EOL
307306
. '* * * * * ' . PHP_BINARY . ' run.php' . PHP_EOL
308-
. CrontabManagerInterface::TASKS_BLOCK_END . PHP_EOL,
307+
. CrontabManagerInterface::TASKS_BLOCK_END . ' ' . md5(BP) . PHP_EOL,
309308
],
310309
[
311310
'tasks' => [
312311
['expression' => '1 2 3 4 5', 'command' => 'run.php']
313312
],
314313
'content' => $content,
315314
'contentToSave' => '* * * * * /bin/php /var/www/cron.php' . PHP_EOL
316-
. CrontabManagerInterface::TASKS_BLOCK_START . PHP_EOL
315+
. CrontabManagerInterface::TASKS_BLOCK_START . ' ' . md5(BP) . PHP_EOL
317316
. '1 2 3 4 5 ' . PHP_BINARY . ' run.php' . PHP_EOL
318-
. CrontabManagerInterface::TASKS_BLOCK_END . PHP_EOL,
317+
. CrontabManagerInterface::TASKS_BLOCK_END . ' ' . md5(BP) . PHP_EOL,
319318
],
320319
[
321320
'tasks' => [
322321
['command' => '{magentoRoot}run.php >> {magentoLog}cron.log']
323322
],
324323
'content' => $content,
325324
'contentToSave' => '* * * * * /bin/php /var/www/cron.php' . PHP_EOL
326-
. CrontabManagerInterface::TASKS_BLOCK_START . PHP_EOL
325+
. CrontabManagerInterface::TASKS_BLOCK_START . ' ' . md5(BP) . PHP_EOL
327326
. '* * * * * ' . PHP_BINARY . ' /var/www/magento2/run.php >>'
328327
. ' /var/www/magento2/var/log/cron.log' . PHP_EOL
329-
. CrontabManagerInterface::TASKS_BLOCK_END . PHP_EOL,
328+
. CrontabManagerInterface::TASKS_BLOCK_END . ' ' . md5(BP) . PHP_EOL,
330329
],
331330
[
332331
'tasks' => [
333332
['command' => '{magentoRoot}run.php % cron:run | grep -v "Ran \'jobs\' by schedule"']
334333
],
335334
'content' => $content,
336335
'contentToSave' => '* * * * * /bin/php /var/www/cron.php' . PHP_EOL
337-
. CrontabManagerInterface::TASKS_BLOCK_START . PHP_EOL
336+
. CrontabManagerInterface::TASKS_BLOCK_START . ' ' . md5(BP) . PHP_EOL
338337
. '* * * * * ' . PHP_BINARY . ' /var/www/magento2/run.php'
339338
. ' %% cron:run | grep -v \"Ran \'jobs\' by schedule\"' . PHP_EOL
340-
. CrontabManagerInterface::TASKS_BLOCK_END . PHP_EOL,
339+
. CrontabManagerInterface::TASKS_BLOCK_END . ' ' . md5(BP) . PHP_EOL,
341340
],
342341
];
343342
}

0 commit comments

Comments
 (0)