Skip to content

Commit 47f36ad

Browse files
committed
ACP2E-3709: [Cloud] Changing table column type from Int to Decimal using db_schema.xml file In Magento 2 Results In Errors
1 parent 9958d72 commit 47f36ad

File tree

2 files changed

+49
-5
lines changed

2 files changed

+49
-5
lines changed

lib/internal/Magento/Framework/Config/Reader/Filesystem.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright 2014 Adobe
4-
* All Rights Reserved.
3+
* Copyright 2014 Adobe
4+
* All Rights Reserved.
55
*/
66

77
namespace Magento\Framework\Config\Reader;
@@ -84,7 +84,7 @@ class Filesystem implements \Magento\Framework\Config\ReaderInterface
8484
/**
8585
* Name of an attribute that stands for data type of node values
8686
*/
87-
public const TYPE_ATTRIBUTE = 'xsi:type';
87+
private const TYPE_ATTRIBUTE = 'xsi:type';
8888

8989
/**
9090
* Constructor

lib/internal/Magento/Framework/Config/Test/Unit/Reader/FilesystemTest.php

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2014 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -15,6 +15,7 @@
1515
use Magento\Framework\Config\ValidationStateInterface;
1616
use PHPUnit\Framework\MockObject\MockObject;
1717
use PHPUnit\Framework\TestCase;
18+
use Magento\Framework\Config\Dom;
1819

1920
/**
2021
* Test for
@@ -53,6 +54,11 @@ class FilesystemTest extends TestCase
5354
*/
5455
protected $_file;
5556

57+
/**
58+
* @var Filesystem
59+
*/
60+
private $filesystem;
61+
5662
protected function setUp(): void
5763
{
5864
if (!function_exists('libxml_set_external_entity_loader')) {
@@ -64,6 +70,16 @@ protected function setUp(): void
6470
$this->_schemaLocatorMock = $this->getMockForAbstractClass(SchemaLocatorInterface::class);
6571
$this->_validationStateMock = $this->getMockForAbstractClass(ValidationStateInterface::class);
6672
$this->urnResolver = new UrnResolver();
73+
$this->filesystem = new Filesystem(
74+
$this->_fileResolverMock,
75+
$this->_converterMock,
76+
$this->_schemaLocatorMock,
77+
$this->_validationStateMock,
78+
'test.xml',
79+
['/test/node' => 'id'],
80+
Dom::class,
81+
'global'
82+
);
6783
}
6884

6985
public function testRead()
@@ -170,4 +186,32 @@ public function testReadException()
170186
);
171187
$model->read();
172188
}
189+
190+
public function testCreateConfigMergerSuccess()
191+
{
192+
$initialContents = '<?xml version="1.0"?><config><test id="1"/></config>';
193+
$reflection = new \ReflectionClass($this->filesystem);
194+
$method = $reflection->getMethod('_createConfigMerger');
195+
$result = $method->invokeArgs(
196+
$this->filesystem,
197+
[Dom::class, $initialContents]
198+
);
199+
$this->assertInstanceOf(\Magento\Framework\Config\Dom::class, $result);
200+
$domReflection = new \ReflectionClass($result);
201+
$typeAttributeProperty = $domReflection->getProperty('typeAttributeName');
202+
$this->assertEquals('xsi:type', $typeAttributeProperty->getValue($result));
203+
}
204+
205+
public function testCreateConfigMergerThrowsException()
206+
{
207+
$initialContents = '<?xml version="1.0"?><config><test id="1"/></config>';
208+
$wrongClass = \stdClass::class;
209+
$reflection = new \ReflectionClass($this->filesystem);
210+
$method = $reflection->getMethod('_createConfigMerger');
211+
$this->expectException(\UnexpectedValueException::class);
212+
$this->expectExceptionMessage(
213+
"Instance of the DOM config merger is expected, got {$wrongClass} instead."
214+
);
215+
$method->invokeArgs($this->filesystem, [$wrongClass, $initialContents]);
216+
}
173217
}

0 commit comments

Comments
 (0)