diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/SendGridTest.php | 2 | ||||
-rw-r--r-- | test/unit/resources/api_keysTest.php | 46 |
2 files changed, 47 insertions, 1 deletions
diff --git a/test/unit/SendGridTest.php b/test/unit/SendGridTest.php index bc220ee..c7ec2bf 100644 --- a/test/unit/SendGridTest.php +++ b/test/unit/SendGridTest.php @@ -12,7 +12,7 @@ class SendGridTest_SendGrid extends PHPUnit_Framework_TestCase public function testVersion() { - $this->assertEquals(SendGrid::VERSION, '4.0.1'); + $this->assertEquals(SendGrid::VERSION, '4.0.2'); $this->assertEquals(json_decode(file_get_contents(__DIR__ . '/../../composer.json'))->version, SendGrid::VERSION); } diff --git a/test/unit/resources/api_keysTest.php b/test/unit/resources/api_keysTest.php index 8045d4c..72ecff9 100644 --- a/test/unit/resources/api_keysTest.php +++ b/test/unit/resources/api_keysTest.php @@ -13,4 +13,50 @@ class SendGridTest_APIKeys extends baseTest $this->assertEquals($code, $response->getStatusCode()); $this->assertEquals($body, $response->getBody()); } + + public function testPOST() + { + $code = 200; + $headers = array('Content-Type' => 'application/json'); + $body = '{ + "api_key": "SG.xxxxxxxx.yyyyyyyy", + "api_key_id": "xxxxxxxx", + "name": "My API Key", + "scopes": [ + "mail.send", + "alerts.create", + "alerts.read" + ] + }'; + $sendgrid = $this->buildClient($code, $headers, $body); + $response = $sendgrid->api_keys->post("My API Key"); + $this->assertEquals($code, $response->getStatusCode()); + $this->assertEquals($body, $response->getBody()); + } + + public function testPATCH() + { + $code = 200; + $headers = array('Content-Type' => 'application/json'); + $body = '{ + "api_key_id": "qfTQ6KG0QBiwWdJ0-pCLCA", + "name": "A New Hope" + }'; + $sendgrid = $this->buildClient($code, $headers, $body); + $response = $sendgrid->api_keys->patch("qfTQ6KG0QBiwWdJ0-pCLCA", "Magic Key Updated"); + $this->assertEquals($code, $response->getStatusCode()); + $this->assertEquals($body, $response->getBody()); + } + + public function testDELETE() + { + $code = 204; + $headers = ''; + $body = ''; + $sendgrid = $this->buildClient($code, $headers, $body); + $response = $sendgrid->api_keys->delete("qfTQ6KG0QBiwWdJ0-pCLCA"); + $this->assertEquals($code, $response->getStatusCode()); + $this->assertEquals($body, $response->getBody()); + } + }
\ No newline at end of file |