@@ -50,9 +50,9 @@ public function unsupportedMessagesProvider(): iterable
50
50
/**
51
51
* @dataProvider provideTestMode()
52
52
*/
53
- public function testTestMode (array $ expected , array $ provided )
53
+ public function testTestMode (int $ expected , bool $ testMode )
54
54
{
55
- $ message = new SmsMessage ($ provided [ ' phone ' ], $ provided [ ' message ' ] );
55
+ $ message = new SmsMessage (' +37012345678 ' , ' Hello World! ' );
56
56
57
57
$ response = $ this ->createMock (ResponseInterface::class);
58
58
$ response ->expects ($ this ->atLeast (1 ))
@@ -62,64 +62,32 @@ public function testTestMode(array $expected, array $provided)
62
62
->method ('getContent ' )
63
63
->willReturn ('OK: 519545 ' );
64
64
65
- $ client = new MockHttpClient (function (string $ method , string $ url , array $ options = []) use ($ response , $ expected ): ResponseInterface {
65
+ $ client = new MockHttpClient (function (string $ method , string $ url , array $ options = []) use ($ response , $ message , $ testMode , $ expected ): ResponseInterface {
66
66
$ this ->assertSame ('GET ' , $ method );
67
67
$ this ->assertSame (sprintf (
68
68
'https://savitarna.smsbiuras.lt/api?uid=uid&apikey=api_key&message=%s&from=from&test=%s&to=%s ' ,
69
- rawurlencode ($ expected [ ' message ' ] ),
70
- $ expected[ ' transport ' ][ ' test_mode ' ] ,
71
- rawurlencode ($ expected [ ' phone ' ] ),
69
+ rawurlencode ($ message-> getSubject () ),
70
+ $ expected ,
71
+ rawurlencode ($ message -> getPhone () ),
72
72
), $ url );
73
- $ this ->assertSame ($ expected[ ' transport ' ][ ' test_mode ' ] , $ options ['query ' ]['test ' ]);
73
+ $ this ->assertSame ($ expected , $ options ['query ' ]['test ' ]);
74
74
75
75
$ this ->assertSame (200 , $ response ->getStatusCode ());
76
76
$ this ->assertSame ('OK: 519545 ' , $ response ->getContent ());
77
77
78
78
return $ response ;
79
79
});
80
80
81
- $ transport = new SmsBiurasTransport ('uid ' , 'api_key ' , 'from ' , $ provided [ ' transport ' ][ ' test_mode ' ] , $ client );
81
+ $ transport = new SmsBiurasTransport ('uid ' , 'api_key ' , 'from ' , $ testMode , $ client );
82
82
83
83
$ sentMessage = $ transport ->send ($ message );
84
84
85
85
$ this ->assertSame ('519545 ' , $ sentMessage ->getMessageId ());
86
86
}
87
87
88
- public static function provideTestMode (): array
88
+ public static function provideTestMode (): iterable
89
89
{
90
- return [
91
- [
92
- [
93
- 'phone ' => '+37012345678 ' ,
94
- 'message ' => 'Hello world! ' ,
95
- 'transport ' => [
96
- 'test_mode ' => 0 ,
97
- ],
98
- ],
99
- [
100
- 'phone ' => '+37012345678 ' ,
101
- 'message ' => 'Hello world! ' ,
102
- 'transport ' => [
103
- 'test_mode ' => 0 ,
104
- ],
105
- ],
106
- ],
107
- [
108
- [
109
- 'phone ' => '+37012345678 ' ,
110
- 'message ' => 'Hello world! ' ,
111
- 'transport ' => [
112
- 'test_mode ' => 1 ,
113
- ],
114
- ],
115
- [
116
- 'phone ' => '+37012345678 ' ,
117
- 'message ' => 'Hello world! ' ,
118
- 'transport ' => [
119
- 'test_mode ' => 1 ,
120
- ],
121
- ],
122
- ],
123
- ];
90
+ yield [1 , true ];
91
+ yield [0 , false ];
124
92
}
125
93
}
0 commit comments