Skip to content

Commit 72fcf13

Browse files
committed
ACP2E-1709: error during declarative schema whitelsit generation
1 parent 9cbd08a commit 72fcf13

File tree

8 files changed

+119
-32
lines changed

8 files changed

+119
-32
lines changed

app/code/Magento/Developer/Test/Mftf/Test/WhitelistGeneratorTest.xml

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
10+
<table name="test_table" resource="default">
11+
<!--Columns-->
12+
<column xsi:type="tinyint" name="tinyint" disabled="true"/>
13+
<column xsi:type="tinyint" name="customint" unsigned="false" nullable="true"
14+
onCreate="migrateDataFrom(tinyint)" comment="Version Id"/>
15+
16+
<!--Constraints-->
17+
<constraint xsi:type="foreign" referenceId="TEST_TABLE_TINYINT_REFERENCE" disabled="1"/>
18+
<constraint xsi:type="foreign" referenceId="TEST_TABLE_CUSTOMINT_REFERENCE"
19+
column="customint" table="test_table"
20+
referenceTable="reference_table" referenceColumn="tinyint_ref" onDelete="NO ACTION"/>
21+
<!--Indexes-->
22+
<index referenceId="TEST_TABLE_INDEX" indexType="btree" disabled="1"/>
23+
<index referenceId="TEST_TABLE_CUSTOMINT_INDEX" indexType="btree">
24+
<column name="customint"/>
25+
<column name="bigint"/>
26+
</index>
27+
</table>
28+
</schema>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"test_table": {
3+
"column": {
4+
"tinyint": true,
5+
"customint": true
6+
},
7+
"index": {
8+
"TEST_TABLE_TINYINT_REFERENCE": true,
9+
"TEST_TABLE_CUSTOMINT_REFERENCE": true
10+
},
11+
"constraint": {
12+
"TEST_TABLE_INDEX": true,
13+
"TEST_TABLE_CUSTOMINT_INDEX": true
14+
}
15+
}
16+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
9+
<module name="Magento_TestSetupDeclarationModule10" setup_version="0.0.1"/>
10+
<sequence>
11+
<module name="Magento_TestSetupDeclarationModule1"/>
12+
</sequence>
13+
</config>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
use Magento\Framework\Component\ComponentRegistrar;
8+
9+
$registrar = new ComponentRegistrar();
10+
if ($registrar->getPath(ComponentRegistrar::MODULE, 'Magento_TestSetupDeclarationModule10') === null) {
11+
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_TestSetupDeclarationModule10', __DIR__);
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
10+
<table name="test_table" resource="default">
11+
<!--Columns-->
12+
<column xsi:type="tinyint" name="tinyint" disabled="true"/>
13+
<column xsi:type="tinyint" name="customint" unsigned="false" nullable="true"
14+
onCreate="migrateDataFrom(tinyint)" comment="Version Id"/>
15+
16+
<!--Constraints-->
17+
<constraint xsi:type="foreign" referenceId="TEST_TABLE_TINYINT_REFERENCE" disabled="1"/>
18+
<constraint xsi:type="foreign" referenceId="TEST_TABLE_CUSTOMINT_REFERENCE"
19+
column="customint" table="test_table"
20+
referenceTable="reference_table" referenceColumn="tinyint_ref" onDelete="NO ACTION"/>
21+
<!--Indexes-->
22+
<index referenceId="TEST_TABLE_INDEX" indexType="btree" disabled="1"/>
23+
<index referenceId="TEST_TABLE_CUSTOMINT_INDEX" indexType="btree">
24+
<column name="customint"/>
25+
<column name="bigint"/>
26+
</index>
27+
</table>
28+
</schema>

dev/tests/setup-integration/testsuite/Magento/Developer/Console/Command/TablesWhitelistGenerateCommandTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,15 @@ protected function setUp(): void
7070
*
7171
* @moduleName Magento_TestSetupDeclarationModule1
7272
* @moduleName Magento_TestSetupDeclarationModule8
73+
* @moduleName Magento_TestSetupDeclarationModule10
7374
* @throws \Exception
7475
*/
7576
public function testExecute()
7677
{
7778
$modules = [
7879
'Magento_TestSetupDeclarationModule1',
7980
'Magento_TestSetupDeclarationModule8',
81+
'Magento_TestSetupDeclarationModule10',
8082
];
8183

8284
$this->cliCommand->install($modules);
@@ -114,7 +116,7 @@ private function checkWhitelistFile(string $moduleName)
114116
$this->assertEmpty($this->tester->getDisplay());
115117

116118
$whitelistFileContent = file_get_contents($whiteListFileName);
117-
$expectedWhitelistContent = file_get_contents(
119+
$expectedWhitelistContent = rtrim(file_get_contents(
118120
dirname(__DIR__, 2)
119121
. DIRECTORY_SEPARATOR
120122
. implode(
@@ -126,7 +128,7 @@ private function checkWhitelistFile(string $moduleName)
126128
'db_schema_whitelist.json'
127129
]
128130
)
129-
);
131+
), "\n");
130132
$this->assertEquals($expectedWhitelistContent, $whitelistFileContent);
131133
}
132134
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"test_table": {
3+
"column": {
4+
"tinyint": true,
5+
"customint": true
6+
},
7+
"index": {
8+
"TEST_TABLE_TINYINT_REFERENCE": true,
9+
"TEST_TABLE_CUSTOMINT_REFERENCE": true,
10+
"TEST_TABLE_CUSTOMINT_BIGINT": true
11+
},
12+
"constraint": {
13+
"TEST_TABLE_INDEX": true,
14+
"TEST_TABLE_CUSTOMINT_INDEX": true,
15+
"TEST_TABLE_CUSTOMINT_REFERENCE_TABLE_TINYINT_REF": true
16+
}
17+
}
18+
}

0 commit comments

Comments
 (0)