NicknameQueryTest.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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/NicknameQuery.php';
  23. /**
  24. * @package Zend_Gdata
  25. * @subpackage UnitTests
  26. */
  27. class Zend_Gdata_Gapps_NicknameQueryTest extends PHPUnit_Framework_TestCase
  28. {
  29. public function setUp()
  30. {
  31. $this->query = new Zend_Gdata_Gapps_NicknameQuery();
  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/nickname/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/nickname/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/nickname/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/nickname/2.0?username=foo",
  61. $this->query->getQueryUrl());
  62. $this->query->setUsername(null);
  63. $this->assertEquals(null, $this->query->getUsername());
  64. $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/nickname/2.0",
  65. $this->query->getQueryUrl());
  66. }
  67. // Test to make sure that the nickname accessor methods work and propagate
  68. // to the query URI.
  69. public function testCanSetNicknameProperty()
  70. {
  71. $this->query->setDomain("my.domain.com");
  72. $this->query->setNickname("foo");
  73. $this->assertEquals("foo", $this->query->getNickname());
  74. $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/nickname/2.0/foo",
  75. $this->query->getQueryUrl());
  76. $this->query->setNickname("bar");
  77. $this->assertEquals("bar", $this->query->getNickname());
  78. $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/nickname/2.0/bar",
  79. $this->query->getQueryUrl());
  80. }
  81. // Test to make sure that the startNickname accessor methods work and
  82. // propagate to the query URI.
  83. public function testCanSetStartNicknameProperty()
  84. {
  85. $this->query->setDomain("my.domain.com");
  86. $this->query->setNickname("foo");
  87. $this->query->setStartNickname("bar");
  88. $this->assertEquals("bar", $this->query->getStartNickname());
  89. $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/nickname/2.0/foo?startNickname=bar",
  90. $this->query->getQueryUrl());
  91. $this->query->setStartNickname(null);
  92. $this->assertEquals(null, $this->query->getStartNickname());
  93. $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/nickname/2.0/foo",
  94. $this->query->getQueryUrl());
  95. }
  96. // Test to make sure that all parameters can be set simultaneously with no
  97. // ill effects.
  98. public function testCanSetAllParameters()
  99. {
  100. $this->query->setDomain("my.domain.com");
  101. $this->query->setNickname("foo");
  102. $this->query->setUsername("bar");
  103. $this->query->setStartNickname("baz");
  104. $this->assertEquals("foo", $this->query->getNickname());
  105. $this->assertEquals("bar", $this->query->getUsername());
  106. $this->assertEquals("baz", $this->query->getStartNickname());
  107. $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/nickname/2.0/foo?username=bar&startNickname=baz",
  108. $this->query->getQueryUrl());
  109. $this->query->setUsername("qux");
  110. $this->query->setNickname("baz");
  111. $this->query->setStartNickname("wibble");
  112. $this->assertEquals("baz", $this->query->getNickname());
  113. $this->assertEquals("qux", $this->query->getUsername());
  114. $this->assertEquals("wibble", $this->query->getStartNickname());
  115. $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/nickname/2.0/baz?username=qux&startNickname=wibble",
  116. $this->query->getQueryUrl());
  117. }
  118. }