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