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 |
||
| 5 | class StorageArrayTest extends PHPUnit_Framework_TestCase |
||
|
|
|||
| 6 | { |
||
| 7 | |||
| 8 | protected function setUp() |
||
| 11 | |||
| 12 | protected function tearDown() |
||
| 15 | |||
| 16 | View Code Duplication | public function testConstructorOk1() |
|
| 25 | |||
| 26 | public function testConstructorOk2() |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @expectedException \Brownie\Util\Exception\UndefinedMethodException |
||
| 35 | */ |
||
| 36 | View Code Duplication | public function testConstructorError() |
|
| 45 | |||
| 46 | public function testSetGetOk() |
||
| 59 | |||
| 60 | /** |
||
| 61 | * @expectedException \Brownie\Util\Exception\UndefinedMethodException |
||
| 62 | */ |
||
| 63 | View Code Duplication | public function testSetError() |
|
| 73 | |||
| 74 | /** |
||
| 75 | * @expectedException \Brownie\Util\Exception\UndefinedMethodException |
||
| 76 | */ |
||
| 77 | View Code Duplication | public function testGetError() |
|
| 87 | } |
||
| 88 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.