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 |
||
13 | class QuestionTest extends \TYPO3\CMS\Core\Tests\UnitTestCase |
||
14 | { |
||
15 | |||
16 | /** |
||
17 | * @var Question |
||
18 | */ |
||
19 | protected $fileDomainModelInstance; |
||
20 | |||
21 | /** |
||
22 | * Setup |
||
23 | * |
||
24 | * @return void |
||
25 | */ |
||
26 | protected function setUp() |
||
27 | { |
||
28 | $this->fileDomainModelInstance = new Question(); |
||
29 | } |
||
30 | |||
31 | /** |
||
32 | * @test |
||
33 | */ |
||
34 | public function titleCanBeSet() |
||
35 | { |
||
36 | $title = 'This is the title'; |
||
37 | $this->fileDomainModelInstance->setTitle($title); |
||
38 | $this->assertEquals($title, $this->fileDomainModelInstance->getTitle()); |
||
39 | } |
||
40 | } |
||
41 |