diff options
author | Arjan Keeman <arjan@araneum.nl> | 2016-09-22 10:58:13 +0200 |
---|---|---|
committer | Arjan Keeman <arjan@araneum.nl> | 2016-09-22 10:58:13 +0200 |
commit | 6b07cdc9a3c78523d22f45a6b304e2eb2c88a088 (patch) | |
tree | 19417149b6b226e3109291baaf1e74f9d4c966f2 /test/unit/ClientTest.php | |
parent | 18415fc7eef5ce2e3d16ba8b9c4077ad7cc630f3 (diff) | |
download | php-http-client-6b07cdc9a3c78523d22f45a6b304e2eb2c88a088.zip php-http-client-6b07cdc9a3c78523d22f45a6b304e2eb2c88a088.tar.gz php-http-client-6b07cdc9a3c78523d22f45a6b304e2eb2c88a088.tar.bz2 |
update tests
Diffstat (limited to 'test/unit/ClientTest.php')
-rw-r--r-- | test/unit/ClientTest.php | 53 |
1 files changed, 44 insertions, 9 deletions
diff --git a/test/unit/ClientTest.php b/test/unit/ClientTest.php index 18cab59..98218ac 100644 --- a/test/unit/ClientTest.php +++ b/test/unit/ClientTest.php @@ -2,6 +2,8 @@ namespace SendGrid\Test; +use SendGrid\Client; + class ClientTest extends \PHPUnit_Framework_TestCase { /** @var MockClient */ @@ -10,7 +12,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase private $host; /** @var array */ private $headers; - + protected function setUp() { $this->host = 'https://localhost:4010'; @@ -20,7 +22,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase ]; $this->client = new MockClient($this->host, $this->headers, '/v3', null); } - + public function testConstructor() { $this->assertAttributeEquals($this->host, 'host', $this->client); @@ -29,36 +31,69 @@ class ClientTest extends \PHPUnit_Framework_TestCase $this->assertAttributeEquals([], 'path', $this->client); $this->assertAttributeEquals(['delete', 'get', 'patch', 'post', 'put'], 'methods', $this->client); } - + public function test_() { $client = $this->client->_('test'); $this->assertAttributeEquals(['test'], 'path', $client); } - + public function test__call() { $client = $this->client->get(); $this->assertAttributeEquals('https://localhost:4010/v3/', 'url', $client); - + $queryParams = ['limit' => 100, 'offset' => 0]; $client = $this->client->get(null, $queryParams); $this->assertAttributeEquals('https://localhost:4010/v3/?limit=100&offset=0', 'url', $client); - + $requestBody = ['name' => 'A New Hope']; $client = $this->client->get($requestBody); $this->assertAttributeEquals($requestBody, 'requestBody', $client); - + $requestHeaders = ['X-Mock: 200']; $client = $this->client->get(null, null, $requestHeaders); $this->assertAttributeEquals($requestHeaders, 'requestHeaders', $client); - + $client = $this->client->version('/v4'); $this->assertAttributeEquals('/v4', 'version', $client); - + $client = $this->client->path_to_endpoint(); $this->assertAttributeEquals(['path_to_endpoint'], 'path', $client); $client = $client->one_more_segment(); $this->assertAttributeEquals(['path_to_endpoint', 'one_more_segment'], 'path', $client); } + + public function testGetHost() + { + $client = new Client('https://localhost:4010'); + $this->assertSame('https://localhost:4010', $client->getHost()); + } + + public function testGetHeaders() + { + $client = new Client('https://localhost:4010', ['Content-Type: application/json', 'Authorization: Bearer SG.XXXX']); + $this->assertSame(['Content-Type: application/json', 'Authorization: Bearer SG.XXXX'], $client->getHeaders()); + + $client2 = new Client('https://localhost:4010', null); + $this->assertSame([], $client2->getHeaders()); + } + + public function testGetVersion() + { + $client = new Client('https://localhost:4010', null, '/v3'); + $this->assertSame('/v3', $client->getVersion()); + + $client = new Client('https://localhost:4010', null, null); + $this->assertSame(null, $client->getVersion()); + } + + public function testGetPath() + { + $client = new Client('https://localhost:4010', null, null, ['/foo/bar']); + $this->assertSame(['/foo/bar'], $client->getPath()); + + $client = new Client('https://localhost:4010', null, null, null); + $this->assertSame([], $client->getPath()); + } }
\ No newline at end of file |