Skip to content

Commit fc3e2bf

Browse files
committed
MAGETWO-52248: Incorrect Usage of \Magento\Framework\Console\CommandList
- Added static test to verify that di.xml file has no directly configured CommandList class and CommandListInterface is used instead;
1 parent f8b0754 commit fc3e2bf

File tree

1 file changed

+26
-0
lines changed
  • dev/tests/static/testsuite/Magento/Test/Legacy/Magento/Framework/ObjectManager

1 file changed

+26
-0
lines changed

dev/tests/static/testsuite/Magento/Test/Legacy/Magento/Framework/ObjectManager/DiConfigTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,30 @@ public function assertObsoleteFormat($file)
5050
'The <value> node is obsolete. Instead, provide the actual value as a text literal.'
5151
);
5252
}
53+
54+
public function testCommandListClassIsNotDirectlyConfigured()
55+
{
56+
$invoker = new \Magento\Framework\App\Utility\AggregateInvoker($this);
57+
$invoker(
58+
[$this, 'assertCommandListClassIsNotDirectlyConfigured'],
59+
\Magento\Framework\App\Utility\Files::init()->getDiConfigs(true)
60+
);
61+
}
62+
63+
/**
64+
* Scan the specified di.xml file and assert that it has no directly configured CommandList class
65+
*
66+
* @param string $file
67+
*/
68+
public function assertCommandListClassIsNotDirectlyConfigured($file)
69+
{
70+
$xml = simplexml_load_file($file);
71+
foreach ($xml->xpath('//type') as $type) {
72+
$this->assertNotContains(
73+
'Magento\Framework\Console\CommandList',
74+
$type->attributes(),
75+
'Use \Magento\Framework\Console\CommandListInterface instead of \Magento\Framework\Console\CommandList'
76+
);
77+
}
78+
}
5379
}

0 commit comments

Comments
 (0)