Passed
Push — develop ( 6bfba2...d35452 )
by Nikolay
05:12
created

CreateExtensionsTest::additionProvider()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 270
Code Lines 212

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 212
c 2
b 0
f 0
dl 0
loc 270
rs 8
cc 1
nc 1
nop 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
/**
4
 * Copyright (C) MIKO LLC - All Rights Reserved
5
 * Unauthorized copying of this file, via any medium is strictly prohibited
6
 * Proprietary and confidential
7
 * Written by Nikolay Beketov, 5 2020
8
 *
9
 */
10
namespace MikoPBX\Tests\AdminCabinet\Tests;
11
12
13
use Facebook\WebDriver\WebDriverBy;
14
use MikoPBX\Tests\AdminCabinet\Lib\MikoPBXTestsBase;
15
16
class CreateExtensionsTest extends MikoPBXTestsBase
17
{
18
    /**
19
     * @depends      testLogin
20
     * @dataProvider additionProvider
21
     *
22
     * @param $params
23
     *
24
     * @throws \Facebook\WebDriver\Exception\NoSuchElementException
25
     * @throws \Facebook\WebDriver\Exception\TimeoutException
26
     */
27
    public function testCreateExtensions($params): void
28
    {
29
            $this->clickSidebarMenuItemByHref('/admin-cabinet/extensions/index/');
30
31
            $this->clickDeleteButtonOnRowWithText($params['username']);
32
33
            $this->clickButtonByHref('/admin-cabinet/extensions/modify');
34
35
            $this->changeInputField('user_username', $params['username']);
36
            $this->changeInputField('number', $params['number']);
37
            $this->changeInputField('mobile_number', $params['mobile']);
38
            self::$driver->executeScript('$("#mobile_number").trigger("change")');
39
            $this->changeInputField('user_email', $params['email']);
40
            $this->changeInputField('sip_secret', $params['secret']);
41
42
            // Раскрываем расширенные опции
43
            $this->openAccordionOnThePage();
44
45
            $this->changeInputField('sip_busylevel', $params['sip_busylevel']);
46
            $this->selectDropdownItem('sip_networkfilterid', $params['sip_networkfilterid']);
47
48
           $this->changeInputField('sip_busylevel', $params['sip_busylevel']);
49
            $this->changeTextAreaValue('sip_manualattributes', $params['manualattributes']);
50
51
            //$filePath           =  __DIR__."/../assets/{$params['number']}.png";
52
            $filePath = 'C:\Users\hello\Documents\images\person.jpg';
53
            $this->changeFileField('file-select', $filePath);
54
55
           $this->submitForm('extensions-form');
56
57
            self::$driver->wait(10, 500)->until(
58
                function () {
59
                    $xpath         = "//input[@name = 'id']";
60
                    $input_ExtensionUniqueID = self::$driver->findElement(WebDriverBy::xpath($xpath));
61
                    return $input_ExtensionUniqueID->getAttribute('value')!=='';
62
                }
63
            );
64
65
            // TESTS
66
            $xpath                   = "//input[@name = 'id']";
67
            $input_ExtensionUniqueID = self::$driver->findElement(WebDriverBy::xpath($xpath));
68
            $this->assertNotEmpty($input_ExtensionUniqueID->getAttribute('value'));
69
70
            $this->clickSidebarMenuItemByHref('/admin-cabinet/extensions/index/');
71
            $this->clickModifyButtonOnRowWithText($params['username']);
72
73
            $this->assertInputFieldValueEqual('user_username',  $params['username']);
74
            $this->assertInputFieldValueEqual('number',  $params['number']);
75
            $this->assertInputFieldValueEqual('user_email',  $params['email']);
76
            // $this->assertInputFieldValueEqual('mobile_number',  $params['mobile']);
77
78
            $this->changeTabOnCurrentPage('routing');
79
            $this->assertInputFieldValueEqual('fwd_ringlength', '45');
80
            $this->assertMenuItemSelected('fwd_forwardingonbusy', $params['mobile']);
81
            $this->assertMenuItemSelected('fwd_forwarding', $params['mobile']);
82
            $this->assertMenuItemSelected('fwd_forwardingonunavailable', $params['mobile']);
83
84
            $this->changeTabOnCurrentPage('general');
85
            $this->assertInputFieldValueEqual('sip_secret',  $params['secret']);
86
87
            // Раскрываем расширенные опции
88
            $this->openAccordionOnThePage();
89
            $this->assertInputFieldValueEqual('mobile_dialstring',  $params['mobile']);
90
            $this->assertInputFieldValueEqual('sip_busylevel', $params['sip_busylevel']);
91
            $this->assertMenuItemSelected('sip_networkfilterid', $params['sip_networkfilterid']);
92
93
            $this->assertTextAreaValueIsEqual('sip_manualattributes', $params['manualattributes']);
94
    }
95
96
    /**
97
     * Dataset provider
98
     * @return array
99
     */
100
    public function additionProvider(): array
101
    {
102
        $params = [];
103
        $params[] = [
104
            [
105
                'number'   => 235,
106
                'email'    => '[email protected]',
107
                'username' => 'Eugeniy Makrchev',
108
                'mobile'   => '79031454088',
109
                'secret'   => '23542354wet',
110
                'sip_busylevel'=>1,
111
                'sip_dtmfmode'=>'auto_info',
112
                'sip_networkfilterid'=>'none',
113
                'manualattributes'=>'[endpoint]
114
callerid=2546456<240>',
115
116
            ]];
117
        $params[] = [
118
            [
119
                'number'   => 229,
120
                'email'    => '[email protected]',
121
                'username' => 'Nikolay Beketov',
122
                'mobile'   => '79265244743',
123
                'secret'   => 'GAb2o%2B_1Ys.25',
124
                'sip_busylevel'=>1,
125
                'sip_dtmfmode'=>'inband',
126
                'sip_networkfilterid'=>'none',
127
                'manualattributes'=>'',
128
               ]];
129
130
        $params[] = [
131
            [
132
                'number'   => 223,
133
                'email'    => '[email protected]',
134
                'username' => 'Svetlana Vlasova',
135
                'mobile'   => '79269900372',
136
                'secret'   => 'GAb2o%qwerqwer2354235.25',
137
                'sip_busylevel'=>1,
138
                'sip_dtmfmode'=>'info',
139
                'sip_networkfilterid'=>'4',
140
                'manualattributes'=>'',
141
              ]];
142
        $params[] = [
143
            [
144
                'number'   => 217,
145
                'email'    => '[email protected]',
146
                'username' => 'Natalia Beketova',
147
                'mobile'   => '79265244843',
148
                'secret'   => 'GAb2o%2B_1Ys.25',
149
                'sip_busylevel'=>1,
150
                'sip_dtmfmode'=>'auto',
151
                'sip_networkfilterid'=>'none',
152
                'manualattributes'=>'',
153
154
                ]];
155
        $params[] = [
156
            [
157
                'number'   => 206,
158
                'email'    => '[email protected]',
159
                'username' => 'Julia Efimova',
160
                'mobile'   => '79851417827',
161
                'secret'   => '23542354wet',
162
                'sip_busylevel'=>1,
163
                'sip_dtmfmode'=>'rfc4733',
164
                'sip_networkfilterid'=>'none',
165
                'manualattributes'=>'',
166
            ]];
167
        $params[] = [
168
            [
169
                'number'   => 231,
170
                'email'    => '[email protected]',
171
                'username' => 'Alisher Usmanov',
172
                'mobile'   => '79265639989',
173
                'secret'   => '23542354wet',
174
                'sip_busylevel'=>1,
175
                'sip_dtmfmode'=>'auto_info',
176
                'sip_networkfilterid'=>'none',
177
                'manualattributes'=>'',
178
            ]];
179
        $params[] = [
180
            [
181
                'number'   => 236,
182
                'email'    => '[email protected]',
183
                'username' => 'Ivan Maltsev',
184
                'mobile'   => '79265679989',
185
                'secret'   => '23542354wet',
186
                'sip_busylevel'=>1,
187
                'sip_dtmfmode'=>'auto_info',
188
                'sip_networkfilterid'=>'none',
189
                'manualattributes'=>'',
190
            ]];
191
192
        $params[] = [
193
            [
194
                'number'   => 214,
195
                'email'    => '[email protected]',
196
                'username' => 'Alexandr Medvedev',
197
                'mobile'   => '79853059396',
198
                'secret'   => '235RTWETtre42354wet',
199
                'sip_busylevel'=>1,
200
                'sip_dtmfmode'=>'auto_info',
201
                'sip_networkfilterid'=>'none',
202
                'manualattributes'=>'',
203
            ]];
204
        $params[] = [
205
            [
206
                'number'   => 212,
207
                'email'    => '[email protected]',
208
                'username' => 'Anna Mzhelskaya',
209
                'mobile'   => '79852888742',
210
                'secret'   => '235RTWETtre42354wet',
211
                'sip_busylevel'=>1,
212
                'sip_dtmfmode'=>'auto_info',
213
                'sip_networkfilterid'=>'none',
214
                'manualattributes'=>'',
215
            ]];
216
        $params[] = [
217
            [
218
                'number'   => 210,
219
                'email'    => '[email protected]',
220
                'username' => 'Viktor Mitin',
221
                'mobile'   => '79251323617',
222
                'secret'   => '235RTWETtre42354wet',
223
                'sip_busylevel'=>1,
224
                'sip_dtmfmode'=>'auto_info',
225
                'sip_networkfilterid'=>'none',
226
                'manualattributes'=>'',
227
            ]];
228
        $params[] = [
229
            [
230
                'number'   => 228,
231
                'email'    => '[email protected]',
232
                'username' => 'Anton Pasutin',
233
                'mobile'   => '79262321957',
234
                'secret'   => '235RTWETtre42354wet',
235
                'sip_busylevel'=>1,
236
                'sip_dtmfmode'=>'auto_info',
237
                'sip_networkfilterid'=>'none',
238
                'manualattributes'=>'',
239
            ]];
240
        $params[] = [
241
            [
242
                'number'   => 213,
243
                'email'    => '[email protected]',
244
                'username' => 'Kristina Perfileva',
245
                'mobile'   => '79256112214',
246
                'secret'   => '235RTWETtre42354wet',
247
                'sip_busylevel'=>1,
248
                'sip_dtmfmode'=>'auto_info',
249
                'sip_networkfilterid'=>'none',
250
                'manualattributes'=>'',
251
            ]];
252
        $params[] = [
253
            [
254
                'number'   => 204,
255
                'email'    => '[email protected]',
256
                'username' => 'Alexey Portnov',
257
                'mobile'   => '79257184255',
258
                'secret'   => '235RTWETtre42354wet',
259
                'sip_busylevel'=>1,
260
                'sip_dtmfmode'=>'auto_info',
261
                'sip_networkfilterid'=>'none',
262
                'manualattributes'=>'',
263
            ]];
264
        $params[] = [
265
            [
266
                'number'   => 233,
267
                'email'    => '[email protected]',
268
                'username' => 'Tatiana Portnova',
269
                'mobile'   => '79606567153',
270
                'secret'   => '235RTWETt543re42354wet',
271
                'sip_busylevel'=>1,
272
                'sip_dtmfmode'=>'auto_info',
273
                'sip_networkfilterid'=>'none',
274
                'manualattributes'=>'',
275
276
            ]];
277
        $params[] = [
278
            [
279
                'number'   => 254,
280
                'email'    => '[email protected]',
281
                'username' => 'Alexandra Pushina',
282
                'mobile'   => '74952293043',
283
                'secret'   => '235RTWETtre5442354wet',
284
                'sip_busylevel'=>1,
285
                'sip_dtmfmode'=>'auto_info',
286
                'sip_networkfilterid'=>'none',
287
                'manualattributes'=>'',
288
            ]];
289
        $params[] = [
290
            [
291
                'number'   => 253,
292
                'email'    => '[email protected]',
293
                'username' => 'Dmitri Fomichev',
294
                'mobile'   => '79152824438',
295
                'secret'   => '235RTWETerwtre42354wet',
296
                'sip_busylevel'=>1,
297
                'sip_dtmfmode'=>'auto_info',
298
                'sip_networkfilterid'=>'none',
299
                'manualattributes'=>'',
300
301
            ]];
302
        $params[] = [
303
            [
304
                'number'   => 230,
305
                'email'    => '[email protected]',
306
                'username' => 'Daria Holodova',
307
                'mobile'   => '79161737472',
308
                'secret'   => '235RTWETtre42354wet',
309
                'sip_busylevel'=>1,
310
                'sip_dtmfmode'=>'auto_info',
311
                'sip_networkfilterid'=>'none',
312
                'manualattributes'=>'',
313
            ]];
314
        $params[] = [
315
            [
316
                'number'   => 219,
317
                'email'    => '[email protected]',
318
                'username' => 'Ilia Tsvetkov',
319
                'mobile'   => '79998201098',
320
                'secret'   => '235RT34WETtre42354wet',
321
                'sip_busylevel'=>1,
322
                'sip_dtmfmode'=>'auto_info',
323
                'sip_networkfilterid'=>'none',
324
                'manualattributes'=>'[endpoint]
325
callerid=2546456<240>',
326
            ]];
327
        $params[] = [
328
            [
329
                'number'   => 240,
330
                'email'    => '[email protected]',
331
                'username' => 'Maxim Tsvetkov',
332
                'mobile'   => '79055651617',
333
                'secret'   => '235RTWETttre42354wet',
334
                'sip_busylevel'=>1,
335
                'sip_dtmfmode'=>'auto_info',
336
                'sip_networkfilterid'=>'none',
337
                'manualattributes'=>'[endpoint]
338
callerid=2546456<240>',
339
            ]];
340
        $params[] = [
341
            [
342
                'number'   => 251,
343
                'email'    => '[email protected]',
344
                'username' => 'Viktor Chentcov',
345
                'mobile'   => '79265775288',
346
                'secret'   => '235RTrWETtre42354wet',
347
                'sip_busylevel'=>1,
348
                'sip_dtmfmode'=>'auto_info',
349
                'sip_networkfilterid'=>'none',
350
                'manualattributes'=>'[endpoint]
351
callerid=2546456<251>',
352
353
            ]];
354
        $params[] = [
355
            [
356
                'number'   => 234,
357
                'email'    => '[email protected]',
358
                'username' => 'Evgenia Chulkova',
359
                'mobile'   => '79161237145',
360
                'secret'   => '235RTWETftre42354wet',
361
                'sip_busylevel'=>1,
362
                'sip_dtmfmode'=>'auto_info',
363
                'sip_networkfilterid'=>'none',
364
                'manualattributes'=>'[endpoint]
365
callerid=2546456<234>',
366
367
            ]
368
        ];
369
        return $params;
370
    }
371
}