EventEntryTest.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. * @feed Zend
  16. * @package Zend_Gdata_App
  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/Calendar/EventEntry.php';
  22. require_once 'Zend/Gdata/Calendar.php';
  23. /**
  24. * @package Zend_Gdata_App
  25. * @subpackage UnitTests
  26. */
  27. class Zend_Gdata_Calendar_EventEntryTest extends PHPUnit_Framework_TestCase
  28. {
  29. public function setUp() {
  30. $this->entryText = file_get_contents(
  31. 'Zend/Gdata/Calendar/_files/EventEntrySample1.xml',
  32. true);
  33. $this->entry = new Zend_Gdata_Calendar_EventEntry();
  34. }
  35. public function testSetters() {
  36. $entry = new Zend_Gdata_Calendar_EventEntry();
  37. $who = new Zend_Gdata_Extension_Who();
  38. $who->setValueString("John Doe");
  39. $who->setEmail("john@doe.com");
  40. $entry->setWho($who);
  41. $whoRetrieved = $entry->getWho();
  42. $this->assertEquals("john@doe.com", $whoRetrieved->getEmail());
  43. $this->assertEquals("John Doe", $whoRetrieved->getValueString());
  44. }
  45. public function testEmptyEntryShouldHaveNoExtensionElements() {
  46. $this->assertTrue(is_array($this->entry->extensionElements));
  47. $this->assertTrue(count($this->entry->extensionElements) == 0);
  48. }
  49. public function testEmptyEntryShouldHaveNoExtensionAttributes() {
  50. $this->assertTrue(is_array($this->entry->extensionAttributes));
  51. $this->assertTrue(count($this->entry->extensionAttributes) == 0);
  52. }
  53. public function testSampleEntryShouldHaveNoExtensionElements() {
  54. $this->entry->transferFromXML($this->entryText);
  55. $this->assertTrue(is_array($this->entry->extensionElements));
  56. $this->assertTrue(count($this->entry->extensionElements) == 0);
  57. }
  58. public function testSampleEntryShouldHaveNoExtensionAttributes() {
  59. $this->entry->transferFromXML($this->entryText);
  60. $this->assertTrue(is_array($this->entry->extensionAttributes));
  61. $this->assertTrue(count($this->entry->extensionAttributes) == 0);
  62. }
  63. public function testEmptyEventEntryToAndFromStringShouldMatch() {
  64. $entryXml = $this->entry->saveXML();
  65. $newEventEntry = new Zend_Gdata_Calendar_EventEntry();
  66. $newEventEntry->transferFromXML($entryXml);
  67. $newEventEntryXml = $newEventEntry->saveXML();
  68. $this->assertTrue($entryXml == $newEventEntryXml);
  69. }
  70. public function testConvertEventEntryToAndFromString() {
  71. $this->entry->transferFromXML($this->entryText);
  72. $entryXml = $this->entry->saveXML();
  73. $newEventEntry = new Zend_Gdata_Calendar_EventEntry();
  74. $newEventEntry->transferFromXML($entryXml);
  75. $newEventEntryXml = $newEventEntry->saveXML();
  76. $this->assertEquals($entryXml, $newEventEntryXml);
  77. $this->assertEquals('http://www.google.com/calendar/feeds/default/private/full/s0dtsvq4pe15ku09jideg67fv4_20070509T193000Z',
  78. $newEventEntry->id->text);
  79. $this->assertEquals('Mantek',
  80. $newEventEntry->extendedProperty[0]->value);
  81. $this->assertEquals('s0dtsvq4pe15ku09jideg67fv4',
  82. $newEventEntry->originalEvent->id);
  83. $this->assertEquals('s0dtsvq4pe15ku09jideg67fv4',
  84. $newEventEntry->originalEvent->id);
  85. $this->assertEquals('http://www.google.com/calendar/feeds/default/private/full/s0dtsvq4pe15ku09jideg67fv4_20070509T193000Z/comments',
  86. $newEventEntry->comments->feedLink->href);
  87. }
  88. /*
  89. public function testEventEntryWithTextAndTypeToAndFromStringShouldMatch() {
  90. $this->feed->text = '<img src="http://www.example.com/image.jpg"/>';
  91. $this->feed->type = 'xhtml';
  92. $feedXml = $this->feed->saveXML();
  93. $newEventEntry = new Zend_Gdata_App_EventEntry();
  94. $newEventEntry->transferFromXML($feedXml);
  95. $newEventEntryXml = $newEventEntry->saveXML();
  96. $this->assertEquals($newEventEntryXml, $feedXml);
  97. $this->assertEquals('<img src="http://www.example.com/image.jpg"/>', $newEventEntry->text);
  98. $this->assertEquals('xhtml', $newEventEntry->type);
  99. }
  100. public function testEventEntryWithSrcAndTypeToAndFromStringShouldMatch() {
  101. $this->feed->src = 'http://www.example.com/image.png';
  102. $this->feed->type = 'image/png';
  103. $feedXml = $this->feed->saveXML();
  104. $newEventEntry = new Zend_Gdata_App_EventEntry();
  105. $newEventEntry->transferFromXML($feedXml);
  106. $newEventEntryXml = $newEventEntry->saveXML();
  107. $this->assertEquals($newEventEntryXml, $feedXml);
  108. $this->assertEquals('http://www.example.com/image.png', $newEventEntry->src);
  109. $this->assertEquals('image/png', $newEventEntry->type);
  110. }
  111. public function testConvertEventEntryWithSrcAndTypeToAndFromString() {
  112. $this->feed->transferFromXML($this->feedText);
  113. $this->assertEquals('http://www.example.com/image.png', $this->feed->src);
  114. $this->assertEquals('image/png', $this->feed->type);
  115. }
  116. */
  117. }