Conditions | 1 |
Paths | 1 |
Total Lines | 71 |
Code Lines | 55 |
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 |
||
114 | public function testGetWidgets() |
||
115 | { |
||
116 | $this->logInWithPermission('ADMIN'); |
||
117 | $this->collector->collect(); |
||
118 | $result = $this->collector->getWidgets(); |
||
119 | // Stub out the dynamic data |
||
120 | $result['version']['tooltip'] = 'Stub'; |
||
121 | $result['locale']['tooltip'] = 'Stub'; |
||
122 | $result['user']['tooltip'] = 'Current member'; |
||
123 | |||
124 | $expected = array( |
||
125 | 'user' => array( |
||
126 | 'icon' => 'user', |
||
127 | 'tooltip' => 'Current member', |
||
128 | 'default' => '', |
||
129 | ), |
||
130 | 'version' => array( |
||
131 | 'icon' => 'desktop', |
||
132 | 'tooltip' => 'Stub', |
||
133 | 'default' => '', |
||
134 | ), |
||
135 | 'locale' => array( |
||
136 | 'icon' => 'globe', |
||
137 | 'tooltip' => 'Stub', |
||
138 | 'default' => '', |
||
139 | ), |
||
140 | 'session' => array( |
||
141 | 'icon' => 'archive', |
||
142 | 'widget' => 'PhpDebugBar.Widgets.VariableListWidget', |
||
143 | 'map' => 'silverstripe.session', |
||
144 | 'default' => '{}', |
||
145 | ), |
||
146 | 'cookies' => array( |
||
147 | 'icon' => 'asterisk', |
||
148 | 'widget' => 'PhpDebugBar.Widgets.VariableListWidget', |
||
149 | 'map' => 'silverstripe.cookies', |
||
150 | 'default' => '{}', |
||
151 | ), |
||
152 | 'parameters' => array( |
||
153 | 'icon' => 'arrow-right', |
||
154 | 'widget' => 'PhpDebugBar.Widgets.VariableListWidget', |
||
155 | 'map' => 'silverstripe.parameters', |
||
156 | 'default' => '{}', |
||
157 | ), |
||
158 | 'SiteConfig' => array( |
||
159 | 'icon' => 'gear', |
||
160 | 'widget' => 'PhpDebugBar.Widgets.VariableListWidget', |
||
161 | 'map' => 'silverstripe.config', |
||
162 | 'default' => '{}', |
||
163 | ), |
||
164 | 'requirements' => array( |
||
165 | 'icon' => 'file-o ', |
||
166 | 'widget' => 'PhpDebugBar.Widgets.ListWidget', |
||
167 | 'map' => 'silverstripe.requirements', |
||
168 | 'default' => '{}', |
||
169 | ), |
||
170 | 'templates' => array( |
||
171 | 'icon' => 'edit', |
||
172 | 'widget' => 'PhpDebugBar.Widgets.ListWidget', |
||
173 | 'map' => "silverstripe.templates.templates", |
||
174 | 'default' => '{}' |
||
175 | ), |
||
176 | 'templates:badge' => array( |
||
177 | 'map' => 'silverstripe.templates.count', |
||
178 | 'default' => 0 |
||
179 | ) |
||
180 | ); |
||
181 | |||
182 | $this->assertSame($expected, $result); |
||
183 | $this->logOut(); |
||
184 | } |
||
185 | |||
198 |