| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,45 @@ |
| 1 |
+<?php |
|
| 2 |
+ |
|
| 3 |
+namespace Telnyx; |
|
| 4 |
+ |
|
| 5 |
+/** |
|
| 6 |
+ * @internal |
|
| 7 |
+ * @covers \Telnyx\ApiOperations\Request |
|
| 8 |
+ */ |
|
| 9 |
+ |
|
| 10 |
+class DummyRequest extends ApiResource |
|
| 11 |
+{
|
|
| 12 |
+ const OBJECT_NAME = 'phone_number'; |
|
| 13 |
+ |
|
| 14 |
+ use \Telnyx\ApiOperations\Request; |
|
| 15 |
+ |
|
| 16 |
+ public static function fail() {
|
|
| 17 |
+ DummyRequest::_validateParams('throw_error');
|
|
| 18 |
+ } |
|
| 19 |
+} |
|
| 20 |
+ |
|
| 21 |
+final class RequestTest extends \Telnyx\TestCase |
|
| 22 |
+{
|
|
| 23 |
+ const TEST_RESOURCE_ID = '1293384261075731499'; |
|
| 24 |
+ |
|
| 25 |
+ public function testTrait() |
|
| 26 |
+ {
|
|
| 27 |
+ try {
|
|
| 28 |
+ $result = DummyRequest::fail(); |
|
| 29 |
+ static::fail('Did not raise error');
|
|
| 30 |
+ } catch (\Telnyx\Exception\InvalidArgumentException $e) {
|
|
| 31 |
+ |
|
| 32 |
+ $message = "You must pass an array as the first argument to Telnyx API " |
|
| 33 |
+ . "method calls. (HINT: an example call to create a call " |
|
| 34 |
+ . "would be: \"Telnyx\\Call::create(['connection_id' => 'uuid', 'to'" |
|
| 35 |
+ . "=> '+18005550199', 'from' => '+18005550100'])\")"; |
|
| 36 |
+ |
|
| 37 |
+ static::assertSame( |
|
| 38 |
+ $message, |
|
| 39 |
+ $e->getMessage() |
|
| 40 |
+ ); |
|
| 41 |
+ } catch (\Exception $e) {
|
|
| 42 |
+ static::fail('Unexpected exception: ' . \get_class($e));
|
|
| 43 |
+ } |
|
| 44 |
+ } |
|
| 45 |
+} |