NicknameQueryTest.php 5.7 KB

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