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

CreateOutgoingCallRules   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 77
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 45
dl 0
loc 77
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Copyright (C) MIKO LLC - All Rights Reserved
4
 * Unauthorized copying of this file, via any medium is strictly prohibited
5
 * Proprietary and confidential
6
 * Written by Nikolay Beketov, 5 2020
7
 *
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 CreateOutgoingCallRules extends MikoPBXTestsBase
17
{
18
    /**
19
     * @depends testLogin
20
     */
21
    public function testDeleteAllRules():void
22
    {
23
        $this->clickSidebarMenuItemByHref('/admin-cabinet/outbound-routes/index/');
24
        $tableId = 'routingTable';
25
        $this->deleteAllRecordsOnTable($tableId);
26
        $xpath         = "//table[@id='{$tableId}']//a[contains(@href,'delete') and not(contains(@class,'disabled'))]";
27
        $this->assertElementNotFound(WebDriverBy::xpath($xpath));
28
    }
29
30
    /**
31
     * @depends testLogin
32
     * @dataProvider additionProvider
33
     *
34
     * @param array $params
35
     */
36
    public function testCreateOutgoingCallRule($params):void
37
    {
38
        $this->clickSidebarMenuItemByHref('/admin-cabinet/outbound-routes/index/');
39
        $this->clickDeleteButtonOnRowWithText($params['rulename']);
40
41
        $this->clickButtonByHref('/admin-cabinet/outbound-routes/modify');
42
        $this->changeInputField('rulename', $params['rulename']);
43
        $this->changeTextAreaValue('note', $params['note']);
44
        $this->changeInputField('numberbeginswith', $params['numberbeginswith']);
45
        $this->changeInputField('restnumbers', $params['restnumbers']);
46
        $this->changeInputField('trimfrombegin', $params['trimfrombegin']);
47
        $this->changeInputField('prepend', $params['prepend']);
48
        $this->selectDropdownItem('providerid', $params['providerid']);
49
50
        $this->submitForm('outbound-route-form');
51
        $id = $this->getCurrentRecordID();
52
53
        $this->clickSidebarMenuItemByHref('/admin-cabinet/outbound-routes/index/');
54
55
        $this->clickModifyButtonOnRowWithID($id);
56
        //Asserts
57
        $this->assertInputFieldValueEqual('rulename', $params['rulename']);
58
        $this->assertTextAreaValueIsEqual('note', $params['note']);
59
        $this->assertInputFieldValueEqual('numberbeginswith', $params['numberbeginswith']);
60
        $this->assertInputFieldValueEqual('restnumbers', $params['restnumbers']);
61
        $this->assertInputFieldValueEqual('trimfrombegin', $params['trimfrombegin']);
62
        $this->assertInputFieldValueEqual('prepend', $params['prepend']);
63
        $this->assertMenuItemSelected('providerid', $params['providerid']);
64
    }
65
66
    /**
67
     * Dataset provider
68
     * @return array
69
     */
70
    public function additionProvider(): array
71
    {
72
        $params=[];
73
        $params[] = [[
74
            'rulename'=>'Local outgoing calls',
75
            'note' => 'Calls only at local landlines',
76
            'numberbeginswith' => '(7|8)',
77
            'restnumbers'        => '10',
78
            'trimfrombegin'        => '1',
79
            'prepend'         => '8',
80
            'providerid'=>'SIP-PROVIDER-34F7CCFE873B9DABD91CC8D75342CB43'
81
        ]];
82
        $params[] = [[
83
            'rulename'=>'International outgoing calls',
84
            'note' => 'Calls to everywhere',
85
            'numberbeginswith' => '00',
86
            'restnumbers'        => '10',
87
            'trimfrombegin'        => '2',
88
            'prepend'         => '777',
89
            'providerid'=>'SIP-PROVIDER-34F7CCFE873B9DABD91CC8D75342CB43'
90
        ]];
91
92
        return $params;
93
    }
94
}