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 |
||
| 8 | class QueueShowCommandTest extends TestCase |
||
| 9 | { |
||
| 10 | public function testExecute() |
||
| 11 | { |
||
| 12 | $application = new Application($this->kernel); |
||
| 13 | $application->add(new QueueShowCommand()); |
||
| 14 | |||
| 15 | $command = $application->find('jobqueue:show'); |
||
| 16 | $commandTester = new CommandTester($command); |
||
| 17 | $commandTester->execute(array( |
||
| 18 | 'command' => $command->getName(), |
||
| 19 | 'queue-name' => 'toto', |
||
| 20 | )); |
||
| 21 | |||
| 22 | $this->assertRegExp('/| id | body | created | ended | failed |/', $commandTester->getDisplay()); |
||
| 23 | } |
||
| 24 | } |
||
| 25 |