Skip to content

Commit

Permalink
fix(queue): "Cron\CronExpression::__construct(): Argument \#1 ($expre…
Browse files Browse the repository at this point in the history
…ssion) must be of type string, null given".
  • Loading branch information
LastDragon-ru committed Dec 25, 2021
1 parent cd3be87 commit d936445
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/queue/src/CronableRegistrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function register(string $cronable): void {
$timezone = $config->get(CronableConfig::Timezone);

// Enabled?
if (!$enabled) {
if (!$enabled || $cron === null) {
if ($this->isDue($cron)) {
$this->jobDisabled($cronable, $job, $config);
}
Expand Down
29 changes: 29 additions & 0 deletions packages/queue/src/CronableRegistratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,35 @@ public function getQueueConfig(): array {
$registrator->register($cronable::class);
}

/**
* @covers ::register
*/
public function testRegisterCronIsNull(): void {
$cronable = new class() implements Cronable {
/**
* @inheritDoc
*/
public function getQueueConfig(): array {
return [];
}
};

$this->override(Schedule::class, static function (MockInterface $mock): void {
$mock
->shouldReceive('call')
->never();
});

$this->setQueueableConfig($cronable, [
CronableConfig::Cron => null,
CronableConfig::Enabled => true,
]);

$registrator = $this->app->make(CronableRegistrator::class);

$registrator->register($cronable::class);
}

/**
* @covers ::isDue
*
Expand Down

0 comments on commit d936445

Please sign in to comment.