Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DiConfigTest.php
Go to the documentation of this file.
1 <?php
7 
8 class DiConfigTest extends \PHPUnit\Framework\TestCase
9 {
10  public function testObsoleteDiFormat()
11  {
12  $invoker = new \Magento\Framework\App\Utility\AggregateInvoker($this);
13  $invoker(
14  [$this, 'assertObsoleteFormat'],
15  \Magento\Framework\App\Utility\Files::init()->getDiConfigs(true)
16  );
17  }
18 
24  public function assertObsoleteFormat($file)
25  {
26  $xml = simplexml_load_file($file);
27  $this->assertSame(
28  [],
29  $xml->xpath('//param'),
30  'The <param> node is obsolete. Instead, use the <argument name="..." xsi:type="...">'
31  );
32  $this->assertSame(
33  [],
34  $xml->xpath('//instance'),
35  'The <instance> node is obsolete. Instead, use the <argument name="..." xsi:type="object">'
36  );
37  $this->assertSame(
38  [],
39  $xml->xpath('//array'),
40  'The <array> node is obsolete. Instead, use the <argument name="..." xsi:type="array">'
41  );
42  $this->assertSame(
43  [],
44  $xml->xpath('//item[@key]'),
45  'The <item key="..."> node is obsolete. Instead, use the <item name="..." xsi:type="...">'
46  );
47  $this->assertSame(
48  [],
49  $xml->xpath('//value'),
50  'The <value> node is obsolete. Instead, provide the actual value as a text literal.'
51  );
52  }
53 
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 
69  {
70  $xml = simplexml_load_file($file);
71  foreach ($xml->xpath('//type') as $type) {
72  $this->assertNotContains(
73  \Magento\Framework\Console\CommandList::class,
74  $type->attributes(),
75  'Use \Magento\Framework\Console\CommandListInterface instead of \Magento\Framework\Console\CommandList'
76  );
77  }
78  }
79 }
$type
Definition: item.phtml:13