Skip to content

Commit 8733f8c

Browse files
committed
MAGETWO-64085: Static versioning and styles minification break email fonts styles #8241
- add integration test
1 parent ca56c0a commit 8733f8c

File tree

5 files changed

+288
-2
lines changed

5 files changed

+288
-2
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Framework\Css\PreProcessor\Adapter;
7+
8+
class CssInlinerTest extends \PHPUnit\Framework\TestCase
9+
{
10+
/**
11+
* @var \Magento\Framework\Css\PreProcessor\Adapter\CssInliner
12+
*/
13+
private $model;
14+
15+
/**
16+
* @var \Magento\Framework\ObjectManagerInterface
17+
*/
18+
private $objectManager;
19+
20+
protected function setUp()
21+
{
22+
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
23+
24+
$this->model = $this->objectManager->create(\Magento\Framework\Css\PreProcessor\Adapter\CssInliner::class);
25+
}
26+
27+
/**
28+
* @param string $htmlFilePath
29+
* @param string $cssFilePath
30+
* @param string $cssExpected
31+
* @dataProvider getFilesDataProvider
32+
*/
33+
public function testGetFiles($htmlFilePath, $cssFilePath, $cssExpected)
34+
{
35+
$html = file_get_contents($htmlFilePath);
36+
$css = file_get_contents($cssFilePath);
37+
$this->model->setCss($css);
38+
$this->model->setHtml($html);
39+
$result = $this->model->process();
40+
$this->assertContains($cssExpected, $result);
41+
}
42+
43+
/**
44+
* @return array
45+
*/
46+
public function getFilesDataProvider()
47+
{
48+
$fixtureDir = dirname(dirname(__DIR__));
49+
return [
50+
'noSpacesCss'=>[
51+
'resultHtml' => $fixtureDir . "/_files/css/test-input.html",
52+
'cssWithoutSpaces' => $fixtureDir . "/_files/css/test-css-no-spaces.css",
53+
'vertical-align: top; padding: 10px 10px 10px 0; width: 50%;'
54+
],
55+
'withSpacesCss'=>[
56+
'resultHtml' => $fixtureDir . "/_files/css/test-input.html",
57+
'cssWithSpaces' => $fixtureDir . "/_files/css/test-css-with-spaces.css",
58+
'vertical-align: top; padding: 10px 10px 10px 0; width: 50%;'
59+
],
60+
];
61+
}
62+
63+
64+
65+
/**
66+
* @param string $htmlFilePath
67+
* @param string $cssFilePath
68+
* @param string $cssExpected
69+
* @dataProvider getFilesDataProviderEmogrifier
70+
*/
71+
public function testGetFilesEmogrifier($htmlFilePath, $cssFilePath, $cssExpected)
72+
{
73+
$emogrifier = new \Pelago\Emogrifier;
74+
75+
$html = file_get_contents($htmlFilePath);
76+
$css = file_get_contents($cssFilePath);
77+
$emogrifier->setCss($css);
78+
$emogrifier->setHtml($html);
79+
$result = $emogrifier->emogrify();
80+
/**
81+
* Tests a bug in the library where there's no spaces to CSS string before passing to Emogrifier
82+
* to fix known parsing issue with library.
83+
* This test should will fail when this bug is fixed in the library and we should fix the adapter.
84+
* https://github.com/jjriv/emogrifier/issues/370
85+
*/
86+
$this->assertNotContains($cssExpected, $result);
87+
}
88+
89+
/**
90+
* @return array
91+
*/
92+
public function getFilesDataProviderEmogrifier()
93+
{
94+
$fixtureDir = dirname(dirname(__DIR__));
95+
return [
96+
'noSpacesCss'=>[
97+
'resultHtml' => $fixtureDir . "/_files/css/test-input.html",
98+
'cssWithoutSpaces' => $fixtureDir . "/_files/css/test-css-no-spaces.css",
99+
'vertical-align: top; padding: 10px 10px 10px 0; width: 50%;'
100+
]
101+
];
102+
}
103+
}

dev/tests/integration/testsuite/Magento/Framework/Css/_files/css/test-css-no-spaces.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)