Ejemplo n.º 1
0
 public function testGetSelectedAttributesInfo()
 {
     $productMock = $this->getMockBuilder('\\Magento\\Catalog\\Model\\Product')->setMethods(['__wakeup', 'getCustomOption', 'hasData', 'getData'])->disableOriginalConstructor()->getMock();
     $optionMock = $this->getMockBuilder('Magento\\Catalog\\Model\\Product\\Configuration\\Item\\Option\\OptionInterface')->setMethods(['getValue'])->disableOriginalConstructor()->getMock();
     $usedAttributeMock = $this->getMockBuilder('\\Magento\\ConfigurableProduct\\Model\\Product\\Type\\Configurable\\Attribute')->setMethods(['getProductAttribute'])->disableOriginalConstructor()->getMock();
     $attributeMock = $this->getMockBuilder('\\Magento\\Catalog\\Model\\Resource\\Eav\\Attribute')->setMethods(['getStoreLabel', 'getSourceModel'])->disableOriginalConstructor()->getMock();
     $optionMock->expects($this->once())->method('getValue')->willReturn(serialize($this->attributeData));
     $productMock->expects($this->once())->method('getCustomOption')->with('attributes')->willReturn($optionMock);
     $productMock->expects($this->once())->method('hasData')->willReturn(true);
     $productMock->expects($this->at(2))->method('getData')->willReturn(true);
     $productMock->expects($this->at(3))->method('getData')->willReturn([1 => $usedAttributeMock]);
     $usedAttributeMock->expects($this->once())->method('getProductAttribute')->willReturn($attributeMock);
     $attributeMock->expects($this->once())->method('getStoreLabel')->willReturn('attr_store_label');
     $attributeMock->expects($this->once())->method('getSourceModel')->willReturn(false);
     $this->assertEquals($this->_model->getSelectedAttributesInfo($productMock), [['label' => 'attr_store_label', 'value' => '']]);
 }