| Conditions | 1 |
| Paths | 1 |
| Total Lines | 67 |
| Code Lines | 46 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 4 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 148 | public function testPrependHtmlForViewActionOnly() { |
||
| 149 | |||
| 150 | $context = new \RequestContext(); |
||
| 151 | $context->setRequest( new \FauxRequest( array( 'action' => 'view' ), true ) ); |
||
| 152 | |||
| 153 | $htmlBreadcrumbLinksBuilder = $this->getMockBuilder( '\SBL\HtmlBreadcrumbLinksBuilder' ) |
||
| 154 | ->disableOriginalConstructor() |
||
| 155 | ->getMock(); |
||
| 156 | |||
| 157 | $htmlBreadcrumbLinksBuilder->expects( $this->once() ) |
||
| 158 | ->method( 'buildBreadcrumbs' ) |
||
| 159 | ->will( $this->returnSelf() ); |
||
| 160 | |||
| 161 | $language = $this->getMockBuilder( '\Language' ) |
||
| 162 | ->disableOriginalConstructor() |
||
| 163 | ->getMock(); |
||
| 164 | |||
| 165 | $title = $this->getMockBuilder( '\Title' ) |
||
| 166 | ->disableOriginalConstructor() |
||
| 167 | ->getMock(); |
||
| 168 | |||
| 169 | $title->expects( $this->once() ) |
||
| 170 | ->method( 'isKnown' ) |
||
| 171 | ->will( $this->returnValue( true ) ); |
||
| 172 | |||
| 173 | $title->expects( $this->once() ) |
||
| 174 | ->method( 'getNamespace' ) |
||
| 175 | ->will( $this->returnValue( NS_MAIN ) ); |
||
| 176 | |||
| 177 | $title->expects( $this->once() ) |
||
| 178 | ->method( 'isSpecialPage' ) |
||
| 179 | ->will( $this->returnValue( false ) ); |
||
| 180 | |||
| 181 | $title->expects( $this->once() ) |
||
| 182 | ->method( 'getPageLanguage' ) |
||
| 183 | ->will( $this->returnValue( $language ) ); |
||
| 184 | |||
| 185 | $output = $this->getMockBuilder( '\OutputPage' ) |
||
| 186 | ->disableOriginalConstructor() |
||
| 187 | ->getMock(); |
||
| 188 | |||
| 189 | $output->expects( $this->once() ) |
||
| 190 | ->method( 'prependHTML' ); |
||
| 191 | |||
| 192 | $output->expects( $this->once() ) |
||
| 193 | ->method( 'getContext' ) |
||
| 194 | ->will( $this->returnValue( $context ) ); |
||
| 195 | |||
| 196 | $output->expects( $this->atLeastOnce() ) |
||
| 197 | ->method( 'getTitle' ) |
||
| 198 | ->will( $this->returnValue( $title ) ); |
||
| 199 | |||
| 200 | $instance = new SkinTemplateOutputModifier( $htmlBreadcrumbLinksBuilder ); |
||
| 201 | |||
| 202 | $this->assertTrue( |
||
| 203 | $instance->modifyOutput( $output ) |
||
| 204 | ); |
||
| 205 | |||
| 206 | $template = new \stdClass; |
||
| 207 | $template->data = array(); |
||
| 208 | |||
| 209 | $instance->modifyTemplate( $template ); |
||
| 210 | |||
| 211 | $this->assertEmpty( |
||
| 212 | $template->data['subtitle'] |
||
| 213 | ); |
||
| 214 | } |
||
| 215 | |||
| 217 |