AlbumDataTest.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Service_Audioscrobbler
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /**
  23. * Test helper
  24. */
  25. require_once dirname(__FILE__) . '/../../../TestHelper.php';
  26. /**
  27. * @see Zend_Service_Audioscrobbler
  28. */
  29. require_once 'Zend/Service/Audioscrobbler.php';
  30. require_once "AudioscrobblerTestCase.php";
  31. /**
  32. * @category Zend
  33. * @package Zend_Service_Audioscrobbler
  34. * @subpackage UnitTests
  35. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  36. * @license http://framework.zend.com/license/new-bsd New BSD License
  37. */
  38. class Zend_Service_Audioscrobbler_AlbumDataTest extends Zend_Service_Audioscrobbler_AudioscrobblerTestCase
  39. {
  40. public function testGetAlbumInfo()
  41. {
  42. $albumInfoResponse = "HTTP/1.1 200 OK\r\nContent-type: text/xml\r\n\r\n".
  43. '<?xml version="1.0" encoding="UTF-8"?>
  44. <album artist="Metallica" title="Metallica">
  45. <reach>85683</reach>
  46. <url>http://www.last.fm/music/Metallica/Metallica</url>
  47. <releasedate> 1 Jan 1994, 00:00</releasedate>
  48. <coverart>
  49. <small>http://static.last.fm/coverart/50x50/1411800.jpg</small>
  50. <medium>http://static.last.fm/coverart/130x130/1411800.jpg</medium>
  51. <large>http://static.last.fm/coverart/300x300/1411800.jpg</large>
  52. </coverart>
  53. <mbid>3750d9e2-59f5-471d-8916-463433069bd1</mbid>
  54. <tracks>
  55. <track title="Enter Sandman (LP Version)">
  56. <reach>26</reach>
  57. <url>http://www.last.fm/music/Metallica/_/Enter+Sandman+%28LP+Version%29</url>
  58. </track>
  59. <track title="Sad But True (LP Version)">
  60. <reach>22</reach>
  61. <url>http://www.last.fm/music/Metallica/_/Sad+But+True+%28LP+Version%29</url>
  62. </track>
  63. <track title="Holier Than Thou (LP Version)">
  64. <reach>2</reach>
  65. <url>http://www.last.fm/music/Metallica/_/Holier+Than+Thou+%28LP+Version%29</url>
  66. </track>
  67. <track title="The Unforgiven (LP Version)">
  68. <reach>10</reach>
  69. <url>http://www.last.fm/music/Metallica/_/The+Unforgiven+%28LP+Version%29</url>
  70. </track>
  71. <track title="Wherever I May Roam (LP Version)">
  72. <reach>4</reach>
  73. <url>http://www.last.fm/music/Metallica/_/Wherever+I+May+Roam+%28LP+Version%29</url>
  74. </track>
  75. <track title="Don\'t Tread On Me (LP Version)">
  76. <reach>3</reach>
  77. <url>http://www.last.fm/music/Metallica/_/Don%27t+Tread+On+Me+%28LP+Version%29</url>
  78. </track>
  79. <track title="Through The Never (LP Version)">
  80. <reach>3</reach>
  81. <url>http://www.last.fm/music/Metallica/_/Through+The+Never+%28LP+Version%29</url>
  82. </track>
  83. <track title="Nothing Else Matters (LP Version)">
  84. <reach>26</reach>
  85. <url>http://www.last.fm/music/Metallica/_/Nothing+Else+Matters+%28LP+Version%29</url>
  86. </track>
  87. <track title="Of Wolf And Man (LP Version)">
  88. <reach>3</reach>
  89. <url>http://www.last.fm/music/Metallica/_/Of+Wolf+And+Man+%28LP+Version%29</url>
  90. </track>
  91. <track title="The God That Failed (LP Version)">
  92. <reach>2</reach>
  93. <url>http://www.last.fm/music/Metallica/_/The+God+That+Failed+%28LP+Version%29</url>
  94. </track>
  95. <track title="My Friend Of Misery (LP Version)">
  96. <reach>3</reach>
  97. <url>http://www.last.fm/music/Metallica/_/My+Friend+Of+Misery+%28LP+Version%29</url>
  98. </track>
  99. <track title="The Struggle Within (LP Version)">
  100. <reach>3</reach>
  101. <url>http://www.last.fm/music/Metallica/_/The+Struggle+Within+%28LP+Version%29</url>
  102. </track>
  103. </tracks>
  104. </album>
  105. ';
  106. $this->setAudioscrobblerResponse($albumInfoResponse);
  107. try {
  108. $as = $this->getAudioscrobblerService();
  109. $as->set('album', 'Metallica');
  110. $as->set('artist', 'Metallica');
  111. $response = $as->albumGetInfo();
  112. $track = $response->tracks->track[0];
  113. $this->assertEquals((string)$response['artist'], 'Metallica');
  114. $this->assertEquals((string)$response['title'], 'Metallica');
  115. $this->assertEquals((string)$track->url, 'http://www.last.fm/music/Metallica/_/Enter+Sandman+%28LP+Version%29');
  116. $this->assertEquals(count($response->tracks->track), 12);
  117. } catch (Exception $e ) {
  118. $this->fail("Exception: [" . $e->getMessage() . "] thrown by test");
  119. }
  120. }
  121. }