Skip to content

Commit fc8d187

Browse files
authored
[develop] Adds Laravel 11 support (#84) (#88)
* Adds Laravel 11 support * Improves test
1 parent a2290ea commit fc8d187

File tree

3 files changed

+26
-37
lines changed

3 files changed

+26
-37
lines changed

.github/workflows/tests.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,14 @@ jobs:
1818
fail-fast: true
1919
matrix:
2020
php: ['8.0', 8.1, 8.2, 8.3]
21-
laravel: [9, 10]
21+
laravel: [9, 10, 11]
2222
exclude:
2323
- php: '8.0'
2424
laravel: 10
25+
- php: '8.0'
26+
laravel: 11
27+
- php: 8.1
28+
laravel: 11
2529
- php: 8.3
2630
laravel: 9
2731

@@ -46,4 +50,4 @@ jobs:
4650
composer update --prefer-dist --no-interaction --no-progress
4751
4852
- name: Execute tests
49-
run: vendor/bin/phpunit --verbose
53+
run: vendor/bin/phpunit

composer.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
"require": {
1313
"php": "^8.0",
1414
"guzzlehttp/guzzle": "^7.0",
15-
"illuminate/http": "^9.0|^10.0",
16-
"illuminate/notifications": "^9.0|^10.0",
17-
"illuminate/support": "^9.0|^10.0"
15+
"illuminate/http": "^9.0|^10.0|^11.0",
16+
"illuminate/notifications": "^9.0|^10.0|^11.0",
17+
"illuminate/support": "^9.0|^10.0|^11.0"
1818
},
1919
"require-dev": {
2020
"mockery/mockery": "^1.0",
21-
"orchestra/testbench": "^7.0|^8.0",
21+
"orchestra/testbench": "^7.0|^8.0|^9.0",
2222
"phpstan/phpstan": "^1.10",
23-
"phpunit/phpunit": "^9.0"
23+
"phpunit/phpunit": "^9.0|^10.4"
2424
},
2525
"autoload": {
2626
"psr-4": {

tests/NotificationSlackChannelTest.php

+15-30
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,6 @@
1414

1515
class NotificationSlackChannelTest extends TestCase
1616
{
17-
/**
18-
* @var \Illuminate\Notifications\Channels\SlackWebhookChannel
19-
*/
20-
private $slackChannel;
21-
22-
/**
23-
* @var \Mockery\MockInterface|\GuzzleHttp\Client
24-
*/
25-
private $guzzleHttp;
26-
27-
protected function setUp(): void
28-
{
29-
parent::setUp();
30-
31-
$this->guzzleHttp = m::mock(Client::class);
32-
33-
$this->slackChannel = new SlackWebhookChannel($this->guzzleHttp);
34-
}
35-
3617
protected function tearDown(): void
3718
{
3819
m::close();
@@ -43,27 +24,31 @@ protected function tearDown(): void
4324
*/
4425
public function testCorrectPayloadIsSentToSlack(Notification $notification, array $payload)
4526
{
46-
$this->guzzleHttp->shouldReceive('post')->andReturnUsing(function ($argUrl, $argPayload) use ($payload) {
27+
$guzzleHttp = m::mock(Client::class);
28+
29+
$slackChannel = new SlackWebhookChannel($guzzleHttp);
30+
31+
$guzzleHttp->shouldReceive('post')->andReturnUsing(function ($argUrl, $argPayload) use ($payload) {
4732
$this->assertEquals($argUrl, 'url');
4833
$this->assertEquals($argPayload, $payload);
4934

5035
return new Response();
5136
});
5237

53-
$this->slackChannel->send(new SlackChannelTestNotifiable('url'), $notification);
38+
$slackChannel->send(new SlackChannelTestNotifiable('url'), $notification);
5439
}
5540

56-
public function payloadDataProvider()
41+
public static function payloadDataProvider()
5742
{
5843
return [
59-
'payloadWithIcon' => $this->getPayloadWithIcon(),
60-
'payloadWithImageIcon' => $this->getPayloadWithImageIcon(),
61-
'payloadWithoutOptionalFields' => $this->getPayloadWithoutOptionalFields(),
62-
'payloadWithAttachmentFieldBuilder' => $this->getPayloadWithAttachmentFieldBuilder(),
44+
'payloadWithIcon' => static::getPayloadWithIcon(),
45+
'payloadWithImageIcon' => static::getPayloadWithImageIcon(),
46+
'payloadWithoutOptionalFields' => static::getPayloadWithoutOptionalFields(),
47+
'payloadWithAttachmentFieldBuilder' => static::getPayloadWithAttachmentFieldBuilder(),
6348
];
6449
}
6550

66-
private function getPayloadWithIcon()
51+
protected static function getPayloadWithIcon()
6752
{
6853
return [
6954
new NotificationSlackChannelTestNotification,
@@ -100,7 +85,7 @@ private function getPayloadWithIcon()
10085
];
10186
}
10287

103-
private function getPayloadWithImageIcon()
88+
protected static function getPayloadWithImageIcon()
10489
{
10590
return [
10691
new NotificationSlackChannelTestNotificationWithImageIcon,
@@ -134,7 +119,7 @@ private function getPayloadWithImageIcon()
134119
];
135120
}
136121

137-
private function getPayloadWithoutOptionalFields()
122+
protected static function getPayloadWithoutOptionalFields()
138123
{
139124
return [
140125
new NotificationSlackChannelWithoutOptionalFieldsTestNotification,
@@ -160,7 +145,7 @@ private function getPayloadWithoutOptionalFields()
160145
];
161146
}
162147

163-
public function getPayloadWithAttachmentFieldBuilder()
148+
protected static function getPayloadWithAttachmentFieldBuilder()
164149
{
165150
return [
166151
new NotificationSlackChannelWithAttachmentFieldBuilderTestNotification,

0 commit comments

Comments
 (0)