Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DeclarativeSchemaRuleTest.php
Go to the documentation of this file.
1 <?php
7 
13 class DeclarativeSchemaRuleTest extends \PHPUnit\Framework\TestCase
14 {
18  protected $model;
19 
20  protected function setUp()
21  {
22  $this->model = new DeclarativeSchemaRule(['some_table' => 'SomeModule']);
23  }
24 
32  public function testGetDependencyInfo($module, $file, $contents, array $expected)
33  {
34  $actualDependencies = $this->model->getDependencyInfo($module, 'db_schema', $file, $contents);
35  $this->assertEquals(
36  $expected,
37  $actualDependencies
38  );
39  }
40 
42  {
43  return [
44  ['any', 'non-db-schema-file.php', 'any', []],
45  [
46  'any',
47  '/app/Magento/Module/etc/db_schema.xml',
48  '<table name="unknown_table"></table>',
49  [['module' => 'Unknown', 'source' => 'unknown_table']]
50  ],
51  [
52  'SomeModule',
53  '/app/some/path/etc/db_schema.xml',
54  '<table name="some_table"></table>',
55  []
56  ],
57  [
58  'any',
59  '/app/some/path/etc/db_schema.xml',
60  '<table name="some_table"></table>',
61  [
62  [
63  'module' => 'SomeModule',
65  'source' => 'some_table',
66  ]
67  ]
68  ],
69  [
70  'any',
71  '/app/some/path/etc/db_schema.xml',
72  '<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
73  xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
74  <table name="some_table">
75  <constraint xsi:type="foreign"
76  name="FK_NAME"
77  table="some_table"
78  column="some_col"
79  referenceTable="ref_table"
80  referenceColumn="ref_col"
81  onDelete="CASCADE"/>
82  </table>
83  </schema>',
84  [
85  [
86  'module' => 'SomeModule',
88  'source' => 'some_table',
89  ],
90  [
91  'module' => 'Unknown',
92  'source' => 'ref_table',
93  ]
94  ]
95  ]
96  ];
97  }
98 }
$contents
Definition: website.php:14
testGetDependencyInfo($module, $file, $contents, array $expected)