@@ -600,74 +600,74 @@ public function testDispatchNotGenerate()
600
600
public function testDispatchGenerate ()
601
601
{
602
602
$ jobConfig = [
603
- 'test_group ' => [
604
- 'default ' => [
605
- 'test_job1 ' => [
606
- 'instance ' => 'CronJob ' ,
607
- 'method ' => 'execute ' ,
608
- ],
603
+ 'default ' => [
604
+ 'test_job1 ' => [
605
+ 'instance ' => 'CronJob ' ,
606
+ 'method ' => 'execute ' ,
609
607
],
610
608
],
611
609
];
612
610
613
- $ this ->_config ->expects ($ this ->at (0 ))->method ('getJobs ' )->will ($ this ->returnValue ($ jobConfig ));
614
611
$ jobs = [
615
- 'test_group ' => [
616
- 'default ' => [
617
- 'job1 ' => ['config_path ' => 'test/path ' ],
618
- 'job2 ' => ['schedule ' => '' ],
619
- 'job3 ' => ['schedule ' => '* * * * * ' ],
620
- ],
612
+ 'default ' => [
613
+ 'job1 ' => ['config_path ' => 'test/path ' ],
614
+ 'job2 ' => ['schedule ' => '' ],
615
+ 'job3 ' => ['schedule ' => '* * * * * ' ],
621
616
],
622
617
];
623
- $ this ->_config ->expects ($ this ->at (1 ))->method ('getJobs ' )->will ($ this ->returnValue ($ jobs ));
624
- $ this ->_request ->expects ($ this ->any ())->method ('getParam ' )->will ($ this ->returnValue ('test_group ' ));
618
+ $ this ->_config ->expects ($ this ->at (0 ))->method ('getJobs ' )->willReturn ($ jobConfig );
619
+ $ this ->_config ->expects ($ this ->at (1 ))->method ('getJobs ' )->willReturn ($ jobs );
620
+ $ this ->_request ->expects ($ this ->any ())->method ('getParam ' )->willReturn ('default ' );
625
621
$ this ->_cache ->expects (
626
622
$ this ->at (0 )
627
623
)->method (
628
624
'load '
629
625
)->with (
630
- $ this ->equalTo (ProcessCronQueueObserver::CACHE_KEY_LAST_SCHEDULE_GENERATE_AT . 'test_group ' )
631
- )->will (
632
- $ this ->returnValue (time () - 10000000 )
633
- );
626
+ $ this ->equalTo (ProcessCronQueueObserver::CACHE_KEY_LAST_SCHEDULE_GENERATE_AT . 'default ' )
627
+ )->willReturn (time () - 10000000 );
634
628
$ this ->_cache ->expects (
635
629
$ this ->at (2 )
636
630
)->method (
637
631
'load '
638
632
)->with (
639
- $ this ->equalTo (ProcessCronQueueObserver::CACHE_KEY_LAST_HISTORY_CLEANUP_AT . 'test_group ' )
640
- )->will (
641
- $ this ->returnValue (time () + 10000000 )
642
- );
633
+ $ this ->equalTo (ProcessCronQueueObserver::CACHE_KEY_LAST_HISTORY_CLEANUP_AT . 'default ' )
634
+ )->willReturn (time () + 10000000 );
643
635
644
- $ this ->_scopeConfig ->expects ($ this ->at (0 ))->method ('getValue ' )->will ($ this ->returnValue (0 ));
636
+ $ this ->_scopeConfig ->expects ($ this ->any ())->method ('getValue ' )->willReturnMap (
637
+ [
638
+ [
639
+ 'system/cron/default/schedule_generate_every ' ,
640
+ \Magento \Store \Model \ScopeInterface::SCOPE_STORE ,
641
+ null ,
642
+ 0
643
+ ],
644
+ [
645
+ 'system/cron/default/schedule_ahead_for ' ,
646
+ \Magento \Store \Model \ScopeInterface::SCOPE_STORE ,
647
+ null ,
648
+ 2
649
+ ]
650
+ ]
651
+ );
645
652
646
- $ scheduleMethods = ['getJobCode ' , 'getScheduledAt ' , 'trySchedule ' , 'unsScheduleId ' , 'save ' , '__wakeup ' ];
647
653
$ schedule = $ this ->getMockBuilder (
648
654
\Magento \Cron \Model \Schedule::class
649
655
)->setMethods (
650
- $ scheduleMethods
656
+ [ ' getJobCode ' , ' save ' , ' getScheduledAt ' , ' unsScheduleId ' , ' trySchedule ' , ' getCollection ' ]
651
657
)->disableOriginalConstructor ()->getMock ();
652
- $ schedule ->expects ($ this ->any ())->method ('getJobCode ' )->will ($ this ->returnValue ('job_code1 ' ));
653
- $ schedule ->expects ($ this ->once ())->method ('getScheduledAt ' )->will ($ this ->returnValue ('* * * * * ' ));
654
- $ schedule ->expects ($ this ->any ())->method ('unsScheduleId ' )->will ($ this ->returnSelf ());
655
- $ schedule ->expects ($ this ->any ())->method ('trySchedule ' )->will ($ this ->returnSelf ());
658
+ $ schedule ->expects ($ this ->any ())->method ('getJobCode ' )->willReturn ('job_code1 ' );
659
+ $ schedule ->expects ($ this ->once ())->method ('getScheduledAt ' )->willReturn ('* * * * * ' );
660
+ $ schedule ->expects ($ this ->any ())->method ('unsScheduleId ' )->willReturnSelf ();
661
+ $ schedule ->expects ($ this ->any ())->method ('trySchedule ' )->willReturnSelf ();
662
+ $ schedule ->expects ($ this ->any ())->method ('getCollection ' )->willReturn ($ this ->_collection );
663
+ $ schedule ->expects ($ this ->exactly (1 ))->method ('save ' )->willReturnSelf ();
656
664
657
665
$ this ->_collection ->addItem (new \Magento \Framework \DataObject ());
658
666
$ this ->_collection ->addItem ($ schedule );
659
667
660
668
$ this ->_cache ->expects ($ this ->any ())->method ('save ' );
661
669
662
- $ scheduleMock = $ this ->getMockBuilder (
663
- \Magento \Cron \Model \Schedule::class
664
- )->disableOriginalConstructor ()->setMethods (
665
- ['getCollection ' , '__wakeup ' ]
666
- )->getMock ();
667
- $ scheduleMock ->expects ($ this ->any ())->method ('getCollection ' )->will ($ this ->returnValue ($ this ->_collection ));
668
- $ this ->_scheduleFactory ->expects ($ this ->any ())->method ('create ' )->will ($ this ->returnValue ($ scheduleMock ));
669
-
670
- $ this ->_scheduleFactory ->expects ($ this ->any ())->method ('create ' )->will ($ this ->returnValue ($ schedule ));
670
+ $ this ->_scheduleFactory ->expects ($ this ->any ())->method ('create ' )->willReturn ($ schedule );
671
671
672
672
$ this ->_observer ->execute ($ this ->observer );
673
673
}
0 commit comments