14
14
15
15
class NotificationSlackChannelTest extends TestCase
16
16
{
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
-
36
17
protected function tearDown (): void
37
18
{
38
19
m::close ();
@@ -43,27 +24,31 @@ protected function tearDown(): void
43
24
*/
44
25
public function testCorrectPayloadIsSentToSlack (Notification $ notification , array $ payload )
45
26
{
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 ) {
47
32
$ this ->assertEquals ($ argUrl , 'url ' );
48
33
$ this ->assertEquals ($ argPayload , $ payload );
49
34
50
35
return new Response ();
51
36
});
52
37
53
- $ this -> slackChannel ->send (new SlackChannelTestNotifiable ('url ' ), $ notification );
38
+ $ slackChannel ->send (new SlackChannelTestNotifiable ('url ' ), $ notification );
54
39
}
55
40
56
- public function payloadDataProvider ()
41
+ public static function payloadDataProvider ()
57
42
{
58
43
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 (),
63
48
];
64
49
}
65
50
66
- private function getPayloadWithIcon ()
51
+ protected static function getPayloadWithIcon ()
67
52
{
68
53
return [
69
54
new NotificationSlackChannelTestNotification ,
@@ -100,7 +85,7 @@ private function getPayloadWithIcon()
100
85
];
101
86
}
102
87
103
- private function getPayloadWithImageIcon ()
88
+ protected static function getPayloadWithImageIcon ()
104
89
{
105
90
return [
106
91
new NotificationSlackChannelTestNotificationWithImageIcon ,
@@ -134,7 +119,7 @@ private function getPayloadWithImageIcon()
134
119
];
135
120
}
136
121
137
- private function getPayloadWithoutOptionalFields ()
122
+ protected static function getPayloadWithoutOptionalFields ()
138
123
{
139
124
return [
140
125
new NotificationSlackChannelWithoutOptionalFieldsTestNotification ,
@@ -160,7 +145,7 @@ private function getPayloadWithoutOptionalFields()
160
145
];
161
146
}
162
147
163
- public function getPayloadWithAttachmentFieldBuilder ()
148
+ protected static function getPayloadWithAttachmentFieldBuilder ()
164
149
{
165
150
return [
166
151
new NotificationSlackChannelWithAttachmentFieldBuilderTestNotification ,
0 commit comments