Skip to content

Commit 6662480

Browse files
MC-3030: Create/Update Integration Tests
- add test to make sure parents and children get converted to allowed parents correctly
1 parent efe6deb commit 6662480

13 files changed

+1254
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\PageBuilder\Model\Config\ContentType;
10+
11+
use Magento\TestFramework\Helper\Bootstrap;
12+
13+
class AllowedParentTest extends \PHPUnit\Framework\TestCase
14+
{
15+
/**
16+
* @var \Magento\PageBuilder\Model\Config\ContentType\Reader
17+
*/
18+
private $model;
19+
20+
/**
21+
* @var \Magento\PageBuilder\Model\Config\FileResolver|\PHPUnit_Framework_MockObject_MockObject
22+
*/
23+
private $fileResolverMock;
24+
25+
protected function setUp()
26+
{
27+
$objectManager = Bootstrap::getObjectManager();
28+
29+
$this->fileResolverMock = $this->createMock(
30+
\Magento\PageBuilder\Model\Config\FileResolver::class
31+
);
32+
33+
$this->model = $objectManager->create(
34+
\Magento\PageBuilder\Model\Config\ContentType\Reader::class,
35+
['fileResolver' => $this->fileResolverMock]
36+
);
37+
}
38+
39+
public function testParentsAndChildrenConvertToAllowedParents()
40+
{
41+
$filePath = '/../../../_files/content_type/allowed_parent/';
42+
$fileList = [
43+
file_get_contents(__DIR__ . $filePath . 'parents_and_children_allow.xml'),
44+
file_get_contents(__DIR__ . $filePath . 'parents_and_children_deny.xml'),
45+
file_get_contents(__DIR__ . $filePath . 'parents_allow.xml'),
46+
file_get_contents(__DIR__ . $filePath . 'parents_deny.xml'),
47+
file_get_contents(__DIR__ . $filePath . 'children_allow.xml'),
48+
file_get_contents(__DIR__ . $filePath . 'children_deny.xml'),
49+
file_get_contents(__DIR__ . $filePath . 'no_parents_and_children.xml'),
50+
file_get_contents(__DIR__ . $filePath . 'parents_allow_with_parent.xml'),
51+
file_get_contents(__DIR__ . $filePath . 'parents_deny_with_parent.xml'),
52+
file_get_contents(__DIR__ . $filePath . 'children_allow_with_child.xml'),
53+
file_get_contents(__DIR__ . $filePath . 'children_deny_with_child.xml'),
54+
];
55+
$this->fileResolverMock->expects($this->once())
56+
->method('get')
57+
->with('content_type/*.xml', 'global')
58+
->willReturn($fileList);
59+
$expected = include __DIR__ . '/../../../_files/content_type/allowed_parent/expected_merged_array.php';
60+
$this->assertEquals($expected, $this->model->read('global'));
61+
}
62+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
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:module:Magento_PageBuilder:etc/content_type.xsd">
9+
<content_types>
10+
<type name="children_allow" translate="label" sortOrder="5" label="Type 5" icon="pagebuilder-type-icon" component="Path/to/component" form="pagebuilder_type_form" group="group">
11+
<children default_policy="allow"/>
12+
<appearances>
13+
<appearance name="default" default="true" preview_template="Path/to/preview/template" render_template="Path/to/render/template" reader="Path/to/reader">
14+
<data_mapping>
15+
<elements>
16+
<element name="main" path=".">
17+
<style_properties>
18+
<property name="style_converter" source="converter" converter="Path/to/converter"/>
19+
<property name="style_no_converter" source="no_converter"/>
20+
</style_properties>
21+
<attributes>
22+
<attribute name="name" source="data-role"/>
23+
</attributes>
24+
<css name="css_classes"/>
25+
</element>
26+
</elements>
27+
</data_mapping>
28+
</appearance>
29+
</appearances>
30+
</type>
31+
</content_types>
32+
</config>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
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:module:Magento_PageBuilder:etc/content_type.xsd">
9+
<content_types>
10+
<type name="children_allow_with_child" translate="label" sortOrder="10" label="Type 10" icon="pagebuilder-type-icon" component="Path/to/component" form="pagebuilder_type_form" group="group">
11+
<children default_policy="allow">
12+
<child name="parents_allow" policy="deny"/>
13+
<child name="children_deny" policy="allow"/>
14+
<child name="no_parents_and_children" policy="deny"/>
15+
</children>
16+
<appearances>
17+
<appearance name="default" default="true" preview_template="Path/to/preview/template" render_template="Path/to/render/template" reader="Path/to/reader">
18+
<data_mapping>
19+
<elements>
20+
<element name="main" path=".">
21+
<style_properties>
22+
<property name="style_converter" source="converter" converter="Path/to/converter"/>
23+
<property name="style_no_converter" source="no_converter"/>
24+
</style_properties>
25+
<attributes>
26+
<attribute name="name" source="data-role"/>
27+
</attributes>
28+
<css name="css_classes"/>
29+
</element>
30+
</elements>
31+
</data_mapping>
32+
</appearance>
33+
</appearances>
34+
</type>
35+
</content_types>
36+
</config>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
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:module:Magento_PageBuilder:etc/content_type.xsd">
9+
<content_types>
10+
<type name="children_deny" translate="label" sortOrder="6" label="Type 6" icon="pagebuilder-type-icon" component="Path/to/component" form="pagebuilder_type_form" group="group">
11+
<children default_policy="deny"/>
12+
<appearances>
13+
<appearance name="default" default="true" preview_template="Path/to/preview/template" render_template="Path/to/render/template" reader="Path/to/reader">
14+
<data_mapping>
15+
<elements>
16+
<element name="main" path=".">
17+
<style_properties>
18+
<property name="style_converter" source="converter" converter="Path/to/converter"/>
19+
<property name="style_no_converter" source="no_converter"/>
20+
</style_properties>
21+
<attributes>
22+
<attribute name="name" source="data-role"/>
23+
</attributes>
24+
<css name="css_classes"/>
25+
</element>
26+
</elements>
27+
</data_mapping>
28+
</appearance>
29+
</appearances>
30+
</type>
31+
</content_types>
32+
</config>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
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:module:Magento_PageBuilder:etc/content_type.xsd">
9+
<content_types>
10+
<type name="children_deny_with_child" translate="label" sortOrder="11" label="Type 11" icon="pagebuilder-type-icon" component="Path/to/component" form="pagebuilder_type_form" group="group">
11+
<children default_policy="deny">
12+
<child name="parents_deny" policy="allow"/>
13+
<child name="children_allow" policy="deny"/>
14+
<child name="no_parents_and_children" policy="allow"/>
15+
</children>
16+
<appearances>
17+
<appearance name="default" default="true" preview_template="Path/to/preview/template" render_template="Path/to/render/template" reader="Path/to/reader">
18+
<data_mapping>
19+
<elements>
20+
<element name="main" path=".">
21+
<style_properties>
22+
<property name="style_converter" source="converter" converter="Path/to/converter"/>
23+
<property name="style_no_converter" source="no_converter"/>
24+
</style_properties>
25+
<attributes>
26+
<attribute name="name" source="data-role"/>
27+
</attributes>
28+
<css name="css_classes"/>
29+
</element>
30+
</elements>
31+
</data_mapping>
32+
</appearance>
33+
</appearances>
34+
</type>
35+
</content_types>
36+
</config>

0 commit comments

Comments
 (0)