PageRenderTime 40ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/ZendFramework/tests/Zend/Gdata/Gapps/EmailListEntryTest.php

https://bitbucket.org/Dal-Papa/is-340-publish-base
PHP | 140 lines | 91 code | 16 blank | 33 comment | 5 complexity | 3708dd1a12abd1f95c6986d2d8e87fb9 MD5 | raw file
  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/EmailListEntry.php';
  23. require_once 'Zend/Gdata/Gapps.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_EmailListEntryTest extends PHPUnit_Framework_TestCase
  34. {
  35. public function setUp() {
  36. $this->entryText = file_get_contents(
  37. 'Zend/Gdata/Gapps/_files/EmailListEntryDataSample1.xml',
  38. true);
  39. $this->entry = new Zend_Gdata_Gapps_EmailListEntry();
  40. }
  41. private function verifyAllSamplePropertiesAreCorrect ($emailListEntry) {
  42. $this->assertEquals('https://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-sales',
  43. $emailListEntry->id->text);
  44. $this->assertEquals('1970-01-01T00:00:00.000Z', $emailListEntry->updated->text);
  45. $this->assertEquals('http://schemas.google.com/g/2005#kind', $emailListEntry->category[0]->scheme);
  46. $this->assertEquals('http://schemas.google.com/apps/2006#emailList', $emailListEntry->category[0]->term);
  47. $this->assertEquals('text', $emailListEntry->title->type);
  48. $this->assertEquals('us-sales', $emailListEntry->title->text);;
  49. $this->assertEquals('self', $emailListEntry->getLink('self')->rel);
  50. $this->assertEquals('application/atom+xml', $emailListEntry->getLink('self')->type);
  51. $this->assertEquals('https://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-sales', $emailListEntry->getLink('self')->href);
  52. $this->assertEquals('edit', $emailListEntry->getLink('edit')->rel);
  53. $this->assertEquals('application/atom+xml', $emailListEntry->getLink('edit')->type);
  54. $this->assertEquals('https://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-sales', $emailListEntry->getLink('edit')->href);
  55. $this->assertEquals('us-sales', $emailListEntry->emailList->name);
  56. $this->assertEquals('http://schemas.google.com/apps/2006#emailList.recipients', $emailListEntry->getFeedLink('http://schemas.google.com/apps/2006#emailList.recipients')->rel);
  57. $this->assertEquals('http://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient/', $emailListEntry->getFeedLink('http://schemas.google.com/apps/2006#emailList.recipients')->href);
  58. }
  59. public function testEmptyEntryShouldHaveNoExtensionElements() {
  60. $this->assertTrue(is_array($this->entry->extensionElements));
  61. $this->assertTrue(count($this->entry->extensionElements) == 0);
  62. }
  63. public function testEmptyEntryShouldHaveNoExtensionAttributes() {
  64. $this->assertTrue(is_array($this->entry->extensionAttributes));
  65. $this->assertTrue(count($this->entry->extensionAttributes) == 0);
  66. }
  67. public function testSampleEntryShouldHaveNoExtensionElements() {
  68. $this->entry->transferFromXML($this->entryText);
  69. $this->assertTrue(is_array($this->entry->extensionElements));
  70. $this->assertTrue(count($this->entry->extensionElements) == 0);
  71. }
  72. public function testSampleEntryShouldHaveNoExtensionAttributes() {
  73. $this->entry->transferFromXML($this->entryText);
  74. $this->assertTrue(is_array($this->entry->extensionAttributes));
  75. $this->assertTrue(count($this->entry->extensionAttributes) == 0);
  76. }
  77. public function testEmptyEmailListEntryToAndFromStringShouldMatch() {
  78. $entryXml = $this->entry->saveXML();
  79. $newEmailListEntry = new Zend_Gdata_Gapps_EmailListEntry();
  80. $newEmailListEntry->transferFromXML($entryXml);
  81. $newEmailListEntryXml = $newEmailListEntry->saveXML();
  82. $this->assertTrue($entryXml == $newEmailListEntryXml);
  83. }
  84. public function testGetFeedLinkReturnsAllStoredEntriesWhenUsedWithNoParameters() {
  85. // Prepare test data
  86. $entry1 = new Zend_Gdata_Extension_FeedLink();
  87. $entry1->rel = "first";
  88. $entry1->href= "foo";
  89. $entry2 = new Zend_Gdata_Extension_FeedLink();
  90. $entry2->rel = "second";
  91. $entry2->href= "bar";
  92. $data = array($entry1, $entry2);
  93. // Load test data and run test
  94. $this->entry->feedLink = $data;
  95. $this->assertEquals(2, count($this->entry->feedLink));
  96. }
  97. public function testGetFeedLinkCanReturnEntriesByRelValue() {
  98. // Prepare test data
  99. $entry1 = new Zend_Gdata_Extension_FeedLink();
  100. $entry1->rel = "first";
  101. $entry1->href= "foo";
  102. $entry2 = new Zend_Gdata_Extension_FeedLink();
  103. $entry2->rel = "second";
  104. $entry2->href= "bar";
  105. $data = array($entry1, $entry2);
  106. // Load test data and run test
  107. $this->entry->feedLink = $data;
  108. $this->assertEquals($entry1, $this->entry->getFeedLink('first'));
  109. $this->assertEquals($entry2, $this->entry->getFeedLink('second'));
  110. }
  111. public function testSamplePropertiesAreCorrect () {
  112. $this->entry->transferFromXML($this->entryText);
  113. $this->verifyAllSamplePropertiesAreCorrect($this->entry);
  114. }
  115. public function testConvertEmailListEntryToAndFromString() {
  116. $this->entry->transferFromXML($this->entryText);
  117. $entryXml = $this->entry->saveXML();
  118. $newEmailListEntry = new Zend_Gdata_Gapps_EmailListEntry();
  119. $newEmailListEntry->transferFromXML($entryXml);
  120. $this->verifyAllSamplePropertiesAreCorrect($newEmailListEntry);
  121. $newEmailListEntryXml = $newEmailListEntry->saveXML();
  122. $this->assertEquals($entryXml, $newEmailListEntryXml);
  123. }
  124. }