Skip to content

Commit

Permalink
fix: tests, gh actions
Browse files Browse the repository at this point in the history
  • Loading branch information
atymic committed Mar 20, 2024
1 parent 15bb348 commit cc0da8b
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 36 deletions.
16 changes: 6 additions & 10 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
/composer.lock
/tests/temp
.phpunit.result.cache
.phpunit.cache
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion src/Models/ScheduledNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
43 changes: 23 additions & 20 deletions src/ScheduledNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
]));
Expand Down Expand Up @@ -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,
];
})
Expand All @@ -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
Expand Down Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion tests/SendCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)'
);
}
}

0 comments on commit cc0da8b

Please sign in to comment.