From 06f945f27840b53e57795dadbc38e76f7e11ab1c Mon Sep 17 00:00:00 2001 From: Horus3 Date: Mon, 24 Feb 2014 16:42:14 +0100 Subject: init --- .../Gdata/Calendar/SendEventNotificationsTest.php | 124 +++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 zend/tests/Zend/Gdata/Calendar/SendEventNotificationsTest.php (limited to 'zend/tests/Zend/Gdata/Calendar/SendEventNotificationsTest.php') diff --git a/zend/tests/Zend/Gdata/Calendar/SendEventNotificationsTest.php b/zend/tests/Zend/Gdata/Calendar/SendEventNotificationsTest.php new file mode 100644 index 0000000..e8d3890 --- /dev/null +++ b/zend/tests/Zend/Gdata/Calendar/SendEventNotificationsTest.php @@ -0,0 +1,124 @@ +sendEventNotificationsText = file_get_contents( + 'Zend/Gdata/Calendar/_files/SendEventNotificationsElementSample1.xml', + true); + $this->sendEventNotifications = new Zend_Gdata_Calendar_Extension_SendEventNotifications(); + } + + public function testEmptySendEventNotificationsShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->sendEventNotifications->extensionElements)); + $this->assertTrue(count($this->sendEventNotifications->extensionElements) == 0); + } + + public function testEmptySendEventNotificationsShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->sendEventNotifications->extensionAttributes)); + $this->assertTrue(count($this->sendEventNotifications->extensionAttributes) == 0); + } + + public function testSampleSendEventNotificationsShouldHaveNoExtensionElements() { + $this->sendEventNotifications->transferFromXML($this->sendEventNotificationsText); + $this->assertTrue(is_array($this->sendEventNotifications->extensionElements)); + $this->assertTrue(count($this->sendEventNotifications->extensionElements) == 0); + } + + public function testSampleSendEventNotificationsShouldHaveNoExtensionAttributes() { + $this->sendEventNotifications->transferFromXML($this->sendEventNotificationsText); + $this->assertTrue(is_array($this->sendEventNotifications->extensionAttributes)); + $this->assertTrue(count($this->sendEventNotifications->extensionAttributes) == 0); + } + + public function testNormalSendEventNotificationsShouldHaveNoExtensionElements() { + $this->sendEventNotifications->value = true; + $this->assertEquals($this->sendEventNotifications->value, true); + $this->assertEquals(count($this->sendEventNotifications->extensionElements), 0); + $newSendEventNotifications = new Zend_Gdata_Calendar_Extension_SendEventNotifications(); + $newSendEventNotifications->transferFromXML($this->sendEventNotifications->saveXML()); + $this->assertEquals(count($newSendEventNotifications->extensionElements), 0); + $newSendEventNotifications->extensionElements = array( + new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); + $this->assertEquals(count($newSendEventNotifications->extensionElements), 1); + $this->assertEquals($newSendEventNotifications->value, true); + + /* try constructing using magic factory */ + $cal = new Zend_Gdata_Calendar(); + $newSendEventNotifications2 = $cal->newSendEventNotifications(); + $newSendEventNotifications2->transferFromXML($newSendEventNotifications->saveXML()); + $this->assertEquals(count($newSendEventNotifications2->extensionElements), 1); + $this->assertEquals($newSendEventNotifications2->value, true); + } + + public function testEmptySendEventNotificationsToAndFromStringShouldMatch() { + $sendEventNotificationsXml = $this->sendEventNotifications->saveXML(); + $newSendEventNotifications = new Zend_Gdata_Calendar_Extension_SendEventNotifications(); + $newSendEventNotifications->transferFromXML($sendEventNotificationsXml); + $newSendEventNotificationsXml = $newSendEventNotifications->saveXML(); + $this->assertTrue($sendEventNotificationsXml == $newSendEventNotificationsXml); + } + + public function testSendEventNotificationsWithValueToAndFromStringShouldMatch() { + $this->sendEventNotifications->value = true; + $sendEventNotificationsXml = $this->sendEventNotifications->saveXML(); + $newSendEventNotifications = new Zend_Gdata_Calendar_Extension_SendEventNotifications(); + $newSendEventNotifications->transferFromXML($sendEventNotificationsXml); + $newSendEventNotificationsXml = $newSendEventNotifications->saveXML(); + $this->assertTrue($sendEventNotificationsXml == $newSendEventNotificationsXml); + $this->assertEquals(true, $newSendEventNotifications->value); + } + + public function testExtensionAttributes() { + $extensionAttributes = $this->sendEventNotifications->extensionAttributes; + $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); + $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); + $this->sendEventNotifications->extensionAttributes = $extensionAttributes; + $this->assertEquals('bar', $this->sendEventNotifications->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $this->sendEventNotifications->extensionAttributes['foo2']['value']); + $sendEventNotificationsXml = $this->sendEventNotifications->saveXML(); + $newSendEventNotifications = new Zend_Gdata_Calendar_Extension_SendEventNotifications(); + $newSendEventNotifications->transferFromXML($sendEventNotificationsXml); + $this->assertEquals('bar', $newSendEventNotifications->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $newSendEventNotifications->extensionAttributes['foo2']['value']); + } + + public function testConvertFullSendEventNotificationsToAndFromString() { + $this->sendEventNotifications->transferFromXML($this->sendEventNotificationsText); + $this->assertEquals($this->sendEventNotifications->value, false); + } + +} -- cgit v1.2.3