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 |
||
| 9 | class ConfigurationTest extends AdminTestBase |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * GetConfigTreeBuilder method should a return valid array nodes. The configuration is more tested in |
||
| 13 | * LagAdminExtensionTest. |
||
| 14 | */ |
||
| 15 | public function testGetConfigTreeBuilder() |
||
| 16 | { |
||
| 17 | $configuration = new Configuration(); |
||
| 18 | $tree = $configuration->getConfigTreeBuilder(); |
||
| 19 | /** @var ArrayNode $arrayNode */ |
||
| 20 | $arrayNode = $tree->buildTree(); |
||
| 21 | $this->assertInstanceOf(ArrayNode::class, $arrayNode); |
||
| 22 | |||
| 23 | $arrayConfiguration = $arrayNode->getChildren(); |
||
| 24 | |||
| 25 | $this->assertArrayHasKey('application', $arrayConfiguration); |
||
| 26 | $this->assertInstanceOf(ArrayNode::class, $arrayNode->getChildren()['application']); |
||
| 27 | $this->assertArrayHasKey('admins', $arrayConfiguration); |
||
| 28 | $this->assertInstanceOf(ArrayNode::class, $arrayNode->getChildren()['admins']); |
||
| 29 | $this->assertArrayHasKey('menus', $arrayConfiguration); |
||
| 30 | $this->assertInstanceOf(ArrayNode::class, $arrayNode->getChildren()['menus']); |
||
| 31 | } |
||
| 32 | } |
||
| 33 |