| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270 |
- <?php
- /**
- * Zend Framework
- *
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@zend.com so we can send you a copy immediately.
- *
- * @category Zend
- * @package Zend_Gdata_Calendar
- * @subpackage UnitTests
- * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id $
- */
- require_once 'Zend/Gdata/Calendar.php';
- require_once 'Zend/Gdata/Calendar/EventQuery.php';
- require_once 'Zend/Http/Client.php';
- /**
- * @category Zend
- * @package Zend_Gdata_Calendar
- * @subpackage UnitTests
- * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- * @group Zend_Gdata
- * @group Zend_Gdata_Calendar
- */
- class Zend_Gdata_Calendar_EventQueryTest extends PHPUnit_Framework_TestCase
- {
- const GOOGLE_DEVELOPER_CALENDAR = 'developer-calendar@google.com';
- const ZEND_CONFERENCE_EVENT = 'bn2h4o4mc3a03ci4t48j3m56pg';
- const ZEND_CONFERENCE_EVENT_COMMENT = 'i9q87onko1uphfs7i21elnnb4g';
- const SAMPLE_RFC3339 = "2007-06-05T18:38:00";
- public function setUp()
- {
- $this->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);
- }
- }
|