Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into fix/l11-errs
Browse files Browse the repository at this point in the history
  • Loading branch information
atymic committed Mar 20, 2024
2 parents 062ba3b + 08ad48e commit 15bb348
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 71 deletions.
64 changes: 38 additions & 26 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,51 @@
name: PHP

on: [push, pull_request]
on:
- push
- pull_request

jobs:
run:
runs-on: ubuntu-latest

strategy:
max-parallel: 15
matrix:
laravel-version: ['^6.0', '^7.0', '^8.0', '^9.0']
php-versions: ['7.3', '7.4', '8.0']
laravel-version: ['11.0', ^8.0, ^9.0, ^10.0]
php-versions: ['8.0', '8.1', '8.2']
exclude:
- laravel-version: ^6.0
php-version: 8.0
- laravel-version: ^7.0
- laravel-version: ^8.0
php-version: 8.2
- laravel-version: ^10.0
php-version: 8.0
- laravel-version: ^9.0
php-version: 7.4
- laravel-version: '11.0'
php-versions: '8.0'
- laravel-version: '11.0'
php-versions: '8.1'

name: PHP ${{ matrix.php-versions }} on ${{ matrix.laravel-version }}

steps:
- name: Checkout
uses: actions/checkout@master
- name: Setup PHP
uses: shivammathur/setup-php@master
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, xdebug
coverage: xdebug
- name: Install dependencies
run: |
composer require --no-update --no-interaction "illuminate/support:${{ matrix.laravel-version }}" satooshi/php-coveralls
composer update --no-interaction --prefer-dist --no-suggest
- name: Lint composer.json
run: composer validate
- name: Run Tests
run: composer test:ci
- name: Upload Coverage
run: bash <(curl -s https://codecov.io/bash)
- name: Checkout
uses: actions/checkout@master

- name: Setup PHP
uses: shivammathur/setup-php@master
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, xdebug
coverage: xdebug

- name: Install dependencies
run: |
composer require --no-update --no-interaction "illuminate/support:${{ matrix.laravel-version }}" satooshi/php-coveralls
composer update --no-interaction --prefer-dist --no-suggest
- name: Lint composer.json
run: composer validate

- name: Run Tests
run: composer test:ci

- name: Upload Coverage
run: bash <(curl -s https://codecov.io/bash)
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
}
],
"require": {
"php": ">=7.4",
"illuminate/support": "~6.0 || ~7.0 || ~8.0 || ^9.0"
"php": "^8.0 | ^8.1",
"illuminate/support": "^8.0 | ^9.0 | ^10.0 | ^11.0"
},
"require-dev": {
"orchestra/testbench": "~4.0|| ~5.0 || ~6.0 || ^7.0",
"phpunit/phpunit": "^9.0",
"timacdonald/log-fake": "^1.7"
"orchestra/testbench": "^7.0 |^8.0 | ^9.0",
"phpunit/phpunit": "^9.0 | ^10.0",
"timacdonald/log-fake": "^2"
},
"autoload": {
"psr-4": {
Expand Down
20 changes: 6 additions & 14 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="package">
<directory suffix="Test.php">tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>
<php>
<env name="APP_ENV" value="testing"/>
<env name="CACHE_DRIVER" value="array"/>
Expand Down
13 changes: 5 additions & 8 deletions src/Models/ScheduledNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,8 @@ public function send(): void
}

/**
* @param object|null $notification
* @param object|null $notifiable
*
* @param object|null $notification
* @param object|null $notifiable
* @return bool
*/
public function shouldInterrupt(?object $notification = null, ?object $notifiable = null): bool
Expand Down Expand Up @@ -113,9 +112,8 @@ public function cancel(): void
}

/**
* @param \DateTimeInterface|string $sendAt
* @param bool $force
*
* @param \DateTimeInterface|string $sendAt
* @param bool $force
* @return self
*
* @throws NotificationAlreadySentException
Expand Down Expand Up @@ -147,8 +145,7 @@ public function reschedule($sendAt, $force = false): self
}

/**
* @param \DateTimeInterface|string $sendAt
*
* @param \DateTimeInterface|string $sendAt
* @return self
*/
public function scheduleAgainAt($sendAt): self
Expand Down
31 changes: 14 additions & 17 deletions src/ScheduledNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@ 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 @@ -57,11 +56,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 @@ -103,7 +102,7 @@ public static function findByTarget(object $notifiable): ?Collection
return self::collection($models);
}

public static function findByMeta($key, $value): ?Collection
public static function findByMeta($key, $value): Collection
{
$modelClass = self::getScheduledNotificationModelClass();

Expand Down Expand Up @@ -158,7 +157,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 @@ -172,9 +171,8 @@ 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
Expand All @@ -186,8 +184,7 @@ public function reschedule( $sendAt, $force = false): self
}

/**
* @param DateTimeInterface|string $sendAt
*
* @param DateTimeInterface|string $sendAt
* @return self
*/
public function scheduleAgainAt($sendAt): self
Expand Down Expand Up @@ -286,7 +283,7 @@ public function getUpdatedAt(): CarbonImmutable
}

/**
* @param null $key
* @param null $key
*/
public function getMeta($key = null)
{
Expand Down
5 changes: 4 additions & 1 deletion tests/SendCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Thomasjohnkane\Snooze\ScheduledNotification;
use Thomasjohnkane\Snooze\Tests\Models\User;
use Thomasjohnkane\Snooze\Tests\Notifications\TestNotification;
use TiMacDonald\Log\LogEntry;
use TiMacDonald\Log\LogFake;

class SendCommandTest extends TestCase
Expand Down Expand Up @@ -73,6 +74,8 @@ public function testItCatchesFailedScheduledNotifications()
->expectsOutput('Starting Sending Scheduled Notifications')
->assertExitCode(0);

Log::assertLoggedMessage('error', 'unserialize(): Error at offset 0 of 10 bytes');
Log::assertLogged(fn (LogEntry $log) => $log->level === 'error'
&& $log->message === 'unserialize(): Error at offset 0 of 10 bytes'
);
}
}

0 comments on commit 15bb348

Please sign in to comment.