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 GridFieldRefreshButtonTest extends SapphireTest |
||
|
|
|||
| 4 | { |
||
| 5 | protected static $fixture_file = 'GridFieldRefreshButtonTest.yml'; |
||
| 6 | |||
| 7 | public function testHasRunningJob() |
||
| 12 | |||
| 13 | public function testDoesNotHaveCancelledCompletedOrBrokenJob() |
||
| 20 | |||
| 21 | View Code Duplication | public function testHandleRefreshDoesNotCreateJobWhenJobIsRunning() |
|
| 30 | |||
| 31 | View Code Duplication | public function testHandleRefreshCreatesJobWhenNoJobIsRunning() |
|
| 42 | |||
| 43 | public function testHandleCheckReturnsValidJson() |
||
| 48 | |||
| 49 | public function testButtonIsDisabledWhenJobIsRunning() |
||
| 59 | |||
| 60 | public function testButtonIsEnabledWhenNoJobIsRunning() |
||
| 72 | |||
| 73 | /** |
||
| 74 | * Turns the running job in the fixture file into a completed job |
||
| 75 | */ |
||
| 76 | protected function completeRunningJob() |
||
| 82 | |||
| 83 | /** |
||
| 84 | * Mocks and returns a gridfield with name 'TestGridField' and 'Link' method, which returns a url |
||
| 85 | * @return mixed |
||
| 86 | */ |
||
| 87 | protected function getGridFieldMock() |
||
| 102 | } |
||
| 103 |
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.