| 1 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,110 +0,0 @@ |
| 1 |
-<?php |
|
| 2 |
- |
|
| 3 |
-namespace Resources; |
|
| 4 |
- |
|
| 5 |
- |
|
| 6 |
-use Plivo\Http\PlivoRequest; |
|
| 7 |
-use Plivo\Http\PlivoResponse; |
|
| 8 |
-use Plivo\Tests\BaseTestCase; |
|
| 9 |
- |
|
| 10 |
-/** |
|
| 11 |
- * Class EndpointTest |
|
| 12 |
- * @package Resources |
|
| 13 |
- */ |
|
| 14 |
-class EndpointTest extends BaseTestCase |
|
| 15 |
-{
|
|
| 16 |
- function testEndpointCreate() |
|
| 17 |
- {
|
|
| 18 |
- $request = new PlivoRequest( |
|
| 19 |
- 'POST', |
|
| 20 |
- 'Account/MAXXXXXXXXXXXXXXXXXX/Endpoint/', |
|
| 21 |
- [ |
|
| 22 |
- "username" => "carter", |
|
| 23 |
- "password" => "retrac", |
|
| 24 |
- "alias" => "mario" |
|
| 25 |
- ]); |
|
| 26 |
- $body = file_get_contents(__DIR__ . '/../Mocks/endpointCreateResponse.json'); |
|
| 27 |
- |
|
| 28 |
- $this->mock(new PlivoResponse($request,201, $body)); |
|
| 29 |
- |
|
| 30 |
- $actual = $this->client->endpoints->create( |
|
| 31 |
- "carter", "retrac", "mario" |
|
| 32 |
- ); |
|
| 33 |
- |
|
| 34 |
- $this->assertRequest($request); |
|
| 35 |
- |
|
| 36 |
- self::assertNotNull($actual); |
|
| 37 |
- } |
|
| 38 |
- |
|
| 39 |
- function testEndpointGet() |
|
| 40 |
- {
|
|
| 41 |
- $endpoint = "lalalala"; |
|
| 42 |
- $request = new PlivoRequest( |
|
| 43 |
- 'GET', |
|
| 44 |
- 'Account/MAXXXXXXXXXXXXXXXXXX/Endpoint/' . $endpoint . '/', |
|
| 45 |
- []); |
|
| 46 |
- $body = file_get_contents(__DIR__ . '/../Mocks/endpointGetResponse.json'); |
|
| 47 |
- |
|
| 48 |
- $this->mock(new PlivoResponse($request,200, $body)); |
|
| 49 |
- |
|
| 50 |
- $actual = $this->client->endpoints->get($endpoint); |
|
| 51 |
- |
|
| 52 |
- $this->assertRequest($request); |
|
| 53 |
- |
|
| 54 |
- self::assertNotNull($actual); |
|
| 55 |
- } |
|
| 56 |
- |
|
| 57 |
- function testEndpointList() |
|
| 58 |
- {
|
|
| 59 |
- $request = new PlivoRequest( |
|
| 60 |
- 'Get', |
|
| 61 |
- 'Account/MAXXXXXXXXXXXXXXXXXX/Endpoint/', |
|
| 62 |
- []); |
|
| 63 |
- $body = file_get_contents(__DIR__ . '/../Mocks/endpointListResponse.json'); |
|
| 64 |
- |
|
| 65 |
- $this->mock(new PlivoResponse($request,202, $body)); |
|
| 66 |
- |
|
| 67 |
- $actual = $this->client->endpoints->list; |
|
| 68 |
- |
|
| 69 |
- $this->assertRequest($request); |
|
| 70 |
- |
|
| 71 |
- self::assertNotNull($actual); |
|
| 72 |
- } |
|
| 73 |
- |
|
| 74 |
- function testEndpointUpdate() |
|
| 75 |
- {
|
|
| 76 |
- $request = new PlivoRequest( |
|
| 77 |
- 'POST', |
|
| 78 |
- 'Account/MAXXXXXXXXXXXXXXXXXX/Endpoint/carter/', |
|
| 79 |
- [ |
|
| 80 |
- "alias" => "hahaha" |
|
| 81 |
- ]); |
|
| 82 |
- $body = file_get_contents(__DIR__ . '/../Mocks/endpointUpdateResponse.json'); |
|
| 83 |
- |
|
| 84 |
- $this->mock(new PlivoResponse($request,200, $body)); |
|
| 85 |
- |
|
| 86 |
- $actual = $this->client->endpoints->update( |
|
| 87 |
- "carter", ['alias' => 'hahaha']); |
|
| 88 |
- |
|
| 89 |
- $this->assertRequest($request); |
|
| 90 |
- |
|
| 91 |
- self::assertNotNull($actual); |
|
| 92 |
- } |
|
| 93 |
- |
|
| 94 |
- function testEndpointDelete() |
|
| 95 |
- {
|
|
| 96 |
- $request = new PlivoRequest( |
|
| 97 |
- 'DELETE', |
|
| 98 |
- 'Account/MAXXXXXXXXXXXXXXXXXX/Endpoint/cxcxcx/', |
|
| 99 |
- []); |
|
| 100 |
- $body = '{}';
|
|
| 101 |
- |
|
| 102 |
- $this->mock(new PlivoResponse($request,200, $body)); |
|
| 103 |
- |
|
| 104 |
- $actual = $this->client->endpoints->delete("cxcxcx");
|
|
| 105 |
- |
|
| 106 |
- $this->assertRequest($request); |
|
| 107 |
- |
|
| 108 |
- self::assertNull($actual); |
|
| 109 |
- } |
|
| 110 |
-} |
|
| 111 | 0 |
\ No newline at end of file |
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,110 @@ |
| 1 |
+<?php |
|
| 2 |
+ |
|
| 3 |
+namespace Resources; |
|
| 4 |
+ |
|
| 5 |
+ |
|
| 6 |
+use Plivo\Http\PlivoRequest; |
|
| 7 |
+use Plivo\Http\PlivoResponse; |
|
| 8 |
+use Plivo\Tests\BaseTestCase; |
|
| 9 |
+ |
|
| 10 |
+/** |
|
| 11 |
+ * Class EndpointTest |
|
| 12 |
+ * @package Resources |
|
| 13 |
+ */ |
|
| 14 |
+class EndpointTest extends BaseTestCase |
|
| 15 |
+{
|
|
| 16 |
+ function testEndpointCreate() |
|
| 17 |
+ {
|
|
| 18 |
+ $request = new PlivoRequest( |
|
| 19 |
+ 'POST', |
|
| 20 |
+ 'Account/MAXXXXXXXXXXXXXXXXXX/Endpoint/', |
|
| 21 |
+ [ |
|
| 22 |
+ "username" => "carter", |
|
| 23 |
+ "password" => "retrac", |
|
| 24 |
+ "alias" => "mario" |
|
| 25 |
+ ]); |
|
| 26 |
+ $body = file_get_contents(__DIR__ . '/../Mocks/endpointCreateResponse.json'); |
|
| 27 |
+ |
|
| 28 |
+ $this->mock(new PlivoResponse($request,201, $body)); |
|
| 29 |
+ |
|
| 30 |
+ $actual = $this->client->endpoints->create( |
|
| 31 |
+ "carter", "retrac", "mario" |
|
| 32 |
+ ); |
|
| 33 |
+ |
|
| 34 |
+ $this->assertRequest($request); |
|
| 35 |
+ |
|
| 36 |
+ self::assertNotNull($actual); |
|
| 37 |
+ } |
|
| 38 |
+ |
|
| 39 |
+ function testEndpointGet() |
|
| 40 |
+ {
|
|
| 41 |
+ $endpoint = "lalalala"; |
|
| 42 |
+ $request = new PlivoRequest( |
|
| 43 |
+ 'GET', |
|
| 44 |
+ 'Account/MAXXXXXXXXXXXXXXXXXX/Endpoint/' . $endpoint . '/', |
|
| 45 |
+ []); |
|
| 46 |
+ $body = file_get_contents(__DIR__ . '/../Mocks/endpointGetResponse.json'); |
|
| 47 |
+ |
|
| 48 |
+ $this->mock(new PlivoResponse($request,200, $body)); |
|
| 49 |
+ |
|
| 50 |
+ $actual = $this->client->endpoints->get($endpoint); |
|
| 51 |
+ |
|
| 52 |
+ $this->assertRequest($request); |
|
| 53 |
+ |
|
| 54 |
+ self::assertNotNull($actual); |
|
| 55 |
+ } |
|
| 56 |
+ |
|
| 57 |
+ function testEndpointList() |
|
| 58 |
+ {
|
|
| 59 |
+ $request = new PlivoRequest( |
|
| 60 |
+ 'Get', |
|
| 61 |
+ 'Account/MAXXXXXXXXXXXXXXXXXX/Endpoint/', |
|
| 62 |
+ []); |
|
| 63 |
+ $body = file_get_contents(__DIR__ . '/../Mocks/endpointListResponse.json'); |
|
| 64 |
+ |
|
| 65 |
+ $this->mock(new PlivoResponse($request,202, $body)); |
|
| 66 |
+ |
|
| 67 |
+ $actual = $this->client->endpoints->list; |
|
| 68 |
+ |
|
| 69 |
+ $this->assertRequest($request); |
|
| 70 |
+ |
|
| 71 |
+ self::assertNotNull($actual); |
|
| 72 |
+ } |
|
| 73 |
+ |
|
| 74 |
+ function testEndpointUpdate() |
|
| 75 |
+ {
|
|
| 76 |
+ $request = new PlivoRequest( |
|
| 77 |
+ 'POST', |
|
| 78 |
+ 'Account/MAXXXXXXXXXXXXXXXXXX/Endpoint/carter/', |
|
| 79 |
+ [ |
|
| 80 |
+ "alias" => "hahaha" |
|
| 81 |
+ ]); |
|
| 82 |
+ $body = file_get_contents(__DIR__ . '/../Mocks/endpointUpdateResponse.json'); |
|
| 83 |
+ |
|
| 84 |
+ $this->mock(new PlivoResponse($request,200, $body)); |
|
| 85 |
+ |
|
| 86 |
+ $actual = $this->client->endpoints->update( |
|
| 87 |
+ "carter", ['alias' => 'hahaha']); |
|
| 88 |
+ |
|
| 89 |
+ $this->assertRequest($request); |
|
| 90 |
+ |
|
| 91 |
+ self::assertNotNull($actual); |
|
| 92 |
+ } |
|
| 93 |
+ |
|
| 94 |
+ function testEndpointDelete() |
|
| 95 |
+ {
|
|
| 96 |
+ $request = new PlivoRequest( |
|
| 97 |
+ 'DELETE', |
|
| 98 |
+ 'Account/MAXXXXXXXXXXXXXXXXXX/Endpoint/cxcxcx/', |
|
| 99 |
+ []); |
|
| 100 |
+ $body = '{}';
|
|
| 101 |
+ |
|
| 102 |
+ $this->mock(new PlivoResponse($request,200, $body)); |
|
| 103 |
+ |
|
| 104 |
+ $actual = $this->client->endpoints->delete("cxcxcx");
|
|
| 105 |
+ |
|
| 106 |
+ $this->assertRequest($request); |
|
| 107 |
+ |
|
| 108 |
+ self::assertNull($actual); |
|
| 109 |
+ } |
|
| 110 |
+} |
|
| 0 | 111 |
\ No newline at end of file |