Skip to content

Commit ea8a450

Browse files
PB-317: Saving PageBuilder Content w/ Background Images on Edge Will Results in No Images on Storefront
- add test
1 parent 3daa3f5 commit ea8a450

File tree

1 file changed

+100
-0
lines changed
  • dev/tests/integration/testsuite/Magento/PageBuilder/Model/Filter

1 file changed

+100
-0
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Pagebuilder\Model\Filter;
9+
10+
use Magento\TestFramework\ObjectManager;
11+
12+
class TemplateTest extends \PHPUnit\Framework\TestCase
13+
{
14+
/**
15+
* @var Template
16+
*/
17+
private $templateFilter;
18+
19+
protected function setUp()
20+
{
21+
$this->templateFilter = ObjectManager::getInstance()->create(Template::class);
22+
}
23+
24+
/**
25+
* @param string $results
26+
* @param bool $contains
27+
* @param string $value
28+
* @dataProvider getFilterForDataProvider
29+
*/
30+
public function testFilterFor(string $results, bool $contains, string $value)
31+
{
32+
$contains ?
33+
self::assertContains($results, $this->templateFilter->filter($value)) :
34+
self::assertNotContains($results, $this->templateFilter->filter($value));
35+
}
36+
37+
/**
38+
* @return array
39+
*/
40+
public function getFilterForDataProvider() : array
41+
{
42+
$template = <<<TEMPLATE
43+
<div data-content-type="row" data-appearance="contained" data-element="main">
44+
<div data-enable-parallax="0" data-parallax-speed="0.5" data-background-images="{\&quot;desktop_image\&quot;:\&quot;{{media url=jb-decorating.jpg}}\&quot;}" data-element="inner" style="justify-content: flex-start; display: flex; flex-direction: column; background-position: center center; background-size: cover; background-repeat: repeat; background-attachment: scroll; border-style: none; border-width: 1px; border-radius: 0px; min-height: 350px; margin: 0px 0px 10px; padding: 10px;"></div>
45+
</div>
46+
TEMPLATE;
47+
48+
$template2 = <<<TEMPLATE
49+
<div data-content-type="row" data-element="main" data-appearance="contained">
50+
<div style="background-position: center; border-width: 1px; border-style: none; margin: 0px 0px 10px; padding: 10px; border-radius: 0px; background-repeat: repeat; background-attachment: scroll; display: flex; min-height: 350px; background-size: cover; flex-direction: column; justify-content: flex-start;" data-element="inner" data-background-images='{\"desktop_image\":\"{{media url=jb-decorating.jpg}}\"}' data-parallax-speed="0.5" data-enable-parallax="0"></div>
51+
</div>
52+
TEMPLATE;
53+
54+
$template3 = <<<TEMPLATE
55+
<div data-content-type="row" data-element="main" data-appearance="contained">
56+
<div style="background-position: center; border-width: 1px; border-style: none; margin: 0px 0px 10px; padding: 10px; border-radius: 0px; background-repeat: repeat; background-attachment: scroll; display: flex; min-height: 350px; background-size: cover; flex-direction: column; justify-content: flex-start;" data-element="inner" data-background-images='{}' data-parallax-speed="0.5" data-enable-parallax="0"></div>
57+
</div>
58+
TEMPLATE;
59+
60+
$expectedResult = <<<EXPECTED_RESULT
61+
<style type="text/css">.background-image-
62+
EXPECTED_RESULT;
63+
64+
$expectedResult2 = <<<EXPECTED_RESULT
65+
class="background-image-
66+
EXPECTED_RESULT;
67+
return [
68+
[
69+
$expectedResult,
70+
true,
71+
$template
72+
],
73+
[
74+
$expectedResult2,
75+
true,
76+
$template
77+
],
78+
[
79+
$expectedResult,
80+
true,
81+
$template2
82+
],
83+
[
84+
$expectedResult2,
85+
true,
86+
$template2
87+
],
88+
[
89+
$expectedResult,
90+
false,
91+
$template3
92+
],
93+
[
94+
$expectedResult2,
95+
false,
96+
$template3
97+
],
98+
];
99+
}
100+
}

0 commit comments

Comments
 (0)