Example #1
0
 /**
  * @expectedException \Magento\Framework\Exception\InputException
  * @expectedExceptionMessage Invalid link type.
  */
 public function testUpdateThrowsExceptionIfLinkTypeIsEmpty()
 {
     $linkId = 1;
     $productSku = 'simple';
     $productId = 1;
     $linkData = ['id' => $linkId, 'title' => 'Title', 'link_type' => '', 'sort_order' => 1, 'price' => 10.1, 'number_of_downloads' => 100, 'is_shareable' => true];
     $this->repositoryMock->expects($this->any())->method('get')->with($productSku, true)->willReturn($this->productMock);
     $this->productMock->expects($this->any())->method('getData')->with('id')->willReturn($productId);
     $linkContentMock = $this->getLinkMock($linkData);
     $this->contentValidatorMock->expects($this->any())->method('isValid')->with($linkContentMock)->willReturn(true);
     $this->service->save($productSku, $linkContentMock, true);
 }
Example #2
0
 /**
  * @expectedException \Magento\Framework\Exception\InputException
  * @expectedExceptionMessage Link title cannot be empty.
  */
 public function testUpdateThrowsExceptionIfTitleIsEmptyAndScopeIsGlobal()
 {
     $linkId = 1;
     $productSku = 'simple';
     $productId = 1;
     $linkData = ['id' => $linkId, 'title' => '', 'sort_order' => 1, 'price' => 10.1, 'number_of_downloads' => 100, 'is_shareable' => true];
     $this->repositoryMock->expects($this->any())->method('get')->with($productSku, true)->will($this->returnValue($this->productMock));
     $this->productMock->expects($this->any())->method('getId')->will($this->returnValue($productId));
     $existingLinkMock = $this->getMock('\\Magento\\Downloadable\\Model\\Link', ['__wakeup', 'getId', 'load', 'save', 'getProductId'], [], '', false);
     $existingLinkMock->expects($this->any())->method('getId')->will($this->returnValue($linkId));
     $existingLinkMock->expects($this->any())->method('getProductId')->will($this->returnValue($productId));
     $existingLinkMock->expects($this->once())->method('load')->with($linkId)->will($this->returnSelf());
     $this->linkFactoryMock->expects($this->once())->method('create')->will($this->returnValue($existingLinkMock));
     $linkContentMock = $this->getLinkMock($linkData);
     $this->contentValidatorMock->expects($this->any())->method('isValid')->with($linkContentMock)->will($this->returnValue(true));
     $this->productTypeMock->expects($this->never())->method('save');
     $this->service->save($productSku, $linkContentMock, true);
 }