Beispiel #1
0
 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));
 }
 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));
 }
Beispiel #3
0
 public function testFlushAssociatedProductsCache()
 {
     $productMock = $this->getMock('\\Magento\\Catalog\\Model\\Product', ['unsData'], [], '', false);
     $productMock->expects($this->once())->method('unsData')->with('_cache_instance_associated_products')->willReturnSelf();
     $this->assertEquals($productMock, $this->_model->flushAssociatedProductsCache($productMock));
 }
Beispiel #4
0
 /**
  * @param array $superGroup
  * @param array $result
  * @dataProvider processBuyRequestDataProvider
  */
 public function testProcessBuyRequest($superGroup, $result)
 {
     $buyRequest = $this->getMock('\\Magento\\Framework\\Object', array('getSuperGroup'), array(), '', false);
     $buyRequest->expects($this->any())->method('getSuperGroup')->will($this->returnValue($superGroup));
     $this->assertEquals($result, $this->_model->processBuyRequest($this->product, $buyRequest));
 }