UserQueryTest.php 3.4 KB

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