From 06f945f27840b53e57795dadbc38e76f7e11ab1c Mon Sep 17 00:00:00 2001 From: Horus3 Date: Mon, 24 Feb 2014 16:42:14 +0100 Subject: init --- zend/tests/Zend/Gdata/DocsOnlineTest.php | 129 +++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100755 zend/tests/Zend/Gdata/DocsOnlineTest.php (limited to 'zend/tests/Zend/Gdata/DocsOnlineTest.php') diff --git a/zend/tests/Zend/Gdata/DocsOnlineTest.php b/zend/tests/Zend/Gdata/DocsOnlineTest.php new file mode 100755 index 0000000..f573f19 --- /dev/null +++ b/zend/tests/Zend/Gdata/DocsOnlineTest.php @@ -0,0 +1,129 @@ +docTitle = constant('TESTS_ZEND_GDATA_DOCS_DOCUMENTTITLE'); + $service = Zend_Gdata_Docs::AUTH_SERVICE_NAME; + $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service); + $this->gdata = new Zend_Gdata_Docs($client); + } + + public function testGetSpreadsheetFeed() + { + $feed = $this->gdata->getDocumentListFeed(); + $this->assertTrue($feed instanceof Zend_Gdata_Docs_DocumentListFeed); + foreach ($feed->entries as $entry) { + $this->assertTrue($entry instanceof Zend_Gdata_Docs_DocumentListEntry); + $this->assertTrue($entry->getHttpClient() == $feed->getHttpClient()); + } + + $query = new Zend_Gdata_Docs_Query(); + $feed = $this->gdata->getDocumentListFeed($query); + $this->assertTrue($feed instanceof Zend_Gdata_Docs_DocumentListFeed); + foreach ($feed->entries as $entry) { + $this->assertTrue($entry instanceof Zend_Gdata_Docs_DocumentListEntry); + $this->assertTrue($entry->getHttpClient() == $feed->getHttpClient()); + } + + $uri = $query->getQueryUrl(); + $feed = $this->gdata->getDocumentListFeed($uri); + $this->assertTrue($feed instanceof Zend_Gdata_Docs_DocumentListFeed); + foreach ($feed->entries as $entry) { + $this->assertTrue($entry instanceof Zend_Gdata_Docs_DocumentListEntry); + $this->assertTrue($entry->getHttpClient() == $feed->getHttpClient()); + } + } + + public function testQueryForTitle() + { + $query = new Zend_Gdata_Docs_Query(); + $query->title = $this->docTitle; + $feed = $this->gdata->getDocumentListFeed($query); + $this->assertTrue(strpos(strtolower($feed->entries[0]->title), strtolower($this->docTitle)) !== FALSE); + } + + public function testGetDocumentListEntry() + { + $query = new Zend_Gdata_Docs_Query(); + $feed = $this->gdata->getDocumentListFeed($query); + $selfLinkHref = $feed->entries[0]->getSelfLink()->href; + $entry = $this->gdata->getDocumentListEntry($selfLinkHref); + $this->assertTrue($entry instanceof Zend_Gdata_Docs_DocumentListEntry); + } + + public function testUploadFindAndDelete() + { + $documentTitle = 'spreadsheet_upload_test.csv'; + $newDocumentEntry = $this->gdata->uploadFile( + 'Zend/Gdata/_files/DocsTest.csv', $documentTitle, + $this->gdata->lookupMimeType('CSV'), + Zend_Gdata_Docs::DOCUMENTS_LIST_FEED_URI); + $this->assertTrue($newDocumentEntry->title->text === $documentTitle); + + // Get the newly created document. + // First extract the document's ID key from the Atom id. + $idParts = explode('/', $newDocumentEntry->id->text); + $keyParts = explode('%3A', end($idParts)); + $documentFromGetDoc = $this->gdata->getDoc($keyParts[1], $keyParts[0]); + $this->assertTrue($documentFromGetDoc->title->text === $documentTitle); + if ($keyParts[0] == 'document') { + $documentFromGetDocument = $this->gdata->getDocument($keyParts[1]); + $this->assertTrue( + $documentFromGetDocument->title->text === $documentTitle); + } + if ($keyParts[0] == 'spreadsheet') { + $documentFromGetSpreadsheet = $this->gdata->getSpreadsheet( + $keyParts[1]); + $this->assertTrue( + $documentFromGetSpreadsheet->title->text === $documentTitle); + } + if ($keyParts[0] == 'presentation') { + $documentFromGetPresentation = $this->gdata->getPresentation( + $keyParts[1]); + $this->assertTrue( + $documentFromGetPresentation->title->text === $documentTitle); + } + + // Cleanup and remove the new document. + $newDocumentEntry->delete(); + } + +} -- cgit v1.2.3