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 |
||
17 | class PrePushTest extends \PHPUnit_Framework_TestCase |
||
18 | { |
||
19 | /** |
||
20 | * Tests CommitMsg::run |
||
21 | */ |
||
22 | public function testExecute() |
||
23 | { |
||
24 | $repo = new DummyRepo(); |
||
25 | $repo->setup(); |
||
26 | |||
27 | $cmd = new PrePush(HMU_PATH_FILES . '/config/empty.json', $repo->getPath()); |
||
28 | $output = new DummyOutput(); |
||
29 | $input = new ArrayInput([]); |
||
30 | |||
31 | $cmd->setIO(new NullIO()); |
||
32 | $cmd->run($input, $output); |
||
33 | |||
34 | $repo->cleanup(); |
||
35 | } |
||
36 | } |
||
37 |