16
16
17
17
class SparkpostTransportMessageTest extends TestCase
18
18
{
19
+ /**
20
+ * @var TransportCallback|MockObject
21
+ */
22
+ private $ transportCallbackMock ;
23
+ private SparkpostTransport $ sparkpost ;
24
+
19
25
public function testCcAndBccFields (): void
20
26
{
21
27
$ emailId = 1 ;
@@ -25,15 +31,15 @@ public function testCcAndBccFields(): void
25
31
// so for maintain 64 bytes last char will be trimmed.
26
32
$ expectedInternalEmailName = '202211_シナリオメール②内視鏡機器提案のご案 ' ;
27
33
28
- $ transportCallbackMock = $ this ->createMock (TransportCallback::class);
29
- $ httpClientMock = $ this ->createMock (HttpClientInterface::class);
30
- $ eventDispatcherMock = $ this ->createMock (EventDispatcherInterface::class);
31
- $ loggerMock = $ this ->createMock (LoggerInterface::class);
34
+ $ this -> transportCallbackMock = $ this ->createMock (TransportCallback::class);
35
+ $ httpClientMock = $ this ->createMock (HttpClientInterface::class);
36
+ $ eventDispatcherMock = $ this ->createMock (EventDispatcherInterface::class);
37
+ $ loggerMock = $ this ->createMock (LoggerInterface::class);
32
38
33
- $ sparkpost = new SparkpostTransport (
39
+ $ this -> sparkpost = new SparkpostTransport (
34
40
'1234 ' ,
35
41
'us ' ,
36
- $ transportCallbackMock ,
42
+ $ this -> transportCallbackMock ,
37
43
$ httpClientMock ,
38
44
$ eventDispatcherMock ,
39
45
$ loggerMock
@@ -66,7 +72,7 @@ public function testCcAndBccFields(): void
66
72
$ sentMessageMock ->method ('getOriginalMessage ' )
67
73
->willReturn ($ message );
68
74
69
- $ payload = $ this ->invokeInaccessibleMethod ($ sparkpost , 'getSparkpostPayload ' , [$ sentMessageMock ]);
75
+ $ payload = $ this ->invokeInaccessibleMethod ($ this -> sparkpost , 'getSparkpostPayload ' , [$ sentMessageMock ]);
70
76
Assert::assertEquals (sprintf ('%s:%s ' , $ emailId , $ expectedInternalEmailName ), $ payload ['campaign_id ' ]);
71
77
Assert::
assertEquals (
'[email protected] ' ,
$ payload[
'content ' ][
'from ' ]);
72
78
Assert::assertEquals ('Test subject ' , $ payload ['content ' ]['subject ' ]);
@@ -187,4 +193,36 @@ private function invokeInaccessibleMethod(object $object, string $methodName, ar
187
193
188
194
return $ method ->invokeArgs ($ object , $ args );
189
195
}
196
+
197
+ /**
198
+ * For the message with 'type': 'out of band' and 'bounce class': 60 should never be called transportCallback.
199
+ */
200
+ public function testProcessCallbackRequestWhenSoftBounce (): void
201
+ {
202
+ $ payload = <<<JSON
203
+ [
204
+ {
205
+ "msys": {
206
+ "message_event": {
207
+ "reason":"550 [internal] [oob] The message is an auto-reply/vacation mail.",
208
+ "msg_from":"msprvs1=18290qww0ygol=bounces-44585-172@bounces.mauticsparkt3.com",
209
+ "event_id":"13251575597141532",
210
+ "raw_reason":"550 [internal] [oob] The message is an auto-reply/vacation mail.",
211
+ "error_code":"550",
212
+ "subaccount_id":172,
213
+ "delv_method":"esmtp",
214
+ "customer_id":44585,
215
+ "type":"out_of_band",
216
+ "bounce_class":"60",
217
+ "timestamp":"2020-01-22T21:59:32.000Z"
218
+ }
219
+ }
220
+ }
221
+ ]
222
+ JSON ;
223
+ $ request = new Request ([], json_decode ($ payload , true ));
224
+ $ this ->sparkpost ->processCallbackRequest ($ request );
225
+ $ this ->transportCallbackMock ->expects ($ this ->never ())
226
+ ->method ($ this ->anything ());
227
+ }
190
228
}
0 commit comments