EmailListQueryTest.php 5.6 KB

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