Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php |
||
13 | class HasStartedProvidingTest extends \PHPUnit_Framework_TestCase |
||
14 | { |
||
15 | public function testConstruction() |
||
16 | { |
||
17 | $entry = $this |
||
18 | ->getMockBuilder(RegistryEntry::class) |
||
19 | ->disableOriginalConstructor() |
||
20 | ->getMock() |
||
21 | ; |
||
22 | |||
23 | $testedInstance = new HasStartedProviding($entry); |
||
24 | |||
25 | $this->assertEquals( |
||
26 | $entry, |
||
27 | $testedInstance->getEntry() |
||
28 | ); |
||
29 | } |
||
30 | } |
||
31 |