Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
MinifyTemplatesTest.php
Go to the documentation of this file.
1 <?php
7 
9 
12 
13 use PHPUnit_Framework_MockObject_MockObject as Mock;
14 
18 class MinifyTemplatesTest extends \PHPUnit\Framework\TestCase
19 {
23  private $service;
24 
28  private $filesUtils;
29 
33  private $htmlMinifier;
34 
38  protected function setUp()
39  {
40  $this->filesUtils = $this->createPartialMock(Files::class, ['getPhtmlFiles']);
41 
42  $this->htmlMinifier = $this->getMockForAbstractClass(
43  MinifierInterface::class,
44  ['minify'],
45  '',
46  false
47  );
48 
49  $this->service = new MinifyTemplates(
50  $this->filesUtils,
51  $this->htmlMinifier
52  );
53  }
54 
58  public function testMinifyTemplates()
59  {
60  $templateMock = "template.phtml";
61  $templatesMock = [$templateMock];
62 
63  $this->filesUtils->expects($this->once())
64  ->method('getPhtmlFiles')
65  ->with(false, false)
66  ->willReturn($templatesMock);
67 
68  $this->htmlMinifier->expects($this->once())->method('minify')->with($templateMock);
69 
70  $this->assertEquals(1, $this->service->minifyTemplates());
71  }
72 }