TemplateMinifierTest.php 1.57 KB
Newer Older
Ketan's avatar
Ketan committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
namespace Magento\Deploy\Test\Unit\Model\Deploy;

/**
 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
 */
class TemplateMinifierTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @var \Magento\Deploy\Model\Deploy\TemplateMinifier
     */
    private $model;

    /**
     * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\Utility\Files
     */
    private $filesUtilsMock;

    /**
     * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\View\Template\Html\MinifierInterface
     */
    private $minifierMock;

    protected function setUp()
    {
        $this->minifierMock = $this->getMock(
            \Magento\Framework\View\Template\Html\MinifierInterface::class,
            [],
            [],
            '',
            false
        );
        $this->filesUtilsMock = $this->getMock(\Magento\Framework\App\Utility\Files::class, [], [], '', false);

        $this->model = new \Magento\Deploy\Model\Deploy\TemplateMinifier(
            $this->filesUtilsMock,
            $this->minifierMock
        );
    }

    public function testMinifyTemplates()
    {
        $templateMock = "template.phtml";
        $templatesMock = [$templateMock];

        $this->filesUtilsMock->expects($this->once())->method('getPhtmlFiles')->with(false, false)
            ->willReturn($templatesMock);
        $this->minifierMock->expects($this->once())->method('minify')->with($templateMock);

        self::assertEquals(1, $this->model->minifyTemplates());
    }
}