AlbumDataTest.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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-2015 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. * @see Zend_Service_Audioscrobbler
  24. */
  25. require_once 'Zend/Service/Audioscrobbler.php';
  26. require_once "AudioscrobblerTestCase.php";
  27. /**
  28. * @category Zend
  29. * @package Zend_Service_Audioscrobbler
  30. * @subpackage UnitTests
  31. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  32. * @license http://framework.zend.com/license/new-bsd New BSD License
  33. * @group Zend_Service
  34. * @group Zend_Service_Audioscrobbler
  35. */
  36. class Zend_Service_Audioscrobbler_AlbumDataTest extends Zend_Service_Audioscrobbler_AudioscrobblerTestCase
  37. {
  38. public function testGetAlbumInfo()
  39. {
  40. $albumInfoResponse = "HTTP/1.1 200 OK\r\nContent-type: text/xml\r\n\r\n".
  41. '<?xml version="1.0" encoding="UTF-8"?>
  42. <album artist="Metallica" title="Metallica">
  43. <reach>85683</reach>
  44. <url>http://www.last.fm/music/Metallica/Metallica</url>
  45. <releasedate> 1 Jan 1994, 00:00</releasedate>
  46. <coverart>
  47. <small>http://static.last.fm/coverart/50x50/1411800.jpg</small>
  48. <medium>http://static.last.fm/coverart/130x130/1411800.jpg</medium>
  49. <large>http://static.last.fm/coverart/300x300/1411800.jpg</large>
  50. </coverart>
  51. <mbid>3750d9e2-59f5-471d-8916-463433069bd1</mbid>
  52. <tracks>
  53. <track title="Enter Sandman (LP Version)">
  54. <reach>26</reach>
  55. <url>http://www.last.fm/music/Metallica/_/Enter+Sandman+%28LP+Version%29</url>
  56. </track>
  57. <track title="Sad But True (LP Version)">
  58. <reach>22</reach>
  59. <url>http://www.last.fm/music/Metallica/_/Sad+But+True+%28LP+Version%29</url>
  60. </track>
  61. <track title="Holier Than Thou (LP Version)">
  62. <reach>2</reach>
  63. <url>http://www.last.fm/music/Metallica/_/Holier+Than+Thou+%28LP+Version%29</url>
  64. </track>
  65. <track title="The Unforgiven (LP Version)">
  66. <reach>10</reach>
  67. <url>http://www.last.fm/music/Metallica/_/The+Unforgiven+%28LP+Version%29</url>
  68. </track>
  69. <track title="Wherever I May Roam (LP Version)">
  70. <reach>4</reach>
  71. <url>http://www.last.fm/music/Metallica/_/Wherever+I+May+Roam+%28LP+Version%29</url>
  72. </track>
  73. <track title="Don\'t Tread On Me (LP Version)">
  74. <reach>3</reach>
  75. <url>http://www.last.fm/music/Metallica/_/Don%27t+Tread+On+Me+%28LP+Version%29</url>
  76. </track>
  77. <track title="Through The Never (LP Version)">
  78. <reach>3</reach>
  79. <url>http://www.last.fm/music/Metallica/_/Through+The+Never+%28LP+Version%29</url>
  80. </track>
  81. <track title="Nothing Else Matters (LP Version)">
  82. <reach>26</reach>
  83. <url>http://www.last.fm/music/Metallica/_/Nothing+Else+Matters+%28LP+Version%29</url>
  84. </track>
  85. <track title="Of Wolf And Man (LP Version)">
  86. <reach>3</reach>
  87. <url>http://www.last.fm/music/Metallica/_/Of+Wolf+And+Man+%28LP+Version%29</url>
  88. </track>
  89. <track title="The God That Failed (LP Version)">
  90. <reach>2</reach>
  91. <url>http://www.last.fm/music/Metallica/_/The+God+That+Failed+%28LP+Version%29</url>
  92. </track>
  93. <track title="My Friend Of Misery (LP Version)">
  94. <reach>3</reach>
  95. <url>http://www.last.fm/music/Metallica/_/My+Friend+Of+Misery+%28LP+Version%29</url>
  96. </track>
  97. <track title="The Struggle Within (LP Version)">
  98. <reach>3</reach>
  99. <url>http://www.last.fm/music/Metallica/_/The+Struggle+Within+%28LP+Version%29</url>
  100. </track>
  101. </tracks>
  102. </album>
  103. ';
  104. $this->setAudioscrobblerResponse($albumInfoResponse);
  105. try {
  106. $as = $this->getAudioscrobblerService();
  107. $as->set('album', 'Metallica');
  108. $as->set('artist', 'Metallica');
  109. $response = $as->albumGetInfo();
  110. $track = $response->tracks->track[0];
  111. $this->assertEquals((string)$response['artist'], 'Metallica');
  112. $this->assertEquals((string)$response['title'], 'Metallica');
  113. $this->assertEquals((string)$track->url, 'http://www.last.fm/music/Metallica/_/Enter+Sandman+%28LP+Version%29');
  114. $this->assertEquals(count($response->tracks->track), 12);
  115. } catch (Exception $e ) {
  116. $this->fail("Exception: [" . $e->getMessage() . "] thrown by test");
  117. }
  118. }
  119. }