Skip to content

Commit 0b3ef05

Browse files
committed
MAGETWO-38686: Merge and Fix Builds
- fixes according to PR comments
1 parent 0810380 commit 0b3ef05

File tree

3 files changed

+118
-22
lines changed

3 files changed

+118
-22
lines changed

app/code/Magento/Catalog/Model/Product/Option.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,6 @@ public function setValues(array $values = null)
851851
$this->_values = $values;
852852
return $this;
853853
}
854-
//@codeCoverageIgnoreEnd
855854

856855
/**
857856
* {@inheritdoc}
@@ -874,4 +873,5 @@ public function setExtensionAttributes(
874873
) {
875874
return $this->_setExtensionAttributes($extensionAttributes);
876875
}
876+
//@codeCoverageIgnoreEnd
877877
}

app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1277,7 +1277,10 @@ public function priceDataProvider()
12771277

12781278
public function testGetOptions()
12791279
{
1280-
$optionInstanceMock = $this->getMockBuilder('\Magento\Catalog\Model\Product\Option')
1280+
$optionInstanceMock = $this->getMockBuilder('Magento\Catalog\Model\Product\Option')
1281+
->disableOriginalConstructor()
1282+
->getMock();
1283+
$joinProcessorMock = $this->getMockBuilder('Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface')
12811284
->disableOriginalConstructor()
12821285
->getMock();
12831286

@@ -1286,6 +1289,7 @@ public function testGetOptions()
12861289
'Magento\Catalog\Model\Product',
12871290
[
12881291
'catalogProductOption' => $optionInstanceMock,
1292+
'joinProcessor' => $joinProcessorMock
12891293
]
12901294
);
12911295
$productModel->setHasOptions(true);
@@ -1325,6 +1329,10 @@ public function testGetOptions()
13251329
->with($productModel)
13261330
->willReturn($optionColl);
13271331

1332+
$joinProcessorMock->expects($this->once())
1333+
->method('process')
1334+
->with($this->isInstanceOf('Magento\Catalog\Model\Resource\Product\Option\Collection'));
1335+
13281336
$expectedOptions = [
13291337
$option1Id => $optionMock1,
13301338
$option2Id => $optionMock2

app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Type/ConfigurableTest.php

Lines changed: 108 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ class ConfigurableTest extends \PHPUnit_Framework_TestCase
8383
*/
8484
protected $_objectHelper;
8585

