EmailListQueryTest.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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-2012 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/EmailListQuery.php';
  24. /**
  25. * @category Zend
  26. * @package Zend_Gdata_Gapps
  27. * @subpackage UnitTests
  28. * @copyright Copyright (c) 2005-2012 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_EmailListQueryTest extends PHPUnit_Framework_TestCase
  34. {
  35. public function setUp()
  36. {
  37. $this->query = new Zend_Gdata_Gapps_EmailListQuery();
  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/emailList/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/emailList/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/emailList/2.0",
  57. $this->query->getQueryUrl());
  58. }
  59. // Test to make sure that the emailListName accessor methods work and propagate
  60. // to the query URI.
  61. public function testCanSetEmailListNameProperty()
  62. {
  63. $this->query->setDomain("my.domain.com");
  64. $this->query->setEmailListName("foo");
  65. $this->assertEquals("foo", $this->query->getEmailListName());
  66. $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/emailList/2.0/foo",
  67. $this->query->getQueryUrl());
  68. $this->query->setEmailListName("bar");
  69. $this->assertEquals("bar", $this->query->getEmailListName());
  70. $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/emailList/2.0/bar",
  71. $this->query->getQueryUrl());
  72. }
  73. // Test to make sure that the recipient accessor methods work and propagate
  74. // to the query URI.
  75. public function testCanSetRecipientProperty()
  76. {
  77. $this->query->setDomain("my.domain.com");
  78. $this->query->setRecipient("bar@qux.com");
  79. $this->assertEquals("bar@qux.com", $this->query->getRecipient());
  80. $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/emailList/2.0?recipient=bar%40qux.com",
  81. $this->query->getQueryUrl());
  82. $this->query->setRecipient(null);
  83. $this->assertEquals(null, $this->query->getRecipient());
  84. $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/emailList/2.0",
  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 testCanSetStartEmailListNameProperty()
  90. {
  91. $this->query->setDomain("my.domain.com");
  92. $this->query->setStartEmailListName("foo");
  93. $this->assertEquals("foo", $this->query->getStartEmailListName());
  94. $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/emailList/2.0?startEmailListName=foo",
  95. $this->query->getQueryUrl());
  96. $this->query->setStartEmailListName(null);
  97. $this->assertEquals(null, $this->query->getStartEmailListName());
  98. $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/emailList/2.0",
  99. $this->query->getQueryUrl());
  100. }
  101. // Test to make sure that all parameters can be set simultaneously with no
  102. // ill effects.
  103. public function testCanSetAllParameters()
  104. {
  105. $this->query->setDomain("my.domain.com");
  106. $this->query->setEmailListName("foo");
  107. $this->query->setRecipient("bar@qux.com");
  108. $this->query->setStartEmailListName("wibble");
  109. $this->assertEquals("foo", $this->query->getEmailListName());
  110. $this->assertEquals("bar@qux.com", $this->query->getRecipient());
  111. $this->assertEquals("wibble", $this->query->getStartEmailListName());
  112. $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/emailList/2.0/foo?recipient=bar%40qux.com&startEmailListName=wibble",
  113. $this->query->getQueryUrl());
  114. $this->query->setRecipient("baz@blah.com");
  115. $this->query->setEmailListName("xyzzy");
  116. $this->query->setStartEmailListName("woof");
  117. $this->assertEquals("xyzzy", $this->query->getEmailListName());
  118. $this->assertEquals("baz@blah.com", $this->query->getRecipient());
  119. $this->assertEquals("woof", $this->query->getStartEmailListName());
  120. $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/emailList/2.0/xyzzy?recipient=baz%40blah.com&startEmailListName=woof",
  121. $this->query->getQueryUrl());
  122. }
  123. }