-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #145 from nickvanderveeken/feature/sparkpost-suppr…
…ession-list Add SparkPost suppression-list support
- Loading branch information
Showing
3 changed files
with
104 additions
and
9 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
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 |
---|---|---|
|
@@ -7,8 +7,6 @@ | |
use Laminas\Mail\Address; | ||
use Laminas\Mail\AddressList; | ||
use Laminas\Mail\Message; | ||
use PHPUnit\Framework\MockObject\MockBuilder; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
use PHPUnit\Framework\TestCase; | ||
use ReflectionMethod; | ||
use SlmMail\Mail\Message\SparkPost; | ||
|
@@ -43,7 +41,7 @@ private function expectApiResponse(int $statusCode = 200, string $responseBody = | |
} | ||
$sendMessageResponse->setContent($responseBody); | ||
|
||
$httpClientMock->expects($this->once()) | ||
$httpClientMock->expects($this->atLeastOnce()) | ||
->method('send') | ||
->willReturn($sendMessageResponse); | ||
|
||
|
@@ -190,14 +188,16 @@ public function testRemoveSendingDomain() | |
{ | ||
/** @var SparkPostService $sparkPostServiceMock */ | ||
$sparkPostServiceMock = $this->expectApiResponse(204); | ||
$this->assertNull($sparkPostServiceMock->removeSendingDomain('sparkpost-sending-domain.com')); | ||
$sparkPostServiceMock->removeSendingDomain('sparkpost-sending-domain.com'); | ||
$this->doesNotPerformAssertions(); | ||
} | ||
|
||
public function testRemoveNonExistingSendingDomain() | ||
{ | ||
/** @var SparkPostService $sparkPostServiceMock */ | ||
$sparkPostServiceMock = $this->expectApiResponse(404); | ||
$this->assertNull($sparkPostServiceMock->removeSendingDomain('sparkpost-sending-domain.com')); | ||
$sparkPostServiceMock->removeSendingDomain('sparkpost-sending-domain.com'); | ||
$this->doesNotPerformAssertions(); | ||
} | ||
|
||
public function testVerifySendingDomain() | ||
|
@@ -232,12 +232,52 @@ public function testVerifySendingDomainWithInvalidDkimRecord() | |
|
||
public function testVerifyUnregisteredSendingDomain() | ||
{ | ||
//** @var SparkPostService $sparkPostServiceMock */ | ||
/** @var SparkPostService $sparkPostServiceMock */ | ||
$sparkPostServiceMock = $this->expectApiResponse( | ||
404, | ||
'{"errors":[{"message":"invalid params","description":"Sending domain \'sparkpost-sending-domain.com\' is not a registered sending domain","code":"1200"}]}' | ||
); | ||
$this->expectException(RuntimeException::class); | ||
$sparkPostServiceMock->verifySendingDomain('sparkpost-sending-domain.com'); | ||
} | ||
|
||
public function testAddToSuppressionList() | ||
{ | ||
/** @var SparkPostService $sparkPostServiceMock */ | ||
$sparkPostServiceMock = $this->expectApiResponse(200, '{"results":{"message":"Suppression List successfully updated"}}'); | ||
$sparkPostServiceMock->addToSuppressionList('[email protected]', 'Permanent block after hard bounce'); | ||
$this->doesNotPerformAssertions(); | ||
} | ||
|
||
public function testAddToTransactionalSuppressionList() | ||
{ | ||
/** @var SparkPostService $sparkPostServiceMock */ | ||
$sparkPostServiceMock = $this->expectApiResponse(200, '{"results":{"message":"Suppression List successfully updated"}}'); | ||
$sparkPostServiceMock->addToSuppressionList('[email protected]', 'Permanent block after hard bounce', [SparkPostService::SUPPRESSION_LIST_TRANSACTIONAL]); | ||
$this->doesNotPerformAssertions(); | ||
} | ||
|
||
public function testRemoveFromSuppressionList() | ||
{ | ||
/** @var SparkPostService $sparkPostServiceMock */ | ||
$sparkPostServiceMock = $this->expectApiResponse(204); | ||
$sparkPostServiceMock->removeFromSuppressionList('[email protected]'); | ||
$this->doesNotPerformAssertions(); | ||
} | ||
|
||
public function testRemoveFromTransactionalSuppressionList() | ||
{ | ||
/** @var SparkPostService $sparkPostServiceMock */ | ||
$sparkPostServiceMock = $this->expectApiResponse(204); | ||
$sparkPostServiceMock->removeFromSuppressionList('[email protected]', [SparkPostService::SUPPRESSION_LIST_TRANSACTIONAL]); | ||
$this->doesNotPerformAssertions(); | ||
} | ||
|
||
public function testRemoveNonExistingAddressFromSuppressionList() | ||
{ | ||
/** @var SparkPostService $sparkPostServiceMock */ | ||
$sparkPostServiceMock = $this->expectApiResponse(404); | ||
$sparkPostServiceMock->removeFromSuppressionList('[email protected]'); | ||
$this->doesNotPerformAssertions(); | ||
} | ||
} |