TrackDataTest.php 4.5 KB

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