TrackDataTest.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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_TrackDataTest extends Zend_Service_Audioscrobbler_AudioscrobblerTestCase
  37. {
  38. var $header = "HTTP/1.1 200 OK\r\nContent-type: text/xml\r\n\r\n";
  39. public function testGetTopFans()
  40. {
  41. $testing_response = $this->header .
  42. '<?xml version="1.0" encoding="UTF-8"?>
  43. <fans artist="Metallica" track="Enter Sandman">
  44. <user username="suhis">
  45. <url>http://www.last.fm/user/suhis/</url>
  46. <image>http://static.last.fm/depth/catalogue/noimage/nouser_140px.jpg</image>
  47. <weight>2816666</weight>
  48. </user>
  49. <user username="M4lu5">
  50. <url>http://www.last.fm/user/M4lu5/</url>
  51. <image>http://static.last.fm/avatar/ea9c0ddf6b6cc236dfc4297e376e9901.jpg</image>
  52. <weight>2380500</weight>
  53. </user>
  54. <user username="Ceniza666">
  55. <url>http://www.last.fm/user/Ceniza666/</url>
  56. <image>http://static.last.fm/depth/catalogue/noimage/nouser_140px.jpg</image>
  57. <weight>1352000</weight>
  58. </user>
  59. </fans>
  60. ';
  61. $this->setAudioscrobblerResponse($testing_response);
  62. $as = $this->getAudioscrobblerService();
  63. $as->set('artist', 'Metallica');
  64. $as->set('track', 'Enter Sandman');
  65. $response = $as->trackGetTopFans();
  66. $this->assertEquals((string)$response['artist'], 'Metallica');
  67. $this->assertEquals((string)$response['track'], 'Enter Sandman');
  68. $this->assertNotNull(count($response->user));
  69. }
  70. public function testGetTopTags()
  71. {
  72. $testing_response = $this->header .
  73. '<?xml version="1.0" encoding="UTF-8"?>
  74. <toptags artist="Metallica" track="Enter Sandman">
  75. <tag>
  76. <name>metal</name>
  77. <count>100</count>
  78. <url>http://www.last.fm/tag/metal</url>
  79. </tag>
  80. <tag>
  81. <name>heavy metal</name>
  82. <count>55</count>
  83. <url>http://www.last.fm/tag/heavy%20metal</url>
  84. </tag>
  85. <tag>
  86. <name>rock</name>
  87. <count>21</count>
  88. <url>http://www.last.fm/tag/rock</url>
  89. </tag>
  90. </toptags>
  91. ';
  92. $this->setAudioscrobblerResponse($testing_response);
  93. $as = $this->getAudioscrobblerService();
  94. $as->set('artist', 'Metallica');
  95. $as->set('track', 'Enter Sandman');
  96. $response = $as->trackGetTopTags();
  97. $this->assertNotNull(count($response->tag));
  98. $this->assertEquals((string)$response['artist'], 'Metallica');
  99. $this->assertEquals((string)$response['track'], 'Enter Sandman');
  100. }
  101. }