Beispiel #1
0
 public function testGetLinkAmount()
 {
     $amount = 100;
     $this->linkMock->expects($this->once())->method('getPrice')->will($this->returnValue($amount));
     $this->linkMock->expects($this->once())->method('getProduct')->will($this->returnValue($this->saleableItemMock));
     $this->calculatorMock->expects($this->once())->method('getAmount')->with($amount, $this->equalTo($this->saleableItemMock))->will($this->returnValue($amount));
     $result = $this->linkPrice->getLinkAmount($this->linkMock);
     $this->assertEquals($amount, $result);
 }
Beispiel #2
0
 /**
  * Delete data specific for Downloadable product type
  *
  * @param \Magento\Catalog\Model\Product $product
  * @return void
  */
 public function deleteTypeSpecificData(\Magento\Catalog\Model\Product $product)
 {
     if ($product->getOrigData('type_id') === \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE) {
         $downloadableData = $product->getDownloadableData();
         $sampleItems = [];
         if (isset($downloadableData['sample'])) {
             foreach ($downloadableData['sample'] as $sample) {
                 $sampleItems[] = $sample['sample_id'];
             }
         }
         if ($sampleItems) {
             $this->_sampleResFactory->create()->deleteItems($sampleItems);
         }
         $linkItems = [];
         if (isset($downloadableData['link'])) {
             foreach ($downloadableData['link'] as $link) {
                 $linkItems[] = $link['link_id'];
             }
         }
         if ($linkItems) {
             $this->_linkResource->deleteItems($linkItems);
         }
     }
 }
Beispiel #3
0
 /**
  * @param \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject $product
  * @param array $data
  * @param array $expectedItems
  * @dataProvider deleteDataProvider
  */
 public function testDelete($product, array $data, array $expectedItems)
 {
     $this->linkResource->expects($this->once())->method('deleteItems')->with($this->equalTo($expectedItems));
     $this->target->save($product, $data);
 }
Beispiel #4
0
 /**
  * @return void
  */
 protected function processDelete()
 {
     if ($this->deletedItems) {
         $this->linkResource->deleteItems($this->deletedItems);
     }
 }