PhotosPhotoQueryTest.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. */
  21. require_once 'Zend/Gdata/Photos.php';
  22. require_once 'Zend/Gdata/Photos/PhotoQuery.php';
  23. require_once 'Zend/Http/Client.php';
  24. require_once 'Zend/Http/Client/Adapter/Test.php';
  25. /**
  26. * @package Zend_Gdata
  27. * @subpackage UnitTests
  28. */
  29. class Zend_Gdata_Photos_PhotosPhotoQueryTest extends PHPUnit_Framework_TestCase
  30. {
  31. /**
  32. * Check the consistency of a user feed request
  33. */
  34. public function testSimplePhotoQuery()
  35. {
  36. $queryString = "http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1/photoid/1";
  37. $query = new Zend_Gdata_Photos_PhotoQuery();
  38. $query->setUser("sample.user");
  39. $query->setAlbumId("1");
  40. $query->setPhotoId("1");
  41. $generatedString = $query->getQueryUrl();
  42. // Assert that the generated query matches the correct one
  43. $this->assertEquals($queryString, $generatedString);
  44. }
  45. /**
  46. * Check the consistency of a user feed request
  47. * Projection is set to base
  48. */
  49. public function testBasePhotoQuery()
  50. {
  51. $queryString = "http://picasaweb.google.com/data/feed/base/user/sample.user/albumid/1/photoid/1";
  52. $query = new Zend_Gdata_Photos_PhotoQuery();
  53. $query->setUser("sample.user");
  54. $query->setAlbumId("1");
  55. $query->setPhotoId("1");
  56. $query->setProjection("base");
  57. $generatedString = $query->getQueryUrl();
  58. // Assert that the generated query matches the correct one
  59. $this->assertEquals($queryString, $generatedString);
  60. }
  61. /**
  62. * Check for thrown exceptions upon improper photoid setting
  63. */
  64. public function testPhotoQueryExceptions()
  65. {
  66. $query = new Zend_Gdata_Photos_PhotoQuery();
  67. $query->setUser("sample.user");
  68. $query->setAlbumId("1");
  69. try {
  70. $generatedString = $query->getQueryUrl();
  71. } catch (Exception $e) {
  72. $this->assertTrue($e instanceof Zend_Gdata_App_InvalidArgumentException);
  73. }
  74. }
  75. /**
  76. * Check the consistency of a user feed request filtered
  77. * for a specific tag
  78. */
  79. public function testTagFilterPhotoQuery()
  80. {
  81. $queryString = "http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1/photoid/1?tag=test";
  82. $query = new Zend_Gdata_Photos_PhotoQuery();
  83. $query->setUser("sample.user");
  84. $query->setAlbumId("1");
  85. $query->setPhotoId("1");
  86. $query->setTag("test");
  87. $generatedString = $query->getQueryUrl();
  88. // Assert that the generated query matches the correct one
  89. $this->assertEquals($queryString, $generatedString);
  90. }
  91. /**
  92. * Check the consistency of a user feed request for private data
  93. */
  94. public function testPrivatePhotoQuery()
  95. {
  96. $queryString = "http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1/photoid/1?access=private";
  97. $query = new Zend_Gdata_Photos_PhotoQuery();
  98. $query->setUser("sample.user");
  99. $query->setAlbumId("1");
  100. $query->setPhotoId("1");
  101. $query->setAccess("private");
  102. $generatedString = $query->getQueryUrl();
  103. // Assert that the generated query matches the correct one
  104. $this->assertEquals($queryString, $generatedString);
  105. }
  106. }