Conditions | 1 |
Paths | 1 |
Total Lines | 56 |
Code Lines | 34 |
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 |
||
78 | public function testAddTrigger() |
||
79 | { |
||
80 | $this->expandMore(); |
||
81 | $this->waitForElement('partialLinkText', "Triggers")->click(); |
||
82 | $this->waitAjax(); |
||
83 | |||
84 | $this->waitForElement('partialLinkText', "Add trigger")->click(); |
||
85 | $this->waitAjax(); |
||
86 | |||
87 | $this->waitForElement('className', "rte_form"); |
||
88 | |||
89 | $this->byName("item_name")->sendKeys("test_trigger"); |
||
90 | |||
91 | $this->selectByLabel( |
||
92 | $this->byName("item_table"), |
||
93 | 'test_table' |
||
94 | ); |
||
95 | |||
96 | $this->selectByLabel( |
||
97 | $this->byName("item_timing"), |
||
98 | 'AFTER' |
||
99 | ); |
||
100 | |||
101 | $this->selectByLabel( |
||
102 | $this->byName("item_event"), |
||
103 | 'INSERT' |
||
104 | ); |
||
105 | |||
106 | $proc = "UPDATE " . $this->database_name . ".`test_table2` SET val=val+1"; |
||
107 | $this->typeInTextArea($proc); |
||
108 | |||
109 | $this->byXPath("//button[contains(., 'Go')]")->click(); |
||
110 | |||
111 | $ele = $this->waitForElement( |
||
|
|||
112 | 'xpath', |
||
113 | "//div[@class='success' and contains(., " |
||
114 | . "'Trigger `test_trigger` has been created')]" |
||
115 | ); |
||
116 | |||
117 | $this->assertTrue( |
||
118 | $this->isElementPresent( |
||
119 | 'xpath', |
||
120 | "//td[contains(., 'test_trigger')]" |
||
121 | ) |
||
122 | ); |
||
123 | |||
124 | $result = $this->dbQuery( |
||
125 | "SHOW TRIGGERS FROM `" . $this->database_name . "`;" |
||
126 | ); |
||
127 | $this->assertEquals(1, $result->num_rows); |
||
128 | |||
129 | // test trigger |
||
130 | $this->dbQuery("INSERT INTO `test_table` (val) VALUES (1);"); |
||
131 | $result = $this->dbQuery("SELECT val FROM `test_table2`;"); |
||
132 | $row = $result->fetch_assoc(); |
||
133 | $this->assertEquals(3, $row['val']); |
||
134 | } |
||
217 |