PhotosPhotoQueryTest.php 4.2 KB

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