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,350 @@
1
+<?php
2
+
3
+namespace Telnyx;
4
+
5
+/**
6
+ * @internal
7
+ * @covers \Telnyx\Call
8
+ */
9
+final class CallTest extends \Telnyx\TestCase
10
+{
11
+    const CALL_CONTROL_ID = 'v2:T02llQxIyaRkhfRKxgAP8nY511EhFLizdvdUKJiSw8d6A9BborherQ';
12
+
13
+    public function testIsCreatable()
14
+    {
15
+        $this->expectsRequest(
16
+            'post',
17
+            '/v2/calls'
18
+        );
19
+        $resource = Call::create([
20
+            'connection_id' => 'uuid',
21
+            'to' => '+18005550199',
22
+            'from' => '+18005550100'
23
+        ]);
24
+        $this->assertInstanceOf(\Telnyx\Call::class, $resource);
25
+    }
26
+
27
+    public function testIsRetrievable()
28
+    {
29
+        $this->expectsRequest(
30
+            'get',
31
+            '/v2/calls/' . urlencode(self::CALL_CONTROL_ID)
32
+        );
33
+        $resource = Call::retrieve(self::CALL_CONTROL_ID);
34
+        $this->assertInstanceOf(\Telnyx\Call::class, $resource);
35
+    }
36
+
37
+    public function testAnswer()
38
+    {
39
+        $call = Call::retrieve(self::CALL_CONTROL_ID);
40
+
41
+        $this->expectsRequest(
42
+            'post',
43
+            '/v2/calls/' . urlencode(self::CALL_CONTROL_ID) . '/actions/answer'
44
+        );
45
+        $resource = $call->answer([
46
+            'client_state' => 'aGF2ZSBhIG5pY2UgZGF5ID1d'
47
+        ]);
48
+        $this->assertInstanceOf(\Telnyx\TelnyxObject::class, $resource);
49
+    }
50
+
51
+    public function testBridge()
52
+    {
53
+        $call = new Call(self::CALL_CONTROL_ID);
54
+
55
+        $this->expectsRequest(
56
+            'post',
57
+            '/v2/calls/' . urlencode(self::CALL_CONTROL_ID) . '/actions/bridge'
58
+        );
59
+        $resource = $call->bridge([
60
+            'call_control_id' => self::CALL_CONTROL_ID
61
+        ]);
62
+        $this->assertInstanceOf(\Telnyx\TelnyxObject::class, $resource);
63
+    }
64
+
65
+    public function testForkStart()
66
+    {
67
+        $call = Call::retrieve(self::CALL_CONTROL_ID);
68
+
69
+        $this->expectsRequest(
70
+            'post',
71
+            '/v2/calls/' . urlencode(self::CALL_CONTROL_ID) . '/actions/fork_start'
72
+        );
73
+        $resource = $call->fork_start([
74
+            'client_state' => 'aGF2ZSBhIG5pY2UgZGF5ID1d'
75
+        ]);
76
+        $this->assertInstanceOf(\Telnyx\TelnyxObject::class, $resource);
77
+    }
78
+
79
+    public function testForkStop()
80
+    {
81
+        $call = Call::retrieve(self::CALL_CONTROL_ID);
82
+
83
+        $this->expectsRequest(
84
+            'post',
85
+            '/v2/calls/' . urlencode(self::CALL_CONTROL_ID) . '/actions/fork_stop'
86
+        );
87
+        $resource = $call->fork_stop([
88
+            'client_state' => 'aGF2ZSBhIG5pY2UgZGF5ID1d'
89
+        ]);
90
+        $this->assertInstanceOf(\Telnyx\TelnyxObject::class, $resource);
91
+    }
92
+
93
+    public function testGatherUsingAudio()
94
+    {
95
+        $call = new Call(self::CALL_CONTROL_ID);
96
+
97
+        $this->expectsRequest(
98
+            'post',
99
+            '/v2/calls/' . urlencode(self::CALL_CONTROL_ID) . '/actions/gather_using_audio'
100
+        );
101
+        $resource = $call->gather_using_audio([
102
+            'audio_url' => 'http://example.com/message.wav'
103
+        ]);
104
+        $this->assertInstanceOf(\Telnyx\TelnyxObject::class, $resource);
105
+    }
106
+
107
+    public function testGatherUsingSpeak()
108
+    {
109
+        $call = new Call(self::CALL_CONTROL_ID);
110
+
111
+        $this->expectsRequest(
112
+            'post',
113
+            '/v2/calls/' . urlencode(self::CALL_CONTROL_ID) . '/actions/gather_using_speak'
114
+        );
115
+        $resource = $call->gather_using_speak([
116
+            'language' => 'en-US',
117
+            'voice' => 'female',
118
+            'payload' => 'Telnyx call control test'
119
+        ]);
120
+        $this->assertInstanceOf(\Telnyx\TelnyxObject::class, $resource);
121
+    }
122
+
123
+    public function testHangup()
124
+    {
125
+        $call = new Call(self::CALL_CONTROL_ID);
126
+
127
+        $this->expectsRequest(
128
+            'post',
129
+            '/v2/calls/' . urlencode(self::CALL_CONTROL_ID) . '/actions/hangup'
130
+        );
131
+        $resource = $call->hangup([
132
+            'client_state' => 'aGF2ZSBhIG5pY2UgZGF5ID1d'
133
+        ]);
134
+        $this->assertInstanceOf(\Telnyx\TelnyxObject::class, $resource);
135
+    }
136
+
137
+    public function testPlaybackStart()
138
+    {
139
+        $call = new Call(self::CALL_CONTROL_ID);
140
+
141
+        $this->expectsRequest(
142
+            'post',
143
+            '/v2/calls/' . urlencode(self::CALL_CONTROL_ID) . '/actions/playback_start'
144
+        );
145
+        $resource = $call->playback_start([
146
+            'audio_url' => 'http://www.example.com/sounds/greeting.wav'
147
+        ]);
148
+        $this->assertInstanceOf(\Telnyx\TelnyxObject::class, $resource);
149
+    }
150
+
151
+    public function testPlaybackStop()
152
+    {
153
+        $call = new Call(self::CALL_CONTROL_ID);
154
+
155
+        $this->expectsRequest(
156
+            'post',
157
+            '/v2/calls/' . urlencode(self::CALL_CONTROL_ID) . '/actions/playback_stop'
158
+        );
159
+        $resource = $call->playback_stop([
160
+            'client_state' => 'aGF2ZSBhIG5pY2UgZGF5ID1d'
161
+        ]);
162
+        $this->assertInstanceOf(\Telnyx\TelnyxObject::class, $resource);
163
+    }
164
+
165
+    public function testRecordStart()
166
+    {
167
+        $call = new Call(self::CALL_CONTROL_ID);
168
+
169
+        $this->expectsRequest(
170
+            'post',
171
+            '/v2/calls/' . urlencode(self::CALL_CONTROL_ID) . '/actions/record_start'
172
+        );
173
+        $resource = $call->record_start([
174
+            'channels' => 'single',
175
+            'format' => 'mp3'
176
+        ]);
177
+        $this->assertInstanceOf(\Telnyx\TelnyxObject::class, $resource);
178
+    }
179
+
180
+    public function testRecordStop()
181
+    {
182
+        $call = new Call(self::CALL_CONTROL_ID);
183
+
184
+        $this->expectsRequest(
185
+            'post',
186
+            '/v2/calls/' . urlencode(self::CALL_CONTROL_ID) . '/actions/record_stop'
187
+        );
188
+        $resource = $call->record_stop([
189
+            'client_state' => 'aGF2ZSBhIG5pY2UgZGF5ID1d'
190
+        ]);
191
+        $this->assertInstanceOf(\Telnyx\TelnyxObject::class, $resource);
192
+    }
193
+
194
+    public function testReject()
195
+    {
196
+        $call = new Call(self::CALL_CONTROL_ID);
197
+
198
+        $this->expectsRequest(
199
+            'post',
200
+            '/v2/calls/' . urlencode(self::CALL_CONTROL_ID) . '/actions/reject'
201
+        );
202
+        $resource = $call->reject([
203
+            'cause' => 'USER_BUSY'
204
+        ]);
205
+        $this->assertInstanceOf(\Telnyx\TelnyxObject::class, $resource);
206
+    }
207
+
208
+    public function testSendDTMF()
209
+    {
210
+        $call = new Call(self::CALL_CONTROL_ID);
211
+
212
+        $this->expectsRequest(
213
+            'post',
214
+            '/v2/calls/' . urlencode(self::CALL_CONTROL_ID) . '/actions/send_dtmf'
215
+        );
216
+        $resource = $call->send_dtmf(['digits' => '1www2WABCDw9']);
217
+        $this->assertInstanceOf(\Telnyx\TelnyxObject::class, $resource);
218
+    }
219
+
220
+    public function testSpeak()
221
+    {
222
+        $call = new Call(self::CALL_CONTROL_ID);
223
+
224
+        $this->expectsRequest(
225
+            'post',
226
+            '/v2/calls/' . urlencode(self::CALL_CONTROL_ID) . '/actions/speak'
227
+        );
228
+        $resource = $call->speak([
229
+            'digits' => '1www2WABCDw9',
230
+            'language' => 'en-US',
231
+            'voice' => 'female',
232
+            'payload' => 'Say this on the call'
233
+        ]);
234
+        $this->assertInstanceOf(\Telnyx\TelnyxObject::class, $resource);
235
+    }
236
+
237
+    public function testTranscriptionStart()
238
+    {
239
+        $call = new Call(self::CALL_CONTROL_ID);
240
+
241
+        $this->expectsRequest(
242
+            'post',
243
+            '/v2/calls/' . urlencode(self::CALL_CONTROL_ID) . '/actions/transcription_start'
244
+        );
245
+        $resource = $call->transcription_start([
246
+            'client_state' => 'aGF2ZSBhIG5pY2UgZGF5ID1d'
247
+        ]);
248
+        $this->assertInstanceOf(\Telnyx\TelnyxObject::class, $resource);
249
+    }
250
+
251
+    public function testTranscriptionStop()
252
+    {
253
+        $call = new Call(self::CALL_CONTROL_ID);
254
+
255
+        $this->expectsRequest(
256
+            'post',
257
+            '/v2/calls/' . urlencode(self::CALL_CONTROL_ID) . '/actions/transcription_stop'
258
+        );
259
+        $resource = $call->transcription_stop([
260
+            'client_state' => 'aGF2ZSBhIG5pY2UgZGF5ID1d'
261
+        ]);
262
+        $this->assertInstanceOf(\Telnyx\TelnyxObject::class, $resource);
263
+    }
264
+
265
+    public function testRecordPause()
266
+    {
267
+        $call = new Call(self::CALL_CONTROL_ID);
268
+
269
+        $this->expectsRequest(
270
+            'post',
271
+            '/v2/calls/' . urlencode(self::CALL_CONTROL_ID) . '/actions/record_pause'
272
+        );
273
+        $resource = $call->record_pause([
274
+            'client_state' => 'aGF2ZSBhIG5pY2UgZGF5ID1d'
275
+        ]);
276
+        $this->assertInstanceOf(\Telnyx\TelnyxObject::class, $resource);
277
+    }
278
+
279
+    public function testRecordResume()
280
+    {
281
+        $call = new Call(self::CALL_CONTROL_ID);
282
+
283
+        $this->expectsRequest(
284
+            'post',
285
+            '/v2/calls/' . urlencode(self::CALL_CONTROL_ID) . '/actions/record_resume'
286
+        );
287
+        $resource = $call->record_resume([
288
+            'client_state' => 'aGF2ZSBhIG5pY2UgZGF5ID1d'
289
+        ]);
290
+        $this->assertInstanceOf(\Telnyx\TelnyxObject::class, $resource);
291
+    }
292
+
293
+    public function testGatherStop()
294
+    {
295
+        $call = new Call(self::CALL_CONTROL_ID);
296
+
297
+        $this->expectsRequest(
298
+            'post',
299
+            '/v2/calls/' . urlencode(self::CALL_CONTROL_ID) . '/actions/gather_stop'
300
+        );
301
+        $resource = $call->gather_stop([
302
+            'client_state' => 'aGF2ZSBhIG5pY2UgZGF5ID1d'
303
+        ]);
304
+        $this->assertInstanceOf(\Telnyx\TelnyxObject::class, $resource);
305
+    }
306
+
307
+    public function testRefer()
308
+    {
309
+        $call = new Call(self::CALL_CONTROL_ID);
310
+
311
+        $this->expectsRequest(
312
+            'post',
313
+            '/v2/calls/' . urlencode(self::CALL_CONTROL_ID) . '/actions/refer'
314
+        );
315
+        $resource = $call->refer([
316
+            'sip_address' => 'sip:username@sip.non-telnyx-address.com'
317
+        ]);
318
+        $this->assertInstanceOf(\Telnyx\TelnyxObject::class, $resource);
319
+    }
320
+
321
+    public function testEnqueue()
322
+    {
323
+        $call = new Call(self::CALL_CONTROL_ID);
324
+
325
+        $this->expectsRequest(
326
+            'post',
327
+            '/v2/calls/' . urlencode(self::CALL_CONTROL_ID) . '/actions/enqueue'
328
+        );
329
+        $resource = $call->enqueue([
330
+            'client_state' => 'aGF2ZSBhIG5pY2UgZGF5ID1d',
331
+            'command_id' => '891510ac-f3e4-11e8-af5b-de00688a4901'
332
+        ]);
333
+        $this->assertInstanceOf(\Telnyx\TelnyxObject::class, $resource);
334
+    }
335
+
336
+    public function testLeaveQueue()
337
+    {
338
+        $call = new Call(self::CALL_CONTROL_ID);
339
+
340
+        $this->expectsRequest(
341
+            'post',
342
+            '/v2/calls/' . urlencode(self::CALL_CONTROL_ID) . '/actions/leave_queue'
343
+        );
344
+        $resource = $call->leave_queue([
345
+            'client_state' => 'aGF2ZSBhIG5pY2UgZGF5ID1d',
346
+            'command_id' => '891510ac-f3e4-11e8-af5b-de00688a4901'
347
+        ]);
348
+        $this->assertInstanceOf(\Telnyx\TelnyxObject::class, $resource);
349
+    }
350
+}