From 06f945f27840b53e57795dadbc38e76f7e11ab1c Mon Sep 17 00:00:00 2001 From: Horus3 Date: Mon, 24 Feb 2014 16:42:14 +0100 Subject: init --- .../tests/Zend/Gdata/Books/CollectionEntryTest.php | 48 +++++++ zend/tests/Zend/Gdata/Books/CollectionFeedTest.php | 48 +++++++ zend/tests/Zend/Gdata/Books/VolumeEntryTest.php | 125 ++++++++++++++++++ zend/tests/Zend/Gdata/Books/VolumeFeedTest.php | 108 ++++++++++++++++ .../Gdata/Books/_files/VolumeEntryDataSample1.xml | 32 +++++ .../Gdata/Books/_files/VolumeFeedDataSample1.xml | 139 +++++++++++++++++++++ 6 files changed, 500 insertions(+) create mode 100644 zend/tests/Zend/Gdata/Books/CollectionEntryTest.php create mode 100644 zend/tests/Zend/Gdata/Books/CollectionFeedTest.php create mode 100644 zend/tests/Zend/Gdata/Books/VolumeEntryTest.php create mode 100644 zend/tests/Zend/Gdata/Books/VolumeFeedTest.php create mode 100644 zend/tests/Zend/Gdata/Books/_files/VolumeEntryDataSample1.xml create mode 100644 zend/tests/Zend/Gdata/Books/_files/VolumeFeedDataSample1.xml (limited to 'zend/tests/Zend/Gdata/Books') diff --git a/zend/tests/Zend/Gdata/Books/CollectionEntryTest.php b/zend/tests/Zend/Gdata/Books/CollectionEntryTest.php new file mode 100644 index 0000000..d53826a --- /dev/null +++ b/zend/tests/Zend/Gdata/Books/CollectionEntryTest.php @@ -0,0 +1,48 @@ +gdata = new Zend_Gdata_Books_CollectionEntry(); + } + + public function testCollectionEntry() + { + $this->assertTrue(true); + } + +} diff --git a/zend/tests/Zend/Gdata/Books/CollectionFeedTest.php b/zend/tests/Zend/Gdata/Books/CollectionFeedTest.php new file mode 100644 index 0000000..b30adee --- /dev/null +++ b/zend/tests/Zend/Gdata/Books/CollectionFeedTest.php @@ -0,0 +1,48 @@ +gdata = new Zend_Gdata_Books_CollectionFeed(); + } + + public function testCollectionFeed() + { + $this->assertTrue(true); + } + +} diff --git a/zend/tests/Zend/Gdata/Books/VolumeEntryTest.php b/zend/tests/Zend/Gdata/Books/VolumeEntryTest.php new file mode 100644 index 0000000..8532122 --- /dev/null +++ b/zend/tests/Zend/Gdata/Books/VolumeEntryTest.php @@ -0,0 +1,125 @@ +entryText = file_get_contents( + 'Zend/Gdata/Books/_files/VolumeEntryDataSample1.xml', + true); + $this->entry = new Zend_Gdata_Books_VolumeEntry(); + } + + private function verifySamplePropertiesAreCorrect ($volumeEntry) { + $this->assertEquals('http://www.google.com/books/feeds/volumes/Mfer_MFwQrkC', + $volumeEntry->id->text); + $this->assertEquals('2008-10-07T15:28:15.000Z', $volumeEntry->updated->text); + $this->assertEquals('http://schemas.google.com/g/2005#kind', $volumeEntry->category[0]->scheme); + $this->assertEquals('http://schemas.google.com/books/2008#volume', $volumeEntry->category[0]->term); + $this->assertEquals('http://bks1.books.google.com/books?id=Mfer_MFwQrkC&printsec=frontcover&img=1&zoom=5&sig=ACfU3U1o90VpMryPI7WKSyIhmAWdC1uDtw&source=gbs_gdata', $volumeEntry->getThumbnailLink()->href); + $this->assertEquals('http://books.google.com/books?id=Mfer_MFwQrkC&ie=ISO-8859-1&source=gbs_gdata', $volumeEntry->getInfoLink()->href); + $this->assertEquals(null, $volumeEntry->getPreviewLink()); + $creators = $volumeEntry->getCreators(); + $this->assertEquals('William Shakespeare', $creators[0]->text); + $titles = $volumeEntry->getTitles(); + $this->assertEquals('Hamlet', $titles[0]->text); + $dates = $volumeEntry->getDates(); + $this->assertEquals('2002-02', $dates[0]->text); + $identifiers = $volumeEntry->getIdentifiers(); + $this->assertEquals('Mfer_MFwQrkC', $identifiers[0]->text); + $this->assertEquals('ISBN:0198320493', $identifiers[1]->text); + $languages = $volumeEntry->getLanguages(); + $this->assertEquals('en', $languages[0]->text); + $formats = $volumeEntry->getFormats(); + $this->assertEquals('178 pages', $formats[0]->text); + $publishers = $volumeEntry->getPublishers(); + $this->assertEquals('Oxford University Press', $publishers[0]->text); + $subjects = $volumeEntry->getSubjects(); + $this->assertEquals('Denmark', $subjects[0]->text); + $this->assertEquals(null, $volumeEntry->getPreviewLink()); + $this->assertEquals('http://www.google.com/books/feeds/users/me/volumes', $volumeEntry->getAnnotationLink()->href); + $this->assertEquals('http://books.google.com/books?id=Mfer_MFwQrkC&ie=ISO-8859-1&source=gbs_gdata', $volumeEntry->getInfoLink()->href); + $this->assertEquals('http://bks1.books.google.com/books?id=Mfer_MFwQrkC&printsec=frontcover&img=1&zoom=5&sig=ACfU3U1o90VpMryPI7WKSyIhmAWdC1uDtw&source=gbs_gdata', $volumeEntry->getThumbnailLink()->href); + $this->assertEquals('Denmark', $subjects[0]->text); + $this->assertEquals('http://schemas.google.com/books/2008#view_partial', $volumeEntry->getViewability()->value); + $this->assertEquals('Mfer_MFwQrkC', $volumeEntry->getVolumeId()); + } + + public function testEmptyEntryShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->entry->extensionElements)); + $this->assertEquals(0, count($this->entry->extensionElements)); + } + + public function testEmptyEntryShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->entry->extensionAttributes)); + $this->assertEquals(0, count($this->entry->extensionAttributes)); + } + + public function testSampleEntryShouldHaveNoExtensionElements() { + $this->entry->transferFromXML($this->entryText); + $this->assertTrue(is_array($this->entry->extensionElements)); + $this->assertEquals(0, count($this->entry->extensionElements)); + } + + public function testSampleEntryShouldHaveNoExtensionAttributes() { + $this->entry->transferFromXML($this->entryText); + $this->assertTrue(is_array($this->entry->extensionAttributes)); + $this->assertEquals(0, count($this->entry->extensionAttributes)); + } + + public function testEmptyVolumeEntryToAndFromStringShouldMatch() { + $entryXml = $this->entry->saveXML(); + $newVolumeEntry = new Zend_Gdata_Books_VolumeEntry(); + $newVolumeEntry->transferFromXML($entryXml); + $newVolumeEntryXml = $newVolumeEntry->saveXML(); + $this->assertEquals($entryXml, $newVolumeEntryXml); + } + + public function testSamplePropertiesAreCorrect () { + $this->entry->transferFromXML($this->entryText); + $this->verifySamplePropertiesAreCorrect($this->entry); + } + + public function testConvertVolumeEntryToAndFromString() { + $this->entry->transferFromXML($this->entryText); + $entryXml = $this->entry->saveXML(); + $newVolumeEntry = new Zend_Gdata_Books_VolumeEntry(); + $newVolumeEntry->transferFromXML($entryXml); + $this->verifySamplePropertiesAreCorrect($newVolumeEntry); + $newVolumeEntryXml = $newVolumeEntry->saveXML(); + $this->assertEquals($entryXml, $newVolumeEntryXml); + } + +} diff --git a/zend/tests/Zend/Gdata/Books/VolumeFeedTest.php b/zend/tests/Zend/Gdata/Books/VolumeFeedTest.php new file mode 100644 index 0000000..423602c --- /dev/null +++ b/zend/tests/Zend/Gdata/Books/VolumeFeedTest.php @@ -0,0 +1,108 @@ +feedText = file_get_contents( + 'Zend/Gdata/Books/_files/VolumeFeedDataSample1.xml', + true); + $this->feed = new Zend_Gdata_Books_VolumeFeed(); + } + + private function verifyAllSamplePropertiesAreCorrect ($volumeFeed) { + $this->assertEquals('http://www.google.com/books/feeds/volumes', + $volumeFeed->id->text); + $this->assertEquals('2008-10-07T16:41:52.000Z', $volumeFeed->updated->text); + $this->assertEquals('http://schemas.google.com/g/2005#kind', $volumeFeed->category[0]->scheme); + $this->assertEquals('http://schemas.google.com/books/2008#volume', $volumeFeed->category[0]->term); + $this->assertEquals('text', $volumeFeed->title->type); + $this->assertEquals('Search results for Hamlet', $volumeFeed->title->text);; + $this->assertEquals('self', $volumeFeed->getLink('self')->rel); + $this->assertEquals('application/atom+xml', $volumeFeed->getLink('self')->type); + $this->assertEquals('http://www.google.com/books/feeds/volumes?q=Hamlet&start-index=3&max-results=5', $volumeFeed->getLink('self')->href); + $this->assertEquals('Google Books Search', $volumeFeed->author[0]->name->text); + $this->assertEquals('http://www.google.com', $volumeFeed->author[0]->uri->text); + $this->assertEquals(512, $volumeFeed->totalResults->text); + $this->assertEquals(3, $volumeFeed->startIndex->text); + $this->assertEquals(5, $volumeFeed->itemsPerPage->text); + } + + public function testEmptyEntryShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->feed->extensionElements)); + $this->assertEquals(0, count($this->feed->extensionElements)); + } + + public function testEmptyEntryShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->feed->extensionAttributes)); + $this->assertEquals(0, count($this->feed->extensionAttributes)); + } + + public function testSampleEntryShouldHaveNoExtensionElements() { + $this->feed->transferFromXML($this->feedText); + $this->assertTrue(is_array($this->feed->extensionElements)); + $this->assertEquals(0, count($this->feed->extensionElements)); + } + + public function testSampleEntryShouldHaveNoExtensionAttributes() { + $this->feed->transferFromXML($this->feedText); + $this->assertTrue(is_array($this->feed->extensionAttributes)); + $this->assertEquals(0, count($this->feed->extensionAttributes)); + } + + public function testEmptyVolumeFeedToAndFromStringShouldMatch() { + $entryXml = $this->feed->saveXML(); + $newVolumeFeed = new Zend_Gdata_Books_VolumeFeed(); + $newVolumeFeed->transferFromXML($entryXml); + $newVolumeFeedXml = $newVolumeFeed->saveXML(); + $this->assertEquals($entryXml, $newVolumeFeedXml); + } + + public function testSamplePropertiesAreCorrect () { + $this->feed->transferFromXML($this->feedText); + $this->verifyAllSamplePropertiesAreCorrect($this->feed); + } + + public function testConvertVolumeFeedToAndFromString() { + $this->feed->transferFromXML($this->feedText); + $entryXml = $this->feed->saveXML(); + $newVolumeFeed = new Zend_Gdata_Books_VolumeFeed(); + $newVolumeFeed->transferFromXML($entryXml); + $this->verifyAllSamplePropertiesAreCorrect($newVolumeFeed); + $newVolumeFeedXml = $newVolumeFeed->saveXML(); + $this->assertEquals($entryXml, $newVolumeFeedXml); + } + +} diff --git a/zend/tests/Zend/Gdata/Books/_files/VolumeEntryDataSample1.xml b/zend/tests/Zend/Gdata/Books/_files/VolumeEntryDataSample1.xml new file mode 100644 index 0000000..0b6cd95 --- /dev/null +++ b/zend/tests/Zend/Gdata/Books/_files/VolumeEntryDataSample1.xml @@ -0,0 +1,32 @@ + + + http://www.google.com/books/feeds/volumes/Mfer_MFwQrkC + 2008-10-07T15:28:15.000Z + + Hamlet + + + + + + + + + Bad review... + William Shakespeare + Roma Gill + 2002-02 + Featuring the images of some of the world's most famous stage and film actors, these additions to the all-new Oxford School Shakespeare introduce--and enthrall--young people to one of the greatest writers of all time. This season brings revised editions of five of the Bard's most famous plays--As You Like It, Othello, Hamlet, Love's Labour Lost and The Taming of the Shrew. Designed specifically for students unfamiliar with Shakespeare's rich literary legacy, these new editions present Shakespeare's sometimes-intimidating Middle English in a way that is easy-to-read and engaging for ages twelve and up. The notes and introductions have been completely revised, allowing unprecedented clarity and accessibility. Featuring new covers and new illustrations--including photos from recent productions of Shakespeare's plays from around the world--Oxford School Shakespeare brings all the pleasure of these literary treasures to life. + 178 pages + Mfer_MFwQrkC + ISBN:0198320493 + en + Oxford University Press + Denmark + Hamlet (Legendary character)/ Drama + Murder victims' families/ Drama + Juvenile Nonfiction / Drama + Drama / English, Irish, Scottish, Welsh + Drama / Shakespeare + Hamlet + diff --git a/zend/tests/Zend/Gdata/Books/_files/VolumeFeedDataSample1.xml b/zend/tests/Zend/Gdata/Books/_files/VolumeFeedDataSample1.xml new file mode 100644 index 0000000..5f17aaa --- /dev/null +++ b/zend/tests/Zend/Gdata/Books/_files/VolumeFeedDataSample1.xml @@ -0,0 +1,139 @@ + + + http://www.google.com/books/feeds/volumes + 2008-10-07T16:41:52.000Z + + Search results for Hamlet + + + + + + + Google Books Search + http://www.google.com + + Google Book Search data API + 512 + 3 + 5 + + http://www.google.com/books/feeds/volumes/aCI_v2-QH04C + 2008-10-07T16:41:52.000Z + + Hamlet + + + + + + + + + William Shakespeare + Barbara Mowat + Paul Werstine + 2003-07-01 + Each edition includes:• Freshly edited text based on the best early printed version of the play• Full explanatory notes conveniently placed on pages facing... + 400 pages + aCI_v2-QH04C + ISBN:074347712X + Washington Square Press + Fiction + Hamlet + Prince of Denmark + + + http://www.google.com/books/feeds/volumes/VBoVAAAAYAAJ + 2008-10-07T16:41:52.000Z + + Hamlet + + + + + + + + + William Shakespeare + George Pierce Baker + 1913 + 219 pages + VBoVAAAAYAAJ + HARVARD:32044100887074 + Hamlet (Legendary character) + Hamlet + Prince of Denmark + + + http://www.google.com/books/feeds/volumes/S5YvAgAACAAJ + 2008-10-07T16:41:52.000Z + + Hamlet + + + + + + + + William Shakespeare + 1995-05-01 + Among Shakespeare's plays, "Hamlet" is considered by many hismasterpiece. + S5YvAgAACAAJ + ISBN:0811468259 + Heinemann/Raintree + Juvenile Fiction + Hamlet + + + http://www.google.com/books/feeds/volumes/Hxk3SFdOJr4C + 2008-10-07T16:41:52.000Z + + Hamlet + + + + + + + + + William Shakespeare + Alan Durband + 1987-05-01 + The significance of the plays is reinforced by sections discussing Shakespeare's life, works and theatre. + 336 pages + Hxk3SFdOJr4C + ISBN:0748703462 + Nelson Thornes Ltd + Drama + Hamlet + Shakespeare Made Easy + + + http://www.google.com/books/feeds/volumes/lZE0AAAAMAAJ + 2008-10-07T16:41:52.000Z + + Julius Caesar + + + + + + + + + William Shakespeare + Samuel Thurber + Arthur Wilson Verity + 1895 + Tan leather binding, gold-embossed, with gilt pattern insert and coat of arms on cover. + 123 pages + lZE0AAAAMAAJ + UOM:39015063516275 + Conspiracies + Julius Caesar + + -- cgit v1.2.3