-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy pathPostmarkAdminClientDomainTest.php
More file actions
138 lines (103 loc) · 4.28 KB
/
PostmarkAdminClientDomainTest.php
File metadata and controls
138 lines (103 loc) · 4.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php
namespace Postmark\Tests;
require_once __DIR__ . '/PostmarkClientBaseTest.php';
use Postmark\PostmarkAdminClient;
/**
* @internal
*
* @coversNothing
*/
class PostmarkAdminClientDomainTest extends PostmarkClientBaseTest
{
public static function tearDownAfterClass(): void
{
$tk = parent::$testKeys;
$client = new PostmarkAdminClient($tk->WRITE_ACCOUNT_TOKEN, $tk->TEST_TIMEOUT);
$domains = $client->listDomains();
foreach ($domains->getDomains() as $key => $value) {
if (preg_match('/test-php.+/', $value->Name)) {
$client->deleteDomain($value->ID);
}
}
}
public function testClientCanGetDomainList()
{
$tk = parent::$testKeys;
$client = new PostmarkAdminClient($tk->WRITE_ACCOUNT_TOKEN, $tk->TEST_TIMEOUT);
$domains = $client->listDomains();
$this->assertGreaterThan(0, $domains->getTotalCount());
$this->assertNotEmpty($domains->getDomains());
}
public function testClientCanGetSingleDomain()
{
$tk = parent::$testKeys;
$client = new PostmarkAdminClient($tk->WRITE_ACCOUNT_TOKEN, $tk->TEST_TIMEOUT);
$tempDomains = $client->listDomains()->getDomains();
$id = $tempDomains[0]->getID();
$domain = $client->getDomain($id);
$this->assertNotEmpty($domain->getName());
}
public function testClientCanCreateDomain()
{
$tk = parent::$testKeys;
$client = new PostmarkAdminClient($tk->WRITE_ACCOUNT_TOKEN, $tk->TEST_TIMEOUT);
$domainName = 'test-php-create-' . $tk->WRITE_TEST_DOMAIN_NAME;
$domain = $client->createDomain($domainName);
$this->assertNotEmpty($domain->getID());
$this->assertNotEmpty($domain->getID());
$this->assertSame($domain->getCustomTrackingVerified(), false);
$this->assertSame($domain->getCustomTrackingDomainCNAMEValue(), '');
$this->assertSame($domain->getCustomTrackingDomain(), '');
}
public function testClientCanEditDomain()
{
$tk = parent::$testKeys;
$client = new PostmarkAdminClient($tk->WRITE_ACCOUNT_TOKEN, $tk->TEST_TIMEOUT);
$domainName = 'test-php-edit-' . $tk->WRITE_TEST_DOMAIN_NAME;
$returnPath = 'return.' . $domainName;
$domain = $client->createDomain($domainName, $returnPath);
$updated = $client->editDomain($domain->getID(), 'updated-' . $returnPath);
$this->assertNotSame($domain->getReturnPathDomain(), $updated->getReturnPathDomain());
}
public function testClientCanDeleteDomain()
{
$tk = parent::$testKeys;
$client = new PostmarkAdminClient($tk->WRITE_ACCOUNT_TOKEN, $tk->TEST_TIMEOUT);
$domainName = $tk->WRITE_TEST_DOMAIN_NAME;
$name = 'test-php-delete-' . $domainName;
$domain = $client->createDomain($name);
$client->deleteDomain($domain->getID());
$domains = $client->listDomains()->getDomains();
// Verify the deleted domain is not in the list
$deletedDomainFound = false;
foreach ($domains as $key => $value) {
if ($value->getID() === $domain->getID()) {
$deletedDomainFound = true;
break;
}
}
$this->assertFalse($deletedDomainFound, 'Deleted domain should not be found in the list');
}
public function testClientCanVerifyDKIM()
{
$tk = parent::$testKeys;
$client = new PostmarkAdminClient($tk->WRITE_ACCOUNT_TOKEN, $tk->TEST_TIMEOUT);
$domains = $client->listDomains()->getDomains();
foreach ($domains as $key => $value) {
$verify = $client->verifyDKIM($value->ID);
$this->assertSame($verify->getID(), $value->getID());
$this->assertSame($verify->getName(), $value->getName());
}
}
public function testClientCanVerifyReturnPath()
{
$tk = parent::$testKeys;
$client = new PostmarkAdminClient($tk->WRITE_ACCOUNT_TOKEN, $tk->TEST_TIMEOUT);
$domains = $client->listDomains()->getDomains();
foreach ($domains as $key => $value) {
$verify = $client->verifyReturnPath($value->getID());
$this->assertSame($verify->getID(), $value->getID());
$this->assertSame($verify->getName(), $value->getName());
}
}
}