UserQueryTest.php 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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_Gapps
  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/Gapps.php';
  23. require_once 'Zend/Gdata/Gapps/UserQuery.php';
  24. /**
  25. * @category Zend
  26. * @package Zend_Gdata_Gapps
  27. * @subpackage UnitTests
  28. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  29. * @license http://framework.zend.com/license/new-bsd New BSD License
  30. * @group Zend_Gdata
  31. * @group Zend_Gdata_Gapps
  32. */
  33. class Zend_Gdata_Gapps_UserQueryTest extends PHPUnit_Framework_TestCase
  34. {
  35. public function setUp()
  36. {
  37. $this->query = new Zend_Gdata_Gapps_UserQuery();
  38. }
  39. // Test to make sure that URI generation works
  40. public function testDefaultQueryURIGeneration()
  41. {
  42. $this->query->setDomain("foo.bar.invalid");
  43. $this->assertEquals("https://apps-apis.google.com/a/feeds/foo.bar.invalid/user/2.0",
  44. $this->query->getQueryUrl());
  45. }
  46. // Test to make sure that the domain accessor methods work and propagate
  47. // to the query URI.
  48. public function testCanSetQueryDomain()
  49. {
  50. $this->query->setDomain("my.domain.com");
  51. $this->assertEquals("my.domain.com", $this->query->getDomain());
  52. $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/user/2.0",
  53. $this->query->getQueryUrl());
  54. $this->query->setDomain("hello.world.baz");
  55. $this->assertEquals("hello.world.baz", $this->query->getDomain());
  56. $this->assertEquals("https://apps-apis.google.com/a/feeds/hello.world.baz/user/2.0",
  57. $this->query->getQueryUrl());
  58. }
  59. // Test to make sure that the username accessor methods work and propagate
  60. // to the query URI.
  61. public function testCanSetUsernameProperty()
  62. {
  63. $this->query->setDomain("my.domain.com");
  64. $this->query->setUsername("foo");
  65. $this->assertEquals("foo", $this->query->getUsername());
  66. $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/user/2.0/foo",
  67. $this->query->getQueryUrl());
  68. $this->query->setUsername("bar");
  69. $this->assertEquals("bar", $this->query->getUsername());
  70. $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/user/2.0/bar",
  71. $this->query->getQueryUrl());
  72. }
  73. // Test to make sure that the startUsername accessor methods work and
  74. // propagate to the query URI.
  75. public function testCanSetStartUsernameProperty()
  76. {
  77. $this->query->setDomain("my.domain.com");
  78. $this->query->setStartUsername("foo");
  79. $this->assertEquals("foo", $this->query->getStartUsername());
  80. $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/user/2.0?startUsername=foo",
  81. $this->query->getQueryUrl());
  82. $this->query->setStartUsername(null);
  83. $this->assertEquals(null, $this->query->getStartUsername());
  84. $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/user/2.0",
  85. $this->query->getQueryUrl());
  86. }
  87. }