Skip to content

Commit 64cef64

Browse files
ENGCOM-7278: Fix #24656: allow 'group' attribute on referenceBlock layout XML element #27575
- Merge Pull Request #27575 from korostii/magento2:korostii-patch-24656 - Merged commits: 1. 20a97cd 2. d1126e7 3. 5c7e2cd 4. fa49d55
2 parents ab59159 + fa49d55 commit 64cef64

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Test\Integrity\Modular;
7+
8+
class LayoutConfigFilesTest extends \PHPUnit\Framework\TestCase
9+
{
10+
/**
11+
* Path to schema file
12+
*
13+
* @var string
14+
*/
15+
protected $schemaFile;
16+
17+
protected function setUp()
18+
{
19+
$urnResolver = new \Magento\Framework\Config\Dom\UrnResolver();
20+
$this->schemaFile = $urnResolver->getRealPath('urn:magento:framework:View/Layout/etc/elements.xsd');
21+
}
22+
23+
/**
24+
* Test a valid layout XML file
25+
*/
26+
public function testValidLayoutXmlFile()
27+
{
28+
$validationStateMock = $this->createMock(\Magento\Framework\Config\ValidationStateInterface::class);
29+
$validationStateMock->method('isValidationRequired')->willReturn(true);
30+
$domConfig = new \Magento\Framework\Config\Dom(
31+
'<referenceBlock name="product.info.something" group="column_left"></referenceBlock>',
32+
$validationStateMock
33+
);
34+
$result = $domConfig->validate($this->schemaFile, $errors);
35+
$this->assertTrue($result);
36+
$this->assertEmpty($errors);
37+
}
38+
39+
/**
40+
* Test a layout XML file having an invalid tag element
41+
*/
42+
public function testBrokenLayoutXmlFile()
43+
{
44+
$validationStateMock = $this->createMock(\Magento\Framework\Config\ValidationStateInterface::class);
45+
$validationStateMock->method('isValidationRequired')->willReturn(true);
46+
$domConfig = new \Magento\Framework\Config\Dom(
47+
'<invalidElement name="some.name"></invalidElement>',
48+
$validationStateMock
49+
);
50+
$result = $domConfig->validate($this->schemaFile, $errors);
51+
$this->assertFalse($result);
52+
$this->assertNotEmpty($errors);
53+
}
54+
}

lib/internal/Magento/Framework/View/Layout/etc/elements.xsd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@
328328
<xs:attribute type="elementNameType" name="name" use="required"/>
329329
<xs:attribute type="xs:string" name="template" use="optional"/>
330330
<xs:attribute type="xs:string" name="class" use="optional"/>
331+
<xs:attribute type="xs:string" name="group" use="optional"/>
331332
<xs:attribute type="xs:boolean" name="display" default="true" use="optional"/>
332333
<xs:attribute type="xs:boolean" name="remove" use="optional"/>
333334
</xs:complexType>

0 commit comments

Comments
 (0)