Skip to content

Commit c5f9154

Browse files
committed
#558: Content Types Output Style Attribute Removal
- Adding Assertions for Style Verification
1 parent f50a767 commit c5f9154

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

dev/tests/integration/testsuite/Magento/PageBuilder/Setup/Converters/PageBuilderStripStylesTest.php

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
namespace Magento\PageBuilder\Setup\Converters;
1010

1111
use DOMDocument;
12+
use DOMElement;
1213
use DOMXPath;
1314
use Magento\Framework\ObjectManagerInterface;
1415
use Magento\TestFramework\Helper\Bootstrap;
@@ -50,11 +51,32 @@ public function testConvert(string $htmlString, int $expectedStyleTags)
5051

5152
libxml_clear_errors();
5253

53-
// Check Inline Styles Were Removed
54+
$getInternalStyles = false;
55+
$nodesBefore = $xpathBefore->query(PageBuilderStripStyles::XPATH_SELECTOR);
56+
$styleRules = [];
57+
58+
foreach ($nodesBefore as $node) {
59+
/* @var DOMElement $node */
60+
$styleAttr = $node->getAttribute('style');
61+
62+
if ($styleAttr) {
63+
$getInternalStyles = $xpathAfter->query('//body/style[last()]')->item(0)->textContent;
64+
$styleRules[] = $styleAttr;
65+
}
66+
}
67+
68+
// Assert Inline Styles Were Removed
5469
$this->assertEquals(0, count($xpathAfter->query(PageBuilderStripStyles::XPATH_SELECTOR)));
5570

56-
// Check Expected Internal Styles
71+
// Assert Expected Internal Styles
5772
$this->assertEquals($expectedStyleTags, count($xpathAfter->query('//style')));
73+
74+
// Assert Converted Styles
75+
if ($getInternalStyles) {
76+
foreach ($styleRules as $styleRule) {
77+
$this->assertStringContainsString($styleRule, $getInternalStyles);
78+
}
79+
}
5880
}
5981

6082
/**

0 commit comments

Comments
 (0)