PhotosUserQueryTest.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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/UserQuery.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_PhotosUserQueryTest extends PHPUnit_Framework_TestCase
  30. {
  31. /**
  32. * Check the consistency of a user feed request
  33. */
  34. public function testSimpleUserQuery()
  35. {
  36. $queryString = "http://picasaweb.google.com/data/feed/api/user/sample.user";
  37. $query = new Zend_Gdata_Photos_UserQuery();
  38. $query->setUser("sample.user");
  39. $generatedString = $query->getQueryUrl();
  40. // Assert that the generated query matches the correct one
  41. $this->assertEquals($queryString, $generatedString);
  42. }
  43. /**
  44. * Check the consistency of a user feed request
  45. * Projection is set to base
  46. */
  47. public function testBaseUserQuery()
  48. {
  49. $queryString = "http://picasaweb.google.com/data/feed/base/user/sample.user";
  50. $query = new Zend_Gdata_Photos_UserQuery();
  51. $query->setUser("sample.user");
  52. $query->setProjection("base");
  53. $generatedString = $query->getQueryUrl();
  54. // Assert that the generated query matches the correct one
  55. $this->assertEquals($queryString, $generatedString);
  56. }
  57. /**
  58. * Check for thrown exceptions upon improper albumname/id setting
  59. */
  60. public function testUserQueryExceptions()
  61. {
  62. $query = new Zend_Gdata_Photos_UserQuery();
  63. $query->setUser("sample.user");
  64. $query->setProjection(null);
  65. try {
  66. $generatedString = $query->getQueryUrl();
  67. } catch (Exception $e) {
  68. $this->assertTrue($e instanceof Zend_Gdata_App_InvalidArgumentException);
  69. }
  70. $query->setProjection("api");
  71. $query->setUser(null);
  72. try {
  73. $generatedString = $query->getQueryUrl();
  74. } catch (Exception $e) {
  75. $this->assertTrue($e instanceof Zend_Gdata_App_InvalidArgumentException);
  76. }
  77. }
  78. /**
  79. * Check the consistency of a user feed request filtered
  80. * for a specific tag
  81. */
  82. public function testTagFilterUserQuery()
  83. {
  84. $queryString = "http://picasaweb.google.com/data/feed/api/user/sample.user?tag=test";
  85. $query = new Zend_Gdata_Photos_UserQuery();
  86. $query->setUser("sample.user");
  87. $query->setTag("test");
  88. $generatedString = $query->getQueryUrl();
  89. // Assert that the generated query matches the correct one
  90. $this->assertEquals($queryString, $generatedString);
  91. }
  92. /**
  93. * Check the consistency of a user feed request for private data
  94. */
  95. public function testPrivateUserQuery()
  96. {
  97. $queryString = "http://picasaweb.google.com/data/feed/api/user/sample.user?access=private";
  98. $query = new Zend_Gdata_Photos_UserQuery();
  99. $query->setUser("sample.user");
  100. $query->setAccess("private");
  101. $generatedString = $query->getQueryUrl();
  102. // Assert that the generated query matches the correct one
  103. $this->assertEquals($queryString, $generatedString);
  104. }
  105. }