Exemple #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->sampleBuilder->expects($this->once())->method('populateWithArray')->with([]);
     $this->sampleBuilder->expects($this->once())->method('create')->willReturn($sampleInterfaceMock);
     $this->assertEquals([$sampleInterfaceMock], $this->service->getSamples($productSku));
 }