Ejemplo n.º 1
0
 /**
  * @magentoDataFixture Magento/ConfigurableProduct/_files/product_configurable.php
  */
 public function testPrepareData()
 {
     $collection = $this->objectManager->get('Magento\\Catalog\\Model\\ResourceModel\\Product\\Collection');
     $select = (string) $collection->getSelect();
     $this->model->prepareData($collection, [1, 2, 3, 4]);
     $this->assertEquals($select, (string) $collection->getSelect());
     $result = $this->model->addData([], 1);
     $this->assertArrayHasKey('configurable_variations', $result);
     $this->assertArrayHasKey('configurable_variation_labels', $result);
     $this->assertEquals('sku=simple_10,test_configurable=Option 1|sku=simple_20,test_configurable=Option 2', $result['configurable_variations']);
 }
Ejemplo n.º 2
0
 protected function _initConfigurableData()
 {
     $productIds = [1, 2, 3];
     $attributes = [[['pricing_is_percent' => true, 'sku' => '_sku_', 'attribute_code' => 'code_of_attribute', 'option_title' => 'Option Title', 'pricing_value' => 12345], ['pricing_is_percent' => false, 'sku' => '_sku_', 'attribute_code' => 'code_of_attribute', 'option_title' => 'Option Title', 'pricing_value' => 12345]]];
     $productMock = $this->getMock('Magento\\Catalog\\Model\\Product', ['getId', 'getTypeInstance', '__wakeup'], [], '', false);
     $productMock->expects($this->any())->method('getId')->will($this->returnValue(11));
     $typeInstanceMock = $this->getMock('Magento\\ConfigurableProduct\\Model\\Product\\Type\\Configurable', [], [], '', false);
     $typeInstanceMock->expects($this->any())->method('getConfigurableOptions')->will($this->returnValue($attributes));
     $productMock->expects($this->any())->method('getTypeInstance')->will($this->returnValue($typeInstanceMock));
     $this->_collectionMock->expects($this->at(0))->method('addAttributeToFilter')->with('entity_id', ['in' => $productIds])->will($this->returnSelf());
     $this->_collectionMock->expects($this->at(1))->method('addAttributeToFilter')->with('type_id', ['eq' => \Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE])->will($this->returnSelf());
     $this->_collectionMock->expects($this->at(2))->method('fetchItem')->will($this->returnValue($productMock));
     $this->_collectionMock->expects($this->at(3))->method('fetchItem')->will($this->returnValue(false));
     $this->_model->prepareData($this->_collectionMock, $productIds);
 }