-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This addresses issue #129. --------- Co-authored-by: Ash <[email protected]> Co-authored-by: Eli Wood <[email protected]>
- Loading branch information
1 parent
610d78a
commit 3c2c848
Showing
5 changed files
with
132 additions
and
5 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 |
---|---|---|
|
@@ -4,7 +4,9 @@ | |
|
||
require_once __DIR__ . '/PostmarkClientBaseTest.php'; | ||
|
||
use Postmark\Models; | ||
use Postmark\PostmarkClient; | ||
use Postmark\tests; | ||
|
||
/** | ||
* @internal | ||
|
@@ -13,6 +15,11 @@ | |
*/ | ||
class PostmarkClientBounceTest extends PostmarkClientBaseTest | ||
{ | ||
public static function setUpBeforeClass(): void | ||
{ | ||
PostmarkClientSuppressionsTest::tearDownAfterClass(); | ||
} | ||
|
||
public function testClientCanGetDeliveryStatistics() | ||
{ | ||
$tk = parent::$testKeys; | ||
|
@@ -41,6 +48,7 @@ public function testClientCanGetBounce() | |
$id = $bounces->getBounces()[0]->getID(); | ||
$bounce = $client->getBounce($id); | ||
$this->assertNotEmpty($bounce); | ||
$this->assertEquals($id, $bounce->getID()); | ||
} | ||
|
||
public function testClientCanGetBounceDump() | ||
|
@@ -51,5 +59,71 @@ public function testClientCanGetBounceDump() | |
$id = $bounces->Bounces[0]->getID(); | ||
$dump = $client->getBounceDump($id); | ||
$this->assertNotEmpty($dump); | ||
$this->assertNotEmpty($dump->getBody()); | ||
} | ||
|
||
public function testClientCanActivateBounce() | ||
{ | ||
$tk = parent::$testKeys; | ||
$client = new PostmarkClient($tk->WRITE_TEST_SERVER_TOKEN, $tk->TEST_TIMEOUT); | ||
|
||
// make sure that this email is not suppressed | ||
// generate a bounces | ||
$fromEmail = $tk->WRITE_TEST_SENDER_EMAIL_ADDRESS; | ||
$toEmail = "[email protected]"; // special email to generate bounce | ||
$subject = "Hello from Postmark!"; | ||
$htmlBody = "<strong>Hello</strong> dear Postmark user."; | ||
$textBody = "Hello dear Postmark user."; | ||
$tag = "example-email-tag"; | ||
$trackOpens = true; | ||
$trackLinks = "None"; | ||
|
||
$sendResult = $client->sendEmail( | ||
$fromEmail, | ||
$toEmail, | ||
$subject, | ||
$htmlBody, | ||
$textBody, | ||
$tag, | ||
$trackOpens, | ||
NULL, // Reply To | ||
NULL, // CC | ||
NULL, // BCC | ||
NULL, // Header array | ||
NULL, // Attachment array | ||
$trackLinks, | ||
NULL // Metadata array | ||
); | ||
|
||
// make sure there is enough time for the bounce to take place. | ||
sleep(180); | ||
|
||
$bounceList = $client->getBounces(20, 0); | ||
$id = 0; | ||
$sentId = $sendResult->getMessageID(); | ||
$bounces = $bounceList->getBounces(); | ||
|
||
$this->assertNotEmpty($bounces); | ||
$this->assertNotEmpty($sentId); | ||
|
||
foreach ($bounces as $bounce) | ||
{ | ||
$bmid = $bounce->getMessageID(); | ||
echo "\n Bounce ID: $bmid Sent id: $sentId"; | ||
if ($sentId === $bmid) | ||
{ | ||
$id = $bounce->getID(); | ||
echo "Made it!! $id"; | ||
break; | ||
} | ||
} | ||
|
||
$this->assertGreaterThan(0, $id); | ||
|
||
$bounceActivation = $client->activateBounce($id); | ||
$actBounce = $bounceActivation->getBounce(); | ||
|
||
$this->assertNotEmpty($actBounce); | ||
$this->assertEquals($id, $actBounce->getID()); | ||
} | ||
} |
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