PhotosUserQueryTest.php 4.1 KB

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