Skip to content

Commit cd6d480

Browse files
author
Anton Evers
committed
Make sure that all current unit tests are functioning again
Some unit tests did not flag as failed even though the thing they were testing did not occur. I have rewritten these tests to be more responsive when things go wrong. There is however a big step to be made to make these tests more readable and more consistent.
1 parent 0518a6c commit cd6d480

File tree

2 files changed

+242
-382
lines changed

2 files changed

+242
-382
lines changed

app/code/Magento/Cron/Observer/ProcessCronQueueObserver.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ class ProcessCronQueueObserver implements ObserverInterface
121121
*/
122122
protected $invalid = [];
123123

124+
/**
125+
* @var array
126+
*/
127+
protected $jobs;
128+
124129
/**
125130
* @param \Magento\Framework\ObjectManagerInterface $objectManager
126131
* @param \Magento\Cron\Model\ScheduleFactory $scheduleFactory
@@ -206,6 +211,7 @@ public function execute(\Magento\Framework\Event\Observer $observer)
206211
continue;
207212
}
208213

214+
/** @var \Magento\Cron\Model\Schedule $schedule */
209215
foreach ($pendingJobs as $schedule) {
210216
$jobConfig = isset($jobsRoot[$schedule->getJobCode()]) ? $jobsRoot[$schedule->getJobCode()] : null;
211217
if (!$jobConfig) {
@@ -342,7 +348,7 @@ public function generate($groupId)
342348
/**
343349
* generate global crontab jobs
344350
*/
345-
$jobs = $this->config->getJobs();
351+
$jobs = $this->getJobs();
346352
$this->invalid = [];
347353
$this->generateJobs($jobs[$groupId], $exists, $groupId);
348354
$this->cleanupScheduleMismatches();
@@ -539,7 +545,7 @@ public function getScheduleTimeInterval($groupId)
539545
*/
540546
public function cleanupDisabledJobs($groupId)
541547
{
542-
$jobs = $this->config->getJobs();
548+
$jobs = $this->getJobs();
543549
foreach ($jobs[$groupId] as $jobCode => $jobConfig) {
544550
if (!$this->getCronExpression($jobConfig)) {
545551
/** @var \Magento\Cron\Model\ResourceModel\Schedule $scheduleResource */
@@ -590,4 +596,15 @@ public function cleanupScheduleMismatches()
590596
}
591597
return $this;
592598
}
599+
600+
/**
601+
* @return array
602+
*/
603+
public function getJobs()
604+
{
605+
if (is_null($this->jobs)) {
606+
$this->jobs = $this->config->getJobs();
607+
}
608+
return $this->jobs;
609+
}
593610
}

0 commit comments

Comments
 (0)