public function testTopTracks() { try { $as = new Zend_Service_Audioscrobbler(); $as->set('artist', 'Metallica'); $response = $as->artistGetTopTracks(); $this->assertNotNull($response->mostknowntracks); $this->assertEquals($response['artist'], 'Metallica'); $this->assertNotNull($response->track); return; } catch (Exception $e) { $this->fail("Exception: [" . $e->getMessage() . "] thrown by test"); } }
public function testTopTracks() { try { $test_response = $this->header . '<?xml version="1.0" encoding="UTF-8"?> <mostknowntracks artist="Metallica"> <track> <name>Nothing Else Matters</name> <mbid></mbid> <reach>7481</reach> <url>http://www.last.fm/music/Metallica/_/Nothing+Else+Matters</url> </track> <track> <name>Enter Sandman</name> <mbid></mbid> <reach>7139</reach> <url>http://www.last.fm/music/Metallica/_/Enter+Sandman</url> </track> </mostknowntracks>'; $as = new Zend_Service_Audioscrobbler(TRUE, $test_response); $as->set('artist', 'Metallica'); $response = $as->artistGetTopTracks(); $track = $response->track[0]; $this->assertEquals((string) $response['artist'], 'Metallica'); $this->assertEquals((string) $track->name, 'Nothing Else Matters'); $this->assertEquals((int) $track->reach, 7481); return; } catch (Exception $e) { $this->fail("Exception: [" . $e->getMessage() . "] thrown by test"); } }