';
+ $this->content->type = 'xhtml';
+ $contentXml = $this->content->saveXML();
+ $newContent = new Zend_Gdata_App_Extension_Content();
+ $newContent->transferFromXML($contentXml);
+ $newContentXml = $newContent->saveXML();
+ $this->assertEquals($newContentXml, $contentXml);
+ $this->assertEquals('
', $newContent->text);
+ $this->assertEquals('xhtml', $newContent->type);
+ }
+
+ public function testContentWithSrcAndTypeToAndFromStringShouldMatch() {
+ $this->content->src = 'http://www.example.com/image.png';
+ $this->content->type = 'image/png';
+ $contentXml = $this->content->saveXML();
+ $newContent = new Zend_Gdata_App_Extension_Content();
+ $newContent->transferFromXML($contentXml);
+ $newContentXml = $newContent->saveXML();
+ $this->assertEquals($newContentXml, $contentXml);
+ $this->assertEquals('http://www.example.com/image.png', $newContent->src);
+ $this->assertEquals('image/png', $newContent->type);
+ }
+
+ public function testConvertContentWithSrcAndTypeToAndFromString() {
+ $this->content->transferFromXML($this->contentText);
+ $this->assertEquals('http://www.example.com/image.png', $this->content->src);
+ $this->assertEquals('image/png', $this->content->type);
+ }
+
+ public function testConvertContentWithTextAndTypeToAndFromString() {
+ $this->content->transferFromXML($this->contentText2);
+ $this->assertEquals('xhtml', $this->content->type);
+ $this->assertEquals(1, count($this->content->extensionElements));
+ }
+
+}
diff --git a/zend/tests/Zend/Gdata/App/ControlTest.php b/zend/tests/Zend/Gdata/App/ControlTest.php
new file mode 100644
index 0000000..b41b361
--- /dev/null
+++ b/zend/tests/Zend/Gdata/App/ControlTest.php
@@ -0,0 +1,75 @@
+controlText = file_get_contents(
+ 'Zend/Gdata/App/_files/ControlElementSample1.xml',
+ true);
+ $this->control = new Zend_Gdata_App_Extension_Control();
+ }
+
+ public function testEmptyControlShouldHaveEmptyExtensionsList() {
+ $this->assertTrue(is_array($this->control->extensionElements));
+ $this->assertTrue(count($this->control->extensionElements) == 0);
+ }
+
+ public function testEmptyControlToAndFromStringShouldMatch() {
+ $controlXml = $this->control->saveXML();
+ $newControl = new Zend_Gdata_App_Extension_Control();
+ $newControl->transferFromXML($controlXml);
+ $newControlXml = $newControl->saveXML();
+ $this->assertTrue($controlXml == $newControlXml);
+ }
+
+ public function testControlWithDraftToAndFromStringShouldMatch() {
+ $draft = new Zend_Gdata_App_Extension_Draft('yes');
+ $this->control->draft = $draft;
+ $controlXml = $this->control->saveXML();
+ $newControl = new Zend_Gdata_App_Extension_Control();
+ $newControl->transferFromXML($controlXml);
+ $newControlXml = $newControl->saveXML();
+ $this->assertEquals($newControlXml, $controlXml);
+ $this->assertEquals('yes', $newControl->draft->text);
+ }
+
+ public function testConvertControlWithDraftToAndFromString() {
+ $this->control->transferFromXML($this->controlText);
+ $this->assertEquals('yes', $this->control->draft->text);
+ }
+
+}
diff --git a/zend/tests/Zend/Gdata/App/EntryTest.php b/zend/tests/Zend/Gdata/App/EntryTest.php
new file mode 100644
index 0000000..5d9ed9b
--- /dev/null
+++ b/zend/tests/Zend/Gdata/App/EntryTest.php
@@ -0,0 +1,614 @@
+enryText = file_get_contents(
+ 'Zend/Gdata/App/_files/EntrySample1.xml',
+ true);
+ $this->httpEntrySample = file_get_contents(
+ 'Zend/Gdata/App/_files/EntrySampleHttp1.txt',
+ true);
+ $this->enry = new Zend_Gdata_App_Entry();
+
+ $this->adapter = new Test_Zend_Gdata_MockHttpClient();
+ $this->client = new Zend_Gdata_HttpClient();
+ $this->client->setAdapter($this->adapter);
+ $this->service = new Zend_Gdata_App($this->client);
+ }
+
+ public function testEmptyEntryShouldHaveEmptyExtensionsList()
+ {
+ $this->assertTrue(is_array($this->enry->extensionElements));
+ $this->assertTrue(count($this->enry->extensionElements) == 0);
+ }
+
+ public function testEmptyEntryToAndFromStringShouldMatch()
+ {
+ $enryXml = $this->enry->saveXML();
+ $newEntry = new Zend_Gdata_App_Entry();
+ $newEntry->transferFromXML($enryXml);
+ $newEntryXml = $newEntry->saveXML();
+ $this->assertTrue($enryXml == $newEntryXml);
+ }
+
+ public function testConvertEntryToAndFromString()
+ {
+ $this->enry->transferFromXML($this->enryText);
+ $enryXml = $this->enry->saveXML();
+ $newEntry = new Zend_Gdata_App_Entry();
+ $newEntry->transferFromXML($enryXml);
+/*
+ $this->assertEquals(1, count($newEntry->entry));
+ $this->assertEquals('dive into mark', $newEntry->title->text);
+ $this->assertEquals('text', $newEntry->title->type);
+ $this->assertEquals('2005-07-31T12:29:29Z', $newEntry->updated->text);
+ $this->assertEquals('tag:example.org,2003:3', $newEntry->id->text);
+ $this->assertEquals(2, count($newEntry->link));
+ $this->assertEquals('http://example.org/',
+ $newEntry->getAlternateLink()->href);
+ $this->assertEquals('en',
+ $newEntry->getAlternateLink()->hrefLang);
+ $this->assertEquals('text/html',
+ $newEntry->getAlternateLink()->type);
+ $this->assertEquals('http://example.org/enry.atom',
+ $newEntry->getSelfLink()->href);
+ $this->assertEquals('application/atom+xml',
+ $newEntry->getSelfLink()->type);
+ $this->assertEquals('Copyright (c) 2003, Mark Pilgrim',
+ $newEntry->rights->text);
+ $entry = $newEntry->entry[0];
+ $this->assertEquals('Atom draft-07 snapshot', $entry->title->text);
+ $this->assertEquals('tag:example.org,2003:3.2397',
+ $entry->id->text);
+ $this->assertEquals('2005-07-31T12:29:29Z', $entry->updated->text);
+ $this->assertEquals('2003-12-13T08:29:29-04:00',
+ $entry->published->text);
+ $this->assertEquals('Mark Pilgrim',
+ $entry->author[0]->name->text);
+ $this->assertEquals('http://example.org/',
+ $entry->author[0]->uri->text);
+ $this->assertEquals(2, count($entry->contributor));
+ $this->assertEquals('Sam Ruby',
+ $entry->contributor[0]->name->text);
+ $this->assertEquals('Joe Gregorio',
+ $entry->contributor[1]->name->text);
+ $this->assertEquals('xhtml', $entry->content->type);
+*/
+ }
+
+ public function testCanSetAndGetEtag()
+ {
+ $data = "W/&FooBarBaz&";
+ $this->enry->setEtag($data);
+ $this->assertEquals($this->enry->getEtag(), $data);
+ }
+
+ public function testCanSetAndgetService()
+ {
+ $data = new Zend_Gdata_App();
+ $this->enry->setService($data);
+ $this->assertEquals($this->enry->getService(), $data);
+
+ $data = null;
+ $this->enry->setService($data);
+ $this->assertEquals($this->enry->getService(), $data);
+ }
+
+ public function testsetServiceProvidesFluentInterface()
+ {
+ $result = $this->enry->setService(null);
+ $this->assertEquals($this->enry, $result);
+ }
+
+ public function testGetHttpClientPullsFromServiceInstance()
+ {
+ $s = new Zend_Gdata_App();
+ $this->enry->setService($s);
+
+ $c = new Zend_Gdata_HttpClient();
+ $s->setHttpClient($c);
+ $this->assertEquals($this->enry->getHttpClient(),
+ $s->getHttpClient());
+
+ $c = new Zend_Http_Client();
+ $s->setHttpClient($c);
+ $this->assertEquals($this->enry->getHttpClient(),
+ $s->getHttpClient($c));
+ }
+
+ public function testSetHttpClientPushesIntoServiceInstance()
+ {
+ $s = new Zend_Gdata_App();
+ $this->enry->setService($s);
+
+ $c = new Zend_Gdata_HttpClient();
+ $this->enry->setHttpClient($c);
+ $this->assertEquals(get_class($s->getHttpClient()),
+ 'Zend_Gdata_HttpClient');
+
+ $c = new Zend_Http_Client();
+ $this->enry->setHttpClient($c);
+ $this->assertEquals(get_class($s->getHttpClient()),
+ 'Zend_Http_Client');
+ }
+
+ public function testSaveSupportsGdataV2()
+ {
+ // Prepare mock response
+ $this->adapter->setResponse("HTTP/1.1 201 Created");
+
+ // Make sure that we're using protocol v2
+ $this->service->setMajorProtocolVersion(2);
+ $this->enry->setService($this->service);
+
+ // Set a URL for posting, so that save() will work
+ $editLink = new Zend_Gdata_App_extension_Link('http://example.com',
+ 'edit');
+ $this->enry->setLink(array($editLink));
+
+ // Perform a (mock) save
+ $this->enry->save();
+
+ // Check to make sure that a v2 header was sent
+ $headers = $this->adapter->popRequest()->headers;
+ $found = false;
+ foreach ($headers as $header) {
+ if ($header == 'GData-Version: 2')
+ $found = true;
+ }
+ $this->assertTrue($found,
+ 'GData-Version header missing or incorrect.');
+ }
+
+ public function testDeleteSupportsGdataV2()
+ {
+ // Prepare mock response
+ $this->adapter->setResponse("HTTP/1.1 200 OK");
+
+ // Make sure that we're using protocol v2
+ $this->service->setMajorProtocolVersion(2);
+ $this->enry->setService($this->service);
+
+ // Set a URL for posting, so that save() will work
+ $editLink = new Zend_Gdata_App_extension_Link('http://example.com',
+ 'edit');
+ $this->enry->setLink(array($editLink));
+
+ // Perform a (mock) save
+ $this->enry->delete();
+
+ // Check to make sure that a v2 header was sent
+ $headers = $this->adapter->popRequest()->headers;
+ $found = false;
+ foreach ($headers as $header) {
+ if ($header == 'GData-Version: 2')
+ $found = true;
+ }
+ $this->assertTrue($found,
+ 'GData-Version header missing or incorrect.');
+ }
+
+ public function testIfMatchHeaderCanBeSetOnSave()
+ {
+ $etagOverride = 'foo';
+ $etag = 'ABCD1234';
+ $this->service->setMajorProtocolVersion(2);
+ $this->adapter->setResponse($this->httpEntrySample);
+ $entry = $this->service->newEntry();
+ $entry->link = array(new Zend_Gdata_App_Extension_Link(
+ 'http://www.example.com',
+ 'edit',
+ 'application/atom+xml'));
+ $entry->setEtag($etag);
+ $newEntry = $entry->save(null, null,
+ array('If-Match' => $etagOverride));
+ $headers = $this->adapter->popRequest()->headers;
+ $found = false;
+ foreach ($headers as $header) {
+ if ($header == 'If-Match: ' . $etagOverride)
+ $found = true;
+ }
+ $this->assertTrue($found,
+ 'If-Match header not found or incorrect');
+ }
+
+ public function testIfNoneMatchHeaderCanBeSetOnSave()
+ {
+ $etagOverride = 'foo';
+ $etag = 'ABCD1234';
+ $this->service->setMajorProtocolVersion(2);
+ $this->adapter->setResponse($this->httpEntrySample);
+ $entry = $this->service->newEntry();
+ $entry->link = array(new Zend_Gdata_App_Extension_Link(
+ 'http://www.example.com',
+ 'edit',
+ 'application/atom+xml'));
+ $entry->setEtag($etag);
+ $newEntry = $entry->save(null, null,
+ array('If-None-Match' => $etagOverride));
+ $headers = $this->adapter->popRequest()->headers;
+ $found = false;
+ foreach ($headers as $header) {
+ if ($header == 'If-None-Match: ' . $etagOverride)
+ $found = true;
+ }
+ $this->assertTrue($found,
+ 'If-None-Match header not found or incorrect');
+ }
+
+ public function testCanSetUriOnSave()
+ {
+ $uri = 'http://example.net/foo/bar';
+ $this->adapter->setResponse($this->httpEntrySample);
+ $entry = $this->service->newEntry();
+ $newEntry = $entry->save($uri);
+ $request = $this->adapter->popRequest();
+ $uriObject = Zend_Uri_Http::fromString($uri);
+ $uriObject->setPort('80');
+ $this->assertEquals($uriObject, $request->uri);
+ }
+
+ public function testCanSetClassnameOnSave()
+ {
+ $className = 'Zend_Gdata_Entry';
+ $this->adapter->setResponse($this->httpEntrySample);
+ $entry = $this->service->newEntry();
+ $entry->link = array(new Zend_Gdata_App_Extension_Link(
+ 'http://www.example.com',
+ 'edit',
+ 'application/atom+xml'));
+ $newEntry = $entry->save(null, $className);
+ $this->assertEquals($className, get_class($newEntry));
+ }
+
+ public function testIfNoneMatchSetOnReload()
+ {
+ $etag = 'ABCD1234';
+ $this->adapter->setResponse($this->httpEntrySample);
+ $entry = $this->service->newEntry();
+ $entry->link = array(new Zend_Gdata_App_Extension_Link(
+ 'http://www.example.com',
+ 'edit',
+ 'application/atom+xml'));
+ $entry->setEtag($etag);
+ $newEntry = $entry->reload();
+ $headers = $this->adapter->popRequest()->headers;
+ $found = false;
+ foreach ($headers as $header) {
+ if ($header == 'If-None-Match: ' . $etag)
+ $found = true;
+ }
+ $this->assertTrue($found,
+ 'If-None-Match header not found or incorrect');
+ }
+
+ public function testIfNoneMatchCanBeSetOnReload()
+ {
+ $etagOverride = 'foo';
+ $etag = 'ABCD1234';
+ $this->adapter->setResponse($this->httpEntrySample);
+ $entry = $this->service->newEntry();
+ $entry->link = array(new Zend_Gdata_App_Extension_Link(
+ 'http://www.example.com',
+ 'edit',
+ 'application/atom+xml'));
+ $entry->setEtag($etag);
+ $newEntry = $entry->reload(null, null,
+ array('If-None-Match' => $etagOverride));
+ $headers = $this->adapter->popRequest()->headers;
+ $found = false;
+ foreach ($headers as $header) {
+ if ($header == 'If-None-Match: ' . $etagOverride)
+ $found = true;
+ }
+ $this->assertTrue($found,
+ 'If-None-Match header not found or incorrect');
+ }
+
+ public function testReloadReturnsEntryObject()
+ {
+ $etag = 'ABCD1234';
+ $this->adapter->setResponse($this->httpEntrySample);
+ $entry = $this->service->newEntry();
+ $entry->link = array(new Zend_Gdata_App_Extension_Link(
+ 'http://www.example.com',
+ 'edit',
+ 'application/atom+xml'));
+ $entry->setEtag($etag);
+ $newEntry = $entry->reload();
+ $this->assertEquals('Zend_Gdata_App_Entry', get_class($newEntry));
+ }
+
+ public function testReloadPopulatesEntryObject()
+ {
+ $etag = 'ABCD1234';
+ $this->adapter->setResponse($this->httpEntrySample);
+ $entry = $this->service->newEntry();
+ $entry->link = array(new Zend_Gdata_App_Extension_Link(
+ 'http://www.example.com',
+ 'edit',
+ 'application/atom+xml'));
+ $entry->setEtag($etag);
+ $newEntry = $entry->reload();
+ $this->assertEquals('Hello world', $newEntry->title->text);
+ }
+
+ public function testReloadDoesntThrowExceptionIfNoEtag()
+ {
+ $this->adapter->setResponse($this->httpEntrySample);
+ $entry = $this->service->newEntry();
+ $entry->link = array(new Zend_Gdata_App_Extension_Link(
+ 'http://www.example.com',
+ 'edit',
+ 'application/atom+xml'));
+ $newEntry = $entry->reload();
+ $this->assertEquals('Zend_Gdata_App_Entry', get_class($newEntry));
+ }
+
+ public function testReloadExtractsURIFromEditLink()
+ {
+ $expectedUri = 'http://www.example.com';
+ $etag = 'ABCD1234';
+ $this->service->setMajorProtocolVersion(2);
+ $this->adapter->setResponse($this->httpEntrySample);
+ $entry = $this->service->newEntry();
+ $entry->link = array(new Zend_Gdata_App_Extension_Link(
+ $expectedUri,
+ 'edit',
+ 'application/atom+xml'));
+ $entry->setEtag($etag);
+ $newEntry = $entry->reload();
+ $requestUri = $this->adapter->popRequest()->uri;
+ $expectedUriObject = Zend_Uri_Http::fromString($expectedUri);
+ $expectedUriObject->setPort('80');
+ $this->assertEquals($expectedUriObject, $requestUri);
+ }
+
+ public function testReloadAllowsCustomURI()
+ {
+ $uriOverride = 'http://www.example.org';
+ $etag = 'ABCD1234';
+ $this->service->setMajorProtocolVersion(2);
+ $this->adapter->setResponse($this->httpEntrySample);
+ $entry = $this->service->newEntry();
+ $entry->link = array(new Zend_Gdata_App_Extension_Link(
+ 'http://www.example.com',
+ 'edit',
+ 'application/atom+xml'));
+ $entry->setEtag($etag);
+ $newEntry = $entry->reload($uriOverride);
+ $requestUri = $this->adapter->popRequest()->uri;
+ $uriOverrideObject = Zend_Uri_Http::fromString($uriOverride);
+ $uriOverrideObject->setPort('80');
+ $this->assertEquals($uriOverrideObject, $requestUri);
+ }
+
+ public function testReloadReturnsNullIfEntryNotModified()
+ {
+ $etag = 'ABCD1234';
+ $this->service->setMajorProtocolVersion(2);
+ $this->adapter->setResponse('HTTP/1.1 304 Not Modified');
+ $entry = $this->service->newEntry();
+ $entry->link = array(new Zend_Gdata_App_Extension_Link(
+ 'http://www.example.com',
+ 'edit',
+ 'application/atom+xml'));
+ $entry->setEtag($etag);
+ $newEntry = $entry->reload();
+ $this->assertEquals(null, $newEntry);
+ }
+
+ public function testCanSetReloadReturnClassname()
+ {
+ $className = 'Zend_Gdata_Entry';
+ $etag = 'ABCD1234';
+ $this->service->setMajorProtocolVersion(2);
+ $this->adapter->setResponse($this->httpEntrySample);
+ $entry = $this->service->newEntry();
+ $entry->link = array(new Zend_Gdata_App_Extension_Link(
+ 'http://www.example.com',
+ 'edit',
+ 'application/atom+xml'));
+ $entry->setEtag($etag);
+ $newEntry = $entry->reload(null, $className);
+ $this->assertEquals($className, get_class($newEntry));
+ }
+
+ public function testReloadInheritsClassname()
+ {
+ $className = 'Zend_Gdata_Entry';
+ $etag = 'ABCD1234';
+ $this->service->setMajorProtocolVersion(2);
+ $this->adapter->setResponse($this->httpEntrySample);
+ $entry = new $className;
+ $entry->setService($this->service);
+ $entry->link = array(new Zend_Gdata_App_Extension_Link(
+ 'http://www.example.com',
+ 'edit',
+ 'application/atom+xml'));
+ $entry->setEtag($etag);
+ $newEntry = $entry->reload();
+ $this->assertEquals($className, get_class($newEntry));
+ }
+
+ public function testCanSetMajorProtocolVersion()
+ {
+ $expectedVersion = 42;
+ $entry = $this->service->newEntry();
+ $entry->setMajorProtocolVersion($expectedVersion);
+ $receivedVersion = $entry->getMajorProtocolVersion();
+ $this->assertEquals($expectedVersion, $receivedVersion);
+ }
+
+ public function testCanSetMinorProtocolVersion()
+ {
+ $expectedVersion = 42;
+ $entry = $this->service->newEntry();
+ $entry->setMinorProtocolVersion($expectedVersion);
+ $receivedVersion = $entry->getMinorProtocolVersion();
+ $this->assertEquals($expectedVersion, $receivedVersion);
+ }
+
+ public function testMajorProtocolVersionCannotBeZero()
+ {
+ $expectedVersion = 0;
+ $entry = $this->service->newEntry();
+ $this->setExpectedException('Zend_Gdata_App_InvalidArgumentException');
+ $entry->setMajorProtocolVersion($expectedVersion);
+ }
+
+ public function testMajorProtocolVersionCannotBeNegative()
+ {
+ $expectedVersion = -1;
+ $entry = $this->service->newEntry();
+ $this->setExpectedException('Zend_Gdata_App_InvalidArgumentException');
+ $entry->setMajorProtocolVersion($expectedVersion);
+ }
+
+ public function testMajorProtocolVersionMayBeNull()
+ {
+ $expectedVersion = null;
+ $entry = $this->service->newEntry();
+ $entry->setMajorProtocolVersion($expectedVersion);
+ $receivedVersion = $entry->getMajorProtocolVersion();
+ $this->assertNull($receivedVersion);
+ }
+
+ public function testMinorProtocolVersionMayBeZero()
+ {
+ $expectedVersion = 0;
+ $entry = $this->service->newEntry();
+ $entry->setMinorProtocolVersion($expectedVersion);
+ $receivedVersion = $entry->getMinorProtocolVersion();
+ $this->assertEquals($expectedVersion, $receivedVersion);
+ }
+
+ public function testMinorProtocolVersionCannotBeNegative()
+ {
+ $expectedVersion = -1;
+ $entry = $this->service->newEntry();
+ $this->setExpectedException('Zend_Gdata_App_InvalidArgumentException');
+ $entry->setMinorProtocolVersion($expectedVersion);
+ }
+
+ public function testMinorProtocolVersionMayBeNull()
+ {
+ $expectedVersion = null;
+ $entry = $this->service->newEntry();
+ $entry->setMinorProtocolVersion($expectedVersion);
+ $receivedVersion = $entry->getMinorProtocolVersion();
+ $this->assertNull($receivedVersion);
+ }
+
+ public function testDefaultMajorProtocolVersionIs1()
+ {
+ $entry = $this->service->newEntry();
+ $this->assertEquals(1, $entry->getMajorProtocolVersion());
+ }
+
+ public function testDefaultMinorProtocolVersionIsNull()
+ {
+ $entry = $this->service->newEntry();
+ $this->assertNull($entry->getMinorProtocolVersion());
+ }
+
+ public function testLookupNamespaceUsesCurrentVersion()
+ {
+ $prefix = 'test';
+ $v1TestString = 'TEST-v1';
+ $v2TestString = 'TEST-v2';
+
+ Zend_Gdata_App_Base::flushNamespaceLookupCache();
+ $entry = $this->service->newEntry();
+ $entry->registerNamespace($prefix, $v1TestString, 1, 0);
+ $entry->registerNamespace($prefix, $v2TestString, 2, 0);
+ $entry->setMajorProtocolVersion(1);
+ $result = $entry->lookupNamespace($prefix);
+ $this->assertEquals($v1TestString, $result);
+ $entry->setMajorProtocolVersion(2);
+ $result = $entry->lookupNamespace($prefix);
+ $this->assertEquals($v2TestString, $result);
+ $entry->setMajorProtocolVersion(null); // Should default to latest
+ $result = $entry->lookupNamespace($prefix);
+ $this->assertEquals($v2TestString, $result);
+ }
+
+ public function testLookupNamespaceObeysParentBehavior()
+ {
+ $prefix = 'test';
+ $testString10 = 'TEST-v1-0';
+ $testString20 = 'TEST-v2-0';
+ $testString11 = 'TEST-v1-1';
+ $testString21 = 'TEST-v2-1';
+ $testString12 = 'TEST-v1-2';
+ $testString22 = 'TEST-v2-2';
+
+ Zend_Gdata_App_Base::flushNamespaceLookupCache();
+ $entry = $this->service->newEntry();
+ $entry->registerNamespace($prefix, $testString10, 1, 0);
+ $entry->registerNamespace($prefix, $testString20, 2, 0);
+ $entry->registerNamespace($prefix, $testString11, 1, 1);
+ $entry->registerNamespace($prefix, $testString21, 2, 1);
+ $entry->registerNamespace($prefix, $testString12, 1, 2);
+ $entry->registerNamespace($prefix, $testString22, 2, 2);
+
+ // Assumes default version (1)
+ $result = $entry->lookupNamespace($prefix, 1, null);
+ $this->assertEquals($testString12, $result);
+ $result = $entry->lookupNamespace($prefix, 2, null);
+ $this->assertEquals($testString22, $result);
+ $result = $entry->lookupNamespace($prefix, 1, 1);
+ $this->assertEquals($testString11, $result);
+ $result = $entry->lookupNamespace($prefix, 2, 1);
+ $this->assertEquals($testString21, $result);
+ $result = $entry->lookupNamespace($prefix, null, null);
+ $this->assertEquals($testString12, $result);
+ $result = $entry->lookupNamespace($prefix, null, 1);
+ $this->assertEquals($testString11, $result);
+
+ // Override to retrieve latest version
+ $entry->setMajorProtocolVersion(null);
+ $result = $entry->lookupNamespace($prefix, null, null);
+ $this->assertEquals($testString22, $result);
+ $result = $entry->lookupNamespace($prefix, null, 1);
+ $this->assertEquals($testString21, $result);
+ }
+
+}
diff --git a/zend/tests/Zend/Gdata/App/FeedTest.php b/zend/tests/Zend/Gdata/App/FeedTest.php
new file mode 100644
index 0000000..a86b6c7
--- /dev/null
+++ b/zend/tests/Zend/Gdata/App/FeedTest.php
@@ -0,0 +1,282 @@
+feedText = file_get_contents(
+ 'Zend/Gdata/App/_files/FeedSample1.xml',
+ true);
+ $this->feed = new Zend_Gdata_App_Feed();
+ }
+
+ public function testEmptyFeedShouldHaveEmptyExtensionsList() {
+ $this->assertTrue(is_array($this->feed->extensionElements));
+ $this->assertTrue(count($this->feed->extensionElements) == 0);
+ }
+
+ public function testEmptyFeedToAndFromStringShouldMatch() {
+ $feedXml = $this->feed->saveXML();
+ $newFeed = new Zend_Gdata_App_Feed();
+ $newFeed->transferFromXML($feedXml);
+ $newFeedXml = $newFeed->saveXML();
+ $this->assertTrue($feedXml == $newFeedXml);
+ }
+
+ public function testConvertFeedToAndFromString() {
+ $this->feed->transferFromXML($this->feedText);
+ $feedXml = $this->feed->saveXML();
+ $newFeed = new Zend_Gdata_App_Feed();
+ $newFeed->transferFromXML($feedXml);
+ $this->assertEquals(1, count($newFeed->entry));
+ $this->assertEquals('dive into mark', $newFeed->title->text);
+ $this->assertEquals('text', $newFeed->title->type);
+ $this->assertEquals('2005-07-31T12:29:29Z', $newFeed->updated->text);
+ $this->assertEquals('tag:example.org,2003:3', $newFeed->id->text);
+ $this->assertEquals(2, count($newFeed->link));
+ $this->assertEquals('http://example.org/',
+ $newFeed->getAlternateLink()->href);
+ $this->assertEquals('en',
+ $newFeed->getAlternateLink()->hrefLang);
+ $this->assertEquals('text/html',
+ $newFeed->getAlternateLink()->type);
+ $this->assertEquals('http://example.org/feed.atom',
+ $newFeed->getSelfLink()->href);
+ $this->assertEquals('application/atom+xml',
+ $newFeed->getSelfLink()->type);
+ $this->assertEquals('Copyright (c) 2003, Mark Pilgrim',
+ $newFeed->rights->text);
+ $entry = $newFeed->entry[0];
+ $this->assertEquals('Atom draft-07 snapshot', $entry->title->text);
+ $this->assertEquals('tag:example.org,2003:3.2397',
+ $entry->id->text);
+ $this->assertEquals('2005-07-31T12:29:29Z', $entry->updated->text);
+ $this->assertEquals('2003-12-13T08:29:29-04:00',
+ $entry->published->text);
+ $this->assertEquals('Mark Pilgrim',
+ $entry->author[0]->name->text);
+ $this->assertEquals('http://example.org/',
+ $entry->author[0]->uri->text);
+ $this->assertEquals(2, count($entry->contributor));
+ $this->assertEquals('Sam Ruby',
+ $entry->contributor[0]->name->text);
+ $this->assertEquals('Joe Gregorio',
+ $entry->contributor[1]->name->text);
+ $this->assertEquals('xhtml', $entry->content->type);
+ }
+
+ public function testCanAddIndividualEntries() {
+ $this->feed->transferFromXML($this->feedText);
+ $this->assertEquals(1, count($this->feed->entry));
+ $oldTitle = $this->feed->entry[0]->title->text;
+ $newEntry = new Zend_Gdata_App_Entry();
+ $newEntry->setTitle(new Zend_Gdata_App_Extension_Title("Foo"));
+ $this->feed->addEntry($newEntry);
+ $this->assertEquals(2, count($this->feed->entry));
+ $this->assertEquals($oldTitle, $this->feed->entry[0]->title->text);
+ $this->assertEquals("Foo", $this->feed->entry[1]->title->text);
+ }
+
+ public function testCanSetAndGetEtag() {
+ $data = "W/&FooBarBaz&";
+ $this->feed->setEtag($data);
+ $this->assertEquals($this->feed->getEtag(), $data);
+ }
+
+ public function testSetServicePropagatesToChildren() {
+ // Setup
+ $entries = array(new Zend_Gdata_App_Entry(),
+ new Zend_Gdata_App_Entry());
+ foreach ($entries as $entry) {
+ $this->feed->addEntry($entry);
+ }
+
+ // Set new service instance and test for propagation
+ $s = new Zend_Gdata_App();
+ $this->feed->setService($s);
+
+ $service = $this->feed->getService();
+ if (!is_object($service)) {
+ $this->fail('No feed service received');
+ }
+ $this->assertEquals('Zend_Gdata_App',
+ get_class($service));
+
+ foreach ($entries as $entry) {
+ $service = $entry->getService();
+ if (!is_object($service)) {
+ $this->fail('No entry service received');
+ }
+ $this->assertEquals('Zend_Gdata_App',
+ get_class($service));
+ }
+
+ // Set null service instance and test for propagation
+ $s = null;
+ $this->feed->setService($s);
+ $this->assertFalse(is_object($this->feed->getService()));
+ foreach ($entries as $entry) {
+ $service = $entry->getService();
+ $this->assertFalse(is_object($service));
+ }
+ }
+
+ public function testCanSetMajorProtocolVersion()
+ {
+ $expectedVersion = 42;
+ $this->feed->setMajorProtocolVersion($expectedVersion);
+ $receivedVersion = $this->feed->getMajorProtocolVersion();
+ $this->assertEquals($expectedVersion, $receivedVersion);
+ }
+
+ public function testCanSetMinorProtocolVersion()
+ {
+ $expectedVersion = 42;
+ $this->feed->setMinorProtocolVersion($expectedVersion);
+ $receivedVersion = $this->feed->getMinorProtocolVersion();
+ $this->assertEquals($expectedVersion, $receivedVersion);
+ }
+
+ public function testEntriesInheritFeedVersionOnCreate()
+ {
+ $major = 98;
+ $minor = 12;
+ $this->feed->setMajorProtocolVersion($major);
+ $this->feed->setMinorProtocolVersion($minor);
+ $this->feed->transferFromXML($this->feedText);
+ foreach ($this->feed->entries as $entry) {
+ $this->assertEquals($major, $entry->getMajorProtocolVersion());
+ $this->assertEquals($minor, $entry->getMinorProtocolVersion());
+ }
+ }
+
+ public function testEntriesInheritFeedVersionOnUpdate()
+ {
+ $major = 98;
+ $minor = 12;
+ $this->feed->transferFromXML($this->feedText);
+ $this->feed->setMajorProtocolVersion($major);
+ $this->feed->setMinorProtocolVersion($minor);
+ foreach ($this->feed->entries as $entry) {
+ $this->assertEquals($major, $entry->getMajorProtocolVersion());
+ $this->assertEquals($minor, $entry->getMinorProtocolVersion());
+ }
+ }
+
+ public function testDefaultMajorProtocolVersionIs1()
+ {
+ $this->assertEquals(1, $this->feed->getMajorProtocolVersion());
+ }
+
+ public function testDefaultMinorProtocolVersionIsNull()
+ {
+ $this->assertNull($this->feed->getMinorProtocolVersion());
+ }
+
+ public function testLookupNamespaceUsesCurrentVersion()
+ {
+ $prefix = 'test';
+ $v1TestString = 'TEST-v1';
+ $v2TestString = 'TEST-v2';
+
+ Zend_Gdata_App_Base::flushNamespaceLookupCache();
+ $feed = $this->feed;
+ $feed->registerNamespace($prefix, $v1TestString, 1, 0);
+ $feed->registerNamespace($prefix, $v2TestString, 2, 0);
+ $feed->setMajorProtocolVersion(1);
+ $result = $feed->lookupNamespace($prefix);
+ $this->assertEquals($v1TestString, $result);
+ $feed->setMajorProtocolVersion(2);
+ $result = $feed->lookupNamespace($prefix);
+ $this->assertEquals($v2TestString, $result);
+ $feed->setMajorProtocolVersion(null); // Should default to latest
+ $result = $feed->lookupNamespace($prefix);
+ }
+
+ public function testLookupNamespaceObeysParentBehavior()
+ {
+ $prefix = 'test';
+ $testString10 = 'TEST-v1-0';
+ $testString20 = 'TEST-v2-0';
+ $testString11 = 'TEST-v1-1';
+ $testString21 = 'TEST-v2-1';
+ $testString12 = 'TEST-v1-2';
+ $testString22 = 'TEST-v2-2';
+
+ Zend_Gdata_App_Base::flushNamespaceLookupCache();
+ $feed = $this->feed;
+ $feed->registerNamespace($prefix, $testString10, 1, 0);
+ $feed->registerNamespace($prefix, $testString20, 2, 0);
+ $feed->registerNamespace($prefix, $testString11, 1, 1);
+ $feed->registerNamespace($prefix, $testString21, 2, 1);
+ $feed->registerNamespace($prefix, $testString12, 1, 2);
+ $feed->registerNamespace($prefix, $testString22, 2, 2);
+
+ // Assumes default version (1)
+ $result = $feed->lookupNamespace($prefix, 1, null);
+ $this->assertEquals($testString12, $result);
+ $result = $feed->lookupNamespace($prefix, 2, null);
+ $this->assertEquals($testString22, $result);
+ $result = $feed->lookupNamespace($prefix, 1, 1);
+ $this->assertEquals($testString11, $result);
+ $result = $feed->lookupNamespace($prefix, 2, 1);
+ $this->assertEquals($testString21, $result);
+ $result = $feed->lookupNamespace($prefix, null, null);
+ $this->assertEquals($testString12, $result);
+ $result = $feed->lookupNamespace($prefix, null, 1);
+ $this->assertEquals($testString11, $result);
+
+ // Override to retrieve latest version
+ $feed->setMajorProtocolVersion(null);
+ $result = $feed->lookupNamespace($prefix, null, null);
+ $this->assertEquals($testString22, $result);
+ $result = $feed->lookupNamespace($prefix, null, 1);
+ $this->assertEquals($testString21, $result);
+ }
+
+ /**
+ * @group ZF-10242
+ */
+ public function testCount()
+ {
+ $feed = new Zend_Gdata_App_Feed();
+ $feed->addEntry('foo')
+ ->addEntry('bar');
+
+ $this->assertEquals(2, $feed->count());
+ $this->assertEquals(2, count($feed));
+ }
+}
diff --git a/zend/tests/Zend/Gdata/App/GeneratorTest.php b/zend/tests/Zend/Gdata/App/GeneratorTest.php
new file mode 100644
index 0000000..ac1a02b
--- /dev/null
+++ b/zend/tests/Zend/Gdata/App/GeneratorTest.php
@@ -0,0 +1,82 @@
+generatorText = file_get_contents(
+ 'Zend/Gdata/App/_files/GeneratorElementSample1.xml',
+ true);
+ $this->generator = new Zend_Gdata_App_Extension_Generator();
+ }
+
+ public function testEmptyGeneratorShouldHaveEmptyExtensionsList() {
+ $this->assertTrue(is_array($this->generator->extensionElements));
+ $this->assertTrue(count($this->generator->extensionElements) == 0);
+ }
+
+ public function testEmptyGeneratorToAndFromStringShouldMatch() {
+ $generatorXml = $this->generator->saveXML();
+ $newGenerator = new Zend_Gdata_App_Extension_Generator();
+ $newGenerator->transferFromXML($generatorXml);
+ $newGeneratorXml = $newGenerator->saveXML();
+ $this->assertTrue($generatorXml == $newGeneratorXml);
+ }
+
+ public function testGeneratorToAndFromStringShouldMatch() {
+ $this->generator->uri = 'http://code.google.com/apis/gdata/';
+ $this->generator->version = '1.0';
+ $this->generator->text = 'Google data APIs';
+ $generatorXml = $this->generator->saveXML();
+ $newGenerator = new Zend_Gdata_App_Extension_Generator();
+ $newGenerator->transferFromXML($generatorXml);
+ $newGeneratorXml = $newGenerator->saveXML();
+ $this->assertEquals($newGeneratorXml, $generatorXml);
+ $this->assertEquals('http://code.google.com/apis/gdata/',
+ $newGenerator->uri);
+ $this->assertEquals('1.0', $newGenerator->version);
+ $this->assertEquals('Google data APIs', $newGenerator->text);
+ }
+
+ public function testConvertGeneratorWithDraftToAndFromString() {
+ $this->generator->transferFromXML($this->generatorText);
+ $this->assertEquals('http://code.google.com/apis/gdata/',
+ $this->generator->uri);
+ $this->assertEquals('1.0', $this->generator->version);
+ $this->assertEquals('Google data APIs', $this->generator->text);
+ }
+
+}
diff --git a/zend/tests/Zend/Gdata/App/HttpExceptionTest.php b/zend/tests/Zend/Gdata/App/HttpExceptionTest.php
new file mode 100755
index 0000000..eba19da
--- /dev/null
+++ b/zend/tests/Zend/Gdata/App/HttpExceptionTest.php
@@ -0,0 +1,71 @@
+sprKey = constant('TESTS_ZEND_GDATA_SPREADSHEETS_SPREADSHEETKEY');
+ $this->wksId = constant('TESTS_ZEND_GDATA_SPREADSHEETS_WORKSHEETID');
+ $service = Zend_Gdata_Spreadsheets::AUTH_SERVICE_NAME;
+ $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
+ $this->gdata = new Zend_Gdata_Spreadsheets($client);
+ }
+
+ public function testGetRawResponseBody()
+ {
+ try {
+ $rowData = array();
+ $entry = $this->gdata->insertRow($rowData, $this->sprKey);
+ $this->fail('Expecting Zend_Gdata_App_HttpException');
+ } catch (Zend_Gdata_App_HttpException $hExc) {
+ $this->assertThat($hExc,
+ $this->isInstanceOf('Zend_Gdata_App_HttpException'),
+ 'Expecting Zend_Gdata_App_HttpException, got '
+ . get_class($hExc));
+
+ $message = $hExc->getMessage();
+ $this->assertEquals($message, 'Expected response code 200, got 400');
+ $body = $hExc->getRawResponseBody();
+ $this->assertNotNull($body);
+ $this->assertNotEquals(stripos($body,
+ 'Blank rows cannot be written; use delete instead.'), false);
+ }
+ }
+}
diff --git a/zend/tests/Zend/Gdata/App/MockBase.php b/zend/tests/Zend/Gdata/App/MockBase.php
new file mode 100644
index 0000000..581fc99
--- /dev/null
+++ b/zend/tests/Zend/Gdata/App/MockBase.php
@@ -0,0 +1,38 @@
+assertEquals('2006-12-01', $date);
+ }
+
+ public function testFormatTimestampFromStringWithTimezone()
+ {
+ // assert that a correctly formatted timestamp is not modified
+ $date = Zend_Gdata_App_Util::formatTimestamp('2007-01-10T13:31:12-04:00');
+ $this->assertEquals('2007-01-10T13:31:12-04:00', $date);
+ }
+
+ public function testFormatTimestampWithMilliseconds()
+ {
+ // assert that a correctly formatted timestamp is not modified
+ $date = Zend_Gdata_App_Util::formatTimestamp('1956-12-14T43:09:54.52376Z');
+ $this->assertEquals('1956-12-14T43:09:54.52376Z', $date);
+ }
+
+ public function testFormatTimestampUsingZuluAsOffset()
+ {
+ // assert that a correctly formatted timestamp is not modified
+ $date = Zend_Gdata_App_Util::formatTimestamp('2024-03-19T01:38:12Z');
+ $this->assertEquals('2024-03-19T01:38:12Z', $date);
+ }
+
+ public function testFormatTimestampUsingLowercaseTAndZ()
+ {
+ // assert that a correctly formatted timestamp is not modified
+ $date = Zend_Gdata_App_Util::formatTimestamp('1945-07-19t12:19:08z');
+ $this->assertEquals('1945-07-19t12:19:08z', $date);
+ }
+
+ public function testFormatTimestampFromStringWithNonCompliantDate()
+ {
+ // assert that a non-compliant date is converted to RFC 3339
+ $date = Zend_Gdata_App_Util::formatTimestamp('2007/07/13');
+ $this->assertEquals('2007-07-13T00:00:00', $date);
+ }
+
+ public function testFormatTimestampFromInteger()
+ {
+ $ts = 1164960000; // Fri Dec 1 00:00:00 PST 2006
+ $date = Zend_Gdata_App_Util::formatTimestamp($ts);
+ $this->assertEquals('2006-12-01T08:00:00+00:00', $date);
+ }
+
+ public function testExceptionFormatTimestampNonsense()
+ {
+ $util = new Zend_Gdata_App_Util();
+ try {
+ $ts = Zend_Gdata_App_Util::formatTimestamp('nonsense string');
+ } catch (Zend_Gdata_App_Exception $e) {
+ $this->assertEquals('Invalid timestamp: nonsense string.', $e->getMessage());
+ return;
+ }
+ // Excetion not thrown, this is bad.
+ $this->fail("Exception not thrown.");
+ }
+
+ public function testExceptionFormatTimestampSemiInvalid()
+ {
+ $util = new Zend_Gdata_App_Util();
+ try {
+ $ts = Zend_Gdata_App_Util::formatTimestamp('2007-06-05adslfkja');
+ } catch (Zend_Gdata_App_Exception $e) {
+ $this->assertEquals('Invalid timestamp: 2007-06-05adslfkja.', $e->getMessage());
+ return;
+ }
+ // Excetion not thrown, this is bad.
+ $this->fail("Exception not thrown.");
+ }
+
+ public function testExceptionFormatTimestampInvalidTime()
+ {
+ $util = new Zend_Gdata_App_Util();
+ try {
+ $ts = Zend_Gdata_App_Util::formatTimestamp('2007-06-05Tadslfkja');
+ } catch (Zend_Gdata_App_Exception $e) {
+ $this->assertEquals('Invalid timestamp: 2007-06-05Tadslfkja.', $e->getMessage());
+ return;
+ }
+ // Excetion not thrown, this is bad.
+ $this->fail("Exception not thrown.");
+ }
+
+ public function testExceptionFormatTimestampInvalidOffset()
+ {
+ $util = new Zend_Gdata_App_Util();
+ try {
+ $ts = Zend_Gdata_App_Util::formatTimestamp('2007-06-05T02:51:12+egg');
+ } catch (Zend_Gdata_App_Exception $e) {
+ $this->assertEquals('Invalid timestamp: 2007-06-05T02:51:12+egg.', $e->getMessage());
+ return;
+ }
+ // Excetion not thrown, this is bad.
+ $this->fail("Exception not thrown.");
+ }
+
+ public function testExceptionFormatTimestampInvalidOffsetHours()
+ {
+ $util = new Zend_Gdata_App_Util();
+ try {
+ $ts = Zend_Gdata_App_Util::formatTimestamp('2007-06-05T02:51:12-ab:00');
+ } catch (Zend_Gdata_App_Exception $e) {
+ $this->assertEquals('Invalid timestamp: 2007-06-05T02:51:12-ab:00.', $e->getMessage());
+ return;
+ }
+ // Excetion not thrown, this is bad.
+ $this->fail("Exception not thrown.");
+ }
+
+ /**
+ * @group ZF-11610
+ */
+ public function testFormatTimestepHandlesSmallUnixTimestampProperly()
+ {
+ $this->assertEquals(
+ '1970-01-01T00:02:03+00:00',
+ Zend_Gdata_App_Util::formatTimestamp(123)
+ );
+ }
+
+ public function testFindGreatestBoundedValueReturnsMax() {
+ $data = array(-1 => null,
+ 0 => null,
+ 1 => null,
+ 2 => null,
+ 3 => null,
+ 5 => null,
+ -2 => null);
+ $result = Zend_Gdata_App_Util::findGreatestBoundedValue(99, $data);
+ $this->assertEquals(5, $result);
+ }
+
+ public function testFindGreatestBoundedValueReturnsMaxWhenBounded() {
+ $data = array(-1 => null,
+ 0 => null,
+ 1 => null,
+ 2 => null,
+ 3 => null,
+ 5 => null,
+ -2 => null);
+ $result = Zend_Gdata_App_Util::findGreatestBoundedValue(4, $data);
+ $this->assertEquals(3, $result);
+ }
+
+ public function testFindGreatestBoundedValueReturnsMaxWhenUnbounded() {
+ $data = array(-1 => null,
+ 0 => null,
+ 1 => null,
+ 2 => null,
+ 3 => null,
+ 5 => null,
+ -2 => null);
+ $result = Zend_Gdata_App_Util::findGreatestBoundedValue(null, $data);
+ $this->assertEquals(5, $result);
+ }
+
+ public function testFindGreatestBoundedValueReturnsZeroWhenZeroBounded() {
+ $data = array(-1 => null,
+ 0 => null,
+ 1 => null,
+ 2 => null,
+ 3 => null,
+ 5 => null,
+ -2 => null);
+ $result = Zend_Gdata_App_Util::findGreatestBoundedValue(0, $data);
+ $this->assertEquals(0, $result);
+ }
+
+ public function testFindGreatestBoundedValueFailsWhenNegativelyBounded() {
+ $data = array(-1 => null,
+ 0 => null,
+ 1 => null,
+ 2 => null,
+ 3 => null,
+ 5 => null,
+ -2 => null);
+ try {
+ $result = Zend_Gdata_App_Util::findGreatestBoundedValue(-1, $data);
+ $failed = true;
+ } catch (Zend_Gdata_App_Exception $e) {
+ $failed = false;
+ }
+ $this->assertFalse($failed, 'Exception not raised.');
+ }
+
+}
diff --git a/zend/tests/Zend/Gdata/App/_files/AuthorElementSample1.xml b/zend/tests/Zend/Gdata/App/_files/AuthorElementSample1.xml
new file mode 100644
index 0000000..772b6f5
--- /dev/null
+++ b/zend/tests/Zend/Gdata/App/_files/AuthorElementSample1.xml
@@ -0,0 +1,6 @@
+
+
[Update: The Atom draft is finished.]
+[Update: The Atom draft is finished.]
+
';
+ $this->feed->type = 'xhtml';
+ $feedXml = $this->feed->saveXML();
+ $newEventEntry = new Zend_Gdata_App_EventEntry();
+ $newEventEntry->transferFromXML($feedXml);
+ $newEventEntryXml = $newEventEntry->saveXML();
+ $this->assertEquals($newEventEntryXml, $feedXml);
+ $this->assertEquals('
', $newEventEntry->text);
+ $this->assertEquals('xhtml', $newEventEntry->type);
+ }
+
+ public function testEventEntryWithSrcAndTypeToAndFromStringShouldMatch() {
+ $this->feed->src = 'http://www.example.com/image.png';
+ $this->feed->type = 'image/png';
+ $feedXml = $this->feed->saveXML();
+ $newEventEntry = new Zend_Gdata_App_EventEntry();
+ $newEventEntry->transferFromXML($feedXml);
+ $newEventEntryXml = $newEventEntry->saveXML();
+ $this->assertEquals($newEventEntryXml, $feedXml);
+ $this->assertEquals('http://www.example.com/image.png', $newEventEntry->src);
+ $this->assertEquals('image/png', $newEventEntry->type);
+ }
+
+ public function testConvertEventEntryWithSrcAndTypeToAndFromString() {
+ $this->feed->transferFromXML($this->feedText);
+ $this->assertEquals('http://www.example.com/image.png', $this->feed->src);
+ $this->assertEquals('image/png', $this->feed->type);
+ }
+*/
+
+}
diff --git a/zend/tests/Zend/Gdata/Calendar/EventQueryExceptionTest.php b/zend/tests/Zend/Gdata/Calendar/EventQueryExceptionTest.php
new file mode 100644
index 0000000..ad78f17
--- /dev/null
+++ b/zend/tests/Zend/Gdata/Calendar/EventQueryExceptionTest.php
@@ -0,0 +1,68 @@
+query = new Zend_Gdata_Calendar_EventQuery();
+ }
+
+ /**
+ * @expectedException Zend_Gdata_App_Exception
+ */
+ public function testSingleEventsThrowsExceptionOnSetInvalidValue()
+ {
+ $this->query->resetParameters();
+ $singleEvents = 'puppy';
+ $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR);
+ $this->query->setSingleEvents($singleEvents);
+ }
+
+ /**
+ * @expectedException Zend_Gdata_App_Exception
+ */
+ public function testFutureEventsThrowsExceptionOnSetInvalidValue()
+ {
+ $this->query->resetParameters();
+ $futureEvents = 'puppy';
+ $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR);
+ $this->query->setFutureEvents($futureEvents);
+ }
+
+}
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);
+ }
+}
diff --git a/zend/tests/Zend/Gdata/Calendar/HiddenTest.php b/zend/tests/Zend/Gdata/Calendar/HiddenTest.php
new file mode 100644
index 0000000..a2a5592
--- /dev/null
+++ b/zend/tests/Zend/Gdata/Calendar/HiddenTest.php
@@ -0,0 +1,124 @@
+hiddenText = file_get_contents(
+ 'Zend/Gdata/Calendar/_files/HiddenElementSample1.xml',
+ true);
+ $this->hidden = new Zend_Gdata_Calendar_Extension_Hidden();
+ }
+
+ public function testEmptyHiddenShouldHaveNoExtensionElements() {
+ $this->assertTrue(is_array($this->hidden->extensionElements));
+ $this->assertTrue(count($this->hidden->extensionElements) == 0);
+ }
+
+ public function testEmptyHiddenShouldHaveNoExtensionAttributes() {
+ $this->assertTrue(is_array($this->hidden->extensionAttributes));
+ $this->assertTrue(count($this->hidden->extensionAttributes) == 0);
+ }
+
+ public function testSampleHiddenShouldHaveNoExtensionElements() {
+ $this->hidden->transferFromXML($this->hiddenText);
+ $this->assertTrue(is_array($this->hidden->extensionElements));
+ $this->assertTrue(count($this->hidden->extensionElements) == 0);
+ }
+
+ public function testSampleHiddenShouldHaveNoExtensionAttributes() {
+ $this->hidden->transferFromXML($this->hiddenText);
+ $this->assertTrue(is_array($this->hidden->extensionAttributes));
+ $this->assertTrue(count($this->hidden->extensionAttributes) == 0);
+ }
+
+ public function testNormalHiddenShouldHaveNoExtensionElements() {
+ $this->hidden->value = true;
+ $this->assertEquals($this->hidden->value, true);
+ $this->assertEquals(count($this->hidden->extensionElements), 0);
+ $newHidden = new Zend_Gdata_Calendar_Extension_Hidden();
+ $newHidden->transferFromXML($this->hidden->saveXML());
+ $this->assertEquals(count($newHidden->extensionElements), 0);
+ $newHidden->extensionElements = array(
+ new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar'));
+ $this->assertEquals(count($newHidden->extensionElements), 1);
+ $this->assertEquals($newHidden->value, true);
+
+ /* try constructing using magic factory */
+ $cal = new Zend_Gdata_Calendar();
+ $newHidden2 = $cal->newHidden();
+ $newHidden2->transferFromXML($newHidden->saveXML());
+ $this->assertEquals(count($newHidden2->extensionElements), 1);
+ $this->assertEquals($newHidden2->value, true);
+ }
+
+ public function testEmptyHiddenToAndFromStringShouldMatch() {
+ $hiddenXml = $this->hidden->saveXML();
+ $newHidden = new Zend_Gdata_Calendar_Extension_Hidden();
+ $newHidden->transferFromXML($hiddenXml);
+ $newHiddenXml = $newHidden->saveXML();
+ $this->assertTrue($hiddenXml == $newHiddenXml);
+ }
+
+ public function testHiddenWithValueToAndFromStringShouldMatch() {
+ $this->hidden->value = true;
+ $hiddenXml = $this->hidden->saveXML();
+ $newHidden = new Zend_Gdata_Calendar_Extension_Hidden();
+ $newHidden->transferFromXML($hiddenXml);
+ $newHiddenXml = $newHidden->saveXML();
+ $this->assertTrue($hiddenXml == $newHiddenXml);
+ $this->assertEquals(true, $newHidden->value);
+ }
+
+ public function testExtensionAttributes() {
+ $extensionAttributes = $this->hidden->extensionAttributes;
+ $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar');
+ $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab');
+ $this->hidden->extensionAttributes = $extensionAttributes;
+ $this->assertEquals('bar', $this->hidden->extensionAttributes['foo1']['value']);
+ $this->assertEquals('rab', $this->hidden->extensionAttributes['foo2']['value']);
+ $hiddenXml = $this->hidden->saveXML();
+ $newHidden = new Zend_Gdata_Calendar_Extension_Hidden();
+ $newHidden->transferFromXML($hiddenXml);
+ $this->assertEquals('bar', $newHidden->extensionAttributes['foo1']['value']);
+ $this->assertEquals('rab', $newHidden->extensionAttributes['foo2']['value']);
+ }
+
+ public function testConvertFullHiddenToAndFromString() {
+ $this->hidden->transferFromXML($this->hiddenText);
+ $this->assertEquals($this->hidden->value, false);
+ }
+
+}
diff --git a/zend/tests/Zend/Gdata/Calendar/LinkTest.php b/zend/tests/Zend/Gdata/Calendar/LinkTest.php
new file mode 100644
index 0000000..cd171ce
--- /dev/null
+++ b/zend/tests/Zend/Gdata/Calendar/LinkTest.php
@@ -0,0 +1,165 @@
+linkText = file_get_contents(
+ 'Zend/Gdata/Calendar/_files/LinkElementSample1.xml',
+ true);
+ $this->link = new Zend_Gdata_Calendar_Extension_Link();
+ }
+
+ public function testEmptyLinkShouldHaveNoExtensionElements() {
+ $this->assertTrue(is_array($this->link->extensionElements));
+ $this->assertTrue(count($this->link->extensionElements) == 0);
+ }
+
+ public function testEmptyLinkShouldHaveNoExtensionAttributes() {
+ $this->assertTrue(is_array($this->link->extensionAttributes));
+ $this->assertTrue(count($this->link->extensionAttributes) == 0);
+ }
+
+ public function testSampleLinkShouldHaveNoExtensionElements() {
+ $this->link->transferFromXML($this->linkText);
+ $this->assertTrue(is_array($this->link->extensionElements));
+ $this->assertTrue(count($this->link->extensionElements) == 0);
+ }
+
+ public function testSampleLinkShouldHaveNoExtensionAttributes() {
+ $this->link->transferFromXML($this->linkText);
+ $this->assertTrue(is_array($this->link->extensionAttributes));
+ $this->assertTrue(count($this->link->extensionAttributes) == 0);
+ }
+
+ public function testNormalLinkShouldHaveNoExtensionElements() {
+ $this->link->rel = "http://nowhere.invalid/";
+ $this->link->title = "Somewhere";
+ $this->link->href = "http://somewhere.invalid/";
+ $this->link->type = "text/plain";
+ $this->link->webContent = new Zend_Gdata_Calendar_Extension_WebContent("a", "1", "2");
+
+ $this->assertEquals($this->link->rel, "http://nowhere.invalid/");
+ $this->assertEquals($this->link->title, "Somewhere");
+ $this->assertEquals($this->link->href, "http://somewhere.invalid/");
+ $this->assertEquals($this->link->type, "text/plain");
+ $this->assertEquals($this->link->webcontent->url, "a");
+ $this->assertEquals($this->link->webcontent->height, "1");
+ $this->assertEquals($this->link->webcontent->width, "2");
+
+ $this->assertEquals(count($this->link->extensionElements), 0);
+ $newLink = new Zend_Gdata_Calendar_Extension_Link();
+ $newLink->transferFromXML($this->link->saveXML());
+ $this->assertEquals(count($newLink->extensionElements), 0);
+ $newLink->extensionElements = array(
+ new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar'));
+ $this->assertEquals(count($newLink->extensionElements), 1);
+ $this->assertEquals($newLink->rel, "http://nowhere.invalid/");
+ $this->assertEquals($newLink->title, "Somewhere");
+ $this->assertEquals($newLink->href, "http://somewhere.invalid/");
+ $this->assertEquals($newLink->type, "text/plain");
+ $this->assertEquals($newLink->webcontent->url, "a");
+ $this->assertEquals($newLink->webcontent->height, "1");
+ $this->assertEquals($newLink->webcontent->width, "2");
+
+ /* try constructing using magic factory */
+ $cal = new Zend_Gdata_Calendar();
+ $newLink2 = $cal->newLink();
+ $newLink2->transferFromXML($newLink->saveXML());
+ $this->assertEquals(count($newLink2->extensionElements), 1);
+ $this->assertEquals($newLink2->rel, "http://nowhere.invalid/");
+ $this->assertEquals($newLink2->title, "Somewhere");
+ $this->assertEquals($newLink2->href, "http://somewhere.invalid/");
+ $this->assertEquals($newLink2->type, "text/plain");
+ $this->assertEquals($newLink2->webcontent->url, "a");
+ $this->assertEquals($newLink2->webcontent->height, "1");
+ $this->assertEquals($newLink2->webcontent->width, "2");
+ }
+
+ public function testEmptyLinkToAndFromStringShouldMatch() {
+ $linkXml = $this->link->saveXML();
+ $newLink = new Zend_Gdata_Calendar_Extension_Link();
+ $newLink->transferFromXML($linkXml);
+ $newLinkXml = $newLink->saveXML();
+ $this->assertTrue($linkXml == $newLinkXml);
+ }
+
+ public function testLinkWithValueToAndFromStringShouldMatch() {
+ $this->link->rel = "http://nowhere.invalid/";
+ $this->link->title = "Somewhere";
+ $this->link->href = "http://somewhere.invalid/";
+ $this->link->type = "text/plain";
+ $this->link->webContent = new Zend_Gdata_Calendar_Extension_WebContent("a", "1", "2");
+ $linkXml = $this->link->saveXML();
+ $newLink = new Zend_Gdata_Calendar_Extension_Link();
+ $newLink->transferFromXML($linkXml);
+ $newLinkXml = $newLink->saveXML();
+ $this->assertTrue($linkXml == $newLinkXml);
+ $this->assertEquals($this->link->rel, "http://nowhere.invalid/");
+ $this->assertEquals($this->link->title, "Somewhere");
+ $this->assertEquals($this->link->href, "http://somewhere.invalid/");
+ $this->assertEquals($this->link->type, "text/plain");
+ $this->assertEquals($this->link->webcontent->url, "a");
+ $this->assertEquals($this->link->webcontent->height, "1");
+ $this->assertEquals($this->link->webcontent->width, "2");
+ }
+
+ public function testExtensionAttributes() {
+ $extensionAttributes = $this->link->extensionAttributes;
+ $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar');
+ $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab');
+ $this->link->extensionAttributes = $extensionAttributes;
+ $this->assertEquals('bar', $this->link->extensionAttributes['foo1']['value']);
+ $this->assertEquals('rab', $this->link->extensionAttributes['foo2']['value']);
+ $linkXml = $this->link->saveXML();
+ $newLink = new Zend_Gdata_Calendar_Extension_Link();
+ $newLink->transferFromXML($linkXml);
+ $this->assertEquals('bar', $newLink->extensionAttributes['foo1']['value']);
+ $this->assertEquals('rab', $newLink->extensionAttributes['foo2']['value']);
+ }
+
+ public function testConvertFullLinkToAndFromString() {
+ $this->link->transferFromXML($this->linkText);
+ $this->assertEquals($this->link->rel, "http://schemas.google.com/gCal/2005/webContent");
+ $this->assertEquals($this->link->title, "Independence Day");
+ $this->assertEquals($this->link->href, "http://www.google.com/calendar/images/google-holiday.gif");
+ $this->assertEquals($this->link->type, "image/gif");
+ $this->assertEquals($this->link->webcontent->url, "http://www.google.com/logos/july4th06.gif");
+ $this->assertEquals($this->link->webcontent->height, "120");
+ $this->assertEquals($this->link->webcontent->width, "276");
+ }
+
+}
diff --git a/zend/tests/Zend/Gdata/Calendar/QuickAddTest.php b/zend/tests/Zend/Gdata/Calendar/QuickAddTest.php
new file mode 100644
index 0000000..bbeb472
--- /dev/null
+++ b/zend/tests/Zend/Gdata/Calendar/QuickAddTest.php
@@ -0,0 +1,124 @@
+quickAddText = file_get_contents(
+ 'Zend/Gdata/Calendar/_files/QuickAddElementSample1.xml',
+ true);
+ $this->quickAdd = new Zend_Gdata_Calendar_Extension_QuickAdd();
+ }
+
+ public function testEmptyQuickAddShouldHaveNoExtensionElements() {
+ $this->assertTrue(is_array($this->quickAdd->extensionElements));
+ $this->assertTrue(count($this->quickAdd->extensionElements) == 0);
+ }
+
+ public function testEmptyQuickAddShouldHaveNoExtensionAttributes() {
+ $this->assertTrue(is_array($this->quickAdd->extensionAttributes));
+ $this->assertTrue(count($this->quickAdd->extensionAttributes) == 0);
+ }
+
+ public function testSampleQuickAddShouldHaveNoExtensionElements() {
+ $this->quickAdd->transferFromXML($this->quickAddText);
+ $this->assertTrue(is_array($this->quickAdd->extensionElements));
+ $this->assertTrue(count($this->quickAdd->extensionElements) == 0);
+ }
+
+ public function testSampleQuickAddShouldHaveNoExtensionAttributes() {
+ $this->quickAdd->transferFromXML($this->quickAddText);
+ $this->assertTrue(is_array($this->quickAdd->extensionAttributes));
+ $this->assertTrue(count($this->quickAdd->extensionAttributes) == 0);
+ }
+
+ public function testNormalQuickAddShouldHaveNoExtensionElements() {
+ $this->quickAdd->value = false;
+ $this->assertEquals($this->quickAdd->value, false);
+ $this->assertEquals(count($this->quickAdd->extensionElements), 0);
+ $newQuickAdd = new Zend_Gdata_Calendar_Extension_QuickAdd();
+ $newQuickAdd->transferFromXML($this->quickAdd->saveXML());
+ $this->assertEquals(count($newQuickAdd->extensionElements), 0);
+ $newQuickAdd->extensionElements = array(
+ new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar'));
+ $this->assertEquals(count($newQuickAdd->extensionElements), 1);
+ $this->assertEquals($newQuickAdd->value, false);
+
+ /* try constructing using magic factory */
+ $cal = new Zend_Gdata_Calendar();
+ $newQuickAdd2 = $cal->newQuickAdd();
+ $newQuickAdd2->transferFromXML($newQuickAdd->saveXML());
+ $this->assertEquals(count($newQuickAdd2->extensionElements), 1);
+ $this->assertEquals($newQuickAdd2->value, false);
+ }
+
+ public function testEmptyQuickAddToAndFromStringShouldMatch() {
+ $quickAddXml = $this->quickAdd->saveXML();
+ $newQuickAdd = new Zend_Gdata_Calendar_Extension_QuickAdd();
+ $newQuickAdd->transferFromXML($quickAddXml);
+ $newQuickAddXml = $newQuickAdd->saveXML();
+ $this->assertTrue($quickAddXml == $newQuickAddXml);
+ }
+
+ public function testQuickAddWithValueToAndFromStringShouldMatch() {
+ $this->quickAdd->value = false;
+ $quickAddXml = $this->quickAdd->saveXML();
+ $newQuickAdd = new Zend_Gdata_Calendar_Extension_QuickAdd();
+ $newQuickAdd->transferFromXML($quickAddXml);
+ $newQuickAddXml = $newQuickAdd->saveXML();
+ $this->assertTrue($quickAddXml == $newQuickAddXml);
+ $this->assertEquals(false, $newQuickAdd->value);
+ }
+
+ public function testExtensionAttributes() {
+ $extensionAttributes = $this->quickAdd->extensionAttributes;
+ $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar');
+ $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab');
+ $this->quickAdd->extensionAttributes = $extensionAttributes;
+ $this->assertEquals('bar', $this->quickAdd->extensionAttributes['foo1']['value']);
+ $this->assertEquals('rab', $this->quickAdd->extensionAttributes['foo2']['value']);
+ $quickAddXml = $this->quickAdd->saveXML();
+ $newQuickAdd = new Zend_Gdata_Calendar_Extension_QuickAdd();
+ $newQuickAdd->transferFromXML($quickAddXml);
+ $this->assertEquals('bar', $newQuickAdd->extensionAttributes['foo1']['value']);
+ $this->assertEquals('rab', $newQuickAdd->extensionAttributes['foo2']['value']);
+ }
+
+ public function testConvertFullQuickAddToAndFromString() {
+ $this->quickAdd->transferFromXML($this->quickAddText);
+ $this->assertEquals($this->quickAdd->value, true);
+ }
+
+}
diff --git a/zend/tests/Zend/Gdata/Calendar/SelectedTest.php b/zend/tests/Zend/Gdata/Calendar/SelectedTest.php
new file mode 100644
index 0000000..1abc205
--- /dev/null
+++ b/zend/tests/Zend/Gdata/Calendar/SelectedTest.php
@@ -0,0 +1,124 @@
+selectedText = file_get_contents(
+ 'Zend/Gdata/Calendar/_files/SelectedElementSample1.xml',
+ true);
+ $this->selected = new Zend_Gdata_Calendar_Extension_Selected();
+ }
+
+ public function testEmptySelectedShouldHaveNoExtensionElements() {
+ $this->assertTrue(is_array($this->selected->extensionElements));
+ $this->assertTrue(count($this->selected->extensionElements) == 0);
+ }
+
+ public function testEmptySelectedShouldHaveNoExtensionAttributes() {
+ $this->assertTrue(is_array($this->selected->extensionAttributes));
+ $this->assertTrue(count($this->selected->extensionAttributes) == 0);
+ }
+
+ public function testSampleSelectedShouldHaveNoExtensionElements() {
+ $this->selected->transferFromXML($this->selectedText);
+ $this->assertTrue(is_array($this->selected->extensionElements));
+ $this->assertTrue(count($this->selected->extensionElements) == 0);
+ }
+
+ public function testSampleSelectedShouldHaveNoExtensionAttributes() {
+ $this->selected->transferFromXML($this->selectedText);
+ $this->assertTrue(is_array($this->selected->extensionAttributes));
+ $this->assertTrue(count($this->selected->extensionAttributes) == 0);
+ }
+
+ public function testNormalSelectedShouldHaveNoExtensionElements() {
+ $this->selected->value = true;
+ $this->assertEquals($this->selected->value, true);
+ $this->assertEquals(count($this->selected->extensionElements), 0);
+ $newSelected = new Zend_Gdata_Calendar_Extension_Selected();
+ $newSelected->transferFromXML($this->selected->saveXML());
+ $this->assertEquals(count($newSelected->extensionElements), 0);
+ $newSelected->extensionElements = array(
+ new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar'));
+ $this->assertEquals(count($newSelected->extensionElements), 1);
+ $this->assertEquals($newSelected->value, true);
+
+ /* try constructing using magic factory */
+ $cal = new Zend_Gdata_Calendar();
+ $newSelected2 = $cal->newSelected();
+ $newSelected2->transferFromXML($newSelected->saveXML());
+ $this->assertEquals(count($newSelected2->extensionElements), 1);
+ $this->assertEquals($newSelected2->value, true);
+ }
+
+ public function testEmptySelectedToAndFromStringShouldMatch() {
+ $selectedXml = $this->selected->saveXML();
+ $newSelected = new Zend_Gdata_Calendar_Extension_Selected();
+ $newSelected->transferFromXML($selectedXml);
+ $newSelectedXml = $newSelected->saveXML();
+ $this->assertTrue($selectedXml == $newSelectedXml);
+ }
+
+ public function testSelectedWithValueToAndFromStringShouldMatch() {
+ $this->selected->value = true;
+ $selectedXml = $this->selected->saveXML();
+ $newSelected = new Zend_Gdata_Calendar_Extension_Selected();
+ $newSelected->transferFromXML($selectedXml);
+ $newSelectedXml = $newSelected->saveXML();
+ $this->assertTrue($selectedXml == $newSelectedXml);
+ $this->assertEquals(true, $newSelected->value);
+ }
+
+ public function testExtensionAttributes() {
+ $extensionAttributes = $this->selected->extensionAttributes;
+ $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar');
+ $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab');
+ $this->selected->extensionAttributes = $extensionAttributes;
+ $this->assertEquals('bar', $this->selected->extensionAttributes['foo1']['value']);
+ $this->assertEquals('rab', $this->selected->extensionAttributes['foo2']['value']);
+ $selectedXml = $this->selected->saveXML();
+ $newSelected = new Zend_Gdata_Calendar_Extension_Selected();
+ $newSelected->transferFromXML($selectedXml);
+ $this->assertEquals('bar', $newSelected->extensionAttributes['foo1']['value']);
+ $this->assertEquals('rab', $newSelected->extensionAttributes['foo2']['value']);
+ }
+
+ public function testConvertFullSelectedToAndFromString() {
+ $this->selected->transferFromXML($this->selectedText);
+ $this->assertEquals($this->selected->value, false);
+ }
+
+}
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);
+ }
+
+}
diff --git a/zend/tests/Zend/Gdata/Calendar/TimezoneTest.php b/zend/tests/Zend/Gdata/Calendar/TimezoneTest.php
new file mode 100644
index 0000000..1ec29a0
--- /dev/null
+++ b/zend/tests/Zend/Gdata/Calendar/TimezoneTest.php
@@ -0,0 +1,124 @@
+timezoneText = file_get_contents(
+ 'Zend/Gdata/Calendar/_files/TimezoneElementSample1.xml',
+ true);
+ $this->timezone = new Zend_Gdata_Calendar_Extension_Timezone();
+ }
+
+ public function testEmptyTimezoneShouldHaveNoExtensionElements() {
+ $this->assertTrue(is_array($this->timezone->extensionElements));
+ $this->assertTrue(count($this->timezone->extensionElements) == 0);
+ }
+
+ public function testEmptyTimezoneShouldHaveNoExtensionAttributes() {
+ $this->assertTrue(is_array($this->timezone->extensionAttributes));
+ $this->assertTrue(count($this->timezone->extensionAttributes) == 0);
+ }
+
+ public function testSampleTimezoneShouldHaveNoExtensionElements() {
+ $this->timezone->transferFromXML($this->timezoneText);
+ $this->assertTrue(is_array($this->timezone->extensionElements));
+ $this->assertTrue(count($this->timezone->extensionElements) == 0);
+ }
+
+ public function testSampleTimezoneShouldHaveNoExtensionAttributes() {
+ $this->timezone->transferFromXML($this->timezoneText);
+ $this->assertTrue(is_array($this->timezone->extensionAttributes));
+ $this->assertTrue(count($this->timezone->extensionAttributes) == 0);
+ }
+
+ public function testNormalTimezoneShouldHaveNoExtensionElements() {
+ $this->timezone->value = "America/Chicago";
+ $this->assertEquals($this->timezone->value, "America/Chicago");
+ $this->assertEquals(count($this->timezone->extensionElements), 0);
+ $newTimezone = new Zend_Gdata_Calendar_Extension_Timezone();
+ $newTimezone->transferFromXML($this->timezone->saveXML());
+ $this->assertEquals(count($newTimezone->extensionElements), 0);
+ $newTimezone->extensionElements = array(
+ new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar'));
+ $this->assertEquals(count($newTimezone->extensionElements), 1);
+ $this->assertEquals($newTimezone->value, "America/Chicago");
+
+ /* try constructing using magic factory */
+ $cal = new Zend_Gdata_Calendar();
+ $newTimezone2 = $cal->newTimezone();
+ $newTimezone2->transferFromXML($newTimezone->saveXML());
+ $this->assertEquals(count($newTimezone2->extensionElements), 1);
+ $this->assertEquals($newTimezone2->value, "America/Chicago");
+ }
+
+ public function testEmptyTimezoneToAndFromStringShouldMatch() {
+ $timezoneXml = $this->timezone->saveXML();
+ $newTimezone = new Zend_Gdata_Calendar_Extension_Timezone();
+ $newTimezone->transferFromXML($timezoneXml);
+ $newTimezoneXml = $newTimezone->saveXML();
+ $this->assertTrue($timezoneXml == $newTimezoneXml);
+ }
+
+ public function testTimezoneWithValueToAndFromStringShouldMatch() {
+ $this->timezone->value = "America/Chicago";
+ $timezoneXml = $this->timezone->saveXML();
+ $newTimezone = new Zend_Gdata_Calendar_Extension_Timezone();
+ $newTimezone->transferFromXML($timezoneXml);
+ $newTimezoneXml = $newTimezone->saveXML();
+ $this->assertTrue($timezoneXml == $newTimezoneXml);
+ $this->assertEquals("America/Chicago", $newTimezone->value);
+ }
+
+ public function testExtensionAttributes() {
+ $extensionAttributes = $this->timezone->extensionAttributes;
+ $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar');
+ $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab');
+ $this->timezone->extensionAttributes = $extensionAttributes;
+ $this->assertEquals('bar', $this->timezone->extensionAttributes['foo1']['value']);
+ $this->assertEquals('rab', $this->timezone->extensionAttributes['foo2']['value']);
+ $timezoneXml = $this->timezone->saveXML();
+ $newTimezone = new Zend_Gdata_Calendar_Extension_Timezone();
+ $newTimezone->transferFromXML($timezoneXml);
+ $this->assertEquals('bar', $newTimezone->extensionAttributes['foo1']['value']);
+ $this->assertEquals('rab', $newTimezone->extensionAttributes['foo2']['value']);
+ }
+
+ public function testConvertFullTimezoneToAndFromString() {
+ $this->timezone->transferFromXML($this->timezoneText);
+ $this->assertEquals($this->timezone->value, "America/Los_Angeles");
+ }
+
+}
diff --git a/zend/tests/Zend/Gdata/Calendar/WebContentTest.php b/zend/tests/Zend/Gdata/Calendar/WebContentTest.php
new file mode 100644
index 0000000..ab959a5
--- /dev/null
+++ b/zend/tests/Zend/Gdata/Calendar/WebContentTest.php
@@ -0,0 +1,140 @@
+webContentText = file_get_contents(
+ 'Zend/Gdata/Calendar/_files/WebContentElementSample1.xml',
+ true);
+ $this->webContent = new Zend_Gdata_Calendar_Extension_WebContent();
+ }
+
+ public function testEmptyWebContentShouldHaveNoExtensionElements() {
+ $this->assertTrue(is_array($this->webContent->extensionElements));
+ $this->assertTrue(count($this->webContent->extensionElements) == 0);
+ }
+
+ public function testEmptyWebContentShouldHaveNoExtensionAttributes() {
+ $this->assertTrue(is_array($this->webContent->extensionAttributes));
+ $this->assertTrue(count($this->webContent->extensionAttributes) == 0);
+ }
+
+ public function testSampleWebContentShouldHaveNoExtensionElements() {
+ $this->webContent->transferFromXML($this->webContentText);
+ $this->assertTrue(is_array($this->webContent->extensionElements));
+ $this->assertTrue(count($this->webContent->extensionElements) == 0);
+ }
+
+ public function testSampleWebContentShouldHaveNoExtensionAttributes() {
+ $this->webContent->transferFromXML($this->webContentText);
+ $this->assertTrue(is_array($this->webContent->extensionAttributes));
+ $this->assertTrue(count($this->webContent->extensionAttributes) == 0);
+ }
+
+ public function testNormalWebContentShouldHaveNoExtensionElements() {
+ $this->webContent->url = "http://nowhere.invalid/";
+ $this->webContent->height = "100";
+ $this->webContent->width = "200";
+
+ $this->assertEquals($this->webContent->url, "http://nowhere.invalid/");
+ $this->assertEquals($this->webContent->height, "100");
+ $this->assertEquals($this->webContent->width, "200");
+
+ $this->assertEquals(count($this->webContent->extensionElements), 0);
+ $newWebContent = new Zend_Gdata_Calendar_Extension_WebContent();
+ $newWebContent->transferFromXML($this->webContent->saveXML());
+ $this->assertEquals(count($newWebContent->extensionElements), 0);
+ $newWebContent->extensionElements = array(
+ new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar'));
+ $this->assertEquals(count($newWebContent->extensionElements), 1);
+ $this->assertEquals($newWebContent->url, "http://nowhere.invalid/");
+ $this->assertEquals($newWebContent->height, "100");
+ $this->assertEquals($newWebContent->width, "200");
+
+ /* try constructing using magic factory */
+ $cal = new Zend_Gdata_Calendar();
+ $newWebContent2 = $cal->newWebContent();
+ $newWebContent2->transferFromXML($newWebContent->saveXML());
+ $this->assertEquals(count($newWebContent2->extensionElements), 1);
+ $this->assertEquals($newWebContent2->url, "http://nowhere.invalid/");
+ $this->assertEquals($newWebContent2->height, "100");
+ $this->assertEquals($newWebContent2->width, "200");
+ }
+
+ public function testEmptyWebContentToAndFromStringShouldMatch() {
+ $webContentXml = $this->webContent->saveXML();
+ $newWebContent = new Zend_Gdata_Calendar_Extension_WebContent();
+ $newWebContent->transferFromXML($webContentXml);
+ $newWebContentXml = $newWebContent->saveXML();
+ $this->assertTrue($webContentXml == $newWebContentXml);
+ }
+
+ public function testWebContentWithValueToAndFromStringShouldMatch() {
+ $this->webContent->url = "http://nowhere.invalid/";
+ $this->webContent->height = "100";
+ $this->webContent->width = "200";
+ $webContentXml = $this->webContent->saveXML();
+ $newWebContent = new Zend_Gdata_Calendar_Extension_WebContent();
+ $newWebContent->transferFromXML($webContentXml);
+ $newWebContentXml = $newWebContent->saveXML();
+ $this->assertTrue($webContentXml == $newWebContentXml);
+ $this->assertEquals($this->webContent->url, "http://nowhere.invalid/");
+ $this->assertEquals($this->webContent->height, "100");
+ $this->assertEquals($this->webContent->width, "200");
+ }
+
+ public function testExtensionAttributes() {
+ $extensionAttributes = $this->webContent->extensionAttributes;
+ $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar');
+ $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab');
+ $this->webContent->extensionAttributes = $extensionAttributes;
+ $this->assertEquals('bar', $this->webContent->extensionAttributes['foo1']['value']);
+ $this->assertEquals('rab', $this->webContent->extensionAttributes['foo2']['value']);
+ $webContentXml = $this->webContent->saveXML();
+ $newWebContent = new Zend_Gdata_Calendar_Extension_WebContent();
+ $newWebContent->transferFromXML($webContentXml);
+ $this->assertEquals('bar', $newWebContent->extensionAttributes['foo1']['value']);
+ $this->assertEquals('rab', $newWebContent->extensionAttributes['foo2']['value']);
+ }
+
+ public function testConvertFullWebContentToAndFromString() {
+ $this->webContent->transferFromXML($this->webContentText);
+ $this->assertEquals($this->webContent->url, "http://www.google.com/logos/july4th06.gif");
+ $this->assertEquals($this->webContent->height, "120");
+ $this->assertEquals($this->webContent->width, "276");
+ }
+
+}
diff --git a/zend/tests/Zend/Gdata/Calendar/_files/AccessLevelElementSample1.xml b/zend/tests/Zend/Gdata/Calendar/_files/AccessLevelElementSample1.xml
new file mode 100644
index 0000000..47843bc
--- /dev/null
+++ b/zend/tests/Zend/Gdata/Calendar/_files/AccessLevelElementSample1.xml
@@ -0,0 +1,2 @@
+
+This is a user supplied comment.
', $comment->getContent()->text); + } + + /** + * Check for the existence of an