Skip to content

Commit

Permalink
Remove webmozart assert dependency (#192)
Browse files Browse the repository at this point in the history
  • Loading branch information
8ctopus authored Oct 21, 2024
1 parent 8c784d0 commit f37e405
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
}
],
"require": {
"php": "^7.2|^8.0",
"webmozart/assert": "^1.0"
"php": "^7.2|^8.0"
},
"require-dev": {
"phpstan/phpstan": "^1.0",
Expand Down
17 changes: 13 additions & 4 deletions tests/Cron/CronExpressionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,22 +339,31 @@ public function testRecognisesTimezonesAsPartOfDateTime(): void
$tzServer = new \DateTimeZone('Europe/London');

$dtCurrent = \DateTime::createFromFormat('!Y-m-d H:i:s', '2017-10-17 10:00:00', $tzServer);
Assert::isInstanceOf($dtCurrent, DateTime::class);
if (!$dtCurrent instanceof \DateTime) {
throw new InvalidArgumentException('invalid current date time');
}

$dtPrev = $cron->getPreviousRunDate($dtCurrent, 0, true, $tzCron);
$this->assertEquals('1508151600 : 2017-10-16T07:00:00-04:00 : America/New_York', $dtPrev->format('U \\: c \\: e'));

$dtCurrent = \DateTimeImmutable::createFromFormat('!Y-m-d H:i:s', '2017-10-17 10:00:00', $tzServer);
Assert::isInstanceOf($dtCurrent, \DateTimeImmutable::class);
if (!$dtCurrent instanceof \DateTimeImmutable) {
throw new InvalidArgumentException('invalid current date time immutable');
}
$dtPrev = $cron->getPreviousRunDate($dtCurrent, 0, true, $tzCron);
$this->assertEquals('1508151600 : 2017-10-16T07:00:00-04:00 : America/New_York', $dtPrev->format('U \\: c \\: e'));

$dtCurrent = \DateTimeImmutable::createFromFormat('!Y-m-d H:i:s', '2017-10-17 10:00:00', $tzServer);
Assert::isInstanceOf($dtCurrent, \DateTimeImmutable::class);
if (!$dtCurrent instanceof \DateTimeImmutable) {
throw new InvalidArgumentException('invalid current date time immutable');
}
$dtPrev = $cron->getPreviousRunDate($dtCurrent->format('c'), 0, true, $tzCron);
$this->assertEquals('1508151600 : 2017-10-16T07:00:00-04:00 : America/New_York', $dtPrev->format('U \\: c \\: e'));

$dtCurrent = \DateTimeImmutable::createFromFormat('!Y-m-d H:i:s', '2017-10-17 10:00:00', $tzServer);
Assert::isInstanceOf($dtCurrent, \DateTimeImmutable::class);
if (!$dtCurrent instanceof \DateTimeImmutable) {
throw new InvalidArgumentException('invalid current date time immutable');
}
$dtPrev = $cron->getPreviousRunDate($dtCurrent->format('\\@U'), 0, true, $tzCron);
$this->assertEquals('1508151600 : 2017-10-16T07:00:00-04:00 : America/New_York', $dtPrev->format('U \\: c \\: e'));
}
Expand Down

0 comments on commit f37e405

Please sign in to comment.