/** * @expectedException \Magento\Framework\Exception\InputException * @expectedExceptionMessage Link title cannot be empty. */ public function testCreateThrowsExceptionIfTitleIsEmpty() { $productSku = 'simple'; $linkContentData = array('title' => '', 'sort_order' => 1, 'price' => 10.1, 'number_of_downloads' => 100, 'shareable' => true, 'link_type' => 'url', 'link_url' => 'http://example.com/'); $this->productMock->expects($this->any())->method('getTypeId')->will($this->returnValue('downloadable')); $this->repositoryMock->expects($this->any())->method('get')->with($productSku, true)->will($this->returnValue($this->productMock)); $linkContentMock = $this->getLinkContentMock($linkContentData); $this->contentValidatorMock->expects($this->any())->method('isValid')->with($linkContentMock)->will($this->returnValue(true)); $this->productMock->expects($this->never())->method('save'); $this->service->create($productSku, $linkContentMock); }