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