-
Notifications
You must be signed in to change notification settings - Fork 610
Expand file tree
/
Copy pathDataResidencyTest.php
More file actions
72 lines (60 loc) · 2.21 KB
/
Copy pathDataResidencyTest.php
File metadata and controls
72 lines (60 loc) · 2.21 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
<?php
/**
* This file tests email address encoding.
*/
namespace SendGrid\Tests\Unit;
use InvalidArgumentException;
use PHPUnit\Framework\TestCase;
/**
* This class tests Data residency
*
* @package SendGrid\Tests
*/
class DataResidencyTest extends TestCase
{
public function testSetResidencyEu()
{
$sendgrid = new \SendGrid(getenv('SENDGRID_API_KEY'));
$sendgrid->setDataResidency("eu");
self::assertEquals("https://api.eu.sendgrid.com", $sendgrid->client->getHost());
}
public function testSetResidencyGlobal()
{
$sendgrid = new \SendGrid(getenv('SENDGRID_API_KEY'));
$sendgrid->setDataResidency("global");
self::assertEquals("https://api.sendgrid.com", $sendgrid->client->getHost());
}
public function testSetResidencyOverrideHost()
{
$sendgrid = new \SendGrid(getenv('SENDGRID_API_KEY'));
$sendgrid->client->setHost("https://test.api.com");
$sendgrid->setDataResidency("eu");
self::assertEquals("https://api.eu.sendgrid.com", $sendgrid->client->getHost());
}
public function testSetResidencyOverrideDataResidency()
{
$sendgrid = new \SendGrid(getenv('SENDGRID_API_KEY'));
$sendgrid->setDataResidency("eu");
$sendgrid->client->setHost("https://test.api.com");
self::assertEquals("https://test.api.com", $sendgrid->client->getHost());
}
public function testSetResidencyIncorrectRegion()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage("region can only be \"eu\" or \"global\"");
$sendgrid = new \SendGrid(getenv('SENDGRID_API_KEY'));
$sendgrid->setDataResidency("foo");
}
public function testSetResidencyNullRegion()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage("region can only be \"eu\" or \"global\"");
$sendgrid = new \SendGrid(getenv('SENDGRID_API_KEY'));
$sendgrid->setDataResidency("");
}
public function testSetResidencyDefaultRegion()
{
$sendgrid = new \SendGrid(getenv('SENDGRID_API_KEY'));
self::assertEquals("https://api.sendgrid.com", $sendgrid->client->getHost());
}
}