Example #1
0
 public function testGetSamples()
 {
     $productSku = 'downloadable_sku';
     $sampleData = ['id' => 324, 'store_title' => 'rock melody sample', 'title' => 'just melody sample', 'sort_order' => 21, 'sample_type' => 'file', 'sample_url' => null, 'sample_file' => '/r/o/rock.melody.ogg'];
     $sampleMock = $this->getMock('\\Magento\\Downloadable\\Model\\Sample', ['getId', 'getStoreTitle', 'getTitle', 'getSampleType', 'getSampleFile', 'getSampleUrl', 'getSortOrder', 'getData', '__wakeup'], [], '', false);
     $sampleInterfaceMock = $this->getMock('\\Magento\\Downloadable\\Api\\Data\\SampleInterface');
     $this->repositoryMock->expects($this->once())->method('get')->with($productSku)->will($this->returnValue($this->productMock));
     $this->productTypeMock->expects($this->once())->method('getSamples')->with($this->productMock)->will($this->returnValue([$sampleMock]));
     $this->setSampleAssertions($sampleMock, $sampleData);
     $this->sampleDataObjectFactory->expects($this->once())->method('create')->willReturn($sampleInterfaceMock);
     $this->assertEquals([$sampleInterfaceMock], $this->service->getSamples($productSku));
 }
 public function testGetList()
 {
     $productSku = 'downloadable_sku';
     $linkData = ['id' => 324, 'store_title' => 'rock melody', 'title' => 'just melody', 'price' => 23, 'number_of_downloads' => 3, 'sort_order' => 21, 'is_shareable' => 2, 'sample_type' => 'file', 'sample_url' => null, 'sample_file' => '/r/o/rock.melody.ogg', 'link_type' => 'url', 'link_url' => 'http://link.url', 'link_file' => null];
     $linkMock = $this->getMock('\\Magento\\Downloadable\\Model\\Link', ['getId', 'getStoreTitle', 'getTitle', 'getPrice', 'getNumberOfDownloads', 'getSortOrder', 'getIsShareable', 'getData', '__wakeup'], [], '', false);
     $linkInterfaceMock = $this->getMock('\\Magento\\Downloadable\\Api\\Data\\LinkInterface');
     $this->repositoryMock->expects($this->once())->method('get')->with($productSku)->will($this->returnValue($this->productMock));
     $this->productTypeMock->expects($this->once())->method('getLinks')->with($this->productMock)->will($this->returnValue([$linkMock]));
     $this->setLinkAssertions($linkMock, $linkData);
     $this->linkDataObjectFactory->expects($this->once())->method('create')->willReturn($linkInterfaceMock);
     $this->assertEquals([$linkInterfaceMock], $this->service->getList($productSku));
 }