Skip to content

Commit

Permalink
Merge pull request #516 from magento-frontend/PR
Browse files Browse the repository at this point in the history
Fixed issues:
- MAGETWO-57432: Functional test Magento\Bundle\Test\TestCase\CreateBundleProductEntityTest is failed
- MAGETWO-55510: "Client side less compilation" does not work properly #3325
- MAGETWO-54935: [Github #1931] Cancellation of element removal in layouts doesn't work
  • Loading branch information
MomotenkoNatalia authored Oct 19, 2016
2 parents ed5eefb + 5a34b0a commit 9451efd
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 51 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
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@
<data name="product/data/price_type" xsi:type="string">Yes</data>
<data name="product/data/price/dataset" xsi:type="string">dynamic-8</data>
<data name="product/data/special_price" xsi:type="string">20</data>
<data name="product/data/special_from_date/pattern" xsi:type="string">M j, Y -1 day</data>
<data name="product/data/special_to_date/pattern" xsi:type="string">M j, Y +3 days</data>
<data name="product/data/special_from_date/pattern" xsi:type="string">m/d/y -1 day</data>
<data name="product/data/special_to_date/pattern" xsi:type="string">m/d/y +3 days</data>
<data name="product/data/bundle_selections/dataset" xsi:type="string">default_dynamic</data>
<data name="product/data/bundle_selections/products" xsi:type="string">catalogProductSimple::product_100_dollar,catalogProductSimple::product_40_dollar</data>
<data name="product/data/checkout_data/dataset" xsi:type="string">bundle_default</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,18 @@ public function testRemove()
$this->assertTrue($layout->isBlock('child_block2'));
}

/**
* @magentoAppIsolation enabled
*/
public function testRemoveCancellation()
{
$layout = $this->_getLayoutModel('remove_cancellation.xml');
$this->assertTrue($layout->isContainer('container1'));
$this->assertTrue($layout->isBlock('child_block1'));
$this->assertTrue($layout->isBlock('no_name2'));
$this->assertFalse($layout->getBlock('not_exist'));
}

/**
* @magentoAppIsolation enabled
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<layout>
<container name="container1" label="Container 1">
<block class="Magento\Framework\View\Element\Text" name="no_name2"/>
</container>
<referenceContainer name="container1" remove="true"/>
<referenceBlock name="child_block1" remove="true"/>
<block class="Magento\Framework\View\Element\Text" name="block_container" as="block.container">
<block class="Magento\Framework\View\Element\Text" name="child_block1"/>
<block class="Magento\Framework\View\Element\Text" name="child_block2"/>
</block>
<referenceContainer name="not_exist" remove="false"/>
<referenceContainer name="container1" remove="false"/>
<referenceBlock name="child_block1" remove="false"/>
</layout>
14 changes: 8 additions & 6 deletions lib/internal/Magento/Framework/View/Layout/Reader/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,15 @@ protected function scheduleReference(
$elementRemove = filter_var($currentElement->getAttribute('remove'), FILTER_VALIDATE_BOOLEAN);
if ($elementRemove) {
$scheduledStructure->setElementToRemoveList($elementName);
} else {
$data = $scheduledStructure->getStructureElementData($elementName, []);
$data['attributes'] = $this->mergeBlockAttributes($data, $currentElement);
$this->updateScheduledData($currentElement, $data);
$this->evaluateArguments($currentElement, $data);
$scheduledStructure->setStructureElementData($elementName, $data);
return;
} elseif ($currentElement->getAttribute('remove')) {
$scheduledStructure->unsetElementFromListToRemove($elementName);
}
$data = $scheduledStructure->getStructureElementData($elementName, []);
$data['attributes'] = $this->mergeBlockAttributes($data, $currentElement);
$this->updateScheduledData($currentElement, $data);
$this->evaluateArguments($currentElement, $data);
$scheduledStructure->setStructureElementData($elementName, $data);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,12 @@ protected function containerReference(
) {
$containerName = $currentElement->getAttribute('name');
$containerRemove = filter_var($currentElement->getAttribute('remove'), FILTER_VALIDATE_BOOLEAN);

if ($containerRemove) {
$scheduledStructure->setElementToRemoveList($containerName);
} else {
$this->mergeContainerAttributes($scheduledStructure, $currentElement);
return;
} elseif ($currentElement->getAttribute('remove')) {
$scheduledStructure->unsetElementFromListToRemove($containerName);
}
$this->mergeContainerAttributes($scheduledStructure, $currentElement);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@ public function testProcessReference(
$setCondition,
$setRemoveCondition
) {
if ($literal == 'referenceBlock' && $remove == 'false') {
$this->scheduledStructure->expects($this->once())
->method('unsetElementFromListToRemove')
->with($literal);
}

$this->context->expects($this->once())->method('getScheduledStructure')
->will($this->returnValue($this->scheduledStructure));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ public function testProcess(
->with($contextMock, $elementCurrent)
->willReturnSelf();

if ($elementCurrent->getAttribute('remove') == 'false') {
$scheduledStructureMock->expects($this->once())
->method('unsetElementFromListToRemove')
->with($elementCurrent->getAttribute('name'));
}

$this->container->interpret($contextMock, $elementCurrent);
}

Expand Down

0 comments on commit 9451efd

Please sign in to comment.