Conditions | 1 |
Paths | 1 |
Total Lines | 59 |
Code Lines | 36 |
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 |
||
61 | public function testAddTrigger(): void |
||
62 | { |
||
63 | $this->expandMore(); |
||
64 | $this->waitForElement('partialLinkText', 'Triggers')->click(); |
||
65 | $this->waitAjax(); |
||
66 | |||
67 | $this->waitForElement('partialLinkText', 'Create new trigger')->click(); |
||
68 | $this->waitAjax(); |
||
69 | |||
70 | $this->waitForElement('className', 'rte_form'); |
||
71 | |||
72 | $this->byName('item_name')->sendKeys('test_trigger'); |
||
73 | |||
74 | $this->selectByLabel( |
||
75 | $this->byName('item_table'), |
||
76 | 'test_table', |
||
77 | ); |
||
78 | |||
79 | $this->selectByLabel( |
||
80 | $this->byName('item_timing'), |
||
81 | 'AFTER', |
||
82 | ); |
||
83 | |||
84 | $this->selectByLabel( |
||
85 | $this->byName('item_event'), |
||
86 | 'INSERT', |
||
87 | ); |
||
88 | |||
89 | $proc = 'UPDATE ' . $this->databaseName . '.`test_table2` SET val=val+1'; |
||
90 | $this->typeInTextArea($proc); |
||
91 | |||
92 | $this->byCssSelector('div.ui-dialog-buttonset button:nth-child(1)')->click(); |
||
93 | |||
94 | $success = $this->waitForElement('cssSelector', '.alert-success'); |
||
95 | $this->assertStringContainsString('Trigger `test_trigger` has been created', $success->getText()); |
||
96 | |||
97 | $this->assertTrue( |
||
98 | $this->isElementPresent( |
||
99 | 'xpath', |
||
100 | "//td[contains(., 'test_trigger')]", |
||
101 | ), |
||
102 | ); |
||
103 | |||
104 | $this->dbQuery( |
||
105 | 'SHOW TRIGGERS FROM `' . $this->databaseName . '`;', |
||
106 | function (): void { |
||
107 | $this->assertTrue($this->isElementPresent('className', 'table_results')); |
||
108 | $this->assertEquals('test_trigger', $this->getCellByTableClass('table_results', 1, 1)); |
||
109 | }, |
||
110 | ); |
||
111 | |||
112 | // test trigger |
||
113 | $this->dbQuery('USE `' . $this->databaseName . '`;INSERT INTO `test_table` (val) VALUES (1);'); |
||
114 | $this->dbQuery( |
||
115 | 'SELECT val FROM `' . $this->databaseName . '`.`test_table2`;', |
||
116 | function (): void { |
||
117 | $this->assertTrue($this->isElementPresent('className', 'table_results')); |
||
118 | // [ ] | Edit | Copy | Delete | 1 | 3 |
||
119 | $this->assertEquals('3', $this->getCellByTableClass('table_results', 1, 5)); |
||
120 | }, |
||
201 |