Skip to content

Commit 9451efd

Browse files
Merge pull request #516 from magento-frontend/PR
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
2 parents ed5eefb + 5a34b0a commit 9451efd

File tree

9 files changed

+63
-51
lines changed

9 files changed

+63
-51
lines changed

app/code/Magento/Developer/Model/View/Asset/PreProcessor/FrontendCompilation.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,6 @@ public function __construct(
7474
*/
7575
public function process(PreProcessor\Chain $chain)
7676
{
77-
$content = $chain->getContent();
78-
if (trim($content) !== '') {
79-
return;
80-
}
8177

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

91-
$result = $this->processContent($path, $content, $module, $context);
87+
$result = $this->processContent($path, $chain->getContent(), $module, $context);
9288
$chain->setContent($result['content']);
9389
$chain->setContentType($result['sourceType']);
9490
} finally {
@@ -107,14 +103,14 @@ public function process(PreProcessor\Chain $chain)
107103
*/
108104
private function processContent($path, $content, $module, FallbackContext $context)
109105
{
110-
$sourceType = '#\.' . preg_quote(pathinfo($path, PATHINFO_EXTENSION), '#') . '$#';
106+
$sourceTypePattern = '#\.' . preg_quote(pathinfo($path, PATHINFO_EXTENSION), '#') . '$#';
111107

112108
foreach ($this->alternativeSource->getAlternativesExtensionsNames() as $name) {
113109
$asset = $this->assetBuilder->setArea($context->getAreaCode())
114110
->setTheme($context->getThemePath())
115111
->setLocale($context->getLocale())
116112
->setModule($module)
117-
->setPath(preg_replace($sourceType, '.' . $name, $path))
113+
->setPath(preg_replace($sourceTypePattern, '.' . $name, $path))
118114
->build();
119115

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

130126
return [
131127
'content' => $content,
132-
'sourceType' => $sourceType
128+
'sourceType' => pathinfo($path, PATHINFO_EXTENSION)
133129
];
134130
}
135131
}

app/code/Magento/Developer/Test/Unit/Model/View/Asset/PreProcessor/FrontendCompilationTest.php

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -189,38 +189,6 @@ public function testProcess()
189189
$frontendCompilation->process($this->getChainMockExpects('', 1, 1, $newContentType));
190190
}
191191

192-
/**
193-
* Run test for process method (content not empty)
194-
*/
195-
public function testProcessContentNotEmpty()
196-
{
197-
$chainMock = $this->getChainMock();
198-
$assetMock = $this->getAssetMock();
199-
200-
$chainMock->expects(self::once())
201-
->method('getContent')
202-
->willReturn('test-content');
203-
204-
$chainMock->expects(self::never())
205-
->method('getAsset')
206-
->willReturn($assetMock);
207-
208-
$this->lockerProcessMock->expects(self::never())
209-
->method('lockProcess');
210-
$this->lockerProcessMock->expects(self::never())
211-
->method('unlockProcess');
212-
213-
$frontendCompilation = new FrontendCompilation(
214-
$this->assetSourceMock,
215-
$this->assetBuilderMock,
216-
$this->alternativeSourceMock,
217-
$this->lockerProcessMock,
218-
'lock'
219-
);
220-
221-
$frontendCompilation->process($chainMock);
222-
}
223-
224192
/**
225193
* @return Chain|\PHPUnit_Framework_MockObject_MockObject
226194
*/

dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/CreateBundleProductEntityTest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@
195195
<data name="product/data/price_type" xsi:type="string">Yes</data>
196196
<data name="product/data/price/dataset" xsi:type="string">dynamic-8</data>
197197
<data name="product/data/special_price" xsi:type="string">20</data>
198-
<data name="product/data/special_from_date/pattern" xsi:type="string">M j, Y -1 day</data>
199-
<data name="product/data/special_to_date/pattern" xsi:type="string">M j, Y +3 days</data>
198+
<data name="product/data/special_from_date/pattern" xsi:type="string">m/d/y -1 day</data>
199+
<data name="product/data/special_to_date/pattern" xsi:type="string">m/d/y +3 days</data>
200200
<data name="product/data/bundle_selections/dataset" xsi:type="string">default_dynamic</data>
201201
<data name="product/data/bundle_selections/products" xsi:type="string">catalogProductSimple::product_100_dollar,catalogProductSimple::product_40_dollar</data>
202202
<data name="product/data/checkout_data/dataset" xsi:type="string">bundle_default</data>

dev/tests/integration/testsuite/Magento/Framework/View/LayoutDirectivesTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,18 @@ public function testRemove()
198198
$this->assertTrue($layout->isBlock('child_block2'));
199199
}
200200

