public function testPrepareForCartAdvancedWithProductsStrictTrue() { $associatedProduct = $this->getMock('Magento\\Catalog\\Model\\Product', [], [], '', false); $associatedId = 9384; $associatedProduct->expects($this->once())->method('getId')->will($this->returnValue($associatedId)); $typeMock = $this->getMock('Magento\\Catalog\\Model\\Product\\Type\\AbstractType', ['_prepareProduct', 'deleteTypeSpecificData'], [], '', false); $associatedPrepareResult = [$this->getMock('Magento\\Catalog\\Model\\Product', [], [], 'resultProduct', false)]; $typeMock->expects($this->once())->method('_prepareProduct')->willReturn($associatedPrepareResult); $associatedProduct->expects($this->once())->method('getTypeInstance')->willReturn($typeMock); $buyRequest = new \Magento\Framework\Object(); $buyRequest->setSuperGroup([$associatedId => 1]); $cached = true; $this->product->expects($this->once())->method('hasData')->will($this->returnValue($cached)); $this->product->expects($this->once())->method('getData')->will($this->returnValue([$associatedProduct])); $this->assertEquals($associatedPrepareResult, $this->_model->prepareForCartAdvanced($buyRequest, $this->product)); }
public function testPrepareForCartAdvancedZeroQty() { $expectedMsg = "Please specify the quantity of product(s)."; $associatedId = 9384; $associatedProduct = $this->getMock('Magento\\Catalog\\Model\\Product', [], [], '', false); $associatedProduct->expects($this->atLeastOnce())->method('getId')->will($this->returnValue($associatedId)); $buyRequest = new \Magento\Framework\Object(); $buyRequest->setSuperGroup([$associatedId => 0]); $cached = true; $this->product->expects($this->atLeastOnce())->method('hasData')->will($this->returnValue($cached)); $this->product->expects($this->atLeastOnce())->method('getData')->will($this->returnValue([$associatedProduct])); $this->assertEquals($expectedMsg, $this->_model->prepareForCartAdvanced($buyRequest, $this->product)); }