Exemplo n.º 1
0
 /**
  * @expectedException \Magento\Framework\Exception\InputException
  * @expectedExceptionMessage Link title cannot be empty.
  */
 public function testUpdateThrowsExceptionIfTitleIsEmptyAndScopeIsGlobal()
 {
     $linkId = 1;
     $productSku = 'simple';
     $productId = 1;
     $linkContentData = array('title' => '', 'sort_order' => 1, 'price' => 10.1, 'number_of_downloads' => 100, '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));
     $linkMock = $this->getMock('\\Magento\\Downloadable\\Model\\Link', array('__wakeup', 'getId', 'load', 'save', 'getProductId'), array(), '', false);
     $linkMock->expects($this->any())->method('getId')->will($this->returnValue($linkId));
     $linkMock->expects($this->any())->method('getProductId')->will($this->returnValue($productId));
     $linkMock->expects($this->once())->method('load')->with($linkId)->will($this->returnSelf());
     $this->linkFactoryMock->expects($this->once())->method('create')->will($this->returnValue($linkMock));
     $linkContentMock = $this->getLinkContentMock($linkContentData);
     $this->contentValidatorMock->expects($this->any())->method('isValid')->with($linkContentMock)->will($this->returnValue(true));
     $linkMock->expects($this->never())->method('save');
     $this->service->update($productSku, $linkId, $linkContentMock, true);
 }