Skip to content

Commit

Permalink
MAGETWO-55510: "Client side less compilation" does not work properly #…
Browse files Browse the repository at this point in the history
  • Loading branch information
eug123 committed Oct 7, 2016
1 parent 3a43a25 commit 9bd170d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ public function __construct(
*/
public function process(PreProcessor\Chain $chain)
{
$content = $chain->getContent();
if (trim($content) !== '') {
return;
}

try {
$this->lockerProcess->lockProcess($this->lockName);
Expand All @@ -88,7 +84,7 @@ public function process(PreProcessor\Chain $chain)
/** @var FallbackContext $context */
$context = $chain->getAsset()->getContext();

$result = $this->processContent($path, $content, $module, $context);
$result = $this->processContent($path, $chain->getContent(), $module, $context);
$chain->setContent($result['content']);
$chain->setContentType($result['sourceType']);
} finally {
Expand All @@ -107,14 +103,14 @@ public function process(PreProcessor\Chain $chain)
*/
private function processContent($path, $content, $module, FallbackContext $context)
{
$sourceType = '#\.' . preg_quote(pathinfo($path, PATHINFO_EXTENSION), '#') . '$#';
$sourceTypePattern = '#\.' . preg_quote(pathinfo($path, PATHINFO_EXTENSION), '#') . '$#';

foreach ($this->alternativeSource->getAlternativesExtensionsNames() as $name) {
$asset = $this->assetBuilder->setArea($context->getAreaCode())
->setTheme($context->getThemePath())
->setLocale($context->getLocale())
->setModule($module)
->setPath(preg_replace($sourceType, '.' . $name, $path))
->setPath(preg_replace($sourceTypePattern, '.' . $name, $path))
->build();

$processedContent = $this->assetSource->getContent($asset);
Expand All @@ -129,7 +125,7 @@ private function processContent($path, $content, $module, FallbackContext $conte

return [
'content' => $content,
'sourceType' => $sourceType
'sourceType' => pathinfo($path, PATHINFO_EXTENSION)
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -189,38 +189,6 @@ public function testProcess()
$frontendCompilation->process($this->getChainMockExpects('', 1, 1, $newContentType));
}

/**
* Run test for process method (content not empty)
*/
public function testProcessContentNotEmpty()
{
$chainMock = $this->getChainMock();
$assetMock = $this->getAssetMock();

$chainMock->expects(self::once())
->method('getContent')
->willReturn('test-content');

$chainMock->expects(self::never())
->method('getAsset')
->willReturn($assetMock);

$this->lockerProcessMock->expects(self::never())
->method('lockProcess');
$this->lockerProcessMock->expects(self::never())
->method('unlockProcess');

$frontendCompilation = new FrontendCompilation(
$this->assetSourceMock,
$this->assetBuilderMock,
$this->alternativeSourceMock,
$this->lockerProcessMock,
'lock'
);

$frontendCompilation->process($chainMock);
}

/**
* @return Chain|\PHPUnit_Framework_MockObject_MockObject
*/
Expand Down

0 comments on commit 9bd170d

Please sign in to comment.