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,99 @@
1
+<?php
2
+namespace Telnyx;
3
+
4
+class CollectionTest extends TestCase
5
+{
6
+    /**
7
+     * @before
8
+     */
9
+    public function setUpFixture()
10
+    {
11
+        $this->fixture = Collection::constructFrom([
12
+            'data' => [['id' => 1]],
13
+            'has_more' => true,
14
+            'url' => '/things',
15
+        ]);
16
+    }
17
+
18
+    public function testCanRetrieve()
19
+    {
20
+        $this->stubRequest(
21
+            'GET',
22
+            '/things/1',
23
+            [],
24
+            null,
25
+            false,
26
+            [
27
+                'id' => 1,
28
+            ]
29
+        );
30
+
31
+        $this->fixture->retrieve(1);
32
+    }
33
+
34
+    public function testCanCreate()
35
+    {
36
+        $this->stubRequest(
37
+            'POST',
38
+            '/things',
39
+            [
40
+                'foo' => 'bar',
41
+            ],
42
+            null,
43
+            false,
44
+            [
45
+                'id' => 2,
46
+            ]
47
+        );
48
+
49
+        $this->fixture->create([
50
+            'foo' => 'bar',
51
+        ]);
52
+    }
53
+
54
+    public function testCanIterate()
55
+    {
56
+        $seen = [];
57
+        foreach ($this->fixture as $item) {
58
+            array_push($seen, $item['id']);
59
+        }
60
+
61
+        $this->assertSame([1], $seen);
62
+    }
63
+
64
+    public function testSupportsIteratorToArray()
65
+    {
66
+        $seen = [];
67
+        foreach (iterator_to_array($this->fixture) as $item) {
68
+            array_push($seen, $item['id']);
69
+        }
70
+
71
+        $this->assertSame([1], $seen);
72
+    }
73
+
74
+    public function testHeaders()
75
+    {
76
+        $this->stubRequest(
77
+            'POST',
78
+            '/things',
79
+            [
80
+                'foo' => 'bar',
81
+            ],
82
+            [
83
+                'Telnyx-Account: acct_foo',
84
+                'Idempotency-Key: qwertyuiop',
85
+            ],
86
+            false,
87
+            [
88
+                'id' => 2,
89
+            ]
90
+        );
91
+
92
+        $this->fixture->create([
93
+            'foo' => 'bar',
94
+        ], [
95
+            'telnyx_account' => 'acct_foo',
96
+            'idempotency_key' => 'qwertyuiop',
97
+        ]);
98
+    }
99
+}