diff options
| author | Horus3 | 2014-02-24 16:42:14 +0100 |
|---|---|---|
| committer | Horus3 | 2014-02-24 16:42:14 +0100 |
| commit | 06f945f27840b53e57795dadbc38e76f7e11ab1c (patch) | |
| tree | 689d5c7f4ffa15460c7e90f47c6a7dd59ce4e8bd /zend/tests/Zend/Gdata/Docs | |
| download | random-06f945f27840b53e57795dadbc38e76f7e11ab1c.tar.gz | |
init
Diffstat (limited to 'zend/tests/Zend/Gdata/Docs')
5 files changed, 268 insertions, 0 deletions
diff --git a/zend/tests/Zend/Gdata/Docs/DocumentListEntryTest.php b/zend/tests/Zend/Gdata/Docs/DocumentListEntryTest.php new file mode 100755 index 0000000..3f50148 --- /dev/null +++ b/zend/tests/Zend/Gdata/Docs/DocumentListEntryTest.php @@ -0,0 +1,72 @@ +<?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_Docs + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 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/Docs.php'; +require_once 'Zend/Http/Client.php'; +require_once 'Zend/Gdata/Docs/DocumentListEntry.php'; + +/** + * @category Zend + * @package Zend_Gdata_Docsj + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 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_Docsj + */ +class Zend_Gdata_Docs_DocumentListEntryTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() + { + $this->doc = new Zend_Gdata_Docs_DocumentListEntry( + file_get_contents('Zend/Gdata/Docs/_files/TestDataDocumentListEntrySample.xml', true)); + } + + public function testToAndFromString() + { + $this->assertTrue($this->doc instanceof Zend_Gdata_Docs_DocumentListEntry); + $this->assertTrue($this->doc->title->text === 'Test Spreadsheet'); + + $newDoc = new Zend_Gdata_Docs_DocumentListEntry(); + $doc = new DOMDocument(); + $doc->loadXML($this->doc->saveXML()); + $newDoc->transferFromDom($doc->documentElement); + + $this->assertTrue($newDoc->title == $this->doc->title); + } + + public function testSetMediaSource() + { + // Service object to create the media file source. + $this->docsClient = new Zend_Gdata_Docs(null); + $mediaSource = $this->docsClient->newMediaFileSource('test_file_name'); + $mediaSource->setSlug('test slug'); + $mediaSource->setContentType('test content type'); + $this->doc->setMediaSource($mediaSource); + $this->assertTrue($this->doc->getMediaSource()->getContentType() === + 'test content type'); + $this->assertTrue($this->doc->getMediaSource()->getSlug() === + 'test slug'); + } + +} diff --git a/zend/tests/Zend/Gdata/Docs/DocumentListFeedTest.php b/zend/tests/Zend/Gdata/Docs/DocumentListFeedTest.php new file mode 100755 index 0000000..69b911b --- /dev/null +++ b/zend/tests/Zend/Gdata/Docs/DocumentListFeedTest.php @@ -0,0 +1,67 @@ +<?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_Docs + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 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/Docs.php'; +require_once 'Zend/Http/Client.php'; + +/** + * @category Zend + * @package Zend_Gdata_Docs + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 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_Docs + */ +class Zend_Gdata_Docs_DocumentListFeedTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() + { + $this->docFeed = new Zend_Gdata_Docs_DocumentListFeed( + file_get_contents(dirname(__FILE__) . '/_files/TestDataDocumentListFeedSample.xml'), + true); + } + + public function testToAndFromString() + { + // There should be 2 entries in the feed. + $this->assertTrue(count($this->docFeed->entries) == 2); + $this->assertTrue($this->docFeed->entries->count() == 2); + foreach($this->docFeed->entries as $entry) + { + $this->assertTrue($entry instanceof Zend_Gdata_Docs_DocumentListEntry); + } + + $newDocFeed = new Zend_Gdata_Docs_DocumentListFeed(); + $doc = new DOMDocument(); + $doc->loadXML($this->docFeed->saveXML()); + $newDocFeed->transferFromDom($doc->documentElement); + + $this->assertTrue(count($newDocFeed->entries) == count($this->docFeed->entries)); + foreach($newDocFeed->entries as $entry) + { + $this->assertTrue($entry instanceof Zend_Gdata_Docs_DocumentListEntry); + } + } + +} diff --git a/zend/tests/Zend/Gdata/Docs/QueryTest.php b/zend/tests/Zend/Gdata/Docs/QueryTest.php new file mode 100755 index 0000000..37efa24 --- /dev/null +++ b/zend/tests/Zend/Gdata/Docs/QueryTest.php @@ -0,0 +1,77 @@ +<?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_Docs + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 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/Docs.php'; +require_once 'Zend/Gdata/Docs/Query.php'; +require_once 'Zend/Http/Client.php'; + +/** + * @category Zend + * @package Zend_Gdata_Docs + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 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_Docs + */ +class Zend_Gdata_Docs_QueryTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() + { + $this->docQuery = new Zend_Gdata_Docs_Query(); + } + + public function testTitle() + { + $this->assertTrue($this->docQuery->getTitle() == null); + $this->docQuery->setTitle('test title'); + $this->assertTrue($this->docQuery->getTitle() == 'test title'); + $this->assertTrue($this->docQuery->getQueryString() == '?title=test+title'); + $this->docQuery->setTitle(null); + $this->assertTrue($this->docQuery->getTitle() == null); + } + + public function testTitleExact() + { + $this->assertTrue($this->docQuery->getTitleExact() == null); + $this->docQuery->setTitleExact('test title'); + $this->assertTrue($this->docQuery->getTitleExact() == 'test title'); + $this->assertTrue($this->docQuery->getQueryString() == '?title-exact=test+title'); + $this->docQuery->setTitleExact(null); + $this->assertTrue($this->docQuery->getTitleExact() == null); + } + + public function testProjection() + { + $this->assertTrue($this->docQuery->getProjection() == 'full'); + $this->docQuery->setProjection('abc'); + $this->assertTrue($this->docQuery->getProjection() == 'abc'); + } + + public function testVisibility() + { + $this->assertTrue($this->docQuery->getVisibility() == 'private'); + $this->docQuery->setVisibility('xyz'); + $this->assertTrue($this->docQuery->getVisibility() == 'xyz'); + } +} diff --git a/zend/tests/Zend/Gdata/Docs/_files/TestDataDocumentListEntrySample.xml b/zend/tests/Zend/Gdata/Docs/_files/TestDataDocumentListEntrySample.xml new file mode 100755 index 0000000..1860425 --- /dev/null +++ b/zend/tests/Zend/Gdata/Docs/_files/TestDataDocumentListEntrySample.xml @@ -0,0 +1,14 @@ +<entry xmlns="http://www.w3.org/2005/Atom">
+ <content src="http://foo.com/fm?fmcmd=102key=supercalifragilisticexpealidocious" type="text/html" />
+ <author>
+ <name>test.user</name>
+ <email>test.user@gmail.com</email>
+ </author>
+ <category label="spreadsheet" scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/docs/2007#spreadsheet" />
+ <id>http://docs.google.com/feeds/documents/private/full/spreadsheet%3Asupercalifragilisticexpealidocious</id>
+ <link href="http://foo.com/ccc?key=supercalifragilisticexpealidocious" rel="alternate" type="text/html" />
+ <link href="http://foo.com/feeds/worksheets/supercalifragilisticexpealidocious/private/full" rel="http://schemas.google.com/spreadsheets/2006#worksheetsfeed" type="application/atom+xml" />
+ <link href="http://docs.google.com/feeds/documents/private/full/spreadsheet%3Asupercalifragilisticexpealidocious" rel="self" type="application/atom+xml" />
+ <title type="text">Test Spreadsheet</title>
+ <updated>2007-07-03T18:03:32.045Z</updated>
+</entry>
diff --git a/zend/tests/Zend/Gdata/Docs/_files/TestDataDocumentListFeedSample.xml b/zend/tests/Zend/Gdata/Docs/_files/TestDataDocumentListFeedSample.xml new file mode 100755 index 0000000..d19a2f2 --- /dev/null +++ b/zend/tests/Zend/Gdata/Docs/_files/TestDataDocumentListFeedSample.xml @@ -0,0 +1,38 @@ +<ns0:feed xmlns:ns0="http://www.w3.org/2005/Atom">
+ <ns1:totalResults xmlns:ns1="http://a9.com/-/spec/opensearchrss/1.0/">2</ns1:totalResults>
+ <ns1:startIndex xmlns:ns1="http://a9.com/-/spec/opensearchrss/1.0/">1</ns1:startIndex>
+ <ns0:entry>
+ <ns0:content src="http://foo.com/fm?fmcmd=102&key=supercalifragilisticexpeadocious" type="text/html"/>
+ <ns0:author>
+ <ns0:name>test.user</ns0:name>
+ <ns0:email>test.user@gmail.com</ns0:email>
+ </ns0:author>
+ <ns0:category label="spreadsheet" scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/docs/2007#spreadsheet" />
+ <ns0:id>http://docs.google.com/feeds/documents/private/full/spreadsheet%3Asupercalifragilisticexpeadocious</ns0:id>
+ <ns0:link href="http://foo.com/ccc?key=supercalifragilisticexpeadocious" rel="alternate" type="text/html" />
+ <ns0:link href="http://foo.com/feeds/worksheets/supercalifragilisticexpeadocious/private/full" rel="http://schemas.google.com/spreadsheets/2006#worksheetsfeed" type="application/atom+xml" />
+ <ns0:link href="http://docs.google.com/feeds/documents/private/full/spreadsheet%3Asupercalifragilisticexpeadocious" rel="self" type="application/atom+xml" />
+ <ns0:title type="text">Test Spreadsheet</ns0:title>
+ <ns0:updated>2007-07-03T18:03:32.045Z</ns0:updated>
+ </ns0:entry>
+ <ns0:entry>
+ <ns0:content src="http://docs.google.com/RawDocContents?action=fetch&docID=gr00vy" type="text/html" />
+ <ns0:author>
+ <ns0:name>test.user</ns0:name>
+ <ns0:email>test.user@gmail.com</ns0:email>
+ </ns0:author>
+ <ns0:category label="document" scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/docs/2007#document" />
+ <ns0:id>http://docs.google.com/feeds/documents/private/full/document%3Agr00vy</ns0:id>
+ <ns0:link href="http://foobar.com/Doc?id=gr00vy" rel="alternate" type="text/html" />
+ <ns0:link href="http://docs.google.com/feeds/documents/private/full/document%3Agr00vy" rel="self" type="application/atom+xml" />
+ <ns0:title type="text">Test Document</ns0:title>
+ <ns0:updated>2007-07-03T18:02:50.338Z</ns0:updated>
+ </ns0:entry>
+ <ns0:id>http://docs.google.com/feeds/documents/private/full</ns0:id>
+ <ns0:link href="http://docs.google.com" rel="alternate" type="text/html" />
+ <ns0:link href="http://docs.google.com/feeds/documents/private/full" rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" />
+ <ns0:link href="http://docs.google.com/feeds/documents/private/full" rel="http://schemas.google.com/g/2005#post" type="application/atom+xml" />
+ <ns0:link href="http://docs.google.com/feeds/documents/private/full" rel="self" type="application/atom+xml" />
+ <ns0:title type="text">Available Documents - test.user@gmail.com</ns0:title>
+ <ns0:updated>2007-07-09T23:07:21.898Z</ns0:updated>
+</ns0:feed>
|
