GroupQueryTest.php 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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/GroupQuery.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_GroupQueryTest extends PHPUnit_Framework_TestCase
  34. {
  35. public function setUp()
  36. {
  37. $this->query = new Zend_Gdata_Gapps_GroupQuery();
  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/group/2.0/foo.bar.invalid",
  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/group/2.0/my.domain.com",
  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/group/2.0/hello.world.baz",
  57. $this->query->getQueryUrl());
  58. }
  59. // Test to make sure that the groupId accessor methods work and propagate
  60. // to the query URI.
  61. public function testCanSetGroupIdProperty()
  62. {
  63. $this->query->setDomain("my.domain.com");
  64. $this->query->setGroupId("foo");
  65. $this->assertEquals("foo", $this->query->getGroupId());
  66. $this->assertEquals("https://apps-apis.google.com/a/feeds/group/2.0/my.domain.com/foo",
  67. $this->query->getQueryUrl());
  68. $this->query->setGroupId("bar");
  69. $this->assertEquals("bar", $this->query->getGroupId());
  70. $this->assertEquals("https://apps-apis.google.com/a/feeds/group/2.0/my.domain.com/bar",
  71. $this->query->getQueryUrl());
  72. }
  73. // Test to make sure that the member accessor methods work and propagate
  74. // to the query URI.
  75. public function testCanSetMemberProperty()
  76. {
  77. $this->query->setDomain("my.domain.com");
  78. $this->query->setMember("bar@qux.com");
  79. $this->assertEquals("bar@qux.com", $this->query->getMember());
  80. $this->assertEquals("https://apps-apis.google.com/a/feeds/group/2.0/my.domain.com/?member=bar%40qux.com",
  81. $this->query->getQueryUrl());
  82. $this->query->setMember(null);
  83. $this->assertEquals(null, $this->query->getMember());
  84. $this->assertEquals("https://apps-apis.google.com/a/feeds/group/2.0/my.domain.com",
  85. $this->query->getQueryUrl());
  86. }
  87. // Test to make sure that the startUsername accessor methods work and
  88. // propagate to the query URI.
  89. public function testCanSetStartGroupIdProperty()
  90. {
  91. $this->query->setDomain("my.domain.com");
  92. $this->query->setStartGroupId("foo");
  93. $this->assertEquals("foo", $this->query->getStartGroupId());
  94. $this->assertEquals("https://apps-apis.google.com/a/feeds/group/2.0/my.domain.com?start=foo",
  95. $this->query->getQueryUrl());
  96. $this->query->setStartGroupId(null);
  97. $this->assertEquals(null, $this->query->getStartGroupId());
  98. $this->assertEquals("https://apps-apis.google.com/a/feeds/group/2.0/my.domain.com",
  99. $this->query->getQueryUrl());
  100. }
  101. public function testCanSetDirectOnlyProperty()
  102. {
  103. $this->query->setDomain("my.domain.com");
  104. $this->query->setMember("bar@qux.com");
  105. $this->query->setDirectOnly(true);
  106. $this->assertEquals(true, $this->query->getDirectOnly());
  107. $expected_url = "https://apps-apis.google.com/a/feeds/group/2.0/my.domain.com/";
  108. $expected_url .= "?member=bar%40qux.com&directOnly=true";
  109. $this->assertEquals($expected_url, $this->query->getQueryUrl());
  110. $this->query->setDirectOnly(false);
  111. $this->assertEquals(false, $this->query->getDirectOnly());
  112. $expected_url = "https://apps-apis.google.com/a/feeds/group/2.0/my.domain.com/";
  113. $expected_url .= "?member=bar%40qux.com&directOnly=false";
  114. $this->assertEquals($expected_url, $this->query->getQueryUrl());
  115. $this->query->setDirectOnly(null);
  116. $this->assertEquals(null, $this->query->getDirectOnly());
  117. $expected_url = "https://apps-apis.google.com/a/feeds/group/2.0/my.domain.com/";
  118. $expected_url .= "?member=bar%40qux.com";
  119. $this->assertEquals($expected_url, $this->query->getQueryUrl());
  120. }
  121. // Test to make sure that all parameters can be set simultaneously with no
  122. // ill effects.
  123. public function testCanSetAllParameters()
  124. {
  125. $this->query->setDomain("my.domain.com");
  126. $this->query->setGroupId("foo");
  127. $this->query->setMember("bar@qux.com");
  128. $this->query->setStartGroupId("wibble");
  129. $this->query->setDirectOnly(true);
  130. $this->assertEquals("foo", $this->query->getGroupId());
  131. $this->assertEquals("bar@qux.com", $this->query->getMember());
  132. $this->assertEquals("wibble", $this->query->getStartGroupId());
  133. $this->assertEquals(true, $this->query->getDirectOnly());
  134. $expected_url = "https://apps-apis.google.com/a/feeds/group/2.0/my.domain.com/";
  135. $expected_url .= "foo/?member=bar%40qux.com&start=wibble&directOnly=true";
  136. $this->assertEquals($expected_url, $this->query->getQueryUrl());
  137. $this->query->setMember("baz@blah.com");
  138. $this->query->setGroupId("xyzzy");
  139. $this->query->setStartGroupId("woof");
  140. $this->query->setDirectOnly(false);
  141. $this->assertEquals("xyzzy", $this->query->getGroupId());
  142. $this->assertEquals("baz@blah.com", $this->query->getMember());
  143. $this->assertEquals("woof", $this->query->getStartGroupId());
  144. $this->assertEquals(false, $this->query->getDirectOnly());
  145. $expected_url = "https://apps-apis.google.com/a/feeds/group/2.0/my.domain.com/";
  146. $expected_url .= "xyzzy/?member=baz%40blah.com&start=woof&directOnly=false";
  147. $this->assertEquals($expected_url, $this->query->getQueryUrl());
  148. }
  149. }