forked from ts-navghane/sparkpost-plugin
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6f781aa
commit 0764b9d
Showing
2 changed files
with
77 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,12 @@ | |
|
||
class SparkpostTransportMessageTest extends TestCase | ||
{ | ||
/** | ||
* @var TransportCallback|MockObject | ||
*/ | ||
private $transportCallbackMock; | ||
private SparkpostTransport $sparkpost; | ||
|
||
public function testCcAndBccFields(): void | ||
{ | ||
$emailId = 1; | ||
|
@@ -25,15 +31,15 @@ public function testCcAndBccFields(): void | |
// so for maintain 64 bytes last char will be trimmed. | ||
$expectedInternalEmailName = '202211_シナリオメール②内視鏡機器提案のご案'; | ||
|
||
$transportCallbackMock = $this->createMock(TransportCallback::class); | ||
$httpClientMock = $this->createMock(HttpClientInterface::class); | ||
$eventDispatcherMock = $this->createMock(EventDispatcherInterface::class); | ||
$loggerMock = $this->createMock(LoggerInterface::class); | ||
$this->transportCallbackMock = $this->createMock(TransportCallback::class); | ||
$httpClientMock = $this->createMock(HttpClientInterface::class); | ||
$eventDispatcherMock = $this->createMock(EventDispatcherInterface::class); | ||
$loggerMock = $this->createMock(LoggerInterface::class); | ||
|
||
$sparkpost = new SparkpostTransport( | ||
$this->sparkpost = new SparkpostTransport( | ||
'1234', | ||
'us', | ||
$transportCallbackMock, | ||
$this->transportCallbackMock, | ||
$httpClientMock, | ||
$eventDispatcherMock, | ||
$loggerMock | ||
|
@@ -66,7 +72,7 @@ public function testCcAndBccFields(): void | |
$sentMessageMock->method('getOriginalMessage') | ||
->willReturn($message); | ||
|
||
$payload = $this->invokeInaccessibleMethod($sparkpost, 'getSparkpostPayload', [$sentMessageMock]); | ||
$payload = $this->invokeInaccessibleMethod($this->sparkpost, 'getSparkpostPayload', [$sentMessageMock]); | ||
Assert::assertEquals(sprintf('%s:%s', $emailId, $expectedInternalEmailName), $payload['campaign_id']); | ||
Assert::assertEquals('[email protected]', $payload['content']['from']); | ||
Assert::assertEquals('Test subject', $payload['content']['subject']); | ||
|
@@ -187,4 +193,36 @@ private function invokeInaccessibleMethod(object $object, string $methodName, ar | |
|
||
return $method->invokeArgs($object, $args); | ||
} | ||
|
||
/** | ||
* For the message with 'type': 'out of band' and 'bounce class': 60 should never be called transportCallback. | ||
*/ | ||
public function testProcessCallbackRequestWhenSoftBounce(): void | ||
{ | ||
$payload = <<<JSON | ||
[ | ||
{ | ||
"msys": { | ||
"message_event": { | ||
"reason":"550 [internal] [oob] The message is an auto-reply/vacation mail.", | ||
"msg_from":"msprvs1=18290qww0ygol=bounces-44585-172@bounces.mauticsparkt3.com", | ||
"event_id":"13251575597141532", | ||
"raw_reason":"550 [internal] [oob] The message is an auto-reply/vacation mail.", | ||
"error_code":"550", | ||
"subaccount_id":172, | ||
"delv_method":"esmtp", | ||
"customer_id":44585, | ||
"type":"out_of_band", | ||
"bounce_class":"60", | ||
"timestamp":"2020-01-22T21:59:32.000Z" | ||
} | ||
} | ||
} | ||
] | ||
JSON; | ||
$request = new Request([], json_decode($payload, true)); | ||
$this->sparkpost->processCallbackRequest($request); | ||
$this->transportCallbackMock->expects($this->never()) | ||
->method($this->anything()); | ||
} | ||
} |