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/Calendar/EventQueryTest.php | 270 ++++++++++++++++++++++ 1 file changed, 270 insertions(+) create mode 100644 zend/tests/Zend/Gdata/Calendar/EventQueryTest.php (limited to 'zend/tests/Zend/Gdata/Calendar/EventQueryTest.php') diff --git a/zend/tests/Zend/Gdata/Calendar/EventQueryTest.php b/zend/tests/Zend/Gdata/Calendar/EventQueryTest.php new file mode 100644 index 0000000..7e4e834 --- /dev/null +++ b/zend/tests/Zend/Gdata/Calendar/EventQueryTest.php @@ -0,0 +1,270 @@ +query = new Zend_Gdata_Calendar_EventQuery(); + } + + public function testDefaultBaseUrlForQuery() + { + $queryUrl = $this->query->getQueryUrl(); + $this->assertEquals('https://www.google.com/calendar/feeds/default/public/full', + $queryUrl); + } + + public function testAlternateBaseUrlForQuery() + { + $this->query = new Zend_Gdata_Calendar_EventQuery('http://www.foo.com'); + $queryUrl = $this->query->getQueryUrl(); + // the URL passed in the constructor has the user, visibility + // projection appended for the return value of $query->getQueryUrl() + $this->assertEquals('http://www.foo.com/default/public/full', $queryUrl); + } + + public function testUpdatedMinMaxParam() + { + $updatedMin = '2006-09-20'; + $updatedMax = '2006-11-05'; + $this->query->resetParameters(); + $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); + $this->query->setUpdatedMin($updatedMin); + $this->query->setUpdatedMax($updatedMax); + $this->assertTrue($this->query->updatedMin != null); + $this->assertTrue($this->query->updatedMax != null); + $this->assertTrue($this->query->user != null); + $this->assertEquals(Zend_Gdata_App_Util::formatTimestamp($updatedMin), $this->query->getUpdatedMin()); + $this->assertEquals(Zend_Gdata_App_Util::formatTimestamp($updatedMax), $this->query->getUpdatedMax()); + $this->assertEquals(self::GOOGLE_DEVELOPER_CALENDAR, $this->query->getUser()); + + $this->query->updatedMin = null; + $this->assertFalse($this->query->updatedMin != null); + $this->query->updatedMax = null; + $this->assertFalse($this->query->updatedMax != null); + $this->query->user = null; + $this->assertFalse($this->query->user != null); + } + + public function testStartMinMaxParam() + { + $this->query->resetParameters(); + $startMin = '2006-10-30'; + $startMax = '2006-11-01'; + $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); + $this->query->setStartMin($startMin); + $this->query->setStartMax($startMax); + $this->assertTrue($this->query->startMin != null); + $this->assertTrue($this->query->startMax != null); + $this->assertEquals(Zend_Gdata_App_Util::formatTimestamp($startMin), $this->query->getStartMin()); + $this->assertEquals(Zend_Gdata_App_Util::formatTimestamp($startMax), $this->query->getStartMax()); + + $this->query->startMin = null; + $this->assertFalse($this->query->startMin != null); + $this->query->startMax = null; + $this->assertFalse($this->query->startMax != null); + $this->query->user = null; + $this->assertFalse($this->query->user != null); + } + + public function testVisibilityParam() + { + $this->query->resetParameters(); + $visibility = 'private'; + $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); + $this->query->setVisibility($visibility); + $this->assertTrue($this->query->visibility != null); + $this->assertEquals($visibility, $this->query->getVisibility()); + $this->query->visibility = null; + $this->assertFalse($this->query->visibility != null); + } + + public function testProjectionParam() + { + $this->query->resetParameters(); + $projection = 'composite'; + $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); + $this->query->setProjection($projection); + $this->assertTrue($this->query->projection != null); + $this->assertEquals($projection, $this->query->getProjection()); + $this->query->projection = null; + $this->assertFalse($this->query->projection != null); + } + + public function testOrderbyParam() + { + $this->query->resetParameters(); + $orderby = 'starttime'; + $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); + $this->query->setOrderby($orderby); + $this->assertTrue($this->query->orderby != null); + $this->assertEquals($orderby, $this->query->getOrderby()); + $this->query->orderby = null; + $this->assertFalse($this->query->orderby != null); + } + + public function testEventParam() + { + $this->query->resetParameters(); + $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); + $this->query->setEvent(self::ZEND_CONFERENCE_EVENT); + $this->assertTrue($this->query->event != null); + $this->assertEquals(self::ZEND_CONFERENCE_EVENT, $this->query->getEvent()); + $this->query->event = null; + $this->assertFalse($this->query->event != null); + } + + public function testCommentsParam() + { + $this->query->resetParameters(); + $comment = 'we need to reschedule'; + $this->query->setComments($comment); + $this->assertTrue($this->query->comments != null); + $this->assertEquals($comment, $this->query->getComments()); + $this->query->comments = null; + $this->assertFalse(isset($this->query->comments)); + } + + public function testSortOrder() + { + $this->query->resetParameters(); + $sortOrder = 'ascending'; + $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); + $this->query->setSortOrder($sortOrder); + $this->assertTrue($this->query->sortOrder != null); + $this->assertEquals($sortOrder, $this->query->getSortOrder()); + $this->query->sortOrder = null; + $this->assertFalse($this->query->sortOrder != null); + } + + public function testRecurrenceExpansionStart() + { + $this->query->resetParameters(); + $res = self::SAMPLE_RFC3339; + $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); + $this->query->setRecurrenceExpansionStart($res); + $this->assertTrue($this->query->recurrenceExpansionStart != null); + $this->assertEquals($res, $this->query->getRecurrenceExpansionStart()); + $this->query->recurrenceExpansionStart = null; + $this->assertFalse($this->query->recurrenceExpansionStart != null); + } + + public function testRecurrenceExpansionEnd() + { + $this->query->resetParameters(); + $ree = self::SAMPLE_RFC3339; + $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); + $this->query->setRecurrenceExpansionEnd($ree); + $this->assertTrue($this->query->recurrenceExpansionEnd != null); + $this->assertEquals($ree, $this->query->getRecurrenceExpansionEnd()); + $this->query->recurrenceExpansionEnd = null; + $this->assertFalse($this->query->recurrenceExpansionEnd != null); + } + + public function testSingleEvents() + { + $this->query->resetParameters(); + // Test string handling + $singleEvents = 'true'; + $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); + $this->query->setSingleEvents($singleEvents); + $this->assertTrue($this->query->singleEvents === true); + // Test bool handling + $singleEvents = false; + $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); + $this->query->setSingleEvents($singleEvents); + $this->assertTrue($this->query->singleEvents === false); + // Test unsetting + $this->assertEquals($singleEvents, $this->query->getSingleEvents()); + $this->query->setSingleEvents(null); + $this->assertFalse($this->query->singleEvents != null); + } + + public function testFutureEvents() + { + $this->query->resetParameters(); + // Test string handling + $singleEvents = 'true'; + $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); + $this->query->setFutureEvents($singleEvents); + $this->assertTrue($this->query->futureEvents === true); + // Test bool handling + $singleEvents = false; + $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); + $this->query->setFutureEvents($singleEvents); + $this->assertTrue($this->query->futureEvents === false); + // Test unsetting + $this->query->futureEvents = null; + $this->assertFalse($this->query->futureEvents != null); + + } + + public function testCustomQueryURIGeneration() + { + $this->query->resetParameters(); + $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); + $this->query->setVisibility("private"); + $this->query->setProjection("composite"); + $this->query->setEvent(self::ZEND_CONFERENCE_EVENT); + $this->query->setComments(self::ZEND_CONFERENCE_EVENT_COMMENT); + $this->assertEquals("https://www.google.com/calendar/feeds/developer-calendar@google.com/private/composite/" . + self::ZEND_CONFERENCE_EVENT . "/comments/" . self::ZEND_CONFERENCE_EVENT_COMMENT, + $this->query->getQueryUrl()); + } + + public function testDefaultQueryURIGeneration() + { + $this->query->resetParameters(); + $this->assertEquals("https://www.google.com/calendar/feeds/default/public/full", + $this->query->getQueryUrl()); + } + + public function testCanNullifyParameters() + { + $testURI = "http://www.google.com/calendar/feeds/foo%40group.calendar.google.com/private/full"; + $this->query = new Zend_Gdata_Calendar_EventQuery($testURI); + $this->query->setUser(null); + $this->query->setVisibility(null); + $this->query->setProjection(null); + $result = $this->query->getQueryUrl(); + $this->assertEquals($testURI, $result); + } +} -- cgit v1.2.3