Skip to content

Commit

Permalink
fixed bug in montly executio
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippGrashoff committed Oct 2, 2022
1 parent 67c41c5 commit 0bcb6a3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
18 changes: 10 additions & 8 deletions src/CronExecutor.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ class CronExecutor extends Model
//format: path => namespace, e.g. 'src/data/cron' => 'YourProject\\Data\\Cron',
public array $cronFilesPath = [];

public $currentDate;
public $currentWeekday;
public $currentDay;
public $currentTime;
public $currentMinute;
//Format MM-DD
public string $currentDate;
public int $currentWeekday;
public int $currentDay;
//Format HH:MM
public string $currentTime;
public int $currentMinute;


protected function init(): void
Expand Down Expand Up @@ -202,10 +204,10 @@ public function run(\DateTime $dateTime = null): void
}

$this->currentDate = $dateTime->format('m-d');
$this->currentWeekday = $dateTime->format('N');
$this->currentDay = $dateTime->format('m');
$this->currentWeekday = (int)$dateTime->format('N');
$this->currentDay = (int)$dateTime->format('d');
$this->currentTime = $dateTime->format('H:i');
$this->currentMinute = $dateTime->format('i');
$this->currentMinute = (int)$dateTime->format('i');

//execute yearly first, minutely last!
foreach ($this->intervalSettings as $interval => $type) {
Expand Down
16 changes: 9 additions & 7 deletions tests/CronExecutorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@

namespace cronforatk\tests;

use Atk4\Data\Exception;
use cronforatk\tests\testclasses\SomeCronJobWithExceptionInExecute;
use traitsforatkdata\TestCase;
use cronforatk\CronExecutor;
use Atk4\Data\Persistence;
use cronforatk\CronExecutor;
use cronforatk\tests\testclasses\SomeCronJob;
use cronforatk\tests\testclasses\SomeCronJobWithExceptionInExecute;
use traitsforatkdata\TestCase;

class CronExecutorTest extends TestCase
{
Expand Down Expand Up @@ -516,7 +515,8 @@ public function testNonExistantFolderIsSkipped()
self::assertEquals(3, count($cm->getAvailableCrons()));
}

public function testExceptionInExecuteDoesNotStopExecutionOfOthers() {
public function testExceptionInExecuteDoesNotStopExecutionOfOthers()
{
$persistence = $this->getSqliteTestPersistence();
$testTime = new \DateTime('2020-05-05');
$testTime->setTime(3, 3);
Expand Down Expand Up @@ -559,7 +559,8 @@ public function testExceptionInExecuteDoesNotStopExecutionOfOthers() {
);
}

public function testDurationIsMonitored() {
public function testDurationIsMonitored()
{
$persistence = $this->getSqliteTestPersistence();
$testTime = new \DateTime('2020-05-05');
$testTime->setTime(3, 3);
Expand All @@ -585,7 +586,8 @@ public function testDurationIsMonitored() {
);
}

public function testExceptionExecuteCronThisNotLoaded() {
public function testExceptionExecuteCronThisNotLoaded()
{
$persitence = $this->getSqliteTestPersistence();
$cr = new CronExecutor($persitence);
self::assertFalse(
Expand Down

0 comments on commit 0bcb6a3

Please sign in to comment.