| Conditions | 1 |
| Paths | 1 |
| Total Lines | 59 |
| 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 |
||
| 36 | public function testGetResult_LinkOnNonFileOutput() { |
||
| 37 | |||
| 38 | $link = $this->getMockBuilder( '\SMWInfolink' ) |
||
| 39 | ->disableOriginalConstructor() |
||
| 40 | ->getMock(); |
||
| 41 | |||
| 42 | $link->expects( $this->any() ) |
||
| 43 | ->method( 'getText' ) |
||
| 44 | ->will( $this->returnValue( 'foo_link' ) ); |
||
| 45 | |||
| 46 | $this->queryResult->expects( $this->any() ) |
||
| 47 | ->method( 'getErrors' ) |
||
| 48 | ->will( $this->returnValue( [] ) ); |
||
| 49 | |||
| 50 | $this->queryResult->expects( $this->any() ) |
||
| 51 | ->method( 'getCount' ) |
||
| 52 | ->will( $this->returnValue( 1 ) ); |
||
| 53 | |||
| 54 | $instance = new OutlineResultPrinter( |
||
| 55 | 'outline' |
||
| 56 | ); |
||
| 57 | |||
| 58 | // IParam is an empty interface !!! so we use stdClass |
||
| 59 | $outlineproperties = $this->getMockBuilder( '\stdClass' ) |
||
| 60 | ->disableOriginalConstructor() |
||
| 61 | ->setMethods( [ 'getName', 'getValue' ] ) |
||
| 62 | ->getMock(); |
||
| 63 | |||
| 64 | $outlineproperties->expects( $this->any() ) |
||
| 65 | ->method( 'getName' ) |
||
| 66 | ->will( $this->returnValue( 'outlineproperties' ) ); |
||
| 67 | |||
| 68 | $outlineproperties->expects( $this->any() ) |
||
| 69 | ->method( 'getValue' ) |
||
| 70 | ->will( $this->returnValue( [] ) ); |
||
| 71 | |||
| 72 | $template = $this->getMockBuilder( '\stdClass' ) |
||
| 73 | ->disableOriginalConstructor() |
||
| 74 | ->setMethods( [ 'getName', 'getValue' ] ) |
||
| 75 | ->getMock(); |
||
| 76 | |||
| 77 | $template->expects( $this->any() ) |
||
| 78 | ->method( 'getName' ) |
||
| 79 | ->will( $this->returnValue( 'template' ) ); |
||
| 80 | |||
| 81 | $template->expects( $this->any() ) |
||
| 82 | ->method( 'getValue' ) |
||
| 83 | ->will( $this->returnValue( '' ) ); |
||
| 84 | |||
| 85 | $parameters = [ |
||
| 86 | $outlineproperties, |
||
| 87 | $template |
||
| 88 | ]; |
||
| 89 | |||
| 90 | $this->assertContains( |
||
| 91 | "<ul>\n</ul>\n", |
||
| 92 | $instance->getResult( $this->queryResult, $parameters, SMW_OUTPUT_HTML ) |
||
| 93 | ); |
||
| 94 | } |
||
| 95 | |||
| 97 |