BooksOnlineTest.php 4.1 KB

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