Skip to content

Commit 114855d

Browse files
ENGCOM-9086: #32309: IncosistentReferenceDefinition wrong check result #32959
- Merge Pull Request #32959 from engcom-Foxtrot/magento2:#32309 - Merged commits: 1. 3d14e8c 2. 00baa67 3. d98d958 4. 0ef6ef9 5. f9dd816 6. e405b8f
2 parents 1990aec + e405b8f commit 114855d

File tree

3 files changed

+45
-1
lines changed

3 files changed

+45
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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" comment="Test Table">
11+
<column xsi:type="int" name="page_id" nullable="true" unsigned="true" identity="true"/>
12+
<constraint xsi:type="primary" referenceId="PRIMARY">
13+
<column name="page_id"/>
14+
</constraint>
15+
</table>
16+
<table name="dependent" resource="default" comment="Lol">
17+
<column xsi:type="float" name="page_id_on" nullable="true" unsigned="true"/>
18+
<constraint xsi:type="foreign" referenceId="FOREIGN" table="dependent" column="page_id_on" referenceColumn="page_id"
19+
referenceTable="test_table"/>
20+
</table>
21+
</schema>

dev/tests/setup-integration/testsuite/Magento/Setup/ValidationRulesTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,29 @@ public function testFailOnIncosistentReferenceDefinition()
8787
$this->schemaConfig->getDeclarationConfig();
8888
}
8989

90+
/**
91+
* @moduleName Magento_TestSetupDeclarationModule8
92+
*/
93+
public function testFailOnInconsistentReferenceTypeDefinition()
94+
{
95+
$this->expectException(LocalizedException::class);
96+
$this->expectExceptionMessageMatches(
97+
'/Column definition "page_id_on" and reference column definition "page_id"'
98+
. ' are different in tables "dependent" and "test_table"/'
99+
);
100+
101+
$this->cliCommad->install(
102+
['Magento_TestSetupDeclarationModule8']
103+
);
104+
$this->moduleManager->updateRevision(
105+
'Magento_TestSetupDeclarationModule8',
106+
'inconsistent_reference_type_definition',
107+
'db_schema.xml',
108+
'etc'
109+
);
110+
$this->schemaConfig->getDeclarationConfig();
111+
}
112+
90113
/**
91114
* @moduleName Magento_TestSetupDeclarationModule8
92115
*/

lib/internal/Magento/Framework/Setup/Declaration/Schema/Declaration/ValidationRules/IncosistentReferenceDefinition.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ private function assertDefinitionEqual(Column $column, Column $referenceColumn)
4040
* Columns should have the same types
4141
*/
4242
if ($column->getType() !== $referenceColumn->getType()) {
43-
return true;
43+
return false;
4444
}
4545

4646
return $this->assertUnsigned($column, $referenceColumn) &&

0 commit comments

Comments
 (0)