Пример #1
0
 /**
  * @dataProvider saveDataProvider
  * @param \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject $product
  * @param array $data
  * @param array $modelData
  */
 public function testSave($product, array $data, array $modelData)
 {
     $link = $this->createSampleModel($product, $modelData, true);
     $this->metadataMock->expects($this->once())->method('getLinkField')->willReturn('id');
     $this->sampleFactory->expects($this->once())->method('create')->willReturn($link);
     $this->target->save($product, $data);
 }
Пример #2
0
 /**
  * @return Sample
  */
 private function getComponent()
 {
     if (!$this->component) {
         $this->component = $this->componentFactory->create();
     }
     return $this->component;
 }
Пример #3
0
 /**
  * {@inheritdoc}
  */
 public function delete($id)
 {
     /** @var $sample \Magento\Downloadable\Model\Sample */
     $sample = $this->sampleFactory->create()->load($id);
     if (!$sample->getId()) {
         throw new NoSuchEntityException(__('There is no downloadable sample with provided ID.'));
     }
     try {
         $sample->delete();
     } catch (\Exception $exception) {
         throw new StateException(__('Cannot delete sample with id %1', $sample->getId()), $exception);
     }
     return true;
 }
Пример #4
0
 /**
  * @return \Magento\Downloadable\Model\Sample
  */
 protected function _createSample()
 {
     return $this->_sampleFactory->create();
 }
Пример #5
0
 /**
  * @return ComponentInterface
  */
 protected function createItem()
 {
     return $this->sampleFactory->create();
 }
Пример #6
0
 /**
  * @dataProvider saveDataProvider
  * @param \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject $product
  * @param array $data
  * @param array $modelData
  */
 public function testSave($product, array $data, array $modelData)
 {
     $link = $this->createSampleModel($product, $modelData, true);
     $this->sampleFactory->expects($this->once())->method('create')->will($this->returnValue($link));
     $this->target->save($product, $data);
 }