| Conditions | 1 |
| Paths | 1 |
| Total Lines | 58 |
| 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 |
||
| 79 | public function testBuildResult(){ |
||
| 80 | |||
| 81 | $instance = new Gallery( |
||
| 82 | 'gallery' |
||
| 83 | ); |
||
| 84 | |||
| 85 | $widget = $this->getMockBuilder( '\stdClass' ) |
||
| 86 | ->disableOriginalConstructor() |
||
| 87 | ->setMethods( [ 'getName', 'getValue' ] ) |
||
| 88 | ->getMock(); |
||
| 89 | |||
| 90 | $widget->expects( $this->any() ) |
||
| 91 | ->method( 'getName' ) |
||
| 92 | ->will( $this->returnValue( 'widget' ) ); |
||
| 93 | |||
| 94 | $widget->expects( $this->any() ) |
||
| 95 | ->method( 'getValue' ) |
||
| 96 | ->will( $this->returnValue( 'carousel' ) ); |
||
| 97 | |||
| 98 | |||
| 99 | $intro = $this->getMockBuilder( '\stdClass' ) |
||
| 100 | ->disableOriginalConstructor() |
||
| 101 | ->setMethods( [ 'getName', 'getValue' ] ) |
||
| 102 | ->getMock(); |
||
| 103 | |||
| 104 | $intro->expects( $this->any() ) |
||
| 105 | ->method( 'getName' ) |
||
| 106 | ->will( $this->returnValue( 'intro' ) ); |
||
| 107 | |||
| 108 | $intro->expects( $this->any() ) |
||
| 109 | ->method( 'getValue' ) |
||
| 110 | ->will( $this->returnValue( '<div class="gallery-intro">' ) ); |
||
| 111 | |||
| 112 | |||
| 113 | $outro = $this->getMockBuilder( '\stdClass' ) |
||
| 114 | ->disableOriginalConstructor() |
||
| 115 | ->setMethods( [ 'getName', 'getValue' ] ) |
||
| 116 | ->getMock(); |
||
| 117 | |||
| 118 | $outro->expects( $this->any() ) |
||
| 119 | ->method( 'getName' ) |
||
| 120 | ->will( $this->returnValue( 'outro' ) ); |
||
| 121 | |||
| 122 | $outro->expects( $this->any() ) |
||
| 123 | ->method( 'getValue' ) |
||
| 124 | ->will( $this->returnValue( '</div>' ) ); |
||
| 125 | |||
| 126 | $parameters = [ |
||
| 127 | $widget, |
||
| 128 | $intro, |
||
| 129 | $outro |
||
| 130 | ]; |
||
| 131 | |||
| 132 | $this->assertContains( |
||
| 133 | '', |
||
| 134 | $instance->getResult( $this->queryResult, $parameters, SMW_OUTPUT_HTML ) |
||
| 135 | ); |
||
| 136 | } |
||
| 137 | |||
| 139 |