Browse code

added appinfo/info.xml appinfo/signature.json CHANGELOG.txt lib/AppInfo/Application.php css/style.css providers/Plivo

DoubleBastionAdmin authored on 05/11/2025 13:35:09
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,132 @@
1
+<?php
2
+
3
+namespace Resources;
4
+
5
+
6
+use Plivo\Http\PlivoRequest;
7
+use Plivo\Http\PlivoResponse;
8
+use Plivo\Tests\BaseTestCase;
9
+
10
+/**
11
+ * Class MaskingSessionlTest
12
+ * @package Resources
13
+ */
14
+class MaskingSessionTest extends BaseTestCase
15
+{
16
+    function testCreateMaskingSession()
17
+    {
18
+        $request = new PlivoRequest(
19
+            'POST',
20
+            'Account/MAXXXXXXXXXXXXXXXXXX/Masking/Session/',
21
+            [
22
+                'first_party' => '919999999999',
23
+                'second_party' => '919999999998'
24
+                
25
+            ]);
26
+        $body = file_get_contents(__DIR__ . '/../Mocks/maskingSessionCreateResponse.json');
27
+
28
+        $this->mock(new PlivoResponse($request,201, $body));
29
+
30
+        $actual = $this->client->maskingSessions->createMaskingSession(
31
+            '919999999999', '919999999998');
32
+
33
+        $this->assertRequest($request);
34
+
35
+        self::assertNotNull($actual);
36
+
37
+        // $actual = json_decode($actual);
38
+
39
+        self::assertEquals($actual->message, "Session created");
40
+        self::assertEquals($actual->apiId, "1c8beb2c-01bf-4649-b0fb-5e3bd7836311");
41
+    }
42
+
43
+    function testUpdateMaskingSession()
44
+    {
45
+        $request = new PlivoRequest(
46
+            'POST',
47
+            'Account/MAXXXXXXXXXXXXXXXXXX/Masking/Session/',
48
+            [
49
+                '4d04c52e-cea3-4458-bbdb-0bfc314ee7cd5',
50
+                array(
51
+                    'call_time_limit' => 1600,
52
+                    'record_file_format' => 'wav'
53
+                )
54
+                
55
+            ]);
56
+        $body = file_get_contents(__DIR__ . '/../Mocks/maskingSessionUpdateResponse.json');
57
+
58
+        $this->mock(new PlivoResponse($request,201, $body));
59
+
60
+        $actual = $this->client->maskingSessions->updateMaskingSession(
61
+            '4d04c52e-cea3-4458-bbdb-0bfc314ee7cd5',
62
+            array('call_time_limit'=>1600,'record_file_format' => 'wav'
63
+                 ));
64
+
65
+        self::assertNotNull($actual);
66
+
67
+        // $actual = json_decode($actual);
68
+
69
+        self::assertEquals($actual->message, "Session updated");
70
+        self::assertEquals($actual->apiId, "b5506536-83d0-498f-929f-4427cb6ca391");
71
+    }
72
+
73
+
74
+    function testDeleteMaskingSession()
75
+    {
76
+        $request = new PlivoRequest(
77
+            'DELETE',
78
+            'Account/MAXXXXXXXXXXXXXXXXXX/Masking/Session/4d04c52e-cea3-4458-bbdb-0bfc314ee7cd5',
79
+            []);
80
+        $body = file_get_contents(__DIR__ . '/../Mocks/maskingSessionDeleteResponse.json');
81
+
82
+        $this->mock(new PlivoResponse($request,204, $body));
83
+
84
+        $actual = $this->client->maskingSessions->deleteMaskingSession("4d04c52e-cea3-4458-bbdb-0bfc314ee7cd5");;
85
+
86
+        self::assertNotNull($actual);
87
+    }
88
+
89
+
90
+    function testGetMaskingSession()
91
+    {
92
+        $request = new PlivoRequest(
93
+            'GET',
94
+            'Account/MAXXXXXXXXXXXXXXXXXX/Masking/Session/4d04c52e-cea3-4458-bbdb-0bfc314ee7cd5/',
95
+            []);
96
+        $body = file_get_contents(__DIR__ . '/../Mocks/maskingSessionGetResponse.json');
97
+
98
+        $this->mock(new PlivoResponse($request,200, $body));
99
+
100
+        $actual = $this->client->maskingSessions->getMaskingSession("4d04c52e-cea3-4458-bbdb-0bfc314ee7cd5");
101
+
102
+        $this->assertRequest($request);
103
+
104
+        self::assertNotNull($actual);
105
+
106
+        self::assertEquals($actual->getId(), "4d04c52e-cea3-4458-bbdb-0bfc314ee7cd5");
107
+    }
108
+
109
+    function testListMaskingSession()
110
+    {
111
+        $request = new PlivoRequest(
112
+            'GET',
113
+            'Account/MAXXXXXXXXXXXXXXXXXX/Masking/Session/',
114
+            [
115
+                array('first_party'=>'916361728680',
116
+                    'second_party' => '917708772011'
117
+            )]);
118
+        $body = file_get_contents(__DIR__ . '/../Mocks/maskingSessionListResponse.json');
119
+
120
+        $this->mock(new PlivoResponse($request,200, $body));
121
+
122
+        $actual = $this->client->maskingSessions->listMaskingSession(array('first_party'=>'916361728680',
123
+        'second_party' => '917708772011'));
124
+
125
+        self::assertNotNull($actual);
126
+
127
+        self::assertEquals($actual->meta, array('total_count'=>2, 'limit'=>20, 'next'=>null, 'offset'=>0, 'previous'=>null));
128
+    }
129
+
130
+    
131
+    
132
+}