| Conditions | 1 |
| Paths | 1 |
| Total Lines | 57 |
| 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 |
||
| 39 | public function testRebuildPagesThatContainDuplicateEntity() { |
||
| 40 | |||
| 41 | $subject = $this->getMockBuilder( '\SMW\DIWikiPage' ) |
||
| 42 | ->disableOriginalConstructor() |
||
| 43 | ->getMock(); |
||
| 44 | |||
| 45 | $subject->expects( $this->exactly( 2 ) ) |
||
| 46 | ->method( 'getTitle' ) |
||
| 47 | ->will( $this->returnValue( Title::newFromText( __METHOD__ ) ) ); |
||
| 48 | |||
| 49 | $queryResult = $this->getMockBuilder( '\SMWQueryResult' ) |
||
| 50 | ->disableOriginalConstructor() |
||
| 51 | ->getMock(); |
||
| 52 | |||
| 53 | $queryResult->expects( $this->once() ) |
||
| 54 | ->method( 'getResults' ) |
||
| 55 | ->will( $this->returnValue( array( $subject, $subject ) ) ); |
||
| 56 | |||
| 57 | $store = $this->getMockBuilder( '\SMW\Store' ) |
||
| 58 | ->disableOriginalConstructor() |
||
| 59 | ->getMockForAbstractClass(); |
||
| 60 | |||
| 61 | $store->expects( $this->at( 1 ) ) |
||
| 62 | ->method( 'getQueryResult' ) |
||
| 63 | ->will( $this->returnValue( $queryResult ) ); |
||
| 64 | |||
| 65 | $bagOStuff = $this->getMockBuilder( 'BagOStuff' ) |
||
| 66 | ->disableOriginalConstructor() |
||
| 67 | ->getMockForAbstractClass(); |
||
| 68 | |||
| 69 | $bagOStuff->expects( $this->at( 0 ) ) |
||
| 70 | ->method( 'delete' ) |
||
| 71 | ->with( $this->stringContains( 'lingotree' ) ); |
||
| 72 | |||
| 73 | $bagOStuff->expects( $this->at( 1 ) ) |
||
| 74 | ->method( 'delete' ) |
||
| 75 | ->with( $this->stringContains( 'semanticglossary' ) ); |
||
| 76 | |||
| 77 | $bagOStuff->expects( $this->at( 2 ) ) |
||
| 78 | ->method( 'delete' ) |
||
| 79 | ->with( $this->stringContains( 'semanticglossary' ) ); |
||
| 80 | |||
| 81 | $instance = new GlossaryCacheRebuilder( |
||
| 82 | $store, |
||
| 83 | new GlossaryCache( $bagOStuff ) |
||
| 84 | ); |
||
| 85 | |||
| 86 | $instance->setParameters( array() ); |
||
| 87 | |||
| 88 | $this->assertTrue( $instance->rebuild() ); |
||
| 89 | |||
| 90 | $this->assertEquals( |
||
| 91 | 1, |
||
| 92 | $instance->getRebuildCount(), |
||
| 93 | 'Asserts that rebuild is counted only once because the duplicate entity was removed' |
||
| 94 | ); |
||
| 95 | } |
||
| 96 | |||
| 98 |