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 |
||
| 8 | class PotatoModelTest extends \PHPUnit_Framework_TestCase |
||
| 9 | { |
||
| 10 | public $mockConnector; |
||
| 11 | public $mockStatement; |
||
| 12 | private $mockQuery; |
||
| 13 | private $mockModel; |
||
| 14 | private $model; |
||
|
|
|||
| 15 | private $connection; |
||
| 16 | |||
| 17 | public function setUp() |
||
| 25 | |||
| 26 | public function teardDown() |
||
| 30 | |||
| 31 | public function testGetMagicFunctionWorksAndREturnTheDataInDatatoSave() |
||
| 39 | |||
| 40 | public function testGetMagicFunctionDoesNotWorkIfCalledREquesIsNotInDataToSave() |
||
| 47 | |||
| 48 | public function tesnotMagicFunctionIsSetWorks() |
||
| 57 | |||
| 58 | public function testGetAllFunctionWorksWithNullAsQuery() |
||
| 61 | |||
| 62 | public function testIsStoredFunctionWorksForFalse() |
||
| 68 | |||
| 69 | public function testIsStoredFunctionWorksForTrue() |
||
| 76 | |||
| 77 | View Code Duplication | public function testSavefunctionWorksForInsert() |
|
| 86 | |||
| 87 | View Code Duplication | public function testSavefunctionWorksForUpdate() |
|
| 97 | |||
| 98 | View Code Duplication | public function testUpdateFunctionworks() |
|
| 108 | |||
| 109 | View Code Duplication | public function testInsertFunctionworks() |
|
| 116 | |||
| 117 | public function testDestroyFunctionWorks() |
||
| 120 | } |
||
| 121 |
This check marks private properties in classes that are never used. Those properties can be removed.