5
5
*/
6
6
namespace Magento \Framework \Crontab \Test \Unit ;
7
7
8
+ use Magento \Framework \App \Filesystem \DirectoryList ;
8
9
use Magento \Framework \Crontab \CrontabManager ;
9
10
use Magento \Framework \Crontab \CrontabManagerInterface ;
10
- use Magento \Framework \ShellInterface ;
11
- use Magento \Framework \Phrase ;
12
11
use Magento \Framework \Exception \LocalizedException ;
13
12
use Magento \Framework \Filesystem ;
14
- use Magento \Framework \App \Filesystem \DirectoryList ;
15
13
use Magento \Framework \Filesystem \Directory \ReadInterface ;
16
14
use Magento \Framework \Filesystem \DriverPool ;
15
+ use Magento \Framework \Phrase ;
16
+ use Magento \Framework \ShellInterface ;
17
17
18
18
class CrontabManagerTest extends \PHPUnit \Framework \TestCase
19
19
{
@@ -87,17 +87,17 @@ public function getTasksDataProvider()
87
87
return [
88
88
[
89
89
'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
91
91
. '* * * * * /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 ,
93
93
'tasks ' => ['* * * * * /bin/php /var/www/magento/bin/magento cron:run ' ],
94
94
],
95
95
[
96
96
'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
98
98
. '* * * * * /bin/php /var/www/magento/bin/magento cron:run ' . PHP_EOL
99
99
. '* * * * * /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 ,
101
101
'tasks ' => [
102
102
'* * * * * /bin/php /var/www/magento/bin/magento cron:run ' ,
103
103
'* * * * * /bin/php /var/www/magento/bin/magento setup:cron:run ' ,
@@ -165,17 +165,17 @@ public function removeTasksDataProvider()
165
165
return [
166
166
[
167
167
'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
169
169
. '* * * * * /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 ,
171
171
'contentAfter ' => '* * * * * /bin/php /var/www/cron.php ' . PHP_EOL
172
172
],
173
173
[
174
174
'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
176
176
. '* * * * * /bin/php /var/www/magento/bin/magento cron:run ' . PHP_EOL
177
177
. '* * * * * /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 ,
179
179
'contentAfter ' => '* * * * * /bin/php /var/www/cron.php ' . PHP_EOL
180
180
],
181
181
[
@@ -198,14 +198,12 @@ public function testSaveTasksWithEmptyTasksList()
198
198
{
199
199
$ baseDirMock = $ this ->getMockBuilder (ReadInterface::class)
200
200
->getMockForAbstractClass ();
201
- $ baseDirMock ->expects ($ this ->once ())
202
- ->method ('getAbsolutePath ' )
203
- ->willReturn ('/var/www/magento2/ ' );
201
+ $ baseDirMock ->expects ($ this ->never ())
202
+ ->method ('getAbsolutePath ' );
204
203
$ logDirMock = $ this ->getMockBuilder (ReadInterface::class)
205
204
->getMockForAbstractClass ();
206
- $ logDirMock ->expects ($ this ->once ())
207
- ->method ('getAbsolutePath ' )
208
- ->willReturn ('/var/www/magento2/var/log/ ' );
205
+ $ logDirMock ->expects ($ this ->never ())
206
+ ->method ('getAbsolutePath ' );
209
207
210
208
$ this ->filesystemMock ->expects ($ this ->any ())
211
209
->method ('getDirectoryRead ' )
@@ -292,9 +290,9 @@ public function testSaveTasks($tasks, $content, $contentToSave)
292
290
public function saveTasksDataProvider ()
293
291
{
294
292
$ content = '* * * * * /bin/php /var/www/cron.php ' . PHP_EOL
295
- . CrontabManagerInterface::TASKS_BLOCK_START . PHP_EOL
293
+ . CrontabManagerInterface::TASKS_BLOCK_START . ' ' . md5 ( BP ) . PHP_EOL
296
294
. '* * * * * /bin/php /var/www/magento/bin/magento cron:run ' . PHP_EOL
297
- . CrontabManagerInterface::TASKS_BLOCK_END . PHP_EOL ;
295
+ . CrontabManagerInterface::TASKS_BLOCK_END . ' ' . md5 ( BP ) . PHP_EOL ;
298
296
299
297
return [
300
298
[
@@ -303,41 +301,41 @@ public function saveTasksDataProvider()
303
301
],
304
302
'content ' => $ content ,
305
303
'contentToSave ' => '* * * * * /bin/php /var/www/cron.php ' . PHP_EOL
306
- . CrontabManagerInterface::TASKS_BLOCK_START . PHP_EOL
304
+ . CrontabManagerInterface::TASKS_BLOCK_START . ' ' . md5 ( BP ) . PHP_EOL
307
305
. '* * * * * ' . PHP_BINARY . ' run.php ' . PHP_EOL
308
- . CrontabManagerInterface::TASKS_BLOCK_END . PHP_EOL ,
306
+ . CrontabManagerInterface::TASKS_BLOCK_END . ' ' . md5 ( BP ) . PHP_EOL ,
309
307
],
310
308
[
311
309
'tasks ' => [
312
310
['expression ' => '1 2 3 4 5 ' , 'command ' => 'run.php ' ]
313
311
],
314
312
'content ' => $ content ,
315
313
'contentToSave ' => '* * * * * /bin/php /var/www/cron.php ' . PHP_EOL
316
- . CrontabManagerInterface::TASKS_BLOCK_START . PHP_EOL
314
+ . CrontabManagerInterface::TASKS_BLOCK_START . ' ' . md5 ( BP ) . PHP_EOL
317
315
. '1 2 3 4 5 ' . PHP_BINARY . ' run.php ' . PHP_EOL
318
- . CrontabManagerInterface::TASKS_BLOCK_END . PHP_EOL ,
316
+ . CrontabManagerInterface::TASKS_BLOCK_END . ' ' . md5 ( BP ) . PHP_EOL ,
319
317
],
320
318
[
321
319
'tasks ' => [
322
320
['command ' => '{magentoRoot}run.php >> {magentoLog}cron.log ' ]
323
321
],
324
322
'content ' => $ content ,
325
323
'contentToSave ' => '* * * * * /bin/php /var/www/cron.php ' . PHP_EOL
326
- . CrontabManagerInterface::TASKS_BLOCK_START . PHP_EOL
324
+ . CrontabManagerInterface::TASKS_BLOCK_START . ' ' . md5 ( BP ) . PHP_EOL
327
325
. '* * * * * ' . PHP_BINARY . ' /var/www/magento2/run.php >> '
328
326
. ' /var/www/magento2/var/log/cron.log ' . PHP_EOL
329
- . CrontabManagerInterface::TASKS_BLOCK_END . PHP_EOL ,
327
+ . CrontabManagerInterface::TASKS_BLOCK_END . ' ' . md5 ( BP ) . PHP_EOL ,
330
328
],
331
329
[
332
330
'tasks ' => [
333
331
['command ' => '{magentoRoot}run.php % cron:run | grep -v "Ran \'jobs \' by schedule" ' ]
334
332
],
335
333
'content ' => $ content ,
336
334
'contentToSave ' => '* * * * * /bin/php /var/www/cron.php ' . PHP_EOL
337
- . CrontabManagerInterface::TASKS_BLOCK_START . PHP_EOL
335
+ . CrontabManagerInterface::TASKS_BLOCK_START . ' ' . md5 ( BP ) . PHP_EOL
338
336
. '* * * * * ' . PHP_BINARY . ' /var/www/magento2/run.php '
339
337
. ' %% cron:run | grep -v \"Ran \'jobs \' by schedule\" ' . PHP_EOL
340
- . CrontabManagerInterface::TASKS_BLOCK_END . PHP_EOL ,
338
+ . CrontabManagerInterface::TASKS_BLOCK_END . ' ' . md5 ( BP ) . PHP_EOL ,
341
339
],
342
340
];
343
341
}
0 commit comments