From 06f945f27840b53e57795dadbc38e76f7e11ab1c Mon Sep 17 00:00:00 2001 From: Horus3 Date: Mon, 24 Feb 2014 16:42:14 +0100 Subject: init --- .../Zend/Gdata/Photos/PhotosAlbumEntryTest.php | 364 ++++++++++++++++ .../Zend/Gdata/Photos/PhotosAlbumFeedTest.php | 469 +++++++++++++++++++++ .../Zend/Gdata/Photos/PhotosAlbumQueryTest.php | 198 +++++++++ .../Zend/Gdata/Photos/PhotosCommentEntryTest.php | 229 ++++++++++ .../Zend/Gdata/Photos/PhotosPhotoEntryTest.php | 395 +++++++++++++++++ .../Zend/Gdata/Photos/PhotosPhotoFeedTest.php | 435 +++++++++++++++++++ .../Zend/Gdata/Photos/PhotosPhotoQueryTest.php | 133 ++++++ .../tests/Zend/Gdata/Photos/PhotosTagEntryTest.php | 130 ++++++ .../Zend/Gdata/Photos/PhotosUserEntryTest.php | 228 ++++++++++ .../tests/Zend/Gdata/Photos/PhotosUserFeedTest.php | 360 ++++++++++++++++ .../Zend/Gdata/Photos/PhotosUserQueryTest.php | 134 ++++++ .../Zend/Gdata/Photos/_files/TestAlbumEntry.xml | 40 ++ .../Zend/Gdata/Photos/_files/TestAlbumFeed.xml | 139 ++++++ .../Zend/Gdata/Photos/_files/TestCommentEntry.xml | 21 + .../Zend/Gdata/Photos/_files/TestPhotoEntry.xml | 51 +++ .../Zend/Gdata/Photos/_files/TestPhotoFeed.xml | 87 ++++ .../Zend/Gdata/Photos/_files/TestTagEntry.xml | 14 + .../Zend/Gdata/Photos/_files/TestUserEntry.xml | 19 + .../Zend/Gdata/Photos/_files/TestUserFeed.xml | 132 ++++++ zend/tests/Zend/Gdata/Photos/_files/test.jpg | Bin 0 -> 14249 bytes 20 files changed, 3578 insertions(+) create mode 100755 zend/tests/Zend/Gdata/Photos/PhotosAlbumEntryTest.php create mode 100755 zend/tests/Zend/Gdata/Photos/PhotosAlbumFeedTest.php create mode 100755 zend/tests/Zend/Gdata/Photos/PhotosAlbumQueryTest.php create mode 100755 zend/tests/Zend/Gdata/Photos/PhotosCommentEntryTest.php create mode 100755 zend/tests/Zend/Gdata/Photos/PhotosPhotoEntryTest.php create mode 100755 zend/tests/Zend/Gdata/Photos/PhotosPhotoFeedTest.php create mode 100755 zend/tests/Zend/Gdata/Photos/PhotosPhotoQueryTest.php create mode 100755 zend/tests/Zend/Gdata/Photos/PhotosTagEntryTest.php create mode 100755 zend/tests/Zend/Gdata/Photos/PhotosUserEntryTest.php create mode 100755 zend/tests/Zend/Gdata/Photos/PhotosUserFeedTest.php create mode 100755 zend/tests/Zend/Gdata/Photos/PhotosUserQueryTest.php create mode 100755 zend/tests/Zend/Gdata/Photos/_files/TestAlbumEntry.xml create mode 100755 zend/tests/Zend/Gdata/Photos/_files/TestAlbumFeed.xml create mode 100755 zend/tests/Zend/Gdata/Photos/_files/TestCommentEntry.xml create mode 100755 zend/tests/Zend/Gdata/Photos/_files/TestPhotoEntry.xml create mode 100755 zend/tests/Zend/Gdata/Photos/_files/TestPhotoFeed.xml create mode 100755 zend/tests/Zend/Gdata/Photos/_files/TestTagEntry.xml create mode 100755 zend/tests/Zend/Gdata/Photos/_files/TestUserEntry.xml create mode 100755 zend/tests/Zend/Gdata/Photos/_files/TestUserFeed.xml create mode 100755 zend/tests/Zend/Gdata/Photos/_files/test.jpg (limited to 'zend/tests/Zend/Gdata/Photos') diff --git a/zend/tests/Zend/Gdata/Photos/PhotosAlbumEntryTest.php b/zend/tests/Zend/Gdata/Photos/PhotosAlbumEntryTest.php new file mode 100755 index 0000000..3e3cc6e --- /dev/null +++ b/zend/tests/Zend/Gdata/Photos/PhotosAlbumEntryTest.php @@ -0,0 +1,364 @@ +albumEntry = new Zend_Gdata_Photos_AlbumEntry($albumEntryText); + } + + /** + * Verify that a given property is set to a specific value + * and that the getter and magic variable return the same value. + * + * @param object $obj The object to be interrogated. + * @param string $name The name of the property to be verified. + * @param object $value The expected value of the property. + */ + protected function verifyProperty($obj, $name, $value) + { + $propName = $name; + $propGetter = "get" . ucfirst($name); + + $this->assertEquals($obj->$propGetter(), $obj->$propName); + $this->assertEquals($value, $obj->$propGetter()); + } + + /** + * Verify that a given property is set to a specific value + * and that the getter and magic variable return the same value. + * + * @param object $obj The object to be interrogated. + * @param string $name The name of the property to be verified. + * @param string $secondName 2nd level accessor function name + * @param object $value The expected value of the property. + */ + protected function verifyProperty2($obj, $name, $secondName, $value) + { + $propName = $name; + $propGetter = "get" . ucfirst($name); + $secondGetter = "get" . ucfirst($secondName); + + $this->assertEquals($obj->$propGetter(), $obj->$propName); + $this->assertEquals($value, $obj->$propGetter()->$secondGetter()); + } + + /** + * Verify that a given property is set to a specific value, + * that it keeps that value when set using the setter, + * and that the getter and magic variable return the same value. + * + * @param object $obj The object to be interrogated. + * @param string $name The name of the property to be verified. + * @param string $secondName 2nd level accessor function name + * @param object $value The expected value of the property. + */ + protected function verifyProperty3($obj, $name, $secondName, $value) + { + $propName = $name; + $propGetter = "get" . ucfirst($name); + $propSetter = "set" . ucfirst($name); + $secondGetter = "get" . ucfirst($secondName); + $secondSetter = "set" . ucfirst($secondName); + + $this->assertEquals($obj->$propGetter(), $obj->$propName); + $obj->$propSetter($obj->$propName); + $this->assertEquals($value, $obj->$propGetter()->$secondGetter()); + } + + /** + * Check for the existence of an and verify that they + * contain the expected values. + */ + public function testAuthor() + { + $entry = $this->albumEntry; + + // Assert that the entry's author is correct + $entryAuthor = $entry->getAuthor(); + $this->assertEquals($entryAuthor, $entry->author); + $this->assertEquals(1, count($entryAuthor)); + $this->assertTrue($entryAuthor[0] instanceof Zend_Gdata_App_Extension_Author); + $this->verifyProperty2($entryAuthor[0], "name", "text", "sample"); + $this->assertTrue($entryAuthor[0]->getUri() instanceof Zend_Gdata_App_Extension_Uri); + $this->verifyProperty2($entryAuthor[0], "uri", "text", "http://picasaweb.google.com/sample.user"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testId() + { + $entry = $this->albumEntry; + + // Assert that the entry's ID is correct + $this->assertTrue($entry->getId() instanceof Zend_Gdata_App_Extension_Id); + $this->verifyProperty2($entry, "id", "text", + "http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testPublished() + { + $entry = $this->albumEntry; + + // Assert that the photo entry has an Atom Published object + $this->assertTrue($entry->getPublished() instanceof Zend_Gdata_App_Extension_Published); + $this->verifyProperty2($entry, "published", "text", "2007-09-05T07:00:00.000Z"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testUpdated() + { + $entry = $this->albumEntry; + + // Assert that the entry's updated date is correct + $this->assertTrue($entry->getUpdated() instanceof Zend_Gdata_App_Extension_Updated); + $this->verifyProperty2($entry, "updated", "text", + "2007-09-05T20:49:24.000Z"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testTitle() + { + $entry = $this->albumEntry; + + // Assert that the entry's title is correct + $this->assertTrue($entry->getTitle() instanceof Zend_Gdata_App_Extension_Title); + $this->verifyProperty2($entry, "title", "text", "Test"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoUser() + { + $entry = $this->albumEntry; + + // Assert that the entry's title is correct + $this->assertTrue($entry->getGphotoUser() instanceof Zend_Gdata_Photos_Extension_User); + $this->verifyProperty2($entry, "gphotoUser", "text", + "sample.user"); + $this->verifyProperty3($entry, "gphotoUser", "text", + "sample.user"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoNickname() + { + $entry = $this->albumEntry; + + // Assert that the entry's title is correct + $this->assertTrue($entry->getGphotoNickname() instanceof Zend_Gdata_Photos_Extension_Nickname); + $this->verifyProperty2($entry, "gphotoNickname", "text", + "sample"); + $this->verifyProperty3($entry, "gphotoNickname", "text", + "sample"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoName() + { + $entry = $this->albumEntry; + + // Assert that the entry's title is correct + $this->assertTrue($entry->getGphotoName() instanceof Zend_Gdata_Photos_Extension_Name); + $this->verifyProperty2($entry, "gphotoName", "text", + "Test"); + $this->verifyProperty3($entry, "gphotoName", "text", + "Test"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoId() + { + $entry = $this->albumEntry; + + // Assert that the entry's title is correct + $this->assertTrue($entry->getGphotoId() instanceof Zend_Gdata_Photos_Extension_Id); + $this->verifyProperty2($entry, "gphotoId", "text", + "1"); + $this->verifyProperty3($entry, "gphotoId", "text", + "1"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoLocation() + { + $entry = $this->albumEntry; + + // Assert that the entry's title is correct + $this->assertTrue($entry->getGphotoLocation() instanceof Zend_Gdata_Photos_Extension_Location); + $this->verifyProperty2($entry, "gphotoLocation", "text", + ""); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoAccess() + { + $entry = $this->albumEntry; + + // Assert that the entry's title is correct + $this->assertTrue($entry->getGphotoAccess() instanceof Zend_Gdata_Photos_Extension_Access); + $this->verifyProperty2($entry, "gphotoAccess", "text", + "public"); + $this->verifyProperty3($entry, "gphotoAccess", "text", + "public"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoTimestamp() + { + $entry = $this->albumEntry; + + // Assert that the entry's title is correct + $this->assertTrue($entry->getGphotoTimestamp() instanceof Zend_Gdata_Photos_Extension_Timestamp); + $this->verifyProperty2($entry, "gphotoTimestamp", "text", + "1188975600000"); + $this->verifyProperty3($entry, "gphotoTimestamp", "text", + "1188975600000"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoNumPhotos() + { + $entry = $this->albumEntry; + + // Assert that the entry's title is correct + $this->assertTrue($entry->getGphotoNumPhotos() instanceof Zend_Gdata_Photos_Extension_NumPhotos); + $this->verifyProperty2($entry, "gphotoNumPhotos", "text", + "2"); + $this->verifyProperty3($entry, "gphotoNumPhotos", "text", + "2"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoCommentingEnabled() + { + $entry = $this->albumEntry; + + // Assert that the entry's title is correct + $this->assertTrue($entry->getGphotoCommentingEnabled() instanceof Zend_Gdata_Photos_Extension_CommentingEnabled); + $this->verifyProperty2($entry, "gphotoCommentingEnabled", "text", + "true"); + $this->verifyProperty3($entry, "gphotoCommentingEnabled", "text", + "true"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoCommentCount() + { + $entry = $this->albumEntry; + + // Assert that the entry's title is correct + $this->assertTrue($entry->getGphotoCommentCount() instanceof Zend_Gdata_Photos_Extension_CommentCount); + $this->verifyProperty2($entry, "gphotoCommentCount", "text", + "0"); + $this->verifyProperty3($entry, "gphotoCommentCount", "text", + "0"); + } + + /** + * Check for the existence of a + */ + public function testMediaGroup() + { + $entry = $this->albumEntry; + + // Assert that the entry's media group exists + $this->assertTrue($entry->getMediaGroup() instanceof Zend_Gdata_Media_Extension_MediaGroup); + } + + /** + * Check for the geo data and verify that it contains the expected values + */ + public function testGeoData() + { + $geoRssWhere = $this->albumEntry->geoRssWhere; + $point = $geoRssWhere->point; + $pos = $point->pos; + $this->assertEquals("42.87194 13.56738", $pos->text); + } + +} diff --git a/zend/tests/Zend/Gdata/Photos/PhotosAlbumFeedTest.php b/zend/tests/Zend/Gdata/Photos/PhotosAlbumFeedTest.php new file mode 100755 index 0000000..0dcd759 --- /dev/null +++ b/zend/tests/Zend/Gdata/Photos/PhotosAlbumFeedTest.php @@ -0,0 +1,469 @@ +albumFeed = new Zend_Gdata_Photos_AlbumFeed($albumFeedText); + } + + /** + * Verify that a given property is set to a specific value + * and that the getter and magic variable return the same value. + * + * @param object $obj The object to be interrogated. + * @param string $name The name of the property to be verified. + * @param object $value The expected value of the property. + */ + protected function verifyProperty($obj, $name, $value) + { + $propName = $name; + $propGetter = "get" . ucfirst($name); + + $this->assertEquals($obj->$propGetter(), $obj->$propName); + $this->assertEquals($value, $obj->$propGetter()); + } + + /** + * Verify that a given property is set to a specific value + * and that the getter and magic variable return the same value. + * + * @param object $obj The object to be interrogated. + * @param string $name The name of the property to be verified. + * @param string $secondName 2nd level accessor function name + * @param object $value The expected value of the property. + */ + protected function verifyProperty2($obj, $name, $secondName, $value) + { + $propName = $name; + $propGetter = "get" . ucfirst($name); + $secondGetter = "get" . ucfirst($secondName); + + $this->assertEquals($obj->$propGetter(), $obj->$propName); + $this->assertEquals($value, $obj->$propGetter()->$secondGetter()); + } + + /** + * Verify that a given property is set to a specific value, + * that it keeps that value when set using the setter, + * and that the getter and magic variable return the same value. + * + * @param object $obj The object to be interrogated. + * @param string $name The name of the property to be verified. + * @param string $secondName 2nd level accessor function name + * @param object $value The expected value of the property. + */ + protected function verifyProperty3($obj, $name, $secondName, $value) + { + $propName = $name; + $propGetter = "get" . ucfirst($name); + $propSetter = "set" . ucfirst($name); + $secondGetter = "get" . ucfirst($secondName); + $secondSetter = "set" . ucfirst($secondName); + + $this->assertEquals($obj->$propGetter(), $obj->$propName); + $obj->$propSetter($obj->$propName); + $this->assertEquals($value, $obj->$propGetter()->$secondGetter()); + } + + /** + * Convert sample feed to XML then back to objects. Ensure that + * all objects are instances of appropriate entry type and object count matches. + */ + public function testAlbumFeedToAndFromString() + { + $entryCount = 0; + foreach ($this->albumFeed as $entry) { + $entryCount++; + $this->assertTrue($entry instanceof Zend_Gdata_Photos_PhotoEntry || + $entry instanceof Zend_Gdata_Photos_TagEntry); + } + $this->assertTrue($entryCount > 0); + + /* Grab XML from $this->albumFeed and convert back to objects */ + $newListFeed = new Zend_Gdata_Photos_UserFeed( + $this->albumFeed->saveXML()); + $newEntryCount = 0; + foreach ($newListFeed as $entry) { + $newEntryCount++; + $this->assertTrue($entry instanceof Zend_Gdata_Photos_PhotoEntry || + $entry instanceof Zend_Gdata_Photos_TagEntry); + } + $this->assertEquals($entryCount, $newEntryCount); + } + + /** + * Ensure that the number of entries equals the number + * of entries defined in the sample file. + */ + public function testEntryCount() + { + $entryCount = 0; + foreach ($this->albumFeed as $entry) { + $entryCount++; + } + $this->assertEquals(4, $entryCount); + } + + /** + * Check for the existence of an and verify that they + * contain the expected values. + */ + public function testAuthor() + { + $feed = $this->albumFeed; + + // Assert that the feed's author is correct + $feedAuthor = $feed->getAuthor(); + $this->assertEquals($feedAuthor, $feed->author); + $this->assertEquals(1, count($feedAuthor)); + $this->assertTrue($feedAuthor[0] instanceof Zend_Gdata_App_Extension_Author); + $this->verifyProperty2($feedAuthor[0], "name", "text", "sample"); + $this->assertTrue($feedAuthor[0]->getUri() instanceof Zend_Gdata_App_Extension_Uri); + $this->verifyProperty2($feedAuthor[0], "uri", "text", "http://picasaweb.google.com/sample.user"); + + // Assert that each entry has valid author data + foreach ($feed as $entry) { + if ($entry instanceof Zend_Gdata_Photos_AlbumEntry) { + $entryAuthor = $entry->getAuthor(); + $this->assertEquals(1, count($entryAuthor)); + $this->verifyProperty2($entryAuthor[0], "name", "text", "sample"); + $this->verifyProperty2($entryAuthor[0], "uri", "text", "http://picasaweb.google.com/sample.user"); + } + } + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testId() + { + $feed = $this->albumFeed; + + // Assert that the feed's ID is correct + $this->assertTrue($feed->getId() instanceof Zend_Gdata_App_Extension_Id); + $this->verifyProperty2($feed, "id", "text", + "http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1"); + + // Assert that all entries have an Atom ID object + foreach ($feed as $entry) { + $this->assertTrue($entry->getId() instanceof Zend_Gdata_App_Extension_Id); + } + + // Assert one of the entry's IDs + $entry = $feed[0]; + $this->verifyProperty2($entry, "id", "text", + "http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/2"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testPublished() + { + $feed = $this->albumFeed; + + // Assert that all photo entries have an Atom Published object + foreach ($feed as $entry) { + if ($entry instanceof Zend_Gdata_Photos_PhotoEntry) { + $this->assertTrue($entry->getPublished() instanceof Zend_Gdata_App_Extension_Published); + } + } + + // Assert one of the entry's Published dates + $entry = $feed[0]; + $this->verifyProperty2($entry, "published", "text", "2007-09-05T20:49:23.000Z"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testUpdated() + { + $feed = $this->albumFeed; + + // Assert that the feed's updated date is correct + $this->assertTrue($feed->getUpdated() instanceof Zend_Gdata_App_Extension_Updated); + $this->verifyProperty2($feed, "updated", "text", + "2007-09-21T18:23:05.000Z"); + + // Assert that all entries have an Atom Updated object + foreach ($feed as $entry) { + $this->assertTrue($entry->getUpdated() instanceof Zend_Gdata_App_Extension_Updated); + } + + // Assert one of the entry's Updated dates + $entry = $feed[0]; + $this->verifyProperty2($entry, "updated", "text", "2007-09-21T18:23:05.000Z"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testTitle() + { + $feed = $this->albumFeed; + + // Assert that the feed's title is correct + $this->assertTrue($feed->getTitle() instanceof Zend_Gdata_App_Extension_Title); + $this->verifyProperty2($feed, "title", "text", "Test"); + + // Assert that all entries have an Atom ID object + foreach ($feed as $entry) { + $this->assertTrue($entry->getTitle() instanceof Zend_Gdata_App_Extension_Title); + } + + // Assert one of the entry's Titles + $entry = $feed[0]; + $this->verifyProperty2($entry, "title", "text", "Aqua Blue.jpg"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testSubtitle() + { + $feed = $this->albumFeed; + + // Assert that the feed's title is correct + $this->assertTrue($feed->getSubtitle() instanceof Zend_Gdata_App_Extension_Subtitle); + $this->verifyProperty2($feed, "subtitle", "text", + ""); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGenerator() + { + $feed = $this->albumFeed; + + // Assert that the feed's generator is correct + $this->assertTrue($feed->getGenerator() instanceof Zend_Gdata_App_Extension_Generator); + $this->verifyProperty2($feed, "generator", "version", "1.00"); + $this->verifyProperty2($feed, "generator", "uri", "http://picasaweb.google.com/"); + $this->verifyProperty2($feed, "generator", "text", "Picasaweb"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testIcon() + { + $feed = $this->albumFeed; + + // Assert that the feed's title is correct + $this->assertTrue($feed->getIcon() instanceof Zend_Gdata_App_Extension_Icon); + $this->verifyProperty2($feed, "icon", "text", + "http://lh6.google.com/sample.user/Rt8WNoDZEJE/AAAAAAAAABk/HQGlDhpIgWo/s160-c/Test.jpg"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoUser() + { + $feed = $this->albumFeed; + + // Assert that the feed's title is correct + $this->assertTrue($feed->getGphotoUser() instanceof Zend_Gdata_Photos_Extension_User); + $this->verifyProperty2($feed, "gphotoUser", "text", + "sample.user"); + $this->verifyProperty3($feed, "gphotoUser", "text", + "sample.user"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoNickname() + { + $feed = $this->albumFeed; + + // Assert that the feed's title is correct + $this->assertTrue($feed->getGphotoNickname() instanceof Zend_Gdata_Photos_Extension_Nickname); + $this->verifyProperty2($feed, "gphotoNickname", "text", + "sample"); + $this->verifyProperty3($feed, "gphotoNickname", "text", + "sample"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoName() + { + $feed = $this->albumFeed; + + // Assert that the feed's title is correct + $this->assertTrue($feed->getGphotoName() instanceof Zend_Gdata_Photos_Extension_Name); + $this->verifyProperty2($feed, "gphotoName", "text", + "Test"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoId() + { + $feed = $this->albumFeed; + + // Assert that the feed's title is correct + $this->assertTrue($feed->getGphotoId() instanceof Zend_Gdata_Photos_Extension_Id); + $this->verifyProperty2($feed, "gphotoId", "text", + "1"); + $this->verifyProperty3($feed, "gphotoId", "text", + "1"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoLocation() + { + $feed = $this->albumFeed; + + // Assert that the feed's title is correct + $this->assertTrue($feed->getGphotoLocation() instanceof Zend_Gdata_Photos_Extension_Location); + $this->verifyProperty2($feed, "gphotoLocation", "text", + ""); + $this->verifyProperty3($feed, "gphotoLocation", "text", + ""); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoAccess() + { + $feed = $this->albumFeed; + + // Assert that the feed's title is correct + $this->assertTrue($feed->getGphotoAccess() instanceof Zend_Gdata_Photos_Extension_Access); + $this->verifyProperty2($feed, "gphotoAccess", "text", + "public"); + $this->verifyProperty3($feed, "gphotoAccess", "text", + "public"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoTimestamp() + { + $feed = $this->albumFeed; + + // Assert that the feed's title is correct + $this->assertTrue($feed->getGphotoTimestamp() instanceof Zend_Gdata_Photos_Extension_Timestamp); + $this->verifyProperty2($feed, "gphotoTimestamp", "text", + "1188975600000"); + $this->verifyProperty3($feed, "gphotoTimestamp", "text", + "1188975600000"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoNumPhotos() + { + $feed = $this->albumFeed; + + // Assert that the feed's title is correct + $this->assertTrue($feed->getGphotoNumPhotos() instanceof Zend_Gdata_Photos_Extension_NumPhotos); + $this->verifyProperty2($feed, "gphotoNumPhotos", "text", + "2"); + $this->verifyProperty3($feed, "gphotoNumPhotos", "text", + "2"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoCommentingEnabled() + { + $feed = $this->albumFeed; + + // Assert that the feed's title is correct + $this->assertTrue($feed->getGphotoCommentingEnabled() instanceof Zend_Gdata_Photos_Extension_CommentingEnabled); + $this->verifyProperty2($feed, "gphotoCommentingEnabled", "text", + "true"); + $this->verifyProperty3($feed, "gphotoCommentingEnabled", "text", + "true"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoCommentCount() + { + $feed = $this->albumFeed; + + // Assert that the feed's title is correct + $this->assertTrue($feed->getGphotoCommentCount() instanceof Zend_Gdata_Photos_Extension_CommentCount); + $this->verifyProperty2($feed, "gphotoCommentCount", "text", + "0"); + $this->verifyProperty3($feed, "gphotoCommentCount", "text", + "0"); + } + +} diff --git a/zend/tests/Zend/Gdata/Photos/PhotosAlbumQueryTest.php b/zend/tests/Zend/Gdata/Photos/PhotosAlbumQueryTest.php new file mode 100755 index 0000000..7035535 --- /dev/null +++ b/zend/tests/Zend/Gdata/Photos/PhotosAlbumQueryTest.php @@ -0,0 +1,198 @@ +setUser("sample.user"); + $query->setAlbumId("1"); + + $generatedString = $query->getQueryUrl(); + + // Assert that the generated query matches the correct one + $this->assertEquals($queryString, $generatedString); + + $queryString = "https://picasaweb.google.com/data/feed/api/user/sample.user/album/test"; + + $query->setAlbumId(null); + $query->setAlbumName("test"); + + $generatedString = $query->getQueryUrl(); + + // Assert that the generated query matches the correct one + $this->assertEquals($queryString, $generatedString); + } + + /** + * Check for thrown exceptions upon improper albumname/id setting + */ + public function testAlbumQueryExceptions() + { + $query = new Zend_Gdata_Photos_AlbumQuery(); + $query->setUser("sample.user"); + + try { + $generatedString = $query->getQueryUrl(); + } catch (Exception $e) { + $this->assertTrue($e instanceof Zend_Gdata_App_InvalidArgumentException); + } + + $query->setAlbumId("1"); + $query->setAlbumName("test"); + + try { + $generatedString = $query->getQueryUrl(); + } catch (Exception $e) { + $this->assertTrue($e instanceof Zend_Gdata_App_InvalidArgumentException); + } + } + + /** + * Check the consistency of an album feed request + * Projection is set to base + */ + public function testBaseAlbumQuery() + { + $queryString = "https://picasaweb.google.com/data/feed/base/user/sample.user/albumid/1"; + + $query = new Zend_Gdata_Photos_AlbumQuery(); + $query->setUser("sample.user"); + $query->setAlbumId("1"); + $query->setProjection("base"); + + $generatedString = $query->getQueryUrl(); + + // Assert that the generated query matches the correct one + $this->assertEquals($queryString, $generatedString); + } + + /** + * Check the consistency of an album feed request filtered + * for a specific tag + */ + public function testTagFilterAlbumQuery() + { + $queryString = "https://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1?tag=test"; + + $query = new Zend_Gdata_Photos_AlbumQuery(); + $query->setUser("sample.user"); + $query->setAlbumId("1"); + $query->setTag("test"); + + $generatedString = $query->getQueryUrl(); + + // Assert that the generated query matches the correct one + $this->assertEquals($queryString, $generatedString); + } + + /** + * Check the consistency of an album feed request for private data + */ + public function testPrivateAlbumQuery() + { + $queryString = "https://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1?access=private"; + + $query = new Zend_Gdata_Photos_AlbumQuery(); + $query->setUser("sample.user"); + $query->setAlbumId("1"); + $query->setAccess("private"); + + $generatedString = $query->getQueryUrl(); + + // Assert that the generated query matches the correct one + $this->assertEquals($queryString, $generatedString); + } + + /** + * Check the consistency of an album feed request for specifically-sized thumbnails + */ + public function testThumbnailAlbumQuery() + { + $queryString = "https://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1?thumbsize=72"; + + $query = new Zend_Gdata_Photos_AlbumQuery(); + $query->setUser("sample.user"); + $query->setAlbumId("1"); + $query->setThumbsize("72"); + + $generatedString = $query->getQueryUrl(); + + // Assert that the set thumbsize is correct + $this->assertEquals("72", $query->getThumbsize()); + + // Assert that the generated query matches the correct one + $this->assertEquals($queryString, $generatedString); + } + + /** + * Check the consistency of an album feed request for specifically-sized images + */ + public function testImgAlbumQuery() + { + $queryString = "https://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1?imgmax=800"; + + $query = new Zend_Gdata_Photos_AlbumQuery(); + $query->setUser("sample.user"); + $query->setAlbumId("1"); + $query->setImgMax("800"); + + // Assert that the set ImgMax is correct + $this->assertEquals("800", $query->getImgMax()); + + $generatedString = $query->getQueryUrl(); + + // Assert that the generated query matches the correct one + $this->assertEquals($queryString, $generatedString); + + // Check that ImgMax is set back to null + $queryString = "https://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1"; + $query->setImgMax(null); + + $generatedString = $query->getQueryUrl(); + + // Assert that the generated query matches the correct one + $this->assertEquals($queryString, $generatedString); + } + +} diff --git a/zend/tests/Zend/Gdata/Photos/PhotosCommentEntryTest.php b/zend/tests/Zend/Gdata/Photos/PhotosCommentEntryTest.php new file mode 100755 index 0000000..b2f1a08 --- /dev/null +++ b/zend/tests/Zend/Gdata/Photos/PhotosCommentEntryTest.php @@ -0,0 +1,229 @@ +commentEntry = new Zend_Gdata_Photos_CommentEntry($commentEntryText); + } + + /** + * Verify that a given property is set to a specific value + * and that the getter and magic variable return the same value. + * + * @param object $obj The object to be interrogated. + * @param string $name The name of the property to be verified. + * @param object $value The expected value of the property. + */ + protected function verifyProperty($obj, $name, $value) + { + $propName = $name; + $propGetter = "get" . ucfirst($name); + + $this->assertEquals($obj->$propGetter(), $obj->$propName); + $this->assertEquals($value, $obj->$propGetter()); + } + + /** + * Verify that a given property is set to a specific value + * and that the getter and magic variable return the same value. + * + * @param object $obj The object to be interrogated. + * @param string $name The name of the property to be verified. + * @param string $secondName 2nd level accessor function name + * @param object $value The expected value of the property. + */ + protected function verifyProperty2($obj, $name, $secondName, $value) + { + $propName = $name; + $propGetter = "get" . ucfirst($name); + $secondGetter = "get" . ucfirst($secondName); + + $this->assertEquals($obj->$propGetter(), $obj->$propName); + $this->assertEquals($value, $obj->$propGetter()->$secondGetter()); + } + + /** + * Verify that a given property is set to a specific value, + * that it keeps that value when set using the setter, + * and that the getter and magic variable return the same value. + * + * @param object $obj The object to be interrogated. + * @param string $name The name of the property to be verified. + * @param string $secondName 2nd level accessor function name + * @param object $value The expected value of the property. + */ + protected function verifyProperty3($obj, $name, $secondName, $value) + { + $propName = $name; + $propGetter = "get" . ucfirst($name); + $propSetter = "set" . ucfirst($name); + $secondGetter = "get" . ucfirst($secondName); + $secondSetter = "set" . ucfirst($secondName); + + $this->assertEquals($obj->$propGetter(), $obj->$propName); + $obj->$propSetter($obj->$propName); + $this->assertEquals($value, $obj->$propGetter()->$secondGetter()); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testId() + { + $entry = $this->commentEntry; + + // Assert that the entry's ID is correct + $this->assertTrue($entry->getId() instanceof Zend_Gdata_App_Extension_Id); + $this->verifyProperty2($entry, "id", "text", + "http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/100/commentid/5"); + } + + /** + * Check for the existence of an and verify that they + * contain the expected values. + */ + public function testAuthor() + { + $entry = $this->commentEntry; + + // Assert that the entry's author is correct + $entryAuthor = $entry->getAuthor(); + $this->assertEquals($entryAuthor, $entry->author); + $this->assertEquals(1, count($entryAuthor)); + $this->assertTrue($entryAuthor[0] instanceof Zend_Gdata_App_Extension_Author); + $this->verifyProperty2($entryAuthor[0], "name", "text", "sample"); + $this->assertTrue($entryAuthor[0]->getUri() instanceof Zend_Gdata_App_Extension_Uri); + $this->verifyProperty2($entryAuthor[0], "uri", "text", "http://picasaweb.google.com/sample.user"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testPublished() + { + $entry = $this->commentEntry; + + // Assert that the photo entry has an Atom Published object + $this->assertTrue($entry->getPublished() instanceof Zend_Gdata_App_Extension_Published); + $this->verifyProperty2($entry, "published", "text", "2007-09-21T18:22:53.000Z"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testUpdated() + { + $entry = $this->commentEntry; + + // Assert that the entry's updated date is correct + $this->assertTrue($entry->getUpdated() instanceof Zend_Gdata_App_Extension_Updated); + $this->verifyProperty2($entry, "updated", "text", + "2007-09-21T18:22:53.000Z"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testTitle() + { + $entry = $this->commentEntry; + + // Assert that the entry's title is correct + $this->assertTrue($entry->getTitle() instanceof Zend_Gdata_App_Extension_Title); + $this->verifyProperty2($entry, "title", "text", "sample"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testContent() + { + $entry = $this->commentEntry; + + // Assert that the entry's title is correct + $this->assertTrue($entry->getContent() instanceof Zend_Gdata_App_Extension_Content); + $this->verifyProperty2($entry, "content", "text", "test comment"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoId() + { + $entry = $this->commentEntry; + + // Assert that the entry's title is correct + $this->assertTrue($entry->getGphotoId() instanceof Zend_Gdata_Photos_Extension_Id); + $this->verifyProperty2($entry, "gphotoId", "text", + "5"); + $this->verifyProperty3($entry, "gphotoId", "text", + "5"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoPhotoId() + { + $entry = $this->commentEntry; + + // Assert that the entry's title is correct + $this->assertTrue($entry->getGphotoPhotoId() instanceof Zend_Gdata_Photos_Extension_PhotoId); + $this->verifyProperty2($entry, "gphotoPhotoId", "text", + "100"); + $this->verifyProperty3($entry, "gphotoPhotoId", "text", + "100"); + } + +} diff --git a/zend/tests/Zend/Gdata/Photos/PhotosPhotoEntryTest.php b/zend/tests/Zend/Gdata/Photos/PhotosPhotoEntryTest.php new file mode 100755 index 0000000..1684454 --- /dev/null +++ b/zend/tests/Zend/Gdata/Photos/PhotosPhotoEntryTest.php @@ -0,0 +1,395 @@ +photoEntry = new Zend_Gdata_Photos_PhotoEntry($photoEntryText); + } + + /** + * Verify that a given property is set to a specific value + * and that the getter and magic variable return the same value. + * + * @param object $obj The object to be interrogated. + * @param string $name The name of the property to be verified. + * @param object $value The expected value of the property. + */ + protected function verifyProperty($obj, $name, $value) + { + $propName = $name; + $propGetter = "get" . ucfirst($name); + + $this->assertEquals($obj->$propGetter(), $obj->$propName); + $this->assertEquals($value, $obj->$propGetter()); + } + + /** + * Verify that a given property is set to a specific value + * and that the getter and magic variable return the same value. + * + * @param object $obj The object to be interrogated. + * @param string $name The name of the property to be verified. + * @param string $secondName 2nd level accessor function name + * @param object $value The expected value of the property. + */ + protected function verifyProperty2($obj, $name, $secondName, $value) + { + $propName = $name; + $propGetter = "get" . ucfirst($name); + $secondGetter = "get" . ucfirst($secondName); + + $this->assertEquals($obj->$propGetter(), $obj->$propName); + $this->assertEquals($value, $obj->$propGetter()->$secondGetter()); + } + + /** + * Verify that a given property is set to a specific value, + * that it keeps that value when set using the setter, + * and that the getter and magic variable return the same value. + * + * @param object $obj The object to be interrogated. + * @param string $name The name of the property to be verified. + * @param string $secondName 2nd level accessor function name + * @param object $value The expected value of the property. + */ + protected function verifyProperty3($obj, $name, $secondName, $value) + { + $propName = $name; + $propGetter = "get" . ucfirst($name); + $propSetter = "set" . ucfirst($name); + $secondGetter = "get" . ucfirst($secondName); + $secondSetter = "set" . ucfirst($secondName); + + $this->assertEquals($obj->$propGetter(), $obj->$propName); + $obj->$propSetter($obj->$propName); + $this->assertEquals($value, $obj->$propGetter()->$secondGetter()); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testId() + { + $entry = $this->photoEntry; + + // Assert that the entry's ID is correct + $this->assertTrue($entry->getId() instanceof Zend_Gdata_App_Extension_Id); + $this->verifyProperty2($entry, "id", "text", + "http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/100"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testPublished() + { + $entry = $this->photoEntry; + + // Assert that the photo entry has an Atom Published object + $this->assertTrue($entry->getPublished() instanceof Zend_Gdata_App_Extension_Published); + $this->verifyProperty2($entry, "published", "text", "2007-09-05T20:49:24.000Z"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testUpdated() + { + $entry = $this->photoEntry; + + // Assert that the entry's updated date is correct + $this->assertTrue($entry->getUpdated() instanceof Zend_Gdata_App_Extension_Updated); + $this->verifyProperty2($entry, "updated", "text", + "2007-09-21T18:19:38.000Z"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testTitle() + { + $entry = $this->photoEntry; + + // Assert that the entry's title is correct + $this->assertTrue($entry->getTitle() instanceof Zend_Gdata_App_Extension_Title); + $this->verifyProperty2($entry, "title", "text", "Aqua Graphite.jpg"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoId() + { + $entry = $this->photoEntry; + + // Assert that the entry's title is correct + $this->assertTrue($entry->getGphotoId() instanceof Zend_Gdata_Photos_Extension_Id); + $this->verifyProperty2($entry, "gphotoId", "text", + "100"); + $this->verifyProperty3($entry, "gphotoId", "text", + "100"); + } + + /** + * Check for the existance of exif namespaced data and verify that it contains + * the expected value. + */ + public function testExifData() + { + $exifTags = $this->photoEntry->exifTags; + $this->assertTrue($exifTags != null); + $this->assertTrue($exifTags->flash != null); + $this->assertTrue($exifTags->fstop != null); + $this->assertTrue($exifTags->exposure != null); + $this->assertTrue($exifTags->focallength != null); + $this->assertTrue($exifTags->iso != null); + $this->assertTrue($exifTags->time != null); + $this->assertTrue($exifTags->distance != null); + $this->assertTrue($exifTags->make != null); + $this->assertTrue($exifTags->model != null); + $this->assertTrue($exifTags->imageUniqueID != null); + $this->assertEquals("true", $exifTags->flash->text); + $this->assertEquals("11.0", $exifTags->fstop->text); + $this->assertEquals("0.0040", $exifTags->exposure->text); + $this->assertEquals("22.0", $exifTags->focallength->text); + $this->assertEquals("200", $exifTags->iso->text); + $this->assertEquals("1180950900000", $exifTags->time->text); + $this->assertEquals("0.0",$exifTags->distance->text); + $this->assertEquals("Fictitious Camera Company",$exifTags->make->text); + $this->assertEquals("AMAZING-100D",$exifTags->model->text); + $this->assertEquals("a5ce2e36b9df7d3cb081511c72e73926", $exifTags->imageUniqueID->text); + } + + /** + * Check for the geo data and verify that it contains the expected values + */ + public function testGeoData() + { + $geoRssWhere = $this->photoEntry->geoRssWhere; + $point = $geoRssWhere->point; + $pos = $point->pos; + $this->assertEquals("41.87194 12.56738", $pos->text); + } + + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoVersion() + { + $entry = $this->photoEntry; + + // Assert that the entry's version is correct + $this->assertTrue($entry->getGphotoVersion() instanceof Zend_Gdata_Photos_Extension_Version); + $this->verifyProperty2($entry, "gphotoVersion", "text", + "1190398778006402"); + $this->verifyProperty3($entry, "gphotoVersion", "text", + "1190398778006402"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoAlbumId() + { + $entry = $this->photoEntry; + + // Assert that the entry's albumid is correct + $this->assertTrue($entry->getGphotoAlbumId() instanceof Zend_Gdata_Photos_Extension_AlbumId); + $this->verifyProperty2($entry, "gphotoAlbumId", "text", + "1"); + $this->verifyProperty3($entry, "gphotoAlbumId", "text", + "1"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoWidth() + { + $entry = $this->photoEntry; + + // Assert that the entry's width is correct + $this->assertTrue($entry->getGphotoWidth() instanceof Zend_Gdata_Photos_Extension_Width); + $this->verifyProperty2($entry, "gphotoWidth", "text", + "2560"); + $this->verifyProperty3($entry, "gphotoWidth", "text", + "2560"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoHeight() + { + $entry = $this->photoEntry; + + // Assert that the entry's height is correct + $this->assertTrue($entry->getGphotoHeight() instanceof Zend_Gdata_Photos_Extension_Height); + $this->verifyProperty2($entry, "gphotoHeight", "text", + "1600"); + $this->verifyProperty3($entry, "gphotoHeight", "text", + "1600"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoSize() + { + $entry = $this->photoEntry; + + // Assert that the entry's size is correct + $this->assertTrue($entry->getGphotoSize() instanceof Zend_Gdata_Photos_Extension_Size); + $this->verifyProperty2($entry, "gphotoSize", "text", + "798334"); + $this->verifyProperty3($entry, "gphotoSize", "text", + "798334"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoClient() + { + $entry = $this->photoEntry; + + // Assert that the entry's client is correct + $this->assertTrue($entry->getGphotoClient() instanceof Zend_Gdata_Photos_Extension_Client); + $this->verifyProperty2($entry, "gphotoClient", "text", + ""); + $this->verifyProperty3($entry, "gphotoClient", "text", + ""); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoChecksum() + { + $entry = $this->photoEntry; + + // Assert that the entry's checksum is correct + $this->assertTrue($entry->getGphotoChecksum() instanceof Zend_Gdata_Photos_Extension_Checksum); + $this->verifyProperty2($entry, "gphotoChecksum", "text", + ""); + $this->verifyProperty3($entry, "gphotoChecksum", "text", + ""); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoTimestamp() + { + $entry = $this->photoEntry; + + // Assert that the entry's title is correct + $this->assertTrue($entry->getGphotoTimestamp() instanceof Zend_Gdata_Photos_Extension_Timestamp); + $this->verifyProperty2($entry, "gphotoTimestamp", "text", + "1189025363000"); + $this->verifyProperty3($entry, "gphotoTimestamp", "text", + "1189025363000"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoCommentingEnabled() + { + $entry = $this->photoEntry; + + // Assert that the entry's title is correct + $this->assertTrue($entry->getGphotoCommentingEnabled() instanceof Zend_Gdata_Photos_Extension_CommentingEnabled); + $this->verifyProperty2($entry, "gphotoCommentingEnabled", "text", + "true"); + $this->verifyProperty3($entry, "gphotoCommentingEnabled", "text", + "true"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoCommentCount() + { + $entry = $this->photoEntry; + + // Assert that the entry's title is correct + $this->assertTrue($entry->getGphotoCommentCount() instanceof Zend_Gdata_Photos_Extension_CommentCount); + $this->verifyProperty2($entry, "gphotoCommentCount", "text", + "0"); + $this->verifyProperty3($entry, "gphotoCommentCount", "text", + "0"); + } + + /** + * Check for the existence of a + */ + public function testMediaGroup() + { + $entry = $this->photoEntry; + + // Assert that the entry's media group exists + $this->assertTrue($entry->getMediaGroup() instanceof Zend_Gdata_Media_Extension_MediaGroup); + } + +} diff --git a/zend/tests/Zend/Gdata/Photos/PhotosPhotoFeedTest.php b/zend/tests/Zend/Gdata/Photos/PhotosPhotoFeedTest.php new file mode 100755 index 0000000..9f6e093 --- /dev/null +++ b/zend/tests/Zend/Gdata/Photos/PhotosPhotoFeedTest.php @@ -0,0 +1,435 @@ +photoFeed = new Zend_Gdata_Photos_PhotoFeed($photoFeedText); + } + + /** + * Verify that a given property is set to a specific value + * and that the getter and magic variable return the same value. + * + * @param object $obj The object to be interrogated. + * @param string $name The name of the property to be verified. + * @param object $value The expected value of the property. + */ + protected function verifyProperty($obj, $name, $value) + { + $propName = $name; + $propGetter = "get" . ucfirst($name); + + $this->assertEquals($obj->$propGetter(), $obj->$propName); + $this->assertEquals($value, $obj->$propGetter()); + } + + /** + * Verify that a given property is set to a specific value + * and that the getter and magic variable return the same value. + * + * @param object $obj The object to be interrogated. + * @param string $name The name of the property to be verified. + * @param string $secondName 2nd level accessor function name + * @param object $value The expected value of the property. + */ + protected function verifyProperty2($obj, $name, $secondName, $value) + { + $propName = $name; + $propGetter = "get" . ucfirst($name); + $secondGetter = "get" . ucfirst($secondName); + + $this->assertEquals($obj->$propGetter(), $obj->$propName); + $this->assertEquals($value, $obj->$propGetter()->$secondGetter()); + } + + /** + * Verify that a given property is set to a specific value, + * that it keeps that value when set using the setter, + * and that the getter and magic variable return the same value. + * + * @param object $obj The object to be interrogated. + * @param string $name The name of the property to be verified. + * @param string $secondName 2nd level accessor function name + * @param object $value The expected value of the property. + */ + protected function verifyProperty3($obj, $name, $secondName, $value) + { + $propName = $name; + $propGetter = "get" . ucfirst($name); + $propSetter = "set" . ucfirst($name); + $secondGetter = "get" . ucfirst($secondName); + $secondSetter = "set" . ucfirst($secondName); + + $this->assertEquals($obj->$propGetter(), $obj->$propName); + $obj->$propSetter($obj->$propName); + $this->assertEquals($value, $obj->$propGetter()->$secondGetter()); + } + + /** + * Convert sample feed to XML then back to objects. Ensure that + * all objects are instances of appropriate entry type and object count matches. + */ + public function testPhotoFeedToAndFromString() + { + $entryCount = 0; + foreach ($this->photoFeed as $entry) { + $entryCount++; + $this->assertTrue($entry instanceof Zend_Gdata_Photos_CommentEntry || + $entry instanceof Zend_Gdata_Photos_TagEntry); + } + $this->assertTrue($entryCount > 0); + + /* Grab XML from $this->photoFeed and convert back to objects */ + $newListFeed = new Zend_Gdata_Photos_PhotoFeed( + $this->photoFeed->saveXML()); + $newEntryCount = 0; + foreach ($newListFeed as $entry) { + $newEntryCount++; + $this->assertTrue($entry instanceof Zend_Gdata_Photos_CommentEntry || + $entry instanceof Zend_Gdata_Photos_TagEntry); + } + $this->assertEquals($entryCount, $newEntryCount); + } + + /** + * Ensure that the number of entries equals the number + * of entries defined in the sample file. + */ + public function testEntryCount() + { + $entryCount = 0; + foreach ($this->photoFeed as $entry) { + $entryCount++; + } + $this->assertEquals(3, $entryCount); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testId() + { + $feed = $this->photoFeed; + + // Assert that the feed's ID is correct + $this->assertTrue($feed->getId() instanceof Zend_Gdata_App_Extension_Id); + $this->verifyProperty2($feed, "id", "text", + "http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1/photoid/100"); + + // Assert that all entries have an Atom ID object + foreach ($feed as $entry) { + $this->assertTrue($entry->getId() instanceof Zend_Gdata_App_Extension_Id); + } + + // Assert one of the entry's IDs + $entry = $feed[0]; + $this->verifyProperty2($entry, "id", "text", + "http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/100/tag/tag"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testUpdated() + { + $feed = $this->photoFeed; + + // Assert that the feed's updated date is correct + $this->assertTrue($feed->getUpdated() instanceof Zend_Gdata_App_Extension_Updated); + $this->verifyProperty2($feed, "updated", "text", + "2007-09-21T18:23:05.000Z"); + + // Assert that all entries have an Atom Updated object + foreach ($feed as $entry) { + $this->assertTrue($entry->getUpdated() instanceof Zend_Gdata_App_Extension_Updated); + } + + // Assert one of the entry's Updated dates + $entry = $feed[0]; + $this->verifyProperty2($entry, "updated", "text", "2007-09-21T18:23:05.000Z"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testTitle() + { + $feed = $this->photoFeed; + + // Assert that the feed's title is correct + $this->assertTrue($feed->getTitle() instanceof Zend_Gdata_App_Extension_Title); + $this->verifyProperty2($feed, "title", "text", "Aqua Blue.jpg"); + + // Assert that all entries have an Atom ID object + foreach ($feed as $entry) { + $this->assertTrue($entry->getTitle() instanceof Zend_Gdata_App_Extension_Title); + } + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testSubtitle() + { + $feed = $this->photoFeed; + + // Assert that the feed's title is correct + $this->assertTrue($feed->getSubtitle() instanceof Zend_Gdata_App_Extension_Subtitle); + $this->verifyProperty2($feed, "subtitle", "text", + "Blue"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGenerator() + { + $feed = $this->photoFeed; + + // Assert that the feed's generator is correct + $this->assertTrue($feed->getGenerator() instanceof Zend_Gdata_App_Extension_Generator); + $this->verifyProperty2($feed, "generator", "version", "1.00"); + $this->verifyProperty2($feed, "generator", "uri", "http://picasaweb.google.com/"); + $this->verifyProperty2($feed, "generator", "text", "Picasaweb"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testIcon() + { + $feed = $this->photoFeed; + + // Assert that the feed's title is correct + $this->assertTrue($feed->getIcon() instanceof Zend_Gdata_App_Extension_Icon); + $this->verifyProperty2($feed, "icon", "text", + "http://lh4.google.com/sample.user/Rt8WU4DZEKI/AAAAAAAAABY/IVgLqmnzJII/s288/Aqua%20Blue.jpg"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoId() + { + $feed = $this->photoFeed; + + // Assert that the feed's title is correct + $this->assertTrue($feed->getGphotoId() instanceof Zend_Gdata_Photos_Extension_Id); + $this->verifyProperty2($feed, "gphotoId", "text", + "100"); + $this->verifyProperty3($feed, "gphotoId", "text", + "100"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoVersion() + { + $feed = $this->photoFeed; + + // Assert that the feed's version is correct + $this->assertTrue($feed->getGphotoVersion() instanceof Zend_Gdata_Photos_Extension_Version); + $this->verifyProperty2($feed, "gphotoVersion", "text", + "1190398985145172"); + $this->verifyProperty3($feed, "gphotoVersion", "text", + "1190398985145172"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoAlbumId() + { + $feed = $this->photoFeed; + + // Assert that the feed's albumid is correct + $this->assertTrue($feed->getGphotoAlbumId() instanceof Zend_Gdata_Photos_Extension_AlbumId); + $this->verifyProperty2($feed, "gphotoAlbumId", "text", + "1"); + $this->verifyProperty3($feed, "gphotoAlbumId", "text", + "1"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoTimestamp() + { + $feed = $this->photoFeed; + + // Assert that the feed's timestamp is correct + $this->assertTrue($feed->getGphotoTimestamp() instanceof Zend_Gdata_Photos_Extension_Timestamp); + $this->verifyProperty2($feed, "gphotoTimestamp", "text", + "1189025362000"); + $this->verifyProperty3($feed, "gphotoTimestamp", "text", + "1189025362000"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoWidth() + { + $feed = $this->photoFeed; + + // Assert that the feed's width is correct + $this->assertTrue($feed->getGphotoWidth() instanceof Zend_Gdata_Photos_Extension_Width); + $this->verifyProperty2($feed, "gphotoWidth", "text", + "2560"); + $this->verifyProperty3($feed, "gphotoWidth", "text", + "2560"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoHeight() + { + $feed = $this->photoFeed; + + // Assert that the feed's height is correct + $this->assertTrue($feed->getGphotoHeight() instanceof Zend_Gdata_Photos_Extension_Height); + $this->verifyProperty2($feed, "gphotoHeight", "text", + "1600"); + $this->verifyProperty3($feed, "gphotoHeight", "text", + "1600"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoSize() + { + $feed = $this->photoFeed; + + // Assert that the feed's size is correct + $this->assertTrue($feed->getGphotoSize() instanceof Zend_Gdata_Photos_Extension_Size); + $this->verifyProperty2($feed, "gphotoSize", "text", + "883405"); + $this->verifyProperty3($feed, "gphotoSize", "text", + "883405"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoClient() + { + $feed = $this->photoFeed; + + // Assert that the feed's client is correct + $this->assertTrue($feed->getGphotoClient() instanceof Zend_Gdata_Photos_Extension_Client); + $this->verifyProperty2($feed, "gphotoClient", "text", + ""); + $this->verifyProperty3($feed, "gphotoClient", "text", + ""); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoChecksum() + { + $feed = $this->photoFeed; + + // Assert that the feed's checksum is correct + $this->assertTrue($feed->getGphotoChecksum() instanceof Zend_Gdata_Photos_Extension_Checksum); + $this->verifyProperty2($feed, "gphotoChecksum", "text", + ""); + $this->verifyProperty3($feed, "gphotoChecksum", "text", + ""); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoCommentingEnabled() + { + $feed = $this->photoFeed; + + // Assert that the feed's title is correct + $this->assertTrue($feed->getGphotoCommentingEnabled() instanceof Zend_Gdata_Photos_Extension_CommentingEnabled); + $this->verifyProperty2($feed, "gphotoCommentingEnabled", "text", + "true"); + $this->verifyProperty3($feed, "gphotoCommentingEnabled", "text", + "true"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoCommentCount() + { + $feed = $this->photoFeed; + + // Assert that the feed's title is correct + $this->assertTrue($feed->getGphotoCommentCount() instanceof Zend_Gdata_Photos_Extension_CommentCount); + $this->verifyProperty2($feed, "gphotoCommentCount", "text", + "1"); + $this->verifyProperty3($feed, "gphotoCommentCount", "text", + "1"); + } + +} diff --git a/zend/tests/Zend/Gdata/Photos/PhotosPhotoQueryTest.php b/zend/tests/Zend/Gdata/Photos/PhotosPhotoQueryTest.php new file mode 100755 index 0000000..53f9f3e --- /dev/null +++ b/zend/tests/Zend/Gdata/Photos/PhotosPhotoQueryTest.php @@ -0,0 +1,133 @@ +setUser("sample.user"); + $query->setAlbumId("1"); + $query->setPhotoId("1"); + + $generatedString = $query->getQueryUrl(); + + // Assert that the generated query matches the correct one + $this->assertEquals($queryString, $generatedString); + } + + /** + * Check the consistency of a user feed request + * Projection is set to base + */ + public function testBasePhotoQuery() + { + $queryString = "https://picasaweb.google.com/data/feed/base/user/sample.user/albumid/1/photoid/1"; + + $query = new Zend_Gdata_Photos_PhotoQuery(); + $query->setUser("sample.user"); + $query->setAlbumId("1"); + $query->setPhotoId("1"); + $query->setProjection("base"); + + $generatedString = $query->getQueryUrl(); + + // Assert that the generated query matches the correct one + $this->assertEquals($queryString, $generatedString); + } + + /** + * Check for thrown exceptions upon improper photoid setting + */ + public function testPhotoQueryExceptions() + { + $query = new Zend_Gdata_Photos_PhotoQuery(); + $query->setUser("sample.user"); + $query->setAlbumId("1"); + + try { + $generatedString = $query->getQueryUrl(); + } catch (Exception $e) { + $this->assertTrue($e instanceof Zend_Gdata_App_InvalidArgumentException); + } + } + + /** + * Check the consistency of a user feed request filtered + * for a specific tag + */ + public function testTagFilterPhotoQuery() + { + $queryString = "https://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1/photoid/1?tag=test"; + + $query = new Zend_Gdata_Photos_PhotoQuery(); + $query->setUser("sample.user"); + $query->setAlbumId("1"); + $query->setPhotoId("1"); + $query->setTag("test"); + + $generatedString = $query->getQueryUrl(); + + // Assert that the generated query matches the correct one + $this->assertEquals($queryString, $generatedString); + } + + /** + * Check the consistency of a user feed request for private data + */ + public function testPrivatePhotoQuery() + { + $queryString = "https://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1/photoid/1?access=private"; + + $query = new Zend_Gdata_Photos_PhotoQuery(); + $query->setUser("sample.user"); + $query->setAlbumId("1"); + $query->setPhotoId("1"); + $query->setAccess("private"); + + $generatedString = $query->getQueryUrl(); + + // Assert that the generated query matches the correct one + $this->assertEquals($queryString, $generatedString); + } + +} diff --git a/zend/tests/Zend/Gdata/Photos/PhotosTagEntryTest.php b/zend/tests/Zend/Gdata/Photos/PhotosTagEntryTest.php new file mode 100755 index 0000000..e3083a1 --- /dev/null +++ b/zend/tests/Zend/Gdata/Photos/PhotosTagEntryTest.php @@ -0,0 +1,130 @@ +tagEntry = new Zend_Gdata_Photos_TagEntry($tagEntryText); + } + + /** + * Verify that a given property is set to a specific value + * and that the getter and magic variable return the same value. + * + * @param object $obj The object to be interrogated. + * @param string $name The name of the property to be verified. + * @param object $value The expected value of the property. + */ + protected function verifyProperty($obj, $name, $value) + { + $propName = $name; + $propGetter = "get" . ucfirst($name); + + $this->assertEquals($obj->$propGetter(), $obj->$propName); + $this->assertEquals($value, $obj->$propGetter()); + } + + /** + * Verify that a given property is set to a specific value + * and that the getter and magic variable return the same value. + * + * @param object $obj The object to be interrogated. + * @param string $name The name of the property to be verified. + * @param string $secondName 2nd level accessor function name + * @param object $value The expected value of the property. + */ + protected function verifyProperty2($obj, $name, $secondName, $value) + { + $propName = $name; + $propGetter = "get" . ucfirst($name); + $secondGetter = "get" . ucfirst($secondName); + + $this->assertEquals($obj->$propGetter(), $obj->$propName); + $this->assertEquals($value, $obj->$propGetter()->$secondGetter()); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testId() + { + $entry = $this->tagEntry; + + // Assert that the entry's ID is correct + $this->assertTrue($entry->getId() instanceof Zend_Gdata_App_Extension_Id); + $this->verifyProperty2($entry, "id", "text", + "http://picasaweb.google.com/data/entry/api/user/sample.user/tag/tag"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testUpdated() + { + $entry = $this->tagEntry; + + // Assert that the entry's updated date is correct + $this->assertTrue($entry->getUpdated() instanceof Zend_Gdata_App_Extension_Updated); + $this->verifyProperty2($entry, "updated", "text", + "1970-01-01T00:01:01.000Z"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testTitle() + { + $entry = $this->tagEntry; + + // Assert that the entry's title is correct + $this->assertTrue($entry->getTitle() instanceof Zend_Gdata_App_Extension_Title); + $this->verifyProperty2($entry, "title", "text", "tag"); + } + +} diff --git a/zend/tests/Zend/Gdata/Photos/PhotosUserEntryTest.php b/zend/tests/Zend/Gdata/Photos/PhotosUserEntryTest.php new file mode 100755 index 0000000..089f3b5 --- /dev/null +++ b/zend/tests/Zend/Gdata/Photos/PhotosUserEntryTest.php @@ -0,0 +1,228 @@ +userEntry = new Zend_Gdata_Photos_UserEntry($userEntryText); + } + + /** + * Verify that a given property is set to a specific value + * and that the getter and magic variable return the same value. + * + * @param object $obj The object to be interrogated. + * @param string $name The name of the property to be verified. + * @param object $value The expected value of the property. + */ + protected function verifyProperty($obj, $name, $value) + { + $propName = $name; + $propGetter = "get" . ucfirst($name); + + $this->assertEquals($obj->$propGetter(), $obj->$propName); + $this->assertEquals($value, $obj->$propGetter()); + } + + /** + * Verify that a given property is set to a specific value + * and that the getter and magic variable return the same value. + * + * @param object $obj The object to be interrogated. + * @param string $name The name of the property to be verified. + * @param string $secondName 2nd level accessor function name + * @param object $value The expected value of the property. + */ + protected function verifyProperty2($obj, $name, $secondName, $value) + { + $propName = $name; + $propGetter = "get" . ucfirst($name); + $secondGetter = "get" . ucfirst($secondName); + + $this->assertEquals($obj->$propGetter(), $obj->$propName); + $this->assertEquals($value, $obj->$propGetter()->$secondGetter()); + } + + /** + * Verify that a given property is set to a specific value, + * that it keeps that value when set using the setter, + * and that the getter and magic variable return the same value. + * + * @param object $obj The object to be interrogated. + * @param string $name The name of the property to be verified. + * @param string $secondName 2nd level accessor function name + * @param object $value The expected value of the property. + */ + protected function verifyProperty3($obj, $name, $secondName, $value) + { + $propName = $name; + $propGetter = "get" . ucfirst($name); + $propSetter = "set" . ucfirst($name); + $secondGetter = "get" . ucfirst($secondName); + $secondSetter = "set" . ucfirst($secondName); + + $this->assertEquals($obj->$propGetter(), $obj->$propName); + $obj->$propSetter($obj->$propName); + $this->assertEquals($value, $obj->$propGetter()->$secondGetter()); + } + + /** + * Check for the existence of an and verify that they + * contain the expected values. + */ + public function testAuthor() + { + $entry = $this->userEntry; + + // Assert that the entry's author is correct + $entryAuthor = $entry->getAuthor(); + $this->assertEquals($entryAuthor, $entry->author); + $this->assertEquals(1, count($entryAuthor)); + $this->assertTrue($entryAuthor[0] instanceof Zend_Gdata_App_Extension_Author); + $this->verifyProperty2($entryAuthor[0], "name", "text", "sample"); + $this->assertTrue($entryAuthor[0]->getUri() instanceof Zend_Gdata_App_Extension_Uri); + $this->verifyProperty2($entryAuthor[0], "uri", "text", "http://picasaweb.google.com/sample.user"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testId() + { + $entry = $this->userEntry; + + // Assert that the entry's ID is correct + $this->assertTrue($entry->getId() instanceof Zend_Gdata_App_Extension_Id); + $this->verifyProperty2($entry, "id", "text", + "http://picasaweb.google.com/data/entry/api/user/sample.user"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testPublished() + { + $entry = $this->userEntry; + + // Assert that the photo entry has an Atom Published object + $this->assertTrue($entry->getPublished() instanceof Zend_Gdata_App_Extension_Published); + $this->verifyProperty2($entry, "published", "text", "2007-09-24T23:45:49.059Z"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testUpdated() + { + $entry = $this->userEntry; + + // Assert that the entry's updated date is correct + $this->assertTrue($entry->getUpdated() instanceof Zend_Gdata_App_Extension_Updated); + $this->verifyProperty2($entry, "updated", "text", + "2007-09-24T23:45:49.059Z"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testTitle() + { + $entry = $this->userEntry; + + // Assert that the entry's title is correct + $this->assertTrue($entry->getTitle() instanceof Zend_Gdata_App_Extension_Title); + $this->verifyProperty2($entry, "title", "text", "sample.user"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoUser() + { + $entry = $this->userEntry; + + // Assert that the entry's user is correct + $this->assertTrue($entry->getGphotoUser() instanceof Zend_Gdata_Photos_Extension_User); + $this->verifyProperty2($entry, "gphotoUser", "text", "sample.user"); + $this->verifyProperty3($entry, "gphotoUser", "text", "sample.user"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoNickname() + { + $entry = $this->userEntry; + + // Assert that the entry's nickname is correct + $this->assertTrue($entry->getGphotoNickname() instanceof Zend_Gdata_Photos_Extension_Nickname); + $this->verifyProperty2($entry, "gphotoNickname", "text", "sample"); + $this->verifyProperty3($entry, "gphotoNickname", "text", "sample"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoThumbnail() + { + $entry = $this->userEntry; + + // Assert that the entry's thumbnail is correct + $this->assertTrue($entry->getGphotoThumbnail() instanceof Zend_Gdata_Photos_Extension_Thumbnail); + $this->verifyProperty2($entry, "gphotoThumbnail", "text", + "http://lh5.google.com/sample.user/AAAAuZnob5E/AAAAAAAAAAA/EtCbNCdLGxM/s64-c/sample.user"); + $this->verifyProperty3($entry, "gphotoThumbnail", "text", + "http://lh5.google.com/sample.user/AAAAuZnob5E/AAAAAAAAAAA/EtCbNCdLGxM/s64-c/sample.user"); + } + +} diff --git a/zend/tests/Zend/Gdata/Photos/PhotosUserFeedTest.php b/zend/tests/Zend/Gdata/Photos/PhotosUserFeedTest.php new file mode 100755 index 0000000..d40bebb --- /dev/null +++ b/zend/tests/Zend/Gdata/Photos/PhotosUserFeedTest.php @@ -0,0 +1,360 @@ +userFeed = new Zend_Gdata_Photos_UserFeed($userFeedText); + } + + /** + * Verify that a given property is set to a specific value + * and that the getter and magic variable return the same value. + * + * @param object $obj The object to be interrogated. + * @param string $name The name of the property to be verified. + * @param object $value The expected value of the property. + */ + protected function verifyProperty($obj, $name, $value) + { + $propName = $name; + $propGetter = "get" . ucfirst($name); + + $this->assertEquals($obj->$propGetter(), $obj->$propName); + $this->assertEquals($value, $obj->$propGetter()); + } + + /** + * Verify that a given property is set to a specific value + * and that the getter and magic variable return the same value. + * + * @param object $obj The object to be interrogated. + * @param string $name The name of the property to be verified. + * @param string $secondName 2nd level accessor function name + * @param object $value The expected value of the property. + */ + protected function verifyProperty2($obj, $name, $secondName, $value) + { + $propName = $name; + $propGetter = "get" . ucfirst($name); + $secondGetter = "get" . ucfirst($secondName); + + $this->assertEquals($obj->$propGetter(), $obj->$propName); + $this->assertEquals($value, $obj->$propGetter()->$secondGetter()); + } + + /** + * Verify that a given property is set to a specific value, + * that it keeps that value when set using the setter, + * and that the getter and magic variable return the same value. + * + * @param object $obj The object to be interrogated. + * @param string $name The name of the property to be verified. + * @param string $secondName 2nd level accessor function name + * @param object $value The expected value of the property. + */ + protected function verifyProperty3($obj, $name, $secondName, $value) + { + $propName = $name; + $propGetter = "get" . ucfirst($name); + $propSetter = "set" . ucfirst($name); + $secondGetter = "get" . ucfirst($secondName); + $secondSetter = "set" . ucfirst($secondName); + + $this->assertEquals($obj->$propGetter(), $obj->$propName); + $obj->$propSetter($obj->$propName); + $this->assertEquals($value, $obj->$propGetter()->$secondGetter()); + } + + /** + * Convert sample feed to XML then back to objects. Ensure that + * all objects are instances of appropriate entry type and object count matches. + */ + public function testUserFeedToAndFromString() + { + $entryCount = 0; + foreach ($this->userFeed as $entry) { + $entryCount++; + $this->assertTrue($entry instanceof Zend_Gdata_Photos_AlbumEntry || + $entry instanceof Zend_Gdata_Photos_PhotoEntry || + $entry instanceof Zend_Gdata_Photos_TagEntry); + } + $this->assertTrue($entryCount > 0); + + /* Grab XML from $this->userFeed and convert back to objects */ + $newListFeed = new Zend_Gdata_Photos_UserFeed( + $this->userFeed->saveXML()); + $newEntryCount = 0; + foreach ($newListFeed as $entry) { + $newEntryCount++; + $this->assertTrue($entry instanceof Zend_Gdata_Photos_AlbumEntry || + $entry instanceof Zend_Gdata_Photos_PhotoEntry || + $entry instanceof Zend_Gdata_Photos_TagEntry); + } + $this->assertEquals($entryCount, $newEntryCount); + } + + /** + * Ensure that the number of entries equals the number + * of entries defined in the sample file. + */ + public function testEntryCount() + { + $entryCount = 0; + foreach ($this->userFeed as $entry) { + $entryCount++; + } + $this->assertEquals(3, $entryCount); + } + + /** + * Check for the existence of an and verify that they + * contain the expected values. + */ + public function testAuthor() + { + $feed = $this->userFeed; + + // Assert that the feed's author is correct + $feedAuthor = $feed->getAuthor(); + $this->assertEquals($feedAuthor, $feed->author); + $this->assertEquals(1, count($feedAuthor)); + $this->assertTrue($feedAuthor[0] instanceof Zend_Gdata_App_Extension_Author); + $this->verifyProperty2($feedAuthor[0], "name", "text", "sample"); + $this->assertTrue($feedAuthor[0]->getUri() instanceof Zend_Gdata_App_Extension_Uri); + $this->verifyProperty2($feedAuthor[0], "uri", "text", "http://picasaweb.google.com/sample.user"); + + // Assert that each entry has valid author data + foreach ($feed as $entry) { + if ($entry instanceof Zend_Gdata_Photos_AlbumEntry) { + $entryAuthor = $entry->getAuthor(); + $this->assertEquals(1, count($entryAuthor)); + $this->verifyProperty2($entryAuthor[0], "name", "text", "sample"); + $this->verifyProperty2($entryAuthor[0], "uri", "text", "http://picasaweb.google.com/sample.user"); + } + } + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testId() + { + $feed = $this->userFeed; + + // Assert that the feed's ID is correct + $this->assertTrue($feed->getId() instanceof Zend_Gdata_App_Extension_Id); + $this->verifyProperty2($feed, "id", "text", + "http://picasaweb.google.com/data/feed/api/user/sample.user"); + + // Assert that all entries have an Atom ID object + foreach ($feed as $entry) { + $this->assertTrue($entry->getId() instanceof Zend_Gdata_App_Extension_Id); + } + + // Assert one of the entry's IDs + $entry = $feed[0]; + $this->verifyProperty2($entry, "id", "text", + "http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/100"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testPublished() + { + $feed = $this->userFeed; + + // Assert that all entries have an Atom Published object + foreach ($feed as $entry) { + $this->assertTrue($entry->getPublished() instanceof Zend_Gdata_App_Extension_Published); + } + + // Assert one of the entry's Published dates + $entry = $feed[0]; + $this->verifyProperty2($entry, "published", "text", "2007-09-05T07:00:00.000Z"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testUpdated() + { + $feed = $this->userFeed; + + // Assert that the feed's updated date is correct + $this->assertTrue($feed->getUpdated() instanceof Zend_Gdata_App_Extension_Updated); + $this->verifyProperty2($feed, "updated", "text", + "2007-09-20T21:09:39.111Z"); + + // Assert that all entries have an Atom Updated object + foreach ($feed as $entry) { + $this->assertTrue($entry->getUpdated() instanceof Zend_Gdata_App_Extension_Updated); + } + + // Assert one of the entry's Updated dates + $entry = $feed[0]; + $this->verifyProperty2($entry, "updated", "text", "2007-09-05T20:49:24.000Z"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testTitle() + { + $feed = $this->userFeed; + + // Assert that the feed's title is correct + $this->assertTrue($feed->getTitle() instanceof Zend_Gdata_App_Extension_Title); + $this->verifyProperty2($feed, "title", "text", + "sample.user"); + + // Assert that all entries have an Atom ID object + foreach ($feed as $entry) { + $this->assertTrue($entry->getTitle() instanceof Zend_Gdata_App_Extension_Title); + } + + // Assert one of the entry's Titles + $entry = $feed[0]; + $this->verifyProperty2($entry, "title", "text", "Test"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testSubtitle() + { + $feed = $this->userFeed; + + // Assert that the feed's title is correct + $this->assertTrue($feed->getSubtitle() instanceof Zend_Gdata_App_Extension_Subtitle); + $this->verifyProperty2($feed, "subtitle", "text", + ""); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGenerator() + { + $feed = $this->userFeed; + + // Assert that the feed's generator is correct + $this->assertTrue($feed->getGenerator() instanceof Zend_Gdata_App_Extension_Generator); + $this->verifyProperty2($feed, "generator", "version", "1.00"); + $this->verifyProperty2($feed, "generator", "uri", "http://picasaweb.google.com/"); + $this->verifyProperty2($feed, "generator", "text", "Picasaweb"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testIcon() + { + $feed = $this->userFeed; + + // Assert that the feed's title is correct + $this->assertTrue($feed->getIcon() instanceof Zend_Gdata_App_Extension_Icon); + $this->verifyProperty2($feed, "icon", "text", + "http://lh5.google.com/sample.user/AAAAuZnob5E/AAAAAAAAAAA/EtCbNCdLGxM/s64-c/sample.user"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoUser() + { + $feed = $this->userFeed; + + // Assert that the feed's title is correct + $this->assertTrue($feed->getGphotoUser() instanceof Zend_Gdata_Photos_Extension_User); + $this->verifyProperty2($feed, "gphotoUser", "text", + "sample.user"); + $this->verifyProperty3($feed, "gphotoUser", "text", + "sample.user"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoNickname() + { + $feed = $this->userFeed; + + // Assert that the feed's title is correct + $this->assertTrue($feed->getGphotoNickname() instanceof Zend_Gdata_Photos_Extension_Nickname); + $this->verifyProperty2($feed, "gphotoNickname", "text", + "sample"); + $this->verifyProperty3($feed, "gphotoNickname", "text", + "sample"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGphotoThumbnail() + { + $feed = $this->userFeed; + + // Assert that the feed's title is correct + $this->assertTrue($feed->getGphotoThumbnail() instanceof Zend_Gdata_Photos_Extension_Thumbnail); + $this->verifyProperty2($feed, "gphotoThumbnail", "text", + "http://lh5.google.com/sample.user/AAAAuZnob5E/AAAAAAAAAAA/EtCbNCdLGxM/s64-c/sample.user"); + $this->verifyProperty3($feed, "gphotoThumbnail", "text", + "http://lh5.google.com/sample.user/AAAAuZnob5E/AAAAAAAAAAA/EtCbNCdLGxM/s64-c/sample.user"); + } + +} diff --git a/zend/tests/Zend/Gdata/Photos/PhotosUserQueryTest.php b/zend/tests/Zend/Gdata/Photos/PhotosUserQueryTest.php new file mode 100755 index 0000000..8b57da1 --- /dev/null +++ b/zend/tests/Zend/Gdata/Photos/PhotosUserQueryTest.php @@ -0,0 +1,134 @@ +setUser("sample.user"); + + $generatedString = $query->getQueryUrl(); + + // Assert that the generated query matches the correct one + $this->assertEquals($queryString, $generatedString); + } + + /** + * Check the consistency of a user feed request + * Projection is set to base + */ + public function testBaseUserQuery() + { + $queryString = "https://picasaweb.google.com/data/feed/base/user/sample.user"; + + $query = new Zend_Gdata_Photos_UserQuery(); + $query->setUser("sample.user"); + $query->setProjection("base"); + + $generatedString = $query->getQueryUrl(); + + // Assert that the generated query matches the correct one + $this->assertEquals($queryString, $generatedString); + } + + /** + * Check for thrown exceptions upon improper albumname/id setting + */ + public function testUserQueryExceptions() + { + $query = new Zend_Gdata_Photos_UserQuery(); + $query->setUser("sample.user"); + $query->setProjection(null); + + try { + $generatedString = $query->getQueryUrl(); + } catch (Exception $e) { + $this->assertTrue($e instanceof Zend_Gdata_App_InvalidArgumentException); + } + + $query->setProjection("api"); + $query->setUser(null); + + try { + $generatedString = $query->getQueryUrl(); + } catch (Exception $e) { + $this->assertTrue($e instanceof Zend_Gdata_App_InvalidArgumentException); + } + } + + /** + * Check the consistency of a user feed request filtered + * for a specific tag + */ + public function testTagFilterUserQuery() + { + $queryString = "https://picasaweb.google.com/data/feed/api/user/sample.user?tag=test"; + + $query = new Zend_Gdata_Photos_UserQuery(); + $query->setUser("sample.user"); + $query->setTag("test"); + + $generatedString = $query->getQueryUrl(); + + // Assert that the generated query matches the correct one + $this->assertEquals($queryString, $generatedString); + } + + /** + * Check the consistency of a user feed request for private data + */ + public function testPrivateUserQuery() + { + $queryString = "https://picasaweb.google.com/data/feed/api/user/sample.user?access=private"; + + $query = new Zend_Gdata_Photos_UserQuery(); + $query->setUser("sample.user"); + $query->setAccess("private"); + + $generatedString = $query->getQueryUrl(); + + // Assert that the generated query matches the correct one + $this->assertEquals($queryString, $generatedString); + } + +} diff --git a/zend/tests/Zend/Gdata/Photos/_files/TestAlbumEntry.xml b/zend/tests/Zend/Gdata/Photos/_files/TestAlbumEntry.xml new file mode 100755 index 0000000..70bef7a --- /dev/null +++ b/zend/tests/Zend/Gdata/Photos/_files/TestAlbumEntry.xml @@ -0,0 +1,40 @@ + + + http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1 + 2007-09-05T07:00:00.000Z + 2007-09-05T20:49:24.000Z + + Test + + public + + + + + sample + http://picasaweb.google.com/sample.user + + 1 + Test + + public + 1188975600000 + 2 + sample.user + sample + true + 0 + + Test + + + + + sample + + + + 42.87194 13.56738 + + + diff --git a/zend/tests/Zend/Gdata/Photos/_files/TestAlbumFeed.xml b/zend/tests/Zend/Gdata/Photos/_files/TestAlbumFeed.xml new file mode 100755 index 0000000..b8758a3 --- /dev/null +++ b/zend/tests/Zend/Gdata/Photos/_files/TestAlbumFeed.xml @@ -0,0 +1,139 @@ + + + http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1 + 2007-09-21T18:23:05.000Z + + Test + + public + http://lh6.google.com/sample.user/Rt8WNoDZEJE/AAAAAAAAABk/HQGlDhpIgWo/s160-c/Test.jpg + + + + + + sample + http://picasaweb.google.com/sample.user + + Picasaweb + 4 + 1 + 500 + 1 + Test + + public + 1188975600000 + 2 + sample.user + sample + true + 0 + + http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/2 + 2007-09-05T20:49:23.000Z + 2007-09-21T18:23:05.000Z + + Aqua Blue.jpg + Blue + + + + + 2 + 1190398985145172 + 0.0 + 1 + 2560 + 1600 + 883405 + + + 1189025362000 + + true + c041ce17aaa637eb656c81d9cf526c24 + + true + 1 + + Aqua Blue.jpg + Blue + tag, test + + + + + sample + + + + 41.87194 12.56738 + + + + + http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/3 + 2007-09-05T20:49:24.000Z + 2007-09-21T18:19:38.000Z + + Aqua Graphite.jpg + Gray + + + + + 3 + 1190398778006402 + 1.0 + 1 + 2560 + 1600 + 798334 + + + 1189025363000 + + true + a5ce2e36b9df7d3cb081511c72e73926 + + true + 0 + + Aqua Graphite.jpg + Gray + + + + + + sample + + + + http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/tag/tag + 2007-09-05T20:49:24.000Z + + tag + tag + + + + sample + http://picasaweb.google.com/sample.user + + + + http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/tag/test + 2007-09-05T20:49:24.000Z + + test + test + + + + sample + http://picasaweb.google.com/sample.user + + + diff --git a/zend/tests/Zend/Gdata/Photos/_files/TestCommentEntry.xml b/zend/tests/Zend/Gdata/Photos/_files/TestCommentEntry.xml new file mode 100755 index 0000000..5b3d423 --- /dev/null +++ b/zend/tests/Zend/Gdata/Photos/_files/TestCommentEntry.xml @@ -0,0 +1,21 @@ + + + http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/100/commentid/5 + 2007-09-21T18:22:53.000Z + 2007-09-21T18:22:53.000Z + + sample + test comment + test comment + + + + sample + http://picasaweb.google.com/sample.user + sample.user + sample + http://lh5.google.com/sample.user/AAAAuZnob5E/AAAAAAAAAAA/EtCbNCdLGxM/s48-c/sample.user + + 5 + 100 + diff --git a/zend/tests/Zend/Gdata/Photos/_files/TestPhotoEntry.xml b/zend/tests/Zend/Gdata/Photos/_files/TestPhotoEntry.xml new file mode 100755 index 0000000..2f6e4b5 --- /dev/null +++ b/zend/tests/Zend/Gdata/Photos/_files/TestPhotoEntry.xml @@ -0,0 +1,51 @@ + + + http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/100 + 2007-09-05T20:49:24.000Z + 2007-09-21T18:19:38.000Z + + Aqua Graphite.jpg + Gray + + + + + 100 + 1190398778006402 + 1 + 2560 + 1600 + 798334 + + + 1189025363000 + + 11.0 + 0.0040 + true + 22.0 + 200 + 1180950900000 + a5ce2e36b9df7d3cb081511c72e73926 + 0.0 + Fictitious Camera Company + AMAZING-100D + + true + 0 + + Aqua Graphite.jpg + Gray + + + + + + sample + + + + 41.87194 12.56738 + + + diff --git a/zend/tests/Zend/Gdata/Photos/_files/TestPhotoFeed.xml b/zend/tests/Zend/Gdata/Photos/_files/TestPhotoFeed.xml new file mode 100755 index 0000000..ea3fb8f --- /dev/null +++ b/zend/tests/Zend/Gdata/Photos/_files/TestPhotoFeed.xml @@ -0,0 +1,87 @@ + + + http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1/photoid/100 + 2007-09-21T18:23:05.000Z + + Aqua Blue.jpg + Blue + http://lh4.google.com/sample.user/Rt8WU4DZEKI/AAAAAAAAABY/IVgLqmnzJII/s288/Aqua%20Blue.jpg + + + + Picasaweb + 3 + 1 + 500 + 100 + 1190398985145172 + 1 + 2560 + 1600 + 883405 + + + 1189025362000 + + true + c041ce17aaa637eb656c81d9cf526c24 + + true + 1 + + Aqua Blue.jpg + Blue + tag, test + + + + + sample + + + http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/100/tag/tag + 2007-09-21T18:23:05.000Z + + tag + tag + + + + sample + http://picasaweb.google.com/sample.user + + + + http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/100/tag/test + 2007-09-21T18:23:05.000Z + + test + test + + + + sample + http://picasaweb.google.com/sample.user + + + + http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/100/commentid/5 + 2007-09-21T18:22:53.000Z + 2007-09-21T18:22:53.000Z + + sample + test comment + test comment + + + + sample + http://picasaweb.google.com/sample.user + sample.user + sample + http://lh5.google.com/sample.user/AAAAuZnob5E/AAAAAAAAAAA/EtCbNCdLGxM/s48-c/sample.user + + 5 + 100 + + diff --git a/zend/tests/Zend/Gdata/Photos/_files/TestTagEntry.xml b/zend/tests/Zend/Gdata/Photos/_files/TestTagEntry.xml new file mode 100755 index 0000000..6e00dd5 --- /dev/null +++ b/zend/tests/Zend/Gdata/Photos/_files/TestTagEntry.xml @@ -0,0 +1,14 @@ + + + http://picasaweb.google.com/data/entry/api/user/sample.user/tag/tag + 1970-01-01T00:01:01.000Z + + tag + tag + + + + sample + http://picasaweb.google.com/sample.user + + diff --git a/zend/tests/Zend/Gdata/Photos/_files/TestUserEntry.xml b/zend/tests/Zend/Gdata/Photos/_files/TestUserEntry.xml new file mode 100755 index 0000000..759818c --- /dev/null +++ b/zend/tests/Zend/Gdata/Photos/_files/TestUserEntry.xml @@ -0,0 +1,19 @@ + + + http://picasaweb.google.com/data/entry/api/user/sample.user + 2007-09-24T23:45:49.059Z + 2007-09-24T23:45:49.059Z + + sample.user + + + + + + sample + http://picasaweb.google.com/sample.user + + sample.user + sample + http://lh5.google.com/sample.user/AAAAuZnob5E/AAAAAAAAAAA/EtCbNCdLGxM/s64-c/sample.user + diff --git a/zend/tests/Zend/Gdata/Photos/_files/TestUserFeed.xml b/zend/tests/Zend/Gdata/Photos/_files/TestUserFeed.xml new file mode 100755 index 0000000..58dd6b4 --- /dev/null +++ b/zend/tests/Zend/Gdata/Photos/_files/TestUserFeed.xml @@ -0,0 +1,132 @@ + + + http://picasaweb.google.com/data/feed/api/user/sample.user + 2007-09-20T21:09:39.111Z + + sample.user + + http://lh5.google.com/sample.user/AAAAuZnob5E/AAAAAAAAAAA/EtCbNCdLGxM/s64-c/sample.user + + + + + + sample + http://picasaweb.google.com/sample.user + + Picasaweb + 4 + 1 + 100 + sample.user + sample + http://lh5.google.com/sample.user/AAAAuZnob5E/AAAAAAAAAAA/EtCbNCdLGxM/s64-c/sample.user + + http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/100 + 2007-09-05T07:00:00.000Z + 2007-09-05T20:49:24.000Z + + Test + + public + + + + + sample + http://picasaweb.google.com/sample.user + + 100 + Test + + public + 1188975600000 + 2 + sample.user + sample + true + 0 + + Test + + + + + sample + + + + http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/100/photoid/2 + 2007-09-05T20:49:24.000Z + 2007-09-05T20:49:23.000Z + + Second.jpg + + + + + + 2 + 1189025363424891 + 100 + 2560 + 1600 + 798334 + + + 1189025363000 + + true + a5ce2e36b9df7d3cb081511c72e73926 + + true + 0 + + Second.jpg + + + + + + + sample + + + + http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/100/photoid/1 + 2007-09-05T20:49:23.000Z + 2007-09-05T20:49:22.000Z + + First.jpg + + + + + + 1 + 1189025362423722 + 100 + 2560 + 1600 + 883405 + + + 1189025362000 + + true + c041ce17aaa637eb656c81d9cf526c24 + + true + 0 + + First.jpg + + + + + + + sample + + + diff --git a/zend/tests/Zend/Gdata/Photos/_files/test.jpg b/zend/tests/Zend/Gdata/Photos/_files/test.jpg new file mode 100755 index 0000000..d4a5a10 Binary files /dev/null and b/zend/tests/Zend/Gdata/Photos/_files/test.jpg differ -- cgit v1.2.3