86+
/**
87+
* @var JoinProcessorInterface|\PHPUnit_Framework_MockObject_MockObject
88+
*/
89+
protected $extensionAttributesJoinProcessorMock;
90+
8691
/**
8792
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
8893
*/
@@ -169,6 +174,14 @@ protected function setUp()
169174
'',
170175
false
171176
);
177+
$this->extensionAttributesJoinProcessorMock = $this->getMock(
178+
'Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface',
179+
[],
180+
[],
181+
'',
182+
false
183+
);
184+
172185
$this->_model = $this->_objectHelper->getObject(
173186
'Magento\ConfigurableProduct\Model\Product\Type\Configurable',
174187
[
@@ -186,7 +199,8 @@ protected function setUp()
186199
'filesystem' => $filesystem,
187200
'coreRegistry' => $coreRegistry,
188201
'logger' => $logger,
189-
'stockConfiguration' => $this->_stockConfiguration
202+
'stockConfiguration' => $this->_stockConfiguration,
203+
'extensionAttributesJoinProcessor' => $this->extensionAttributesJoinProcessorMock
190204
]
191205
);
192206
}
@@ -202,9 +216,20 @@ public function testHasWeightTrue()
202216
public function testSave()
203217
{
204218
$product = $this->getMockBuilder('\Magento\Catalog\Model\Product')
205-
->setMethods(['getIsDuplicate', 'dataHasChangedFor', 'getConfigurableAttributesData', 'getStoreId',
206-
'getId', 'getData', 'hasData', 'getAssociatedProductIds', '__wakeup', '__sleep',
207-
])->disableOriginalConstructor()
219+
->setMethods(
220+
[
221+
'getIsDuplicate',
222+
'dataHasChangedFor',
223+
'getConfigurableAttributesData',
224+
'getStoreId',
225+
'getId',
226+
'getData',
227+
'hasData',
228+
'getAssociatedProductIds',
229+
'__wakeup',
230+
'__sleep',
231+
]
232+
)->disableOriginalConstructor()
208233
->getMock();
209234
$product->expects($this->any())->method('dataHasChangedFor')->will($this->returnValue('false'));
210235
$product->expects($this->any())->method('getConfigurableAttributesData')
@@ -297,28 +322,48 @@ public function testGetUsedProducts()
297322
$this->_attributeCollectionFactory->expects($this->any())->method('create')
298323
->will($this->returnValue($attributeCollection));
299324
$product = $this->getMockBuilder('\Magento\Catalog\Model\Product')
300-
->setMethods(['dataHasChangedFor', 'getConfigurableAttributesData', 'getStoreId',
301-
'getId', 'getData', 'hasData', 'getAssociatedProductIds', '__wakeup', '__sleep',
302-
])->disableOriginalConstructor()
325+
->setMethods(
326+
[
327+
'dataHasChangedFor',
328+
'getConfigurableAttributesData',
329+
'getStoreId',
330+
'getId',
331+
'getData',
332+
'hasData',
333+
'getAssociatedProductIds',
334+
'__wakeup',
335+
'__sleep',
336+
]
337+
)->disableOriginalConstructor()
303338
->getMock();
304339
$product->expects($this->any())->method('getConfigurableAttributesData')
305340
->will($this->returnValue($this->attributeData));
306341
$product->expects($this->any())->method('getStoreId')->will($this->returnValue(5));
307342
$product->expects($this->any())->method('getId')->will($this->returnValue(1));
308343
$product->expects($this->any())->method('getAssociatedProductIds')->will($this->returnValue([2]));
309344
$product->expects($this->any())->method('hasData')
310-
->will($this->returnValueMap([
311-
['_cache_instance_used_product_attribute_ids', 1],
312-
['_cache_instance_products', 0],
313-
['_cache_instance_configurable_attributes', 1],
314-
]));
345+
->will(
346+
$this->returnValueMap(
347+
[
348+
['_cache_instance_used_product_attribute_ids', 1],
349+
['_cache_instance_products', 0],
350+
['_cache_instance_configurable_attributes', 1],
351+
]
352+
)
353+
);
315354
$product->expects($this->any())->method('getData')
316355
->will($this->returnValue(1));
317356
$productCollection = $this->getMockBuilder(
318357
'Magento\ConfigurableProduct\Model\Resource\Product\Type\Configurable\Product\Collection'
319358
)->setMethods(
320-
['setFlag', 'setProductFilter', 'addStoreFilter', 'addAttributeToSelect', 'addFilterByRequiredOptions',
321-
'setStoreId', ]
359+
[
360+
'setFlag',
361+
'setProductFilter',
362+
'addStoreFilter',
363+
'addAttributeToSelect',
364+
'addFilterByRequiredOptions',
365+
'setStoreId',
366+
]
322367
)->disableOriginalConstructor()
323368
->getMock();
324369
$productCollection->expects($this->any())->method('addAttributeToSelect')->will($this->returnSelf());
@@ -385,13 +430,21 @@ public function testGetConfigurableAttributesAsArray($productStore, $attributeSt
385430
->getMock();
386431
$product->expects($this->any())->method('getStoreId')->will($this->returnValue($productStore));
387432
$product->expects($this->any())->method('hasData')
388-
->will($this->returnValueMap([
389-
['_cache_instance_configurable_attributes', 1],
390-
]));
433+
->will(
434+
$this->returnValueMap(
435+
[
436+
['_cache_instance_configurable_attributes', 1],
437+
]
438+
)
439+
);
391440
$product->expects($this->any())->method('getData')
392-
->will($this->returnValueMap([
393-
['_cache_instance_configurable_attributes', null, [$attribute]],
394-
]));
441+
->will(
442+
$this->returnValueMap(
443+
[
444+
['_cache_instance_configurable_attributes', null, [$attribute]],
445+
]
446+
)
447+
);
395448

396449
$result = $this->_model->getConfigurableAttributesAsArray($product);
397450
$this->assertCount(1, $result);
@@ -408,6 +461,41 @@ public function getConfigurableAttributesAsArrayDataProvider()
408461
];
409462
}
410463

464+
public function testGetConfigurableAttributes()
465+
{
466+
$expectedData = [1];
467+
$configurableAttributes = '_cache_instance_configurable_attributes';
468+
469+
/** @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject $product */
470+
$product = $this->getMockBuilder('Magento\Catalog\Model\Product')
471+
->setMethods(['getData', 'hasData', 'setData'])
472+
->disableOriginalConstructor()
473+
->getMock();
474+
$product->expects($this->once())->method('hasData')->with($configurableAttributes)->willReturn(false);
475+
$product->expects($this->once())->method('setData')->willReturnSelf();
476+
$product->expects($this->once())->method('getData')->with($configurableAttributes)->willReturn($expectedData);
477+
478+
$attributeCollection = $this->getMockBuilder(
479+
'Magento\ConfigurableProduct\Model\Resource\Product\Type\Configurable\Attribute\Collection'
480+
)
481+
->setMethods(['setProductFilter', 'orderByPosition', 'load'])
482+
->disableOriginalConstructor()
483+
->getMock();
484+
$attributeCollection->expects($this->any())->method('setProductFilter')->will($this->returnSelf());
485+
$attributeCollection->expects($this->any())->method('orderByPosition')->will($this->returnSelf());
486+
$this->_attributeCollectionFactory->expects($this->any())->method('create')->willReturn($attributeCollection);
487+
488+
$this->extensionAttributesJoinProcessorMock->expects($this->once())
489+
->method('process')
490+
->with(
491+
$this->isInstanceOf(
492+
'Magento\ConfigurableProduct\Model\Resource\Product\Type\Configurable\Attribute\Collection'
493+
)
494+
);
495+
496+
$this->assertEquals($expectedData, $this->_model->getConfigurableAttributes($product));
497+
}
498+
411499
public function testResetConfigurableAttributes()
412500
{
413501
$product = $this->getMockBuilder('\Magento\Catalog\Model\Product')

0 commit comments

Comments
 (0)