From f37e405332cd1cca9d287f5044ae2a72c2f53239 Mon Sep 17 00:00:00 2001 From: 8ctopus Date: Mon, 21 Oct 2024 16:57:55 +0400 Subject: [PATCH] Remove webmozart assert dependency (#192) --- composer.json | 3 +-- tests/Cron/CronExpressionTest.php | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index fdb46ee..3d98ced 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/tests/Cron/CronExpressionTest.php b/tests/Cron/CronExpressionTest.php index 1569a8e..e28f929 100644 --- a/tests/Cron/CronExpressionTest.php +++ b/tests/Cron/CronExpressionTest.php @@ -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')); }