From cc0da8b7a7bc075794507f5822bcd2149edb59b3 Mon Sep 17 00:00:00 2001 From: atymic Date: Wed, 20 Mar 2024 12:36:47 +1100 Subject: [PATCH] fix: tests, gh actions --- .github/workflows/php.yml | 16 ++++------- .gitignore | 1 + composer.json | 8 +++--- src/Models/ScheduledNotification.php | 2 +- src/ScheduledNotification.php | 43 +++++++++++++++------------- tests/SendCommandTest.php | 2 +- 6 files changed, 36 insertions(+), 36 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index e6490e2..cc0aca6 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -11,16 +11,12 @@ jobs: strategy: max-parallel: 15 matrix: - laravel-version: ['11.0', ^8.0, ^9.0, ^10.0] - php-versions: ['8.0', '8.1', '8.2'] + laravel-version: [^10.0, ^11.0] + php-versions: ['8.1', '8.2', '8.3'] exclude: - - laravel-version: ^8.0 - php-version: 8.2 - - laravel-version: ^10.0 - php-version: 8.0 - - laravel-version: '11.0' - php-versions: '8.0' - - laravel-version: '11.0' + - laravel-version: '^10.0' + php-versions: '8.1' + - laravel-version: '^11.0' php-versions: '8.1' name: PHP ${{ matrix.php-versions }} on ${{ matrix.laravel-version }} @@ -38,7 +34,7 @@ jobs: - name: Install dependencies run: | - composer require --no-update --no-interaction "illuminate/support:${{ matrix.laravel-version }}" satooshi/php-coveralls + composer require --no-update --no-interaction "illuminate/support:${{ matrix.laravel-version }}" php-coveralls/php-coveralls composer update --no-interaction --prefer-dist --no-suggest - name: Lint composer.json diff --git a/.gitignore b/.gitignore index e98468b..aecf24a 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ /composer.lock /tests/temp .phpunit.result.cache +.phpunit.cache diff --git a/composer.json b/composer.json index c370f9b..ff7291c 100644 --- a/composer.json +++ b/composer.json @@ -16,12 +16,12 @@ } ], "require": { - "php": "^8.0 | ^8.1", - "illuminate/support": "^8.0 | ^9.0 | ^10.0 | ^11.0" + "php": "^8.1", + "illuminate/support": "^10.0 | ^11.0" }, "require-dev": { - "orchestra/testbench": "^7.0 |^8.0 | ^9.0", - "phpunit/phpunit": "^9.0 | ^10.0", + "orchestra/testbench": "^8.0 | ^9.0", + "phpunit/phpunit": "^10.0 | ^11.0", "timacdonald/log-fake": "^2" }, "autoload": { diff --git a/src/Models/ScheduledNotification.php b/src/Models/ScheduledNotification.php index f4e5158..903e337 100644 --- a/src/Models/ScheduledNotification.php +++ b/src/Models/ScheduledNotification.php @@ -56,7 +56,7 @@ public function send(): void $notifiable = $this->serializer->unserialize($this->target); $notification = $this->serializer->unserialize($this->notification); } catch (\Exception $exception) { - throw new UnserializeFailedException('Cannot Send. Unserialize Failed.', 2, $exception); + throw new UnserializeFailedException(sprintf('Cannot Send. Unserialize Failed. (%s)', $exception->getMessage()), 2, $exception); } if ($this->shouldInterrupt($notification, $notifiable)) { diff --git a/src/ScheduledNotification.php b/src/ScheduledNotification.php index 1b6e75d..77f2935 100644 --- a/src/ScheduledNotification.php +++ b/src/ScheduledNotification.php @@ -26,10 +26,11 @@ public function __construct(ScheduledNotificationModel $scheduleNotificationMode } /** - * @param object $notifiable - * @param Notification $notification - * @param DateTimeInterface $sendAt - * @param array $meta + * @param object $notifiable + * @param Notification $notification + * @param DateTimeInterface $sendAt + * @param array $meta + * * @return self * * @throws SchedulingFailedException @@ -56,11 +57,11 @@ public static function create( $targetType = $notifiable instanceof AnonymousNotifiable ? AnonymousNotifiable::class : get_class($notifiable); return new self($modelClass::create([ - 'target_id' => $targetId, - 'target_type' => $targetType, + 'target_id' => $targetId, + 'target_type' => $targetType, 'notification_type' => get_class($notification), - 'target' => $serializer->serialize($notifiable), - 'notification' => $serializer->serialize($notification), + 'target' => $serializer->serialize($notifiable), + 'notification' => $serializer->serialize($notification), 'send_at' => $sendAt, 'meta' => $meta, ])); @@ -157,7 +158,7 @@ public static function cancelAnonymousNotificationsByChannel(string $channel, st ->get() ->map(function (ScheduledNotificationModel $model) use ($serializer) { return [ - 'id' => $model->id, + 'id' => $model->id, 'routes' => $serializer->unserialize($model->target)->routes, ]; }) @@ -171,20 +172,22 @@ public static function cancelAnonymousNotificationsByChannel(string $channel, st } /** - * @param DateTimeInterface|string $sendAt - * @param bool $force + * @param DateTimeInterface|string $sendAt + * @param bool $force + * * @return self * * @throws NotificationAlreadySentException * @throws NotificationCancelledException */ - public function reschedule( $sendAt, $force = false): self + public function reschedule($sendAt, $force = false): self { return new self($this->scheduleNotificationModel->reschedule($sendAt, $force)); } /** - * @param DateTimeInterface|string $sendAt + * @param DateTimeInterface|string $sendAt + * * @return self */ public function scheduleAgainAt($sendAt): self @@ -252,38 +255,38 @@ public function getTargetId() return $this->scheduleNotificationModel->target_id; } - public function getSentAt(): ?CarbonImmutable + public function getSentAt(): Carbon|CarbonImmutable|null { return $this->scheduleNotificationModel->sent_at; } - public function getCancelledAt(): ?CarbonImmutable + public function getCancelledAt(): Carbon|CarbonImmutable|null { return $this->scheduleNotificationModel->cancelled_at; } - public function getRescheduledAt(): ?CarbonImmutable + public function getRescheduledAt(): Carbon|CarbonImmutable|null { return $this->scheduleNotificationModel->rescheduled_at; } - public function getSendAt(): CarbonImmutable + public function getSendAt(): Carbon|CarbonImmutable { return $this->scheduleNotificationModel->send_at; } - public function getCreatedAt(): CarbonImmutable + public function getCreatedAt(): Carbon|CarbonImmutable { return $this->scheduleNotificationModel->created_at; } - public function getUpdatedAt(): CarbonImmutable + public function getUpdatedAt(): Carbon|CarbonImmutable { return $this->scheduleNotificationModel->updated_at; } /** - * @param null $key + * @param null $key */ public function getMeta($key = null) { diff --git a/tests/SendCommandTest.php b/tests/SendCommandTest.php index e52d8a4..0802bee 100644 --- a/tests/SendCommandTest.php +++ b/tests/SendCommandTest.php @@ -75,7 +75,7 @@ public function testItCatchesFailedScheduledNotifications() ->assertExitCode(0); Log::assertLogged(fn (LogEntry $log) => $log->level === 'error' - && $log->message === 'unserialize(): Error at offset 0 of 10 bytes' + && $log->message === 'Cannot Send. Unserialize Failed. (unserialize(): Error at offset 0 of 10 bytes)' ); } }