public function testCreateFromResponse() { $mockResponse = $this->createMockResponse('MockAffiliationResponse'); $affiliation = Affiliation::createFromResponse($mockResponse); $this->assertInstanceOf('BinaryThinking\\LastfmBundle\\Lastfm\\Model\\Affiliation', $affiliation, 'object created is not an instance of Affiliation'); $this->assertNotEmpty($affiliation->getSupplierName(), 'empty affiliation supplier name'); $this->assertNotEmpty($affiliation->getPrice(), 'empty affiliation price'); $this->assertNotEmpty($affiliation->getSupplierIcon(), 'empty affiliation supplier icon'); $this->assertNotEmpty($affiliation->getIsSearch(), 'empty affiliation is search'); $this->assertNotEmpty($affiliation->getBuyLink(), 'empty affiliation buy link'); }
/** * Get a list of Buy Links for a particular Album. It is required that you supply either the artist and album params or the mbid param. * * @param string $artist the artist name * @param string $album the album name * @param string $mbid the musicbrainz id for the album * @param bool $autocorrect transform misspelled artist names into correct artist names * @param string $country a country name, as defined by the ISO 3166-1 country names standard. */ public function getBuylinks($artist, $album, $mbid = null, $autocorrect = true, $country = null) { $response = $this->call(array('method' => 'album.getBuylinks', 'artist' => $artist, 'album' => $album, 'autocorrect' => $autocorrect, 'mbid' => $mbid, 'country' => $country)); $affiliations = array(); if (!empty($response->affiliations->physicals->affiliation)) { foreach ($response->affiliations->physicals->affiliation as $physicalAffiliation) { $affiliations['physicals'][] = LastfmModel\Affiliation::createFromResponse($physicalAffiliation); } } if (!empty($response->affiliations->downloads->affiliation)) { foreach ($response->affiliations->downloads->affiliation as $downloadAffiliation) { $affiliations['downloads'][] = LastfmModel\Affiliation::createFromResponse($downloadAffiliation); } } return $affiliations; }