Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CssInlinerTest.php
Go to the documentation of this file.
1 <?php
7 
8 class CssInlinerTest extends \PHPUnit\Framework\TestCase
9 {
13  private $model;
14 
18  private $objectManager;
19 
20  protected function setUp()
21  {
23 
24  $this->model = $this->objectManager->create(\Magento\Framework\Css\PreProcessor\Adapter\CssInliner::class);
25  }
26 
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 
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 
69  public function testGetFilesEmogrifier($htmlFilePath, $cssFilePath, $cssExpected)
70  {
71  $emogrifier = new \Pelago\Emogrifier;
72 
73  $html = file_get_contents($htmlFilePath);
74  $css = file_get_contents($cssFilePath);
75  $emogrifier->setCss($css);
76  $emogrifier->setHtml($html);
77  $result = $emogrifier->emogrify();
78 
83  $this->assertContains($cssExpected, $result);
84  }
85 
90  {
91  $fixtureDir = dirname(dirname(__DIR__));
92  return [
93  'noSpacesCss'=>[
94  'resultHtml' => $fixtureDir . "/_files/css/test-input.html",
95  'cssWithoutSpaces' => $fixtureDir . "/_files/css/test-css-no-spaces.css",
96  'vertical-align: top; padding: 10px 10px 10px 0; width: 50%;'
97  ]
98  ];
99  }
100 }
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60
testGetFiles($htmlFilePath, $cssFilePath, $cssExpected)
testGetFilesEmogrifier($htmlFilePath, $cssFilePath, $cssExpected)