Browse code

Added README.md appinfo/info.xml appinfo/signature.json lib/Controller/AuthorApiController.php and the providers directory

DoubleBastionAdmin authored on 20/08/2022 16:33:00
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,48 @@
1
+<?php
2
+
3
+namespace Telnyx;
4
+
5
+/**
6
+ * @internal
7
+ * @covers \Telnyx\ApiOperations\All
8
+ */
9
+
10
+class DummyAll extends ApiResource
11
+{
12
+    const OBJECT_NAME = 'phone_number';
13
+
14
+    use \Telnyx\ApiOperations\All;
15
+}
16
+class DummyInvalidAll extends ApiResource
17
+{
18
+    const OBJECT_NAME = 'balance';
19
+
20
+    use \Telnyx\ApiOperations\All;
21
+
22
+    public static function classUrl() {
23
+        return '/v2/balance';
24
+    }
25
+}
26
+
27
+final class AllTest extends \Telnyx\TestCase
28
+{
29
+    public function testTrait()
30
+    {
31
+        $result = DummyAll::all();
32
+        $this->assertInstanceOf(\Telnyx\Collection::class, $result);
33
+    }
34
+    public function testTraitInvalid()
35
+    {
36
+        try {
37
+            $result = DummyInvalidAll::all();
38
+            static::fail('Did not raise error');
39
+        } catch (\Telnyx\Exception\UnexpectedValueException $e) {
40
+            static::assertSame(
41
+                'Expected type ' . \Telnyx\Collection::class . ', got "Telnyx\Balance" instead.',
42
+                $e->getMessage()
43
+            );
44
+        } catch (\Exception $e) {
45
+            static::fail('Unexpected exception: ' . \get_class($e));
46
+        }
47
+    }
48
+}