19
19
use Symfony \Component \Notifier \Message \MessageInterface ;
20
20
use Symfony \Component \Notifier \Message \SmsMessage ;
21
21
use Symfony \Component \Notifier \Test \TransportTestCase ;
22
+ use Symfony \Component \Notifier \Tests \Fixtures \DummyHttpClient ;
23
+ use Symfony \Component \Notifier \Tests \Fixtures \DummyMessage ;
22
24
use Symfony \Component \Notifier \Transport \TransportInterface ;
23
25
use Symfony \Contracts \HttpClient \HttpClientInterface ;
24
26
@@ -27,25 +29,25 @@ final class SmsapiTransportTest extends TransportTestCase
27
29
/**
28
30
* @return SmsapiTransport
29
31
*/
30
- public function createTransport (HttpClientInterface $ client = null ): TransportInterface
32
+ public static function createTransport (HttpClientInterface $ client = null ): TransportInterface
31
33
{
32
- return (new SmsapiTransport ('testToken ' , 'testFrom ' , $ client ?? $ this -> createMock (HttpClientInterface::class )))->setHost ('test.host ' );
34
+ return (new SmsapiTransport ('testToken ' , 'testFrom ' , $ client ?? new DummyHttpClient ( )))->setHost ('test.host ' );
33
35
}
34
36
35
- public function toStringProvider (): iterable
37
+ public static function toStringProvider (): iterable
36
38
{
37
- yield ['smsapi://test.host?from=testFrom ' , $ this -> createTransport ()];
39
+ yield ['smsapi://test.host?from=testFrom ' , self :: createTransport ()];
38
40
}
39
41
40
- public function supportedMessagesProvider (): iterable
42
+ public static function supportedMessagesProvider (): iterable
41
43
{
42
44
yield [new SmsMessage ('0611223344 ' , 'Hello! ' )];
43
45
}
44
46
45
- public function unsupportedMessagesProvider (): iterable
47
+ public static function unsupportedMessagesProvider (): iterable
46
48
{
47
49
yield [new ChatMessage ('Hello! ' )];
48
- yield [$ this -> createMock (MessageInterface::class )];
50
+ yield [new DummyMessage ( )];
49
51
}
50
52
51
53
public function createClient (int $ statusCode , string $ content ): HttpClientInterface
@@ -75,7 +77,7 @@ public function responseProvider(): iterable
75
77
public function testThrowExceptionWhenMessageWasNotSent (int $ statusCode , string $ content , string $ errorMessage )
76
78
{
77
79
$ client = $ this ->createClient ($ statusCode , $ content );
78
- $ transport = $ this -> createTransport ($ client );
80
+ $ transport = self :: createTransport ($ client );
79
81
$ message = new SmsMessage ('0611223344 ' , 'Hello! ' );
80
82
81
83
$ this ->expectException (TransportException::class);
0 commit comments