From 06f945f27840b53e57795dadbc38e76f7e11ab1c Mon Sep 17 00:00:00 2001 From: Horus3 Date: Mon, 24 Feb 2014 16:42:14 +0100 Subject: init --- zend/tests/Zend/Gdata/CalendarOnlineTest.php | 172 +++++++++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 zend/tests/Zend/Gdata/CalendarOnlineTest.php (limited to 'zend/tests/Zend/Gdata/CalendarOnlineTest.php') diff --git a/zend/tests/Zend/Gdata/CalendarOnlineTest.php b/zend/tests/Zend/Gdata/CalendarOnlineTest.php new file mode 100644 index 0000000..223de50 --- /dev/null +++ b/zend/tests/Zend/Gdata/CalendarOnlineTest.php @@ -0,0 +1,172 @@ +gdata = new Zend_Gdata_Calendar($client); + } + + public function testCalendarListFeed() + { + $calFeed = $this->gdata->getCalendarListFeed(); + $this->assertTrue(strpos($calFeed->title->text, 'Calendar List') + !== false); + $calCount = 0; + foreach ($calFeed as $calendar) { + $calCount++; + } + $this->assertTrue($calCount > 0); + } + + /** + * @group ZF-1701 + */ + public function testCalendarOnlineFeed() + { + $eventFeed = $this->gdata->getCalendarEventFeed(); + $this->assertTrue(strpos($eventFeed->title->text, TESTS_ZEND_GDATA_CLIENTLOGIN_EMAIL) + !== false); + $eventCount = 0; + foreach ( $eventFeed as $event ) { + $this->assertType('Zend_Gdata_Calendar_EventEntry', $event); + $eventCount++; + } + $this->assertTrue($eventCount > 0 ); + $this->assertTrue(count($eventFeed) == $eventCount); + } + + function getEvent($eventId) + { + $query = $this->gdata->newEventQuery(); + $query->setUser('default'); + $query->setVisibility('private'); + $query->setProjection('full'); + $query->setEvent($eventId); + + $eventEntry = $this->gdata->getCalendarEventEntry($query); + $this->assertTrue( + $eventEntry instanceof Zend_Gdata_Calendar_EventEntry); + return $eventEntry; + } + + public function createEvent( + $title = 'Tennis with Beth', + $desc='Meet for a quick lesson', $where = 'On the courts', + $startDate = '2008-01-20', $startTime = '10:00', + $endDate = '2008-01-20', $endTime = '11:00', $tzOffset = '-08') + { + $newEntry = $this->gdata->newEventEntry(); + $newEntry->title = $this->gdata->newTitle(trim($title)); + $newEntry->where = array($this->gdata->newWhere($where)); + + $newEntry->content = $this->gdata->newContent($desc); + $newEntry->content->type = 'text'; + + $when = $this->gdata->newWhen(); + $when->startTime = "{$startDate}T{$startTime}:00.000{$tzOffset}:00"; + $when->endTime = "{$endDate}T{$endTime}:00.000{$tzOffset}:00"; + $reminder = $this->gdata->newReminder(); + $reminder->minutes = '30'; + $reminder->method = 'email'; + $when->reminders = array($reminder); + $newEntry->when = array($when); + + $createdEntry = $this->gdata->insertEvent($newEntry); + + $this->assertEquals('email in 30 minutes', $reminder->__toString()); + $this->assertEquals($title, $createdEntry->title->text); + $this->assertEquals($desc, $createdEntry->content->text); + $this->assertEquals(strtotime($when->startTime), + strtotime($createdEntry->when[0]->startTime)); + $this->assertEquals(strtotime($when->endTime), + strtotime($createdEntry->when[0]->endTime)); + $this->assertEquals($reminder->method, + $createdEntry->when[0]->reminders[0]->method); + $this->assertEquals($reminder->minutes, + $createdEntry->when[0]->reminders[0]->minutes); + $this->assertEquals($where, $createdEntry->where[0]->valueString); + + return $createdEntry; + } + + function updateEvent ($eventId, $newTitle) + { + $eventOld = $this->getEvent($eventId); + $eventOld->title = $this->gdata->newTitle($newTitle); + $eventOld->save(); + $eventNew = $this->getEvent($eventId); + $this->assertEquals($newTitle, $eventNew->title->text); + return $eventNew; + } + + public function testCreateEvent() + { + $createdEntry = $this->createEvent(); + } + + public function testCreateAndUpdateEvent() + { + $newTitle = 'my new title'; + $createdEntry = $this->createEvent(); + preg_match('#.*/([A-Za-z0-9]+)$#', $createdEntry->id->text, $matches); + $id = $matches[1]; + $updatedEvent = $this->updateEvent($id, $newTitle); + $this->assertEquals($newTitle, $updatedEvent->title->text); + } + + public function testCreateAndDeleteEvent() + { + /* deletion can be performed in several different ways-- test all */ + $createdEntry = $this->createEvent(); + $createdEntry->delete(); + + $createdEntry2 = $this->createEvent(); + $this->gdata->delete($createdEntry2); + + $createdEntry3 = $this->createEvent(); + $this->gdata->delete($createdEntry3->getEditLink()->href); + } +} -- cgit v1.2.3