201+
/**
202+
* @magentoAppIsolation enabled
203+
*/
204+
public function testRemoveCancellation()
205+
{
206+
$layout = $this->_getLayoutModel('remove_cancellation.xml');
207+
$this->assertTrue($layout->isContainer('container1'));
208+
$this->assertTrue($layout->isBlock('child_block1'));
209+
$this->assertTrue($layout->isBlock('no_name2'));
210+
$this->assertFalse($layout->getBlock('not_exist'));
211+
}
212+
201213
/**
202214
* @magentoAppIsolation enabled
203215
*/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © 2016 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<layout>
9+
<container name="container1" label="Container 1">
10+
<block class="Magento\Framework\View\Element\Text" name="no_name2"/>
11+
</container>
12+
<referenceContainer name="container1" remove="true"/>
13+
<referenceBlock name="child_block1" remove="true"/>
14+
<block class="Magento\Framework\View\Element\Text" name="block_container" as="block.container">
15+
<block class="Magento\Framework\View\Element\Text" name="child_block1"/>
16+
<block class="Magento\Framework\View\Element\Text" name="child_block2"/>
17+
</block>
18+
<referenceContainer name="not_exist" remove="false"/>
19+
<referenceContainer name="container1" remove="false"/>
20+
<referenceBlock name="child_block1" remove="false"/>
21+
</layout>

lib/internal/Magento/Framework/View/Layout/Reader/Block.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,15 @@ protected function scheduleReference(
207207
$elementRemove = filter_var($currentElement->getAttribute('remove'), FILTER_VALIDATE_BOOLEAN);
208208
if ($elementRemove) {
209209
$scheduledStructure->setElementToRemoveList($elementName);
210-
} else {
211-
$data = $scheduledStructure->getStructureElementData($elementName, []);
212-
$data['attributes'] = $this->mergeBlockAttributes($data, $currentElement);
213-
$this->updateScheduledData($currentElement, $data);
214-
$this->evaluateArguments($currentElement, $data);
215-
$scheduledStructure->setStructureElementData($elementName, $data);
210+
return;
211+
} elseif ($currentElement->getAttribute('remove')) {
212+
$scheduledStructure->unsetElementFromListToRemove($elementName);
216213
}
214+
$data = $scheduledStructure->getStructureElementData($elementName, []);
215+
$data['attributes'] = $this->mergeBlockAttributes($data, $currentElement);
216+
$this->updateScheduledData($currentElement, $data);
217+
$this->evaluateArguments($currentElement, $data);
218+
$scheduledStructure->setStructureElementData($elementName, $data);
217219
}
218220

219221
/**

lib/internal/Magento/Framework/View/Layout/Reader/Container.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,12 @@ protected function containerReference(
141141
) {
142142
$containerName = $currentElement->getAttribute('name');
143143
$containerRemove = filter_var($currentElement->getAttribute('remove'), FILTER_VALIDATE_BOOLEAN);
144-
145144
if ($containerRemove) {
146145
$scheduledStructure->setElementToRemoveList($containerName);
147-
} else {
148-
$this->mergeContainerAttributes($scheduledStructure, $currentElement);
146+
return;
147+
} elseif ($currentElement->getAttribute('remove')) {
148+
$scheduledStructure->unsetElementFromListToRemove($containerName);
149149
}
150+
$this->mergeContainerAttributes($scheduledStructure, $currentElement);
150151
}
151152
}

lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/BlockTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,12 @@ public function testProcessReference(
188188
$setCondition,
189189
$setRemoveCondition
190190
) {
191+
if ($literal == 'referenceBlock' && $remove == 'false') {
192+
$this->scheduledStructure->expects($this->once())
193+
->method('unsetElementFromListToRemove')
194+
->with($literal);
195+
}
196+
191197
$this->context->expects($this->once())->method('getScheduledStructure')
192198
->will($this->returnValue($this->scheduledStructure));
193199

lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/ContainerTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ public function testProcess(
102102
->with($contextMock, $elementCurrent)
103103
->willReturnSelf();
104104

105+
if ($elementCurrent->getAttribute('remove') == 'false') {
106+
$scheduledStructureMock->expects($this->once())
107+
->method('unsetElementFromListToRemove')
108+
->with($elementCurrent->getAttribute('name'));
109+
}
110+
105111
$this->container->interpret($contextMock, $elementCurrent);
106112
}
107113

0 commit comments

Comments
 (0)