BooksOnlineTest.php 4.0 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_Gdata_Books
  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. require_once 'Zend/Gdata/Books.php';
  23. require_once 'Zend/Http/Client.php';
  24. require_once 'Zend/Gdata/ClientLogin.php';
  25. /**
  26. * @category Zend
  27. * @package Zend_Gdata_Books
  28. * @subpackage UnitTests
  29. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  30. * @license http://framework.zend.com/license/new-bsd New BSD License
  31. * @group Zend_Gdata
  32. * @group Zend_Gdata_Books
  33. */
  34. class Zend_Gdata_BooksOnlineTest extends PHPUnit_Framework_TestCase
  35. {
  36. public function setUp()
  37. {
  38. $user = constant('TESTS_ZEND_GDATA_CLIENTLOGIN_EMAIL');
  39. $pass = constant('TESTS_ZEND_GDATA_CLIENTLOGIN_PASSWORD');
  40. $service = Zend_Gdata_Books::AUTH_SERVICE_NAME;
  41. $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
  42. $this->gdata = new Zend_Gdata_Books($client);
  43. }
  44. public function testGetVolumeFeed()
  45. {
  46. $query = $this->gdata->newVolumeQuery();
  47. $query->setQuery('Hamlet');
  48. $query->setStartIndex(5);
  49. $query->setMaxResults(8);
  50. $query->setMinViewability('partial_view');
  51. $feed = $this->gdata->getVolumeFeed($query);
  52. $this->assertTrue($feed instanceof Zend_Gdata_Books_VolumeFeed);
  53. foreach ($feed->entries as $entry) {
  54. $this->assertTrue($entry instanceof Zend_Gdata_Books_VolumeEntry);
  55. $this->assertEquals($feed->getHttpClient(), $entry->getHttpClient());
  56. }
  57. $this->assertEquals(5, $feed->startIndex->text);
  58. $this->assertEquals(8, $feed->itemsPerPage->text);
  59. }
  60. public function testGetVolumetEntry()
  61. {
  62. $entry = $this->gdata->getVolumeEntry('Mfer_MFwQrkC');
  63. $this->assertTrue($entry instanceof Zend_Gdata_Books_VolumeEntry);
  64. }
  65. public function testUserLibraryFeed()
  66. {
  67. $feed = $this->gdata->getUserLibraryFeed();
  68. $this->assertTrue($feed instanceof Zend_Gdata_Books_VolumeFeed);
  69. foreach ($feed->entries as $entry) {
  70. $this->assertTrue($entry instanceof Zend_Gdata_Books_VolumeEntry);
  71. $this->assertEquals(
  72. $feed->getHttpClient(), $entry->getHttpClient());
  73. }
  74. $entry = new Zend_Gdata_Books_VolumeEntry();
  75. $entry->setId(new Zend_Gdata_App_Extension_Id('Mfer_MFwQrkC'));
  76. $newEntry = $this->gdata->insertVolume($entry);
  77. $this->assertTrue($newEntry instanceof Zend_Gdata_Books_VolumeEntry);
  78. $this->gdata->deleteVolume($newEntry);
  79. }
  80. public function testUserAnnotationFeed()
  81. {
  82. $feed = $this->gdata->getUserAnnotationFeed();
  83. $this->assertTrue($feed instanceof Zend_Gdata_Books_VolumeFeed);
  84. foreach ($feed->entries as $entry) {
  85. $this->assertTrue($entry instanceof Zend_Gdata_Books_VolumeEntry);
  86. $this->assertEquals(
  87. $feed->getHttpClient(), $entry->getHttpClient());
  88. }
  89. $entry = new Zend_Gdata_Books_VolumeEntry();
  90. $entry->setId(new Zend_Gdata_App_Extension_Id('Mfer_MFwQrkC'));
  91. $entry->setRating(new Zend_Gdata_Extension_Rating(3, 1, 5, 1));
  92. $newEntry = $this->gdata->insertVolume($entry,
  93. Zend_Gdata_Books::MY_ANNOTATION_FEED_URI);
  94. $this->assertTrue($newEntry instanceof Zend_Gdata_Books_VolumeEntry);
  95. $this->gdata->deleteVolume($newEntry);
  96. }
  97. }