Skip to content

Commit b97e4a8

Browse files
L11 compatibility (#54)
* Bump dependencies for Laravel 11 * Update GitHub Actions for Laravel 11 * Update for Laravel 11 * Fix styling * Install Pest 2 only * drop windows * Fix composer.json --------- Co-authored-by: Shift <[email protected]> Co-authored-by: peterfox <[email protected]>
1 parent 5316e5c commit b97e4a8

File tree

7 files changed

+63
-97
lines changed

7 files changed

+63
-97
lines changed

.github/workflows/run-tests.yml

Lines changed: 45 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,50 @@
11
name: run-tests
22

33
on:
4-
push:
5-
pull_request:
6-
branches: [main]
4+
push:
5+
pull_request:
6+
branches:
7+
- main
78

89
jobs:
9-
test:
10-
runs-on: ${{ matrix.os }}
11-
strategy:
12-
fail-fast: false
13-
matrix:
14-
os: [ubuntu-latest, windows-latest]
15-
php: [8.1, 8.0, 7.4]
16-
laravel: [9.*, 8.*, 7.*, 10.*]
17-
stability: [prefer-lowest, prefer-stable]
18-
include:
19-
- laravel: 10.*
20-
testbench: 8.*
21-
- laravel: 9.*
22-
testbench: 7.*
23-
- laravel: 8.*
24-
testbench: ^6.24.1
25-
- laravel: 7.*
26-
testbench: ^5.20.0
27-
exclude:
28-
- laravel: 10.*
29-
php: 8.0
30-
- laravel: 10.*
31-
php: 7.4
32-
- laravel: 9.*
33-
php: 7.4
34-
- laravel: 7.*
35-
php: 8.0
36-
- laravel: 7.*
37-
php: 8.1
38-
39-
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
40-
41-
steps:
42-
- name: Checkout code
43-
uses: actions/checkout@v4
44-
45-
- name: Setup PHP
46-
uses: shivammathur/setup-php@v2
47-
with:
48-
php-version: ${{ matrix.php }}
49-
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
50-
coverage: none
51-
52-
- name: Setup problem matchers
53-
run: |
54-
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
55-
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
56-
57-
- name: Install dependencies
58-
run: |
59-
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
60-
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
61-
62-
- name: Execute tests
63-
run: vendor/bin/phpunit
10+
test:
11+
runs-on: ${{ matrix.os }}
12+
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
os: [ubuntu-latest]
17+
php: [8.3, 8.2]
18+
laravel: ['11.*', '10.*']
19+
stability: [prefer-lowest, prefer-stable]
20+
include:
21+
- laravel: 10.*
22+
testbench: 8.*
23+
- laravel: 11.*
24+
testbench: 9.*
25+
26+
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
27+
28+
steps:
29+
- name: Checkout code
30+
uses: actions/checkout@v4
31+
32+
- name: Setup PHP
33+
uses: shivammathur/setup-php@v2
34+
with:
35+
php-version: ${{ matrix.php }}
36+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
37+
coverage: none
38+
39+
- name: Setup problem matchers
40+
run: |
41+
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
42+
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
43+
44+
- name: Install dependencies
45+
run: |
46+
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
47+
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
48+
49+
- name: Execute tests
50+
run: vendor/bin/phpunit

composer.json

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,15 @@
1717
}
1818
],
1919
"require": {
20-
"php": "^8.0|^7.4",
21-
"illuminate/contracts": "9.*|8.*|7.*|^10.0"
20+
"php": "^8.2",
21+
"illuminate/contracts": "11.*|10.*"
2222
},
2323
"require-dev": {
24-
"orchestra/testbench": "^7.0|^6.24.1|^v5.20.0|^8.0",
25-
"phpunit/phpunit": "^9.5.13|^8.3|^9.5.10",
26-
"nunomaduro/collision": "^6.0|^5.0",
27-
"nunomaduro/larastan": "^2.0|^1.0",
28-
"pestphp/pest": "^1.21",
29-
"pestphp/pest-plugin-laravel": "^1.1",
24+
"orchestra/testbench": "^8.0|^9.0",
25+
"nunomaduro/collision": "^8.0|^7.8|^6.0",
26+
"larastan/larastan": "^2.0",
27+
"pestphp/pest": "^2.34",
28+
"pestphp/pest-plugin-laravel": "^2.3",
3029
"phpstan/extension-installer": "^1.1",
3130
"phpstan/phpstan-deprecation-rules": "^1.0",
3231
"phpstan/phpstan-phpunit": "^1.0",

src/Channels/SubscriberMailChannel.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ class SubscriberMailChannel extends MailChannel
2525
*
2626
* @param mixed $notifiable
2727
* @param \Illuminate\Notifications\Notification $notification
28-
*
29-
* @return void
28+
* @return \Illuminate\Mail\SentMessage|null
3029
*/
3130
public function send($notifiable, Notification $notification)
3231
{
@@ -35,7 +34,7 @@ public function send($notifiable, Notification $notification)
3534
$notification instanceof CheckNotifiableSubscriptionStatus &&
3635
$notification->checkMailSubscriptionStatus() &&
3736
! $notifiable->mailSubscriptionStatus($notification)) {
38-
return;
37+
return null;
3938
}
4039

4140
if (method_exists($notification, 'toMail')) {
@@ -56,16 +55,16 @@ public function send($notifiable, Notification $notification)
5655

5756
if (! $notifiable->routeNotificationFor('mail', $notification) &&
5857
! $message instanceof Mailable) {
59-
return;
58+
return null;
6059
}
6160

6261
if ($message instanceof Mailable) {
6362
$message->send($this->mailer);
6463

65-
return;
64+
return null;
6665
}
6766

68-
$this->mailer->mailer($message->mailer ?? null)->send(
67+
return $this->mailer->mailer($message->mailer ?? null)->send(
6968
$this->buildView($message),
7069
array_merge($message->data(), $this->additionalMessageData($notification)),
7170
$this->messageBuilder($notifiable, $notification, $message)

src/Facades/Subscriber.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*
1313
* @method static void routes()
1414
* @method static string routeName()
15-
* @method static userModel(string $model = null)
15+
* @method static mixed userModel(string $model = null)
1616
* @method static void onCompletion(callable|string $handler)
1717
* @method static void onUnsubscribeFromMailingList(callable|string $handler)
1818
* @method static void onUnsubscribeFromAllMailingLists(callable|string $handler)

src/SubscribableApplicationServiceProvider.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ public function boot()
2222
$this->loadRoutes();
2323
}
2424

25-
\YlsIdeas\SubscribableNotifications\Facades\Subscriber::userModel($this->userModel());
25+
\YlsIdeas\SubscribableNotifications\Facades\Subscriber::userModel(
26+
$this->userModel()
27+
);
2628

2729
\YlsIdeas\SubscribableNotifications\Facades\Subscriber::onUnsubscribeFromMailingList(
2830
$this->onUnsubscribeFromMailingList()

src/Subscriber.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use Illuminate\Contracts\Foundation\Application;
66
use Illuminate\Http\Response;
77
use Illuminate\Support\Str;
8-
use InvalidArgumentException;
98

109
class Subscriber
1110
{
@@ -176,22 +175,15 @@ public function checkSubscriptionStatus($user, ?string $mailingList = null)
176175
return (bool) call_user_func($this->onCheckSubscriptionStatusForAllMailingLists, $user);
177176
}
178177

179-
/**
180-
* @param string|callable $handler
181-
* @return callable
182-
* @throws \Illuminate\Contracts\Container\BindingResolutionException
183-
*/
184-
protected function parseHandler($handler)
178+
protected function parseHandler(string|callable$handler): callable
185179
{
186180
if (is_string($handler)) {
187181
$parsed = Str::parseCallback($handler);
188182
$parsed[0] = $this->app->make($parsed[0]);
189183

190184
return $parsed;
191-
} elseif (is_callable($handler)) {
192-
return $handler;
193185
}
194186

195-
throw new InvalidArgumentException('Handler argument must be either a string or callable.');
187+
return $handler;
196188
}
197189
}

tests/SubscriberTest.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -291,19 +291,6 @@ public function it_handles_checking_subscription_status_of_all_mailing_lists_via
291291
$this->assertTrue($subscriber->checkSubscriptionStatus($expectedUser));
292292
}
293293

294-
/** @test */
295-
public function it_handles_type_checks_for_a_callable_or_string_handler()
296-
{
297-
$this->expectException(\InvalidArgumentException::class);
298-
$this->expectExceptionMessage('Handler argument must be either a string or callable.');
299-
300-
$subscriber = new Subscriber($this->app);
301-
302-
$subscriber->onCompletion(
303-
new \stdClass()
304-
);
305-
}
306-
307294
/** @test */
308295
public function it_can_provide_a_user_model()
309296
{

0 commit comments

Comments
 (0)