EmailListRecipientEntryTest.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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) 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/EmailListRecipientEntry.php';
  22. require_once 'Zend/Gdata/Gapps.php';
  23. /**
  24. * @package Zend_Gdata_App
  25. * @subpackage UnitTests
  26. */
  27. class Zend_Gdata_Gapps_EmailListRecipientEntryTest extends PHPUnit_Framework_TestCase
  28. {
  29. public function setUp() {
  30. $this->entryText = file_get_contents(
  31. 'Zend/Gdata/Gapps/_files/EmailListRecipientEntryDataSample1.xml',
  32. true);
  33. $this->entry = new Zend_Gdata_Gapps_EmailListRecipientEntry();
  34. }
  35. private function verifyAllSamplePropertiesAreCorrect ($emailListRecipientEntry) {
  36. $this->assertEquals('https://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient/SusanJones%40example.com',
  37. $emailListRecipientEntry->id->text);
  38. $this->assertEquals('1970-01-01T00:00:00.000Z', $emailListRecipientEntry->updated->text);
  39. $this->assertEquals('http://schemas.google.com/g/2005#kind', $emailListRecipientEntry->category[0]->scheme);
  40. $this->assertEquals('http://schemas.google.com/apps/2006#emailList.recipient', $emailListRecipientEntry->category[0]->term);
  41. $this->assertEquals('text', $emailListRecipientEntry->title->type);
  42. $this->assertEquals('SusanJones', $emailListRecipientEntry->title->text);;
  43. $this->assertEquals('self', $emailListRecipientEntry->getLink('self')->rel);
  44. $this->assertEquals('application/atom+xml', $emailListRecipientEntry->getLink('self')->type);
  45. $this->assertEquals('https://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient/SusanJones%40example.com', $emailListRecipientEntry->getLink('self')->href);
  46. $this->assertEquals('edit', $emailListRecipientEntry->getLink('edit')->rel);
  47. $this->assertEquals('application/atom+xml', $emailListRecipientEntry->getLink('edit')->type);
  48. $this->assertEquals('https://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient/SusanJones%40example.com', $emailListRecipientEntry->getLink('edit')->href);
  49. $this->assertEquals('SusanJones@example.com', $emailListRecipientEntry->who->email);
  50. }
  51. public function testEmptyEntryShouldHaveNoExtensionElements() {
  52. $this->assertTrue(is_array($this->entry->extensionElements));
  53. $this->assertTrue(count($this->entry->extensionElements) == 0);
  54. }
  55. public function testEmptyEntryShouldHaveNoExtensionAttributes() {
  56. $this->assertTrue(is_array($this->entry->extensionAttributes));
  57. $this->assertTrue(count($this->entry->extensionAttributes) == 0);
  58. }
  59. public function testSampleEntryShouldHaveNoExtensionElements() {
  60. $this->entry->transferFromXML($this->entryText);
  61. $this->assertTrue(is_array($this->entry->extensionElements));
  62. $this->assertTrue(count($this->entry->extensionElements) == 0);
  63. }
  64. public function testSampleEntryShouldHaveNoExtensionAttributes() {
  65. $this->entry->transferFromXML($this->entryText);
  66. $this->assertTrue(is_array($this->entry->extensionAttributes));
  67. $this->assertTrue(count($this->entry->extensionAttributes) == 0);
  68. }
  69. public function testEmptyEmailListRecipientEntryToAndFromStringShouldMatch() {
  70. $entryXml = $this->entry->saveXML();
  71. $newEmailListRecipientEntry = new Zend_Gdata_Gapps_EmailListRecipientEntry();
  72. $newEmailListRecipientEntry->transferFromXML($entryXml);
  73. $newEmailListRecipientEntryXml = $newEmailListRecipientEntry->saveXML();
  74. $this->assertTrue($entryXml == $newEmailListRecipientEntryXml);
  75. }
  76. public function testSamplePropertiesAreCorrect () {
  77. $this->entry->transferFromXML($this->entryText);
  78. $this->verifyAllSamplePropertiesAreCorrect($this->entry);
  79. }
  80. public function testConvertEmailListRecipientEntryToAndFromString() {
  81. $this->entry->transferFromXML($this->entryText);
  82. $entryXml = $this->entry->saveXML();
  83. $newEmailListRecipientEntry = new Zend_Gdata_Gapps_EmailListRecipientEntry();
  84. $newEmailListRecipientEntry->transferFromXML($entryXml);
  85. $this->verifyAllSamplePropertiesAreCorrect($newEmailListRecipientEntry);
  86. $newEmailListRecipientEntryXml = $newEmailListRecipientEntry->saveXML();
  87. $this->assertEquals($entryXml, $newEmailListRecipientEntryXml);
  88. }
  89. }