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