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,161 @@
1
+<?php
2
+
3
+namespace Telnyx;
4
+
5
+/**
6
+ * @internal
7
+ * @covers \Telnyx\Conference
8
+ */
9
+final class ConferenceTest extends \Telnyx\TestCase
10
+{
11
+    const TEST_RESOURCE_ID = '123';
12
+    const TEST_CALL_CONTROL_ID = '891510ac-f3e4-11e8-af5b-de00688a4931';
13
+
14
+    public function testIsListable()
15
+    {
16
+        $this->expectsRequest(
17
+            'get',
18
+            '/v2/conferences'
19
+        );
20
+        $resources = Conference::all();
21
+        $this->assertInstanceOf(\Telnyx\Collection::class, $resources);
22
+        $this->assertInstanceOf(\Telnyx\Conference::class, $resources['data'][0]);
23
+    }
24
+
25
+    public function testIsCreatable()
26
+    {
27
+        $this->expectsRequest(
28
+            'post',
29
+            '/v2/conferences'
30
+        );
31
+        $resource = Conference::create([
32
+            "name" => "Business",
33
+            "call_control_id" => self::TEST_CALL_CONTROL_ID
34
+        ]);
35
+        $this->assertInstanceOf(\Telnyx\Conference::class, $resource);
36
+    }
37
+
38
+    public function testIsRetrievable()
39
+    {
40
+        $this->expectsRequest(
41
+            'get',
42
+            '/v2/conferences/' . urlencode(self::TEST_RESOURCE_ID)
43
+        );
44
+        $resource = Conference::retrieve(self::TEST_RESOURCE_ID);
45
+        $this->assertInstanceOf(\Telnyx\Conference::class, $resource);
46
+    }
47
+
48
+    public function testJoin()
49
+    {
50
+        $conference = Conference::retrieve(self::TEST_RESOURCE_ID);
51
+
52
+        $this->expectsRequest(
53
+            'post',
54
+            '/v2/conferences/' . urlencode(self::TEST_RESOURCE_ID) . '/actions/join'
55
+        );
56
+        $resource = $conference->join([
57
+            'call_control_id' => self::TEST_CALL_CONTROL_ID
58
+        ]);
59
+        $this->assertInstanceOf(\Telnyx\TelnyxObject::class, $resource);
60
+    }
61
+    
62
+    public function testMute()
63
+    {
64
+        $conference = Conference::retrieve(self::TEST_RESOURCE_ID);
65
+
66
+        $this->expectsRequest(
67
+            'post',
68
+            '/v2/conferences/' . urlencode(self::TEST_RESOURCE_ID) . '/actions/mute'
69
+        );
70
+        $resource = $conference->mute([
71
+            'call_control_ids' => [self::TEST_CALL_CONTROL_ID]
72
+        ]);
73
+        $this->assertInstanceOf(\Telnyx\TelnyxObject::class, $resource);
74
+    }
75
+    
76
+    public function testUnute()
77
+    {
78
+        $conference = Conference::retrieve(self::TEST_RESOURCE_ID);
79
+
80
+        $this->expectsRequest(
81
+            'post',
82
+            '/v2/conferences/' . urlencode(self::TEST_RESOURCE_ID) . '/actions/unmute'
83
+        );
84
+        $resource = $conference->unmute([
85
+            'call_control_ids' => [self::TEST_CALL_CONTROL_ID]
86
+        ]);
87
+        $this->assertInstanceOf(\Telnyx\TelnyxObject::class, $resource);
88
+    }
89
+    
90
+    public function testHold()
91
+    {
92
+        $conference = Conference::retrieve(self::TEST_RESOURCE_ID);
93
+
94
+        $this->expectsRequest(
95
+            'post',
96
+            '/v2/conferences/' . urlencode(self::TEST_RESOURCE_ID) . '/actions/hold'
97
+        );
98
+        $resource = $conference->hold([
99
+            'audio_url' => 'http://example.com/message.wav',
100
+            'call_control_ids' => [self::TEST_CALL_CONTROL_ID]
101
+        ]);
102
+        $this->assertInstanceOf(\Telnyx\TelnyxObject::class, $resource);
103
+    }
104
+    
105
+    public function testUnhold()
106
+    {
107
+        $conference = Conference::retrieve(self::TEST_RESOURCE_ID);
108
+
109
+        $this->expectsRequest(
110
+            'post',
111
+            '/v2/conferences/' . urlencode(self::TEST_RESOURCE_ID) . '/actions/unhold'
112
+        );
113
+        $resource = $conference->unhold([
114
+            'call_control_ids' => [self::TEST_CALL_CONTROL_ID]
115
+        ]);
116
+        $this->assertInstanceOf(\Telnyx\TelnyxObject::class, $resource);
117
+    }
118
+    
119
+    public function testParticipants()
120
+    {
121
+        $conference = Conference::retrieve(self::TEST_RESOURCE_ID);
122
+
123
+        $this->expectsRequest(
124
+            'get',
125
+            '/v2/conferences/' . urlencode(self::TEST_RESOURCE_ID) . '/participants'
126
+        );
127
+        $resources = $conference->participants();
128
+        $this->assertInstanceOf(\Telnyx\Conference::class, $resources);
129
+    }
130
+
131
+    /*
132
+    public function testDialParticipant()
133
+    {
134
+        $conference = Conference::retrieve(self::TEST_RESOURCE_ID);
135
+
136
+        $this->expectsRequest(
137
+            'post',
138
+            '/v2/conferences/' . urlencode(self::TEST_RESOURCE_ID) . '/actions/dial_participant'
139
+        );
140
+        $resource = $conference->dial_participant();
141
+        $this->assertInstanceOf(\Telnyx\TelnyxObject::class, $resource);
142
+    }
143
+    */
144
+    
145
+    public function testSpeak()
146
+    {
147
+        $conference = Conference::retrieve(self::TEST_RESOURCE_ID);
148
+
149
+        $this->expectsRequest(
150
+            'post',
151
+            '/v2/conferences/' . urlencode(self::TEST_RESOURCE_ID) . '/actions/speak'
152
+        );
153
+        $resource = $conference->speak([
154
+            'language' => 'en-US',
155
+            'payload' => 'Say this to participants',
156
+            'voice' => 'female'
157
+        ]);
158
+        $this->assertInstanceOf(\Telnyx\TelnyxObject::class, $resource);
159
+    }
160
+
161
+}