Skip to content

Commit

Permalink
MAGETWO-47892: [GitHub] Max execution time of 60 seconds exceeded in …
Browse files Browse the repository at this point in the history
…CLI #2461
  • Loading branch information
Dale Sikkema committed Mar 29, 2016
1 parent 3b7548a commit 4350c73
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Framework\Code\Minifier\Adapter\Css;

use CSSmin as CssMinLibrary;
Expand All @@ -26,10 +25,24 @@ class CSSmin implements AdapterInterface

/**
* @param CssMinLibrary $cssMinifier
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function __construct(CssMinLibrary $cssMinifier)
{
$this->cssMinifier = $cssMinifier;
// TODO: set $cssMinifier in constructor once MAGETWO-51176 is resolved.
}

/**
* Get CSS Minifier
*
* @return \CSSMin
*/
private function getCssMin()
{
if (!($this->cssMinifier instanceof \CSSMin)) {
$this->cssMinifier = new \CSSmin(false);
}
return $this->cssMinifier;
}

/**
Expand All @@ -42,7 +55,7 @@ public function minify($content)
{
$pcreRecursionLimit = ini_get('pcre.recursion_limit');
ini_set('pcre.recursion_limit', self::PCRE_RECURSION_LIMIT);
$result = $this->cssMinifier->run($content);
$result = $this->getCssMin()->run($content);
ini_set('pcre.recursion_limit', $pcreRecursionLimit);
return $result;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Framework\Code\Test\Unit\Minifier\Adapter\Css;

class CssMinTest extends \PHPUnit_Framework_TestCase
{
public function testMinify()
{
$cssMinMock = $this->getMockBuilder(\CSSmin::class)
->disableOriginalConstructor()
->getMock();
$cssMinAdapter = new \Magento\Framework\Code\Minifier\Adapter\Css\CSSmin($cssMinMock);
$property = new \ReflectionProperty(\Magento\Framework\Code\Minifier\Adapter\Css\CSSmin::class, 'cssMinifier');
$property->setAccessible(true);
$property->setValue($cssMinAdapter, $cssMinMock);

$expectedResult = 'minified content';
$cssMinMock->expects($this->once())->method('run')->willReturn($expectedResult);
$this->assertEquals($expectedResult, $cssMinAdapter->minify('not minified'));
}
}

0 comments on commit 4350c73

Please sign in to comment.