@@ -530,23 +530,19 @@ public function testDispatchGenerate()
530
530
{
531
531
$ jobConfig = [
532
532
'test_group ' => [
533
- 'default ' => [
534
- 'test_job1 ' => [
535
- 'instance ' => 'CronJob ' ,
536
- 'method ' => 'execute ' ,
537
- ],
533
+ 'test_job1 ' => [
534
+ 'instance ' => 'CronJob ' ,
535
+ 'method ' => 'execute ' ,
538
536
],
539
537
],
540
538
];
541
539
542
540
$ this ->_config ->expects ($ this ->at (0 ))->method ('getJobs ' )->will ($ this ->returnValue ($ jobConfig ));
543
541
$ jobs = [
544
542
'test_group ' => [
545
- 'default ' => [
546
- 'job1 ' => ['config_path ' => 'test/path ' ],
547
- 'job2 ' => ['schedule ' => '' ],
548
- 'job3 ' => ['schedule ' => '* * * * * ' ],
549
- ],
543
+ 'job1 ' => ['config_path ' => 'test/path ' ],
544
+ 'job2 ' => ['schedule ' => '' ],
545
+ 'job3 ' => ['schedule ' => '* * * * * ' ],
550
546
],
551
547
];
552
548
$ this ->_config ->expects ($ this ->at (1 ))->method ('getJobs ' )->will ($ this ->returnValue ($ jobs ));
@@ -570,32 +566,40 @@ public function testDispatchGenerate()
570
566
$ this ->returnValue (time () + 10000000 )
571
567
);
572
568
573
- $ this ->_scopeConfig ->expects ($ this ->at (0 ))->method ('getValue ' )->will ($ this ->returnValue (0 ));
569
+ $ this ->_scopeConfig ->expects ($ this ->any ())->method ('getValue ' )->willReturnMap (
570
+ [
571
+ [
572
+ 'system/cron/test_group/schedule_generate_every ' ,
573
+ \Magento \Store \Model \ScopeInterface::SCOPE_STORE ,
574
+ null ,
575
+ 0
576
+ ],
577
+ [
578
+ 'system/cron/test_group/schedule_ahead_for ' ,
579
+ \Magento \Store \Model \ScopeInterface::SCOPE_STORE ,
580
+ null ,
581
+ 2
582
+ ]
583
+ ]
584
+ );
574
585
575
- $ scheduleMethods = ['getJobCode ' , 'getScheduledAt ' , 'trySchedule ' , 'unsScheduleId ' , 'save ' , '__wakeup ' ];
576
586
$ schedule = $ this ->getMockBuilder (
577
587
'Magento\Cron\Model\Schedule '
578
588
)->setMethods (
579
- $ scheduleMethods
589
+ [ ' getJobCode ' , ' getScheduledAt ' , ' trySchedule ' , ' unsScheduleId ' , ' save ' , ' __wakeup ' , ' getCollection ' ]
580
590
)->disableOriginalConstructor ()->getMock ();
581
591
$ schedule ->expects ($ this ->any ())->method ('getJobCode ' )->will ($ this ->returnValue ('job_code1 ' ));
582
592
$ schedule ->expects ($ this ->once ())->method ('getScheduledAt ' )->will ($ this ->returnValue ('* * * * * ' ));
583
593
$ schedule ->expects ($ this ->any ())->method ('unsScheduleId ' )->will ($ this ->returnSelf ());
584
594
$ schedule ->expects ($ this ->any ())->method ('trySchedule ' )->will ($ this ->returnSelf ());
595
+ $ schedule ->expects ($ this ->any ())->method ('getCollection ' )->willReturn ($ this ->_collection );
596
+ $ schedule ->expects ($ this ->atLeastOnce ())->method ('save ' )->willReturnSelf ();
585
597
586
598
$ this ->_collection ->addItem (new \Magento \Framework \DataObject ());
587
599
$ this ->_collection ->addItem ($ schedule );
588
600
589
601
$ this ->_cache ->expects ($ this ->any ())->method ('save ' );
590
602
591
- $ scheduleMock = $ this ->getMockBuilder (
592
- 'Magento\Cron\Model\Schedule '
593
- )->disableOriginalConstructor ()->setMethods (
594
- ['getCollection ' , '__wakeup ' ]
595
- )->getMock ();
596
- $ scheduleMock ->expects ($ this ->any ())->method ('getCollection ' )->will ($ this ->returnValue ($ this ->_collection ));
597
- $ this ->_scheduleFactory ->expects ($ this ->any ())->method ('create ' )->will ($ this ->returnValue ($ scheduleMock ));
598
-
599
603
$ this ->_scheduleFactory ->expects ($ this ->any ())->method ('create ' )->will ($ this ->returnValue ($ schedule ));
600
604
601
605
$ this ->_observer ->execute ($ this ->observer );
0 commit comments