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 |
||
| 3 | class DMSDocumentAddControllerTest extends FunctionalTest |
||
|
|
|||
| 4 | { |
||
| 5 | protected static $fixture_file = 'dms/tests/dmstest.yml'; |
||
| 6 | |||
| 7 | /** |
||
| 8 | * @var DMSDocumentAddController |
||
| 9 | */ |
||
| 10 | protected $controller; |
||
| 11 | |||
| 12 | public function setUp() |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Ensure that if no ID is provided then a SiteTree singleton is returned (which will not have an ID). If one is |
||
| 22 | * provided then it should be loaded from the database via versioning. |
||
| 23 | */ |
||
| 24 | View Code Duplication | public function testCurrentPageReturnsSiteTree() |
|
| 33 | |||
| 34 | /** |
||
| 35 | * Ensure that if no "dsid" is given a singleton is returned (which will not have an ID). If one is provided |
||
| 36 | * it should be loaded from the database |
||
| 37 | */ |
||
| 38 | View Code Duplication | public function testGetCurrentDocumentSetReturnsDocumentSet() |
|
| 47 | |||
| 48 | /** |
||
| 49 | * Test that extra allowed extensions are merged into the default upload field allowed extensions |
||
| 50 | */ |
||
| 51 | public function testGetAllowedExtensions() |
||
| 60 | |||
| 61 | /** |
||
| 62 | * Test that the back link will be the document set that a file is uploaded into if relevant, otherwise the model |
||
| 63 | * admin that it was uploaded from |
||
| 64 | */ |
||
| 65 | public function testBacklink() |
||
| 74 | |||
| 75 | /** |
||
| 76 | * Test that the document autocomplete endpoint returns JSON, matching on ID, title or filename (case insensitive) |
||
| 77 | */ |
||
| 78 | public function testDocumentAutocomplete() |
||
| 90 | } |
||
| 91 |
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.