21
21
use Symfony \Component \Notifier \Message \SmsMessage ;
22
22
use Symfony \Component \Notifier \Notification \Notification ;
23
23
use Symfony \Component \Notifier \Test \TransportTestCase ;
24
+ use Symfony \Component \Notifier \Tests \Fixtures \DummyHttpClient ;
25
+ use Symfony \Component \Notifier \Tests \Fixtures \DummyMessage ;
26
+ use Symfony \Component \Notifier \Transport \TransportInterface ;
24
27
use Symfony \Contracts \HttpClient \HttpClientInterface ;
25
28
use Symfony \Contracts \HttpClient \ResponseInterface ;
26
29
27
30
final class LinkedInTransportTest extends TransportTestCase
28
31
{
29
- public function createTransport (HttpClientInterface $ client = null ): LinkedInTransport
32
+ public static function createTransport (HttpClientInterface $ client = null ): LinkedInTransport
30
33
{
31
- return (new LinkedInTransport ('AuthToken ' , 'AccountId ' , $ client ?? $ this -> createMock (HttpClientInterface::class )))->setHost ('host.test ' );
34
+ return (new LinkedInTransport ('AuthToken ' , 'AccountId ' , $ client ?? new DummyHttpClient ( )))->setHost ('host.test ' );
32
35
}
33
36
34
- public function toStringProvider (): iterable
37
+ public static function toStringProvider (): iterable
35
38
{
36
- yield ['linkedin://host.test ' , $ this -> createTransport ()];
39
+ yield ['linkedin://host.test ' , self :: createTransport ()];
37
40
}
38
41
39
- public function supportedMessagesProvider (): iterable
42
+ public static function supportedMessagesProvider (): iterable
40
43
{
41
44
yield [new ChatMessage ('Hello! ' )];
42
45
}
43
46
44
- public function unsupportedMessagesProvider (): iterable
47
+ public static function unsupportedMessagesProvider (): iterable
45
48
{
46
49
yield [new SmsMessage ('0611223344 ' , 'Hello! ' )];
47
- yield [$ this -> createMock (MessageInterface::class )];
50
+ yield [new DummyMessage ( )];
48
51
}
49
52
50
53
public function testSendWithEmptyArrayResponseThrowsTransportException ()
@@ -59,7 +62,7 @@ public function testSendWithEmptyArrayResponseThrowsTransportException()
59
62
60
63
$ client = new MockHttpClient (static fn (): ResponseInterface => $ response );
61
64
62
- $ transport = $ this -> createTransport ($ client );
65
+ $ transport = self :: createTransport ($ client );
63
66
64
67
$ this ->expectException (TransportException::class);
65
68
@@ -82,7 +85,7 @@ public function testSendWithErrorResponseThrowsTransportException()
82
85
83
86
$ client = new MockHttpClient (static fn (): ResponseInterface => $ response );
84
87
85
- $ transport = $ this -> createTransport ($ client );
88
+ $ transport = self :: createTransport ($ client );
86
89
87
90
$ transport ->send (new ChatMessage ('testMessage ' ));
88
91
}
@@ -126,7 +129,7 @@ public function testSendWithOptions()
126
129
127
130
return $ response ;
128
131
});
129
- $ transport = $ this -> createTransport ($ client );
132
+ $ transport = self :: createTransport ($ client );
130
133
131
134
$ transport ->send (new ChatMessage ($ message ));
132
135
}
@@ -174,7 +177,7 @@ public function testSendWithNotification()
174
177
return $ response ;
175
178
});
176
179
177
- $ transport = $ this -> createTransport ($ client );
180
+ $ transport = self :: createTransport ($ client );
178
181
179
182
$ transport ->send ($ chatMessage );
180
183
}
@@ -185,7 +188,7 @@ public function testSendWithInvalidOptions()
185
188
186
189
$ client = new MockHttpClient (fn (string $ method , string $ url , array $ options = []): ResponseInterface => $ this ->createMock (ResponseInterface::class));
187
190
188
- $ transport = $ this -> createTransport ($ client );
191
+ $ transport = self :: createTransport ($ client );
189
192
190
193
$ transport ->send (new ChatMessage ('testMessage ' , $ this ->createMock (MessageOptionsInterface::class)));
191
194
}
0 commit comments