| Conditions | 4 |
| Paths | 6 |
| Total Lines | 75 |
| Code Lines | 45 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
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:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 24 | public function testCreateCallQueue($params):void |
||
| 25 | { |
||
| 26 | |||
| 27 | $this->clickSidebarMenuItemByHref('/admin-cabinet/call-queues/index/'); |
||
| 28 | $this->clickDeleteButtonOnRowWithText($params['name']); |
||
| 29 | |||
| 30 | $this->clickButtonByHref('/admin-cabinet/call-queues/modify'); |
||
| 31 | $this->changeTextAreaValue('description', $params['description']); |
||
| 32 | $this->changeInputField('name', $params['name']); |
||
| 33 | |||
| 34 | // Добавляем агентов очереди |
||
| 35 | foreach ($params['agents'] as $agent) { |
||
| 36 | $this->selectDropdownItem('extensionselect', $agent); |
||
| 37 | } |
||
| 38 | |||
| 39 | $this->selectDropdownItem('strategy', $params['strategy']); |
||
| 40 | |||
| 41 | // Раскрываем расширенные опции |
||
| 42 | $this->openAccordionOnThePage(); |
||
| 43 | |||
| 44 | // Заполняем поля из базы данных с исходными данными |
||
| 45 | $this->changeInputField('extension', $params['extension']); |
||
| 46 | $this->changeInputField('seconds_to_ring_each_member', $params['seconds_to_ring_each_member']); |
||
| 47 | $this->changeInputField('seconds_for_wrapup', $params['seconds_for_wrapup']); |
||
| 48 | $this->changeCheckBoxState('recive_calls_while_on_a_call', $params['recive_calls_while_on_a_call']); |
||
| 49 | |||
| 50 | $this->selectDropdownItem('caller_hear', $params['caller_hear']); |
||
| 51 | $this->changeCheckBoxState('announce_position', $params['announce_position']); |
||
| 52 | $this->changeCheckBoxState('announce_hold_time', $params['announce_hold_time']); |
||
| 53 | |||
| 54 | $this->selectDropdownItem('periodic_announce_sound_id', $params['periodic_announce_sound_id']); |
||
| 55 | |||
| 56 | $this->changeInputField('periodic_announce_frequency', $params['periodic_announce_frequency']); |
||
| 57 | $this->changeInputField('timeout_to_redirect_to_extension', $params['timeout_to_redirect_to_extension']); |
||
| 58 | |||
| 59 | $this->selectDropdownItem('timeout_extension', $params['timeout_extension']); |
||
| 60 | $this->selectDropdownItem('redirect_to_extension_if_empty', $params['redirect_to_extension_if_empty']); |
||
| 61 | |||
| 62 | $this->submitForm('queue-form'); |
||
| 63 | $this->clickSidebarMenuItemByHref('/admin-cabinet/call-queues/index/'); |
||
| 64 | |||
| 65 | $this->clickModifyButtonOnRowWithText($params['name']); |
||
| 66 | $this->assertInputFieldValueEqual('name', $params['name']); |
||
| 67 | $this->assertInputFieldValueEqual('extension', $params['extension']); |
||
| 68 | $this->assertTextAreaValueIsEqual('description', $params['description']); |
||
| 69 | |||
| 70 | // Обойдем всех членов очереди, проверим что они есть |
||
| 71 | foreach ($params['agents'] as $agent) { |
||
| 72 | $xpath = '//table[@id="extensionsTable"]//td[contains(text(), "'.$agent.'")]'; |
||
| 73 | $members = self::$driver->findElements(WebDriverBy::xpath($xpath)); |
||
| 74 | if (count($members)===0){ |
||
| 75 | $this->assertTrue(false, 'Not found agent '.$agent.' in queue agents list'); |
||
| 76 | } |
||
| 77 | |||
| 78 | } |
||
| 79 | $this->assertMenuItemSelected('strategy', $params['strategy']); |
||
| 80 | |||
| 81 | // Раскрываем расширенные опции |
||
| 82 | $this->openAccordionOnThePage(); |
||
| 83 | |||
| 84 | $this->assertInputFieldValueEqual('seconds_to_ring_each_member', $params['seconds_to_ring_each_member']); |
||
| 85 | $this->assertInputFieldValueEqual('seconds_for_wrapup', $params['seconds_for_wrapup']); |
||
| 86 | $this->assertCheckBoxStageIsEqual('recive_calls_while_on_a_call', $params['recive_calls_while_on_a_call']); |
||
| 87 | |||
| 88 | $this->assertMenuItemSelected('caller_hear', $params['caller_hear']); |
||
| 89 | $this->assertCheckBoxStageIsEqual('announce_position', $params['announce_position']); |
||
| 90 | $this->assertCheckBoxStageIsEqual('announce_hold_time', $params['announce_hold_time']); |
||
| 91 | |||
| 92 | $this->assertMenuItemSelected('periodic_announce_sound_id', $params['periodic_announce_sound_id']); |
||
| 93 | |||
| 94 | $this->assertInputFieldValueEqual('periodic_announce_frequency', $params['periodic_announce_frequency']); |
||
| 95 | $this->assertInputFieldValueEqual('timeout_to_redirect_to_extension', $params['timeout_to_redirect_to_extension']); |
||
| 96 | |||
| 97 | $this->assertMenuItemSelected('timeout_extension', $params['timeout_extension']); |
||
| 98 | $this->assertMenuItemSelected('redirect_to_extension_if_empty', $params['redirect_to_extension_if_empty']); |
||
| 99 | |||
| 157 | } |