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 QueueFlushCommandTest extends TestCase |
||
| 9 | { |
||
| 10 | public function testExecute() |
||
| 11 | { |
||
| 12 | $application = new Application($this->kernel); |
||
| 13 | $application->add(new QueueFlushCommand()); |
||
| 14 | |||
| 15 | $command = $application->find('jobqueue:flush'); |
||
| 16 | $commandTester = new CommandTester($command); |
||
| 17 | $commandTester->execute(array('command' => $command->getName())); |
||
| 18 | |||
| 19 | $this->assertRegExp('/Cleaned exceptions/', $commandTester->getDisplay()); |
||
| 20 | } |
||
| 21 | } |
||
| 22 |