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 |
||
| 16 | class TextPreserverTest extends \PHPUnit_Framework_TestCase |
||
| 17 | { |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @var TextPreserver |
||
| 21 | */ |
||
| 22 | protected $object; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Sets up the fixture, for example, opens a network connection. |
||
| 26 | * This method is called before a test is executed. |
||
| 27 | */ |
||
| 28 | protected function setUp() |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Tears down the fixture, for example, closes a network connection. |
||
| 35 | * This method is called after a test is executed. |
||
| 36 | */ |
||
| 37 | protected function tearDown() |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @covers Trefoil\Helpers\TextPreserver::setText |
||
| 44 | * @covers Trefoil\Helpers\TextPreserver::getText |
||
| 45 | */ |
||
| 46 | public function testNoChange() |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @covers Trefoil\Helpers\TextPreserver::preserveHtmlTags |
||
| 54 | * @covers Trefoil\Helpers\TextPreserver::restore |
||
| 55 | */ |
||
| 56 | View Code Duplication | public function testPreserveHtmlTags() |
|
| 70 | |||
| 71 | /** |
||
| 72 | * @covers Trefoil\Helpers\TextPreserver::preserveHtmlTagAttributes |
||
| 73 | * @covers Trefoil\Helpers\TextPreserver::restore |
||
| 74 | */ |
||
| 75 | View Code Duplication | public function testPreserveHtmlTagAttributes() |
|
| 89 | |||
| 90 | /** |
||
| 91 | * @covers Trefoil\Helpers\TextPreserver::internalCreatePlacehoder |
||
| 92 | */ |
||
| 93 | public function testCreatePlacehoder() |
||
| 107 | |||
| 108 | } |
||
| 109 |