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)); }
public function get_links() { if (is_null($this->links)) { $this->links = LinkRepository::instance()->find_by_category($this); } return $this->links; }
public function find_link_by_url($url) { $c_id = $this->c_id; $session_id = $this->session_id; $repo = LinkRepository::instance(); $link = $repo->find_one_by_course_and_url($c_id, $session_id, $url); return $link; }