public function testCreateFromResponse() { $mockResponse = $this->createMockResponse('MockUserResponse'); $user = User::createFromResponse($mockResponse); $this->assertInstanceOf('BinaryThinking\\LastfmBundle\\Lastfm\\Model\\User', $user, 'object created is not an instance of User'); $this->assertNotEmpty($user->getName(), 'name is empty'); $this->assertNotEmpty($user->getRealName(), 'real name is empty'); $this->assertNotEmpty($user->getUrl(), 'url is empty'); $this->assertNotEmpty($user->getWeight(), 'weight is empty'); $this->assertNotEmpty($user->getImages(), 'images are empty'); }
/** * Get the top fans for an artist on Last.fm, based on listening data. * * @param string $artist the artist name * @param string $mbid the musicbrainz id for the artist * @param bool $autocorrect transform misspelled artist names into correct artist names */ public function getTopFans($artist, $mbid = null, $autocorrect = true) { $response = $this->call(array('method' => 'artist.getTopFans', 'artist' => $artist, 'mbid' => $mbid, 'autocorrect' => $autocorrect)); $fans = array(); if (!empty($response->topfans->user)) { foreach ($response->topfans->user as $fan) { $fans[] = LastfmModel\User::createFromResponse($fan); } } return $fans; }