Skip to content

Commit 46d2502

Browse files
committed
MAGETWO-80091: Merge 2.0.17-develop into 2.0-develop
- Resolve conflicts
1 parent 7d64bdc commit 46d2502

File tree

10 files changed

+146
-26
lines changed

10 files changed

+146
-26
lines changed

app/code/Magento/CatalogWidget/Block/Product/Widget/Conditions.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,14 @@ public function __construct(
8282
protected function _construct()
8383
{
8484
$widget = $this->registry->registry('current_widget_instance');
85-
$widgetOptions = $this->getLayout()->getBlock('wysiwyg_widget.options');
8685

8786
if ($widget) {
8887
$widgetParameters = $widget->getWidgetParameters();
89-
} elseif ($widgetOptions) {
90-
$widgetParameters = $widgetOptions->getWidgetValues();
88+
} else {
89+
$widgetOptions = $this->getLayout()->getBlock('wysiwyg_widget.options');
90+
if ($widgetOptions) {
91+
$widgetParameters = $widgetOptions->getWidgetValues();
92+
}
9193
}
9294

9395
if (isset($widgetParameters['conditions'])) {

app/code/Magento/ConfigurableProduct/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/ConfigurableTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,8 @@ public function testAfterInitializeForNotConfigurableProduct()
191191
}
192192

193193
/**
194-
* generate product resource model mock
194+
* Generate product resource model mock.
195+
*
195196
* @param $postValue
196197
* @return \PHPUnit_Framework_MockObject_MockObject
197198
*/

app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/configurable_associated_product_listing.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,5 +172,18 @@
172172
</item>
173173
</argument>
174174
</column>
175+
<column name="status">
176+
<argument name="data" xsi:type="array">
177+
<item name="options" xsi:type="object">Magento\Catalog\Model\Product\Attribute\Source\Status</item>
178+
<item name="config" xsi:type="array">
179+
<item name="filter" xsi:type="string">select</item>
180+
<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item>
181+
<item name="add_field" xsi:type="boolean">true</item>
182+
<item name="dataType" xsi:type="string">select</item>
183+
<item name="label" xsi:type="string" translate="true">Status</item>
184+
<item name="sortOrder" xsi:type="number">100</item>
185+
</item>
186+
</argument>
187+
</column>
175188
</columns>
176189
</listing>

app/code/Magento/Customer/Test/Unit/Model/ResourceModel/CustomerRepositoryTest.php

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,12 @@ protected function setUp()
159159
\Magento\Customer\Api\Data\CustomerInterface::class,
160160
[],
161161
'',
162-
false
162+
true,
163+
true,
164+
true,
165+
[
166+
'__toArray'
167+
]
163168
);
164169

165170
$this->model = new \Magento\Customer\Model\ResourceModel\CustomerRepository(
@@ -274,6 +279,11 @@ public function testSave()
274279
'',
275280
false
276281
);
282+
283+
$this->customer->expects($this->atLeastOnce())
284+
->method('__toArray')
285+
->willReturn(['default_billing', 'default_shipping']);
286+
277287
$customerAttributesMetaData = $this->getMockForAbstractClass(
278288
\Magento\Framework\Api\CustomAttributesDataInterface::class,
279289
[],
@@ -315,7 +325,7 @@ public function testSave()
315325
->with($this->customer, CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER, $this->customer)
316326
->willReturn($customerAttributesMetaData);
317327
$this->customerRegistry->expects($this->atLeastOnce())
318-
->method("remove")
328+
->method('remove')
319329
->with($customerId);
320330
$address->expects($this->once())
321331
->method('setCustomerId')
@@ -341,7 +351,7 @@ public function testSave()
341351
->with([$address]);
342352
$this->extensibleDataObjectConverter->expects($this->once())
343353
->method('toNestedArray')
344-
->with($customerAttributesMetaData, [], '\Magento\Customer\Api\Data\CustomerInterface')
354+
->with($customerAttributesMetaData, [], \Magento\Customer\Api\Data\CustomerInterface::class)
345355
->willReturn(['customerData']);
346356
$this->customerFactory->expects($this->once())
347357
->method('create')
@@ -476,6 +486,11 @@ public function testSaveWithPasswordHash()
476486
'getId'
477487
]
478488
);
489+
490+
$this->customer->expects($this->atLeastOnce())
491+
->method('__toArray')
492+
->willReturn(['default_billing', 'default_shipping']);
493+
479494
$customerModel = $this->getMock(
480495
\Magento\Customer\Model\Customer::class,
481496
[
@@ -548,7 +563,7 @@ public function testSaveWithPasswordHash()
548563
->with([$address]);
549564
$this->extensibleDataObjectConverter->expects($this->once())
550565
->method('toNestedArray')
551-
->with($customerAttributesMetaData, [], '\Magento\Customer\Api\Data\CustomerInterface')
566+
->with($customerAttributesMetaData, [], \Magento\Customer\Api\Data\CustomerInterface::class)
552567
->willReturn(['customerData']);
553568
$this->customerFactory->expects($this->once())
554569
->method('create')
@@ -557,7 +572,7 @@ public function testSaveWithPasswordHash()
557572
$customerModel->expects($this->once())
558573
->method('getStoreId')
559574
->willReturn(null);
560-
$store = $this->getMock('Magento\Store\Model\Store', [], [], '', false);
575+
$store = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false);
561576
$store->expects($this->once())
562577
->method('getId')
563578
->willReturn($storeId);
@@ -684,7 +699,7 @@ public function testGetList()
684699
->willReturn($collection);
685700
$this->extensionAttributesJoinProcessor->expects($this->once())
686701
->method('process')
687-
->with($collection, 'Magento\Customer\Api\Data\CustomerInterface');
702+
->with($collection, \Magento\Customer\Api\Data\CustomerInterface::class);
688703
$this->customerMetadata->expects($this->once())
689704
->method('getAllAttributesMetadata')
690705
->willReturn([$metadata]);

app/code/Magento/Eav/Model/AttributeRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function getList($entityTypeCode, \Magento\Framework\Api\SearchCriteriaIn
103103
'main_table.entity_type_id = entity_type.entity_type_id',
104104
[]
105105
);
106-
$attributeCollection->getSelect()->joinLeft(
106+
$attributeCollection->joinLeft(
107107
['eav_entity_attribute' => $attributeCollection->getTable('eav_entity_attribute')],
108108
'main_table.attribute_id = eav_entity_attribute.attribute_id',
109109
[]

app/code/Magento/Widget/Controller/Adminhtml/Widget/LoadOptions.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@
44
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
55
* See COPYING.txt for license details.
66
*/
7+
78
namespace Magento\Widget\Controller\Adminhtml\Widget;
89

910
use Magento\Framework\App\ObjectManager;
1011

12+
/**
13+
* Load widget options
14+
*/
1115
class LoadOptions extends \Magento\Backend\App\Action
1216
{
1317
/**
@@ -19,7 +23,7 @@ class LoadOptions extends \Magento\Backend\App\Action
1923
* @var \Magento\Widget\Helper\Conditions
2024
*/
2125
private $conditionsHelper;
22-
26+
2327
/**
2428
* Ajax responder for loading plugin options form
2529
*
@@ -29,7 +33,9 @@ public function execute()
2933
{
3034
try {
3135
$this->_view->loadLayout();
32-
if ($paramsJson = $this->getRequest()->getParam('widget')) {
36+
$paramsJson = $this->getRequest()->getParam('widget');
37+
38+
if ($paramsJson) {
3339
$request = $this->_objectManager->get(\Magento\Framework\Json\Helper\Data::class)
3440
->jsonDecode($paramsJson);
3541
if (is_array($request)) {
@@ -51,13 +57,11 @@ public function execute()
5157
} catch (\Magento\Framework\Exception\LocalizedException $e) {
5258
$result = ['error' => true, 'message' => $e->getMessage()];
5359
$this->getResponse()->representJson(
54-
$this->_objectManager->get(\Magento\Framework\Json\Helper\Data::class)
55-
->jsonEncode($result)
60+
$this->_objectManager->get(\Magento\Framework\Json\Helper\Data::class)->jsonEncode($result)
5661
);
5762
}
5863
}
59-
60-
64+
6165
/**
6266
* @return \Magento\Widget\Helper\Conditions
6367
* @deprecated

app/code/Magento/Widget/Test/Unit/Controller/Adminhtml/Widget/LoadOptionsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ protected function setUp()
105105
/**
106106
* @return void
107107
*/
108-
public function dtestExecuteWithException()
108+
public function testExecuteWithException()
109109
{
110110
$jsonResult = '{"error":true,"message":"Some error"}';
111111
$errorMessage = 'Some error';

app/code/Magento/Widget/Test/Unit/Model/WidgetTest.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Widget\Test\Unit\Model;
77

8+
use Magento\CatalogWidget\Block\Product\ProductsList;
9+
810
/**
911
* Test class for \Magento\Widget\Model\Widget
1012
*/
@@ -143,4 +145,50 @@ public function testGetConfigAsObjectWidgetNoFound()
143145
$this->assertInstanceOf(\Magento\Framework\DataObject::class, $resultObject);
144146
$this->assertSame([], $resultObject->getData());
145147
}
148+
149+
public function testGetWidgetDeclaration()
150+
{
151+
$mathRandomMock = $this->getMock(\Magento\Framework\Math\Random::class, ['getRandomString'], [], '', false);
152+
$mathRandomMock->expects($this->any())->method('getRandomString')->willReturn('asdf');
153+
$reflection = new \ReflectionClass(get_class($this->widget));
154+
$reflectionProperty = $reflection->getProperty('mathRandom');
155+
$reflectionProperty->setAccessible(true);
156+
$reflectionProperty->setValue($this->widget, $mathRandomMock);
157+
158+
$conditions = [
159+
[
160+
'type' => \Magento\CatalogWidget\Model\Rule\Condition\Combine::class,
161+
'aggregator' => 'all',
162+
'value' => '1',
163+
'new_child' => ''
164+
]
165+
];
166+
$params = [
167+
'title' => 'my "widget"',
168+
'show_pager' => '1',
169+
'products_per_page' => '5',
170+
'products_count' => '10',
171+
'template' => 'product/widget/content/grid.phtml',
172+
'conditions' => $conditions
173+
];
174+
175+
$this->conditionsHelper->expects($this->once())->method('encode')->with($conditions)
176+
->willReturn('encoded-conditions-string');
177+
$this->escaperMock->expects($this->atLeastOnce())
178+
->method('escapeQuote')
179+
->willReturnMap([
180+
['my "widget"', false, 'my &quot;widget&quot;'],
181+
['1', false, '1'],
182+
['5', false, '5'],
183+
['10', false, '10'],
184+
['product/widget/content/grid.phtml', false, 'product/widget/content/grid.phtml'],
185+
['encoded-conditions-string', false, 'encoded-conditions-string'],
186+
]);
187+
188+
$result = $this->widget->getWidgetDeclaration(ProductsList::class, $params);
189+
$this->assertContains('{{widget type="' . ProductsList::class .'"', $result);
190+
$this->assertContains('title="my &quot;widget&quot;"', $result);
191+
$this->assertContains('conditions_encoded="encoded-conditions-string"', $result);
192+
$this->assertContains('page_var_name="pasdf"}}', $result);
193+
}
146194
}

dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Variations/Config.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public function generateVariations()
165165
public function getAttributeBlock()
166166
{
167167
return $this->blockFactory->create(
168-
'Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Variations\Config\Attribute',
168+
\Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Variations\Config\Attribute::class,
169169
['element' => $this->_rootElement]
170170
);
171171
}
@@ -178,7 +178,7 @@ public function getAttributeBlock()
178178
public function getVariationsBlock()
179179
{
180180
return $this->blockFactory->create(
181-
'Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Variations\Config\Matrix',
181+
\Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Variations\Config\Matrix::class,
182182
['element' => $this->_rootElement->find($this->variationsMatrix)]
183183
);
184184
}
@@ -191,7 +191,7 @@ public function getVariationsBlock()
191191
public function getTemplateBlock()
192192
{
193193
return $this->blockFactory->create(
194-
'Magento\Backend\Test\Block\Template',
194+
\Magento\Backend\Test\Block\Template::class,
195195
['element' => $this->_rootElement->find($this->template, Locator::SELECTOR_XPATH)]
196196
);
197197
}
@@ -243,6 +243,7 @@ public function addProductsManually($configurableAttributesData = null)
243243

244244
if (is_null($configurableAttributesData) || !$configurableAttributesData['matrix']) {
245245
$errors[] = sprintf("\nThere are no simples assigned to configurable.");
246+
246247
return $errors;
247248
}
248249

@@ -268,4 +269,14 @@ public function addProductsManually($configurableAttributesData = null)
268269

269270
return $errors;
270271
}
272+
273+
/**
274+
* Delete all attributes.
275+
*
276+
* @return void
277+
*/
278+
public function deleteVariations()
279+
{
280+
$this->getVariationsBlock()->deleteVariations();
281+
}
271282
}

dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Variations/Config/Matrix.php

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,23 +91,30 @@ class Matrix extends Form
9191
*
9292
* @var string
9393
*/
94-
protected $actionMenu = '.action-select';
94+
private $actionMenu = '.action-select';
9595

9696
/**
9797
* Choose a different Product button selector.
9898
*
9999
* @var string
100100
*/
101-
protected $chooseProduct = '[data-bind*="showGrid"]';
101+
private $chooseProduct = '[data-bind*="showGrid"]';
102102

103103
/**
104104
* Selector for row on product grid by product id.
105105
*
106106
* @var string
107107
*/
108-
protected $associatedProductGrid =
108+
private $associatedProductGrid =
109109
'[data-bind*="configurable_associated_product_listing.configurable_associated_product_listing"]';
110110

111+
/**
112+
* Delete variation button selector.
113+
*
114+
* @var string
115+
*/
116+
private $deleteVariation = '[data-bind*="removeProduct"]';
117+
111118
/**
112119
* Fill variations.
113120
*
@@ -122,7 +129,6 @@ public function fillVariations(array $matrix)
122129
sprintf($this->variationRowByNumber, $count),
123130
Locator::SELECTOR_XPATH
124131
);
125-
ksort($variation);
126132
++$count;
127133

128134
if (isset($variation['configurable_attribute'])) {
@@ -131,7 +137,6 @@ public function fillVariations(array $matrix)
131137
}
132138

133139
$mapping = $this->dataMapping($variation);
134-
135140
$this->_fill($mapping, $variationRow);
136141
}
137142
}
@@ -218,4 +223,25 @@ public function getAssociatedProductGrid()
218223
['element' => $this->browser->find($this->associatedProductGrid)]
219224
);
220225
}
226+
227+
/**
228+
* Delete variations.
229+
*
230+
* @throws \Exception
231+
*/
232+
public function deleteVariations()
233+
{
234+
$rowLocator = sprintf($this->variationRowByNumber, 1);
235+
$variationText = '';
236+
while ($this->_rootElement->find($rowLocator, Locator::SELECTOR_XPATH)->isVisible()) {
237+
$variation = $this->_rootElement->find($rowLocator, Locator::SELECTOR_XPATH);
238+
if ($variationText == $variation->getText()) {
239+
throw new \Exception("Failed to delete configurable product variation");
240+
}
241+
$variationText = $variation->getText();
242+
$variation->find($this->actionMenu)->hover();
243+
$variation->find($this->actionMenu)->click();
244+
$variation->find($this->deleteVariation)->click();
245+
}
246+
}
221247
}

0 commit comments

Comments
 (0)