-
Notifications
You must be signed in to change notification settings - Fork 627
/
Copy pathSendGridTest.php
65 lines (54 loc) · 1.9 KB
/
SendGridTest.php
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
<?php
namespace SendGrid\Tests\Unit;
use SendGrid\Tests\BaseTestClass;
/**
* This class tests the Twilio SendGrid Client.
*
* @package SendGrid\Tests\Unit
*/
class SendGridTest extends BaseTestClass
{
/**
* Test that we can connect to the Twilio SendGrid API.
*/
public function testCanConnectToSendGridApi()
{
$sg = new \SendGrid(self::$apiKey);
$headers = [
'Authorization: Bearer ' . self::$apiKey,
'User-Agent: sendgrid/' . $sg->version . ';php',
'Accept: application/json'
];
$this->assertEquals('https://api.sendgrid.com', $sg->client->getHost());
$this->assertEquals($headers, $sg->client->getHeaders());
$this->assertEquals('/v3', $sg->client->getVersion());
$sg = new \SendGrid(self::$apiKey, ['host' => 'https://api.test.com']);
$this->assertEquals('https://api.test.com', $sg->client->getHost());
$sg = new \SendGrid(self::$apiKey, ['curl' => ['foo' => 'bar']]);
$this->assertEquals(['foo' => 'bar'], $sg->client->getCurlOptions());
$sg = new \SendGrid(
self::$apiKey,
['curl' => [CURLOPT_PROXY => '127.0.0.1:8000']]
);
$this->assertEquals(
[10004 => '127.0.0.1:8000'],
$sg->client->getCurlOptions()
);
$subuser = 'abcxyz@this.is.a.test.subuser';
$headers[] = 'On-Behalf-Of: ' . $subuser;
$sg = new \SendGrid(
self::$apiKey,
['impersonateSubuser' => $subuser]
);
$this->assertSame($headers, $sg->client->getHeaders());
}
/**
* Test that user can override the API version when instantiating a new SendGrid client.
*/
public function testCanOverridePath()
{
$opts['version'] = '/v4';
$sg = new \SendGrid(self::$apiKey, $opts);
$this->assertEquals('/v4', $sg->client->getVersion());
}
}