@@ -69,28 +69,28 @@ public function createClient(int $statusCode, array $content): HttpClientInterfa
69
69
public function responseProvider (): iterable
70
70
{
71
71
$ responses = [
72
- ['status ' => 200 , 'content ' => '{"error":101,"message":"Authorization failed"} ' ],
73
- ['status ' => 500 , 'content ' => '{} ' ],
74
- ['status ' => 500 , 'content ' => '{"error":null,"message":"Unknown"} ' ],
75
- ['status ' => 500 , 'content ' => '{"error":null,"message":null} ' ],
72
+ ['status ' => 200 , 'content ' => '{"error":101,"message":"Authorization failed"} ' , ' errorMessage ' => ' Unable to send the SMS: "Authorization failed". ' ],
73
+ ['status ' => 500 , 'content ' => '{} ' , ' errorMessage ' => ' Unable to send the SMS: "unknown error". ' ],
74
+ ['status ' => 500 , 'content ' => '{"error":null,"message":"Unknown"} ' , ' errorMessage ' => ' Unable to send the SMS: "Unknown". ' ],
75
+ ['status ' => 500 , 'content ' => '{"error":null,"message":null} ' , ' errorMessage ' => ' Unable to send the SMS: "unknown error". ' ],
76
76
];
77
77
78
78
foreach ($ responses as $ response ) {
79
- yield [$ response ['status ' ], json_decode ($ response ['content ' ], true )];
79
+ yield [$ response ['status ' ], json_decode ($ response ['content ' ], true ), $ response [ ' errorMessage ' ] ];
80
80
}
81
81
}
82
82
83
83
/**
84
84
* @dataProvider responseProvider
85
85
*/
86
- public function testThrowExceptionWhenMessageWasNotSent (int $ statusCode , array $ content )
86
+ public function testThrowExceptionWhenMessageWasNotSent (int $ statusCode , array $ content, string $ errorMessage )
87
87
{
88
88
$ client = $ this ->createClient ($ statusCode , $ content );
89
89
$ transport = $ this ->createTransport ($ client );
90
90
$ message = new SmsMessage ('0611223344 ' , 'Hello! ' );
91
91
92
92
$ this ->expectException (TransportException::class);
93
- $ this ->expectExceptionMessage (sprintf ( ' Unable to send the SMS: "%s". ' , $ content [ ' message ' ] ?? ' unknown error ' ) );
93
+ $ this ->expectExceptionMessage ($ errorMessage );
94
94
95
95
$ transport ->send ($ message );
96
96
}
0 commit comments