TrackDataTest.php 4.6 KB

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