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,100 @@
1
+<?php
2
+
3
+namespace Telnyx;
4
+
5
+/**
6
+ * @internal
7
+ * @covers \Telnyx\PhoneNumber
8
+ */
9
+final class PhoneNumberTest extends \Telnyx\TestCase
10
+{
11
+    const TEST_RESOURCE_ID = '123';
12
+
13
+    public function testIsListable()
14
+    {
15
+        $this->expectsRequest(
16
+            'get',
17
+            '/v2/phone_numbers'
18
+        );
19
+        $resources = PhoneNumber::all();
20
+        $this->assertInstanceOf(\Telnyx\Collection::class, $resources);
21
+        $this->assertInstanceOf(\Telnyx\PhoneNumber::class, $resources['data'][0]);
22
+    }
23
+
24
+    public function testIsDeletable()
25
+    {
26
+        $resource = PhoneNumber::retrieve(self::TEST_RESOURCE_ID);
27
+        $this->expectsRequest(
28
+            'delete',
29
+            '/v2/phone_numbers/' . urlencode(self::TEST_RESOURCE_ID)
30
+        );
31
+        $resource->delete();
32
+        $this->assertInstanceOf(\Telnyx\PhoneNumber::class, $resource);
33
+    }
34
+
35
+    public function testIsRetrievable()
36
+    {
37
+        $this->expectsRequest(
38
+            'get',
39
+            '/v2/phone_numbers/' . urlencode(self::TEST_RESOURCE_ID)
40
+        );
41
+        $resource = PhoneNumber::retrieve(self::TEST_RESOURCE_ID);
42
+        $this->assertInstanceOf(\Telnyx\PhoneNumber::class, $resource);
43
+    }
44
+
45
+    public function testIsUpdatable()
46
+    {
47
+        $this->expectsRequest(
48
+            'patch',
49
+            '/v2/phone_numbers/' . urlencode(self::TEST_RESOURCE_ID)
50
+        );
51
+        $resource = PhoneNumber::update(self::TEST_RESOURCE_ID, [
52
+            "name" => "Test",
53
+        ]);
54
+        $this->assertInstanceOf(\Telnyx\PhoneNumber::class, $resource);
55
+    }
56
+
57
+    public function testVoice()
58
+    {
59
+        $phone_number = PhoneNumber::retrieve(self::TEST_RESOURCE_ID);
60
+        $this->expectsRequest(
61
+            'get',
62
+            '/v2/phone_numbers/' . urlencode(self::TEST_RESOURCE_ID) . '/voice'
63
+        );
64
+        $resource = $phone_number->voice();
65
+        $this->assertInstanceOf(\Telnyx\TelnyxObject::class, $resource); // record_type: voice_settings
66
+    }
67
+
68
+    public function testUpdateVoice()
69
+    {
70
+        $phone_number = PhoneNumber::retrieve(self::TEST_RESOURCE_ID);
71
+        $this->expectsRequest(
72
+            'patch',
73
+            '/v2/phone_numbers/' . urlencode(self::TEST_RESOURCE_ID) . '/voice'
74
+        );
75
+        $resource = $phone_number->update_voice();
76
+        $this->assertInstanceOf(\Telnyx\TelnyxObject::class, $resource); // record_type: voice_settings
77
+    }
78
+
79
+    public function testMessaging()
80
+    {
81
+        $phone_number = PhoneNumber::retrieve(self::TEST_RESOURCE_ID);
82
+        $this->expectsRequest(
83
+            'get',
84
+            '/v2/phone_numbers/' . urlencode(self::TEST_RESOURCE_ID) . '/messaging'
85
+        );
86
+        $resource = $phone_number->messaging();
87
+        $this->assertInstanceOf(\Telnyx\TelnyxObject::class, $resource); // record_type: voice_settings
88
+    }
89
+
90
+    public function testUpdateMessaging()
91
+    {
92
+        $phone_number = PhoneNumber::retrieve(self::TEST_RESOURCE_ID);
93
+        $this->expectsRequest(
94
+            'patch',
95
+            '/v2/phone_numbers/' . urlencode(self::TEST_RESOURCE_ID) . '/messaging'
96
+        );
97
+        $resource = $phone_number->update_messaging();
98
+        $this->assertInstanceOf(\Telnyx\TelnyxObject::class, $resource); // record_type: voice_settings
99
+    }
100
+}