Пример #1
0
 private function prepareGetJsonSwatchConfig()
 {
     $product1 = $this->getMock('\\Magento\\Catalog\\Model\\Product', [], [], '', false);
     $product1->expects($this->atLeastOnce())->method('isSaleable')->willReturn(true);
     $product1->expects($this->atLeastOnce())->method('getData')->with('code')->willReturn(1);
     $product2 = $this->getMock('\\Magento\\Catalog\\Model\\Product', [], [], '', false);
     $product2->expects($this->atLeastOnce())->method('isSaleable')->willReturn(true);
     $product2->expects($this->atLeastOnce())->method('getData')->with('code')->willReturn(3);
     $simpleProducts = [$product1, $product2];
     $configurableType = $this->getMock('\\Magento\\ConfigurableProduct\\Model\\Product\\Type\\Configurable', [], [], '', false);
     $configurableType->expects($this->atLeastOnce())->method('getUsedProducts')->with($this->product, null)->willReturn($simpleProducts);
     $this->product->expects($this->any())->method('getTypeInstance')->willReturn($configurableType);
     $productAttribute1 = $this->getMock('\\Magento\\Eav\\Model\\Entity\\Attribute\\AbstractAttribute', [], [], '', false);
     $productAttribute1->expects($this->any())->method('getId')->willReturn(1);
     $productAttribute1->expects($this->any())->method('getAttributeCode')->willReturn('code');
     $attribute1 = $this->getMock('\\Magento\\ConfigurableProduct\\Model\\Product\\Type\\Configurable\\Attribute', ['getProductAttribute'], [], '', false);
     $attribute1->expects($this->any())->method('getProductAttribute')->willReturn($productAttribute1);
     $this->helper->expects($this->any())->method('getAllowAttributes')->with($this->product)->willReturn([$attribute1]);
 }