From 06f945f27840b53e57795dadbc38e76f7e11ab1c Mon Sep 17 00:00:00 2001 From: Horus3 Date: Mon, 24 Feb 2014 16:42:14 +0100 Subject: init --- zend/tests/Zend/AllTests.php | 97 ++ zend/tests/Zend/Gdata/AllTests.php | 424 ++++++ .../tests/Zend/Gdata/Analytics/AccountFeedTest.php | 71 + .../Zend/Gdata/Analytics/AccountQueryTest.php | 126 ++ zend/tests/Zend/Gdata/Analytics/DataFeedTest.php | 80 ++ zend/tests/Zend/Gdata/Analytics/DataQueryTest.php | 101 ++ .../Gdata/Analytics/_files/TestAccountFeed.xml | 32 + .../Zend/Gdata/Analytics/_files/TestDataFeed.xml | 76 + zend/tests/Zend/Gdata/App/AuthorTest.php | 118 ++ zend/tests/Zend/Gdata/App/BaseTest.php | 133 ++ .../Gdata/App/CaptchaRequiredExceptionTest.php | 58 + zend/tests/Zend/Gdata/App/CategoryTest.php | 114 ++ zend/tests/Zend/Gdata/App/ContentTest.php | 97 ++ zend/tests/Zend/Gdata/App/ControlTest.php | 75 + zend/tests/Zend/Gdata/App/EntryTest.php | 614 ++++++++ zend/tests/Zend/Gdata/App/FeedTest.php | 282 ++++ zend/tests/Zend/Gdata/App/GeneratorTest.php | 82 ++ zend/tests/Zend/Gdata/App/HttpExceptionTest.php | 71 + zend/tests/Zend/Gdata/App/MockBase.php | 38 + zend/tests/Zend/Gdata/App/UtilTest.php | 229 +++ .../Zend/Gdata/App/_files/AuthorElementSample1.xml | 6 + .../Gdata/App/_files/CategoryElementSample1.xml | 4 + .../Gdata/App/_files/ContentElementSample1.xml | 3 + .../Gdata/App/_files/ContentElementSample2.xml | 2 + .../Gdata/App/_files/ControlElementSample1.xml | 4 + zend/tests/Zend/Gdata/App/_files/EntrySample1.xml | 28 + .../Zend/Gdata/App/_files/EntrySampleHttp1.txt | 29 + zend/tests/Zend/Gdata/App/_files/FeedSample1.xml | 45 + .../Gdata/App/_files/GeneratorElementSample1.xml | 2 + zend/tests/Zend/Gdata/AppTest.php | 633 +++++++++ zend/tests/Zend/Gdata/AttendeeStatusTest.php | 125 ++ zend/tests/Zend/Gdata/AttendeeTypeTest.php | 125 ++ zend/tests/Zend/Gdata/AuthSubTest.php | 275 ++++ .../tests/Zend/Gdata/Books/CollectionEntryTest.php | 48 + zend/tests/Zend/Gdata/Books/CollectionFeedTest.php | 48 + zend/tests/Zend/Gdata/Books/VolumeEntryTest.php | 125 ++ zend/tests/Zend/Gdata/Books/VolumeFeedTest.php | 108 ++ .../Gdata/Books/_files/VolumeEntryDataSample1.xml | 32 + .../Gdata/Books/_files/VolumeFeedDataSample1.xml | 139 ++ zend/tests/Zend/Gdata/BooksOnlineTest.php | 108 ++ zend/tests/Zend/Gdata/BooksTest.php | 48 + zend/tests/Zend/Gdata/Calendar/AccessLevelTest.php | 124 ++ zend/tests/Zend/Gdata/Calendar/ColorTest.php | 124 ++ zend/tests/Zend/Gdata/Calendar/EventEntryTest.php | 138 ++ .../Gdata/Calendar/EventQueryExceptionTest.php | 68 + zend/tests/Zend/Gdata/Calendar/EventQueryTest.php | 270 ++++ zend/tests/Zend/Gdata/Calendar/HiddenTest.php | 124 ++ zend/tests/Zend/Gdata/Calendar/LinkTest.php | 165 +++ zend/tests/Zend/Gdata/Calendar/QuickAddTest.php | 124 ++ zend/tests/Zend/Gdata/Calendar/SelectedTest.php | 124 ++ .../Gdata/Calendar/SendEventNotificationsTest.php | 124 ++ zend/tests/Zend/Gdata/Calendar/TimezoneTest.php | 124 ++ zend/tests/Zend/Gdata/Calendar/WebContentTest.php | 140 ++ .../Calendar/_files/AccessLevelElementSample1.xml | 2 + .../Gdata/Calendar/_files/ColorElementSample1.xml | 2 + .../Gdata/Calendar/_files/EventEntrySample1.xml | 51 + .../Calendar/_files/EventFeedCompositeSample1.xml | 362 +++++ .../Gdata/Calendar/_files/HiddenElementSample1.xml | 2 + .../Gdata/Calendar/_files/LinkElementSample1.xml | 10 + .../Zend/Gdata/Calendar/_files/ListFeedSample1.xml | 192 +++ .../Calendar/_files/QuickAddElementSample1.xml | 2 + .../Calendar/_files/SelectedElementSample1.xml | 2 + .../SendEventNotificationsElementSample1.xml | 2 + .../Calendar/_files/TestDataEventFeedSample1.xml | 460 ++++++ .../Calendar/_files/TimezoneElementSample1.xml | 2 + .../Calendar/_files/WebContentElementSample1.xml | 4 + zend/tests/Zend/Gdata/CalendarEventTest.php | 494 +++++++ .../tests/Zend/Gdata/CalendarFeedCompositeTest.php | 509 +++++++ zend/tests/Zend/Gdata/CalendarFeedTest.php | 388 +++++ zend/tests/Zend/Gdata/CalendarOnlineTest.php | 172 +++ zend/tests/Zend/Gdata/CalendarTest.php | 102 ++ zend/tests/Zend/Gdata/CommentsTest.php | 127 ++ .../Zend/Gdata/Docs/DocumentListEntryTest.php | 72 + .../tests/Zend/Gdata/Docs/DocumentListFeedTest.php | 67 + zend/tests/Zend/Gdata/Docs/QueryTest.php | 77 + .../_files/TestDataDocumentListEntrySample.xml | 14 + .../Docs/_files/TestDataDocumentListFeedSample.xml | 38 + zend/tests/Zend/Gdata/DocsOnlineTest.php | 129 ++ zend/tests/Zend/Gdata/DocsTest.php | 95 ++ zend/tests/Zend/Gdata/EntryLinkTest.php | 141 ++ zend/tests/Zend/Gdata/EntryTest.php | 126 ++ zend/tests/Zend/Gdata/EventStatusTest.php | 125 ++ zend/tests/Zend/Gdata/ExtendedPropertyTest.php | 132 ++ zend/tests/Zend/Gdata/FeedLinkTest.php | 148 ++ zend/tests/Zend/Gdata/FeedTest.php | 158 +++ zend/tests/Zend/Gdata/Gapps/EmailListEntryTest.php | 140 ++ zend/tests/Zend/Gdata/Gapps/EmailListFeedTest.php | 109 ++ zend/tests/Zend/Gdata/Gapps/EmailListQueryTest.php | 138 ++ .../Gdata/Gapps/EmailListRecipientEntryTest.php | 107 ++ .../Gdata/Gapps/EmailListRecipientFeedTest.php | 109 ++ .../Gdata/Gapps/EmailListRecipientQueryTest.php | 90 ++ zend/tests/Zend/Gdata/Gapps/EmailListTest.php | 126 ++ zend/tests/Zend/Gdata/Gapps/ErrorTest.php | 88 ++ zend/tests/Zend/Gdata/Gapps/GroupEntryTest.php | 110 ++ zend/tests/Zend/Gdata/Gapps/GroupFeedTest.php | 109 ++ zend/tests/Zend/Gdata/Gapps/GroupQueryTest.php | 168 +++ zend/tests/Zend/Gdata/Gapps/LoginTest.php | 169 +++ zend/tests/Zend/Gdata/Gapps/MemberEntryTest.php | 108 ++ zend/tests/Zend/Gdata/Gapps/MemberFeedTest.php | 109 ++ zend/tests/Zend/Gdata/Gapps/MemberQueryTest.php | 109 ++ zend/tests/Zend/Gdata/Gapps/NameTest.php | 133 ++ zend/tests/Zend/Gdata/Gapps/NicknameEntryTest.php | 112 ++ zend/tests/Zend/Gdata/Gapps/NicknameFeedTest.php | 109 ++ zend/tests/Zend/Gdata/Gapps/NicknameQueryTest.php | 140 ++ zend/tests/Zend/Gdata/Gapps/NicknameTest.php | 126 ++ zend/tests/Zend/Gdata/Gapps/OwnerEntryTest.php | 104 ++ zend/tests/Zend/Gdata/Gapps/OwnerFeedTest.php | 109 ++ zend/tests/Zend/Gdata/Gapps/OwnerQueryTest.php | 91 ++ zend/tests/Zend/Gdata/Gapps/PropertyTest.php | 133 ++ zend/tests/Zend/Gdata/Gapps/QuotaTest.php | 126 ++ .../Zend/Gdata/Gapps/ServiceExceptionTest.php | 128 ++ zend/tests/Zend/Gdata/Gapps/UserEntryTest.php | 145 ++ zend/tests/Zend/Gdata/Gapps/UserFeedTest.php | 109 ++ zend/tests/Zend/Gdata/Gapps/UserQueryTest.php | 98 ++ .../_files/AppsForYourDomainElementSample1.xml | 6 + .../Gdata/Gapps/_files/EmailListElementSample1.xml | 2 + .../Gapps/_files/EmailListEntryDataSample1.xml | 17 + .../Gapps/_files/EmailListFeedDataSample1.xml | 55 + .../_files/EmailListRecipientEntryDataSample1.xml | 15 + .../_files/EmailListRecipientFeedDataSample1.xml | 51 + .../Gdata/Gapps/_files/GroupEntryDataSample1.xml | 14 + .../Gdata/Gapps/_files/GroupFeedDataSample1.xml | 31 + .../Gdata/Gapps/_files/LoginElementSample1.xml | 2 + .../Gdata/Gapps/_files/MemberEntryDataSample1.xml | 13 + .../Gdata/Gapps/_files/MemberFeedDataSample1.xml | 29 + .../Zend/Gdata/Gapps/_files/NameElementSample1.xml | 2 + .../Gdata/Gapps/_files/NicknameElementSample1.xml | 2 + .../Gapps/_files/NicknameEntryDataSample1.xml | 16 + .../Gdata/Gapps/_files/NicknameFeedDataSample1.xml | 50 + .../Gdata/Gapps/_files/OwnerEntryDataSample1.xml | 10 + .../Gdata/Gapps/_files/OwnerFeedDataSample1.xml | 30 + .../Gdata/Gapps/_files/PropertyElementSample1.xml | 2 + .../Gdata/Gapps/_files/QuotaElementSample1.xml | 2 + .../Gdata/Gapps/_files/UserEntryDataSample1.xml | 20 + .../Gdata/Gapps/_files/UserFeedDataSample1.xml | 66 + zend/tests/Zend/Gdata/GappsOnlineTest.php | 834 +++++++++++ zend/tests/Zend/Gdata/GappsTest.php | 79 ++ zend/tests/Zend/Gdata/GdataOnlineTest.php | 341 +++++ zend/tests/Zend/Gdata/GdataTest.php | 102 ++ zend/tests/Zend/Gdata/MediaMimeStreamTest.php | 186 +++ .../Zend/Gdata/OpenSearchItemsPerPageTest.php | 126 ++ zend/tests/Zend/Gdata/OpenSearchStartIndexTest.php | 126 ++ .../Zend/Gdata/OpenSearchTotalResultsTest.php | 126 ++ zend/tests/Zend/Gdata/OriginalEventTest.php | 134 ++ .../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 zend/tests/Zend/Gdata/PhotosOnlineTest.php | 288 ++++ zend/tests/Zend/Gdata/QueryTest.php | 122 ++ zend/tests/Zend/Gdata/RecurrenceExceptionTest.php | 129 ++ zend/tests/Zend/Gdata/RecurrenceTest.php | 125 ++ zend/tests/Zend/Gdata/ReminderTest.php | 153 ++ zend/tests/Zend/Gdata/SkipTests.php | 55 + .../Zend/Gdata/Spreadsheets/CellEntryTest.php | 64 + .../tests/Zend/Gdata/Spreadsheets/CellFeedTest.php | 91 ++ .../Zend/Gdata/Spreadsheets/CellQueryTest.php | 138 ++ zend/tests/Zend/Gdata/Spreadsheets/CellTest.php | 67 + .../tests/Zend/Gdata/Spreadsheets/ColCountTest.php | 54 + zend/tests/Zend/Gdata/Spreadsheets/CustomTest.php | 57 + .../Zend/Gdata/Spreadsheets/DocumentQueryTest.php | 91 ++ .../Zend/Gdata/Spreadsheets/ListEntryTest.php | 225 +++ .../tests/Zend/Gdata/Spreadsheets/ListFeedTest.php | 68 + .../Zend/Gdata/Spreadsheets/ListQueryTest.php | 109 ++ .../tests/Zend/Gdata/Spreadsheets/RowCountTest.php | 54 + .../Gdata/Spreadsheets/SpreadsheetFeedTest.php | 65 + .../Zend/Gdata/Spreadsheets/WorksheetEntryTest.php | 57 + .../Zend/Gdata/Spreadsheets/WorksheetFeedTest.php | 65 + .../_files/TestDataCellFeedSample1.xml | 49 + .../_files/TestDataListFeedSample1.xml | 56 + .../_files/TestDataSpreadsheetFeedSample1.xml | 38 + .../_files/TestDataWorksheetFeedSample1.xml | 37 + zend/tests/Zend/Gdata/SpreadsheetsOnlineTest.php | 295 ++++ zend/tests/Zend/Gdata/SpreadsheetsTest.php | 48 + .../Zend/Gdata/TestUtility/MockHttpClient.php | 81 ++ zend/tests/Zend/Gdata/TransparencyTest.php | 125 ++ zend/tests/Zend/Gdata/VisibilityTest.php | 125 ++ zend/tests/Zend/Gdata/WhenTest.php | 144 ++ zend/tests/Zend/Gdata/WhereTest.php | 141 ++ zend/tests/Zend/Gdata/WhoTest.php | 145 ++ .../tests/Zend/Gdata/YouTube/ActivityEntryTest.php | 153 ++ zend/tests/Zend/Gdata/YouTube/ActivityFeedTest.php | 149 ++ zend/tests/Zend/Gdata/YouTube/CommentEntryTest.php | 107 ++ zend/tests/Zend/Gdata/YouTube/CommentFeedTest.php | 109 ++ zend/tests/Zend/Gdata/YouTube/ContactEntryTest.php | 109 ++ zend/tests/Zend/Gdata/YouTube/ContactFeedTest.php | 109 ++ zend/tests/Zend/Gdata/YouTube/InboxEntryTest.php | 217 +++ zend/tests/Zend/Gdata/YouTube/InboxFeedTest.php | 182 +++ .../Zend/Gdata/YouTube/PlaylistListEntryTest.php | 239 ++++ .../Zend/Gdata/YouTube/PlaylistListFeedTest.php | 171 +++ .../Zend/Gdata/YouTube/PlaylistVideoEntryTest.php | 356 +++++ .../Zend/Gdata/YouTube/PlaylistVideoFeedTest.php | 112 ++ .../Zend/Gdata/YouTube/SubscriptionEntryTest.php | 332 +++++ .../Zend/Gdata/YouTube/SubscriptionFeedTest.php | 178 +++ .../Zend/Gdata/YouTube/UserProfileEntryTest.php | 253 ++++ zend/tests/Zend/Gdata/YouTube/VideoEntryTest.php | 767 ++++++++++ zend/tests/Zend/Gdata/YouTube/VideoFeedTest.php | 109 ++ zend/tests/Zend/Gdata/YouTube/VideoQueryTest.php | 277 ++++ .../YouTube/_files/ActivityEntryDataSample1.xml | 23 + .../YouTube/_files/ActivityFeedDataSample1.xml | 47 + .../YouTube/_files/CommentEntryDataSample1.xml | 20 + .../YouTube/_files/CommentFeedDataSample1.xml | 112 ++ .../YouTube/_files/ContactEntryDataSample1.xml | 26 + .../YouTube/_files/ContactFeedDataSample1.xml | 51 + .../_files/FormUploadTokenResponseSample.xml | 1 + .../Gdata/YouTube/_files/InboxEntryDataSample1.xml | 82 ++ .../YouTube/_files/InboxEntryDataSampleV2.xml | 88 ++ .../Gdata/YouTube/_files/InboxFeedDataSample1.xml | 107 ++ .../Gdata/YouTube/_files/InboxFeedDataSampleV2.xml | 119 ++ .../_files/PlaylistListEntryDataSample1.xml | 30 + .../_files/PlaylistListEntryDataSampleV2.xml | 16 + .../YouTube/_files/PlaylistListFeedDataSample1.xml | 79 ++ .../_files/PlaylistListFeedDataSampleV2.xml | 553 ++++++++ .../_files/PlaylistListVideoEntryDataSampleV2.xml | 66 + .../_files/PlaylistVideoEntryDataSample1.xml | 109 ++ .../_files/PlaylistVideoEntryDataSampleV2.xml | 89 ++ .../_files/PlaylistVideoFeedDataSample1.xml | 1495 ++++++++++++++++++++ .../_files/SubscriptionEntryDataSample1.xml | 29 + .../_files/SubscriptionEntryDataSampleV2.xml | 33 + .../SubscriptionEntryDataSample_channelV2.xml | 33 + .../SubscriptionEntryDataSample_favoritesV2.xml | 30 + .../SubscriptionEntryDataSample_playlistV2.xml | 32 + .../_files/SubscriptionEntryDataSample_queryV2.xml | 31 + .../YouTube/_files/SubscriptionFeedDataSample1.xml | 105 ++ .../_files/SubscriptionFeedDataSampleV2.xml | 138 ++ .../YouTube/_files/UserProfileEntryDataSample1.xml | 47 + .../_files/UserProfileEntryDataSampleV2.xml | 71 + .../Gdata/YouTube/_files/VideoEntryDataSample1.xml | 138 ++ .../YouTube/_files/VideoEntryDataSamplePrivate.xml | 139 ++ .../YouTube/_files/VideoEntryDataSampleV2.xml | 63 + .../Gdata/YouTube/_files/VideoFeedDataSample1.xml | 743 ++++++++++ zend/tests/Zend/Gdata/YouTubeOnlineTest.php | 1049 ++++++++++++++ zend/tests/Zend/Gdata/YouTubeTest.php | 72 + zend/tests/Zend/Gdata/_files/AppSample1.txt | 30 + zend/tests/Zend/Gdata/_files/AppSample2.txt | 29 + zend/tests/Zend/Gdata/_files/AppSample3.txt | 68 + zend/tests/Zend/Gdata/_files/AppSample4.txt | 67 + .../Gdata/_files/AttendeeStatusElementSample1.xml | 2 + .../Gdata/_files/AttendeeTypeElementSample1.xml | 2 + .../Zend/Gdata/_files/CommentsElementSample1.xml | 5 + zend/tests/Zend/Gdata/_files/DocsTest.csv | 4 + .../Zend/Gdata/_files/EntryLinkElementSample1.xml | 10 + zend/tests/Zend/Gdata/_files/EntrySample1.xml | 20 + .../Gdata/_files/EventStatusElementSample1.xml | 2 + .../_files/ExtendedPropertyElementSample1.xml | 3 + .../Zend/Gdata/_files/FeedLinkElementSample1.xml | 9 + zend/tests/Zend/Gdata/_files/FeedSampleV1.xml | 58 + zend/tests/Zend/Gdata/_files/FeedSampleV2.xml | 58 + .../Zend/Gdata/_files/MediaMimeStreamSample1.txt | 1 + .../OpenSearchItemsPerPageElementSample1.xml | 2 + .../_files/OpenSearchStartIndexElementSample1.xml | 2 + .../OpenSearchTotalResultsElementSample1.xml | 2 + .../Gdata/_files/OriginalEventElementSample1.xml | 4 + .../Zend/Gdata/_files/RecurrenceElementSample1.xml | 6 + .../_files/RecurrenceExceptionElementSample1.xml | 6 + .../Zend/Gdata/_files/ReminderElementSample1.xml | 2 + zend/tests/Zend/Gdata/_files/RsaCert.pem | 17 + zend/tests/Zend/Gdata/_files/RsaKey.pem | 15 + .../Gdata/_files/TransparencyElementSample1.xml | 2 + .../Zend/Gdata/_files/VisibilityElementSample1.xml | 2 + .../tests/Zend/Gdata/_files/WhenElementSample1.xml | 2 + .../Zend/Gdata/_files/WhereElementSample1.xml | 5 + zend/tests/Zend/Gdata/_files/WhoElementSample1.xml | 7 + zend/tests/Zend/Gdata/_files/testImage.jpg | Bin 0 -> 13475 bytes 280 files changed, 33828 insertions(+) create mode 100644 zend/tests/Zend/AllTests.php create mode 100644 zend/tests/Zend/Gdata/AllTests.php create mode 100755 zend/tests/Zend/Gdata/Analytics/AccountFeedTest.php create mode 100644 zend/tests/Zend/Gdata/Analytics/AccountQueryTest.php create mode 100644 zend/tests/Zend/Gdata/Analytics/DataFeedTest.php create mode 100644 zend/tests/Zend/Gdata/Analytics/DataQueryTest.php create mode 100644 zend/tests/Zend/Gdata/Analytics/_files/TestAccountFeed.xml create mode 100644 zend/tests/Zend/Gdata/Analytics/_files/TestDataFeed.xml create mode 100644 zend/tests/Zend/Gdata/App/AuthorTest.php create mode 100644 zend/tests/Zend/Gdata/App/BaseTest.php create mode 100644 zend/tests/Zend/Gdata/App/CaptchaRequiredExceptionTest.php create mode 100644 zend/tests/Zend/Gdata/App/CategoryTest.php create mode 100644 zend/tests/Zend/Gdata/App/ContentTest.php create mode 100644 zend/tests/Zend/Gdata/App/ControlTest.php create mode 100644 zend/tests/Zend/Gdata/App/EntryTest.php create mode 100644 zend/tests/Zend/Gdata/App/FeedTest.php create mode 100644 zend/tests/Zend/Gdata/App/GeneratorTest.php create mode 100755 zend/tests/Zend/Gdata/App/HttpExceptionTest.php create mode 100644 zend/tests/Zend/Gdata/App/MockBase.php create mode 100644 zend/tests/Zend/Gdata/App/UtilTest.php create mode 100644 zend/tests/Zend/Gdata/App/_files/AuthorElementSample1.xml create mode 100644 zend/tests/Zend/Gdata/App/_files/CategoryElementSample1.xml create mode 100644 zend/tests/Zend/Gdata/App/_files/ContentElementSample1.xml create mode 100644 zend/tests/Zend/Gdata/App/_files/ContentElementSample2.xml create mode 100644 zend/tests/Zend/Gdata/App/_files/ControlElementSample1.xml create mode 100644 zend/tests/Zend/Gdata/App/_files/EntrySample1.xml create mode 100644 zend/tests/Zend/Gdata/App/_files/EntrySampleHttp1.txt create mode 100644 zend/tests/Zend/Gdata/App/_files/FeedSample1.xml create mode 100644 zend/tests/Zend/Gdata/App/_files/GeneratorElementSample1.xml create mode 100644 zend/tests/Zend/Gdata/AppTest.php create mode 100644 zend/tests/Zend/Gdata/AttendeeStatusTest.php create mode 100644 zend/tests/Zend/Gdata/AttendeeTypeTest.php create mode 100755 zend/tests/Zend/Gdata/AuthSubTest.php create mode 100644 zend/tests/Zend/Gdata/Books/CollectionEntryTest.php create mode 100644 zend/tests/Zend/Gdata/Books/CollectionFeedTest.php create mode 100644 zend/tests/Zend/Gdata/Books/VolumeEntryTest.php create mode 100644 zend/tests/Zend/Gdata/Books/VolumeFeedTest.php create mode 100644 zend/tests/Zend/Gdata/Books/_files/VolumeEntryDataSample1.xml create mode 100644 zend/tests/Zend/Gdata/Books/_files/VolumeFeedDataSample1.xml create mode 100644 zend/tests/Zend/Gdata/BooksOnlineTest.php create mode 100644 zend/tests/Zend/Gdata/BooksTest.php create mode 100644 zend/tests/Zend/Gdata/Calendar/AccessLevelTest.php create mode 100644 zend/tests/Zend/Gdata/Calendar/ColorTest.php create mode 100644 zend/tests/Zend/Gdata/Calendar/EventEntryTest.php create mode 100644 zend/tests/Zend/Gdata/Calendar/EventQueryExceptionTest.php create mode 100644 zend/tests/Zend/Gdata/Calendar/EventQueryTest.php create mode 100644 zend/tests/Zend/Gdata/Calendar/HiddenTest.php create mode 100644 zend/tests/Zend/Gdata/Calendar/LinkTest.php create mode 100644 zend/tests/Zend/Gdata/Calendar/QuickAddTest.php create mode 100644 zend/tests/Zend/Gdata/Calendar/SelectedTest.php create mode 100644 zend/tests/Zend/Gdata/Calendar/SendEventNotificationsTest.php create mode 100644 zend/tests/Zend/Gdata/Calendar/TimezoneTest.php create mode 100644 zend/tests/Zend/Gdata/Calendar/WebContentTest.php create mode 100644 zend/tests/Zend/Gdata/Calendar/_files/AccessLevelElementSample1.xml create mode 100644 zend/tests/Zend/Gdata/Calendar/_files/ColorElementSample1.xml create mode 100644 zend/tests/Zend/Gdata/Calendar/_files/EventEntrySample1.xml create mode 100644 zend/tests/Zend/Gdata/Calendar/_files/EventFeedCompositeSample1.xml create mode 100644 zend/tests/Zend/Gdata/Calendar/_files/HiddenElementSample1.xml create mode 100644 zend/tests/Zend/Gdata/Calendar/_files/LinkElementSample1.xml create mode 100644 zend/tests/Zend/Gdata/Calendar/_files/ListFeedSample1.xml create mode 100644 zend/tests/Zend/Gdata/Calendar/_files/QuickAddElementSample1.xml create mode 100644 zend/tests/Zend/Gdata/Calendar/_files/SelectedElementSample1.xml create mode 100644 zend/tests/Zend/Gdata/Calendar/_files/SendEventNotificationsElementSample1.xml create mode 100644 zend/tests/Zend/Gdata/Calendar/_files/TestDataEventFeedSample1.xml create mode 100644 zend/tests/Zend/Gdata/Calendar/_files/TimezoneElementSample1.xml create mode 100644 zend/tests/Zend/Gdata/Calendar/_files/WebContentElementSample1.xml create mode 100644 zend/tests/Zend/Gdata/CalendarEventTest.php create mode 100644 zend/tests/Zend/Gdata/CalendarFeedCompositeTest.php create mode 100644 zend/tests/Zend/Gdata/CalendarFeedTest.php create mode 100644 zend/tests/Zend/Gdata/CalendarOnlineTest.php create mode 100644 zend/tests/Zend/Gdata/CalendarTest.php create mode 100644 zend/tests/Zend/Gdata/CommentsTest.php create mode 100755 zend/tests/Zend/Gdata/Docs/DocumentListEntryTest.php create mode 100755 zend/tests/Zend/Gdata/Docs/DocumentListFeedTest.php create mode 100755 zend/tests/Zend/Gdata/Docs/QueryTest.php create mode 100755 zend/tests/Zend/Gdata/Docs/_files/TestDataDocumentListEntrySample.xml create mode 100755 zend/tests/Zend/Gdata/Docs/_files/TestDataDocumentListFeedSample.xml create mode 100755 zend/tests/Zend/Gdata/DocsOnlineTest.php create mode 100755 zend/tests/Zend/Gdata/DocsTest.php create mode 100644 zend/tests/Zend/Gdata/EntryLinkTest.php create mode 100644 zend/tests/Zend/Gdata/EntryTest.php create mode 100644 zend/tests/Zend/Gdata/EventStatusTest.php create mode 100644 zend/tests/Zend/Gdata/ExtendedPropertyTest.php create mode 100644 zend/tests/Zend/Gdata/FeedLinkTest.php create mode 100644 zend/tests/Zend/Gdata/FeedTest.php create mode 100644 zend/tests/Zend/Gdata/Gapps/EmailListEntryTest.php create mode 100644 zend/tests/Zend/Gdata/Gapps/EmailListFeedTest.php create mode 100644 zend/tests/Zend/Gdata/Gapps/EmailListQueryTest.php create mode 100644 zend/tests/Zend/Gdata/Gapps/EmailListRecipientEntryTest.php create mode 100644 zend/tests/Zend/Gdata/Gapps/EmailListRecipientFeedTest.php create mode 100644 zend/tests/Zend/Gdata/Gapps/EmailListRecipientQueryTest.php create mode 100644 zend/tests/Zend/Gdata/Gapps/EmailListTest.php create mode 100644 zend/tests/Zend/Gdata/Gapps/ErrorTest.php create mode 100644 zend/tests/Zend/Gdata/Gapps/GroupEntryTest.php create mode 100644 zend/tests/Zend/Gdata/Gapps/GroupFeedTest.php create mode 100644 zend/tests/Zend/Gdata/Gapps/GroupQueryTest.php create mode 100644 zend/tests/Zend/Gdata/Gapps/LoginTest.php create mode 100644 zend/tests/Zend/Gdata/Gapps/MemberEntryTest.php create mode 100644 zend/tests/Zend/Gdata/Gapps/MemberFeedTest.php create mode 100644 zend/tests/Zend/Gdata/Gapps/MemberQueryTest.php create mode 100644 zend/tests/Zend/Gdata/Gapps/NameTest.php create mode 100644 zend/tests/Zend/Gdata/Gapps/NicknameEntryTest.php create mode 100644 zend/tests/Zend/Gdata/Gapps/NicknameFeedTest.php create mode 100644 zend/tests/Zend/Gdata/Gapps/NicknameQueryTest.php create mode 100644 zend/tests/Zend/Gdata/Gapps/NicknameTest.php create mode 100644 zend/tests/Zend/Gdata/Gapps/OwnerEntryTest.php create mode 100644 zend/tests/Zend/Gdata/Gapps/OwnerFeedTest.php create mode 100644 zend/tests/Zend/Gdata/Gapps/OwnerQueryTest.php create mode 100644 zend/tests/Zend/Gdata/Gapps/PropertyTest.php create mode 100644 zend/tests/Zend/Gdata/Gapps/QuotaTest.php create mode 100644 zend/tests/Zend/Gdata/Gapps/ServiceExceptionTest.php create mode 100644 zend/tests/Zend/Gdata/Gapps/UserEntryTest.php create mode 100644 zend/tests/Zend/Gdata/Gapps/UserFeedTest.php create mode 100644 zend/tests/Zend/Gdata/Gapps/UserQueryTest.php create mode 100644 zend/tests/Zend/Gdata/Gapps/_files/AppsForYourDomainElementSample1.xml create mode 100644 zend/tests/Zend/Gdata/Gapps/_files/EmailListElementSample1.xml create mode 100644 zend/tests/Zend/Gdata/Gapps/_files/EmailListEntryDataSample1.xml create mode 100644 zend/tests/Zend/Gdata/Gapps/_files/EmailListFeedDataSample1.xml create mode 100644 zend/tests/Zend/Gdata/Gapps/_files/EmailListRecipientEntryDataSample1.xml create mode 100644 zend/tests/Zend/Gdata/Gapps/_files/EmailListRecipientFeedDataSample1.xml create mode 100644 zend/tests/Zend/Gdata/Gapps/_files/GroupEntryDataSample1.xml create mode 100644 zend/tests/Zend/Gdata/Gapps/_files/GroupFeedDataSample1.xml create mode 100644 zend/tests/Zend/Gdata/Gapps/_files/LoginElementSample1.xml create mode 100644 zend/tests/Zend/Gdata/Gapps/_files/MemberEntryDataSample1.xml create mode 100644 zend/tests/Zend/Gdata/Gapps/_files/MemberFeedDataSample1.xml create mode 100644 zend/tests/Zend/Gdata/Gapps/_files/NameElementSample1.xml create mode 100644 zend/tests/Zend/Gdata/Gapps/_files/NicknameElementSample1.xml create mode 100644 zend/tests/Zend/Gdata/Gapps/_files/NicknameEntryDataSample1.xml create mode 100644 zend/tests/Zend/Gdata/Gapps/_files/NicknameFeedDataSample1.xml create mode 100644 zend/tests/Zend/Gdata/Gapps/_files/OwnerEntryDataSample1.xml create mode 100644 zend/tests/Zend/Gdata/Gapps/_files/OwnerFeedDataSample1.xml create mode 100644 zend/tests/Zend/Gdata/Gapps/_files/PropertyElementSample1.xml create mode 100644 zend/tests/Zend/Gdata/Gapps/_files/QuotaElementSample1.xml create mode 100644 zend/tests/Zend/Gdata/Gapps/_files/UserEntryDataSample1.xml create mode 100644 zend/tests/Zend/Gdata/Gapps/_files/UserFeedDataSample1.xml create mode 100644 zend/tests/Zend/Gdata/GappsOnlineTest.php create mode 100644 zend/tests/Zend/Gdata/GappsTest.php create mode 100644 zend/tests/Zend/Gdata/GdataOnlineTest.php create mode 100644 zend/tests/Zend/Gdata/GdataTest.php create mode 100644 zend/tests/Zend/Gdata/MediaMimeStreamTest.php create mode 100644 zend/tests/Zend/Gdata/OpenSearchItemsPerPageTest.php create mode 100644 zend/tests/Zend/Gdata/OpenSearchStartIndexTest.php create mode 100644 zend/tests/Zend/Gdata/OpenSearchTotalResultsTest.php create mode 100644 zend/tests/Zend/Gdata/OriginalEventTest.php 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 create mode 100755 zend/tests/Zend/Gdata/PhotosOnlineTest.php create mode 100644 zend/tests/Zend/Gdata/QueryTest.php create mode 100644 zend/tests/Zend/Gdata/RecurrenceExceptionTest.php create mode 100644 zend/tests/Zend/Gdata/RecurrenceTest.php create mode 100644 zend/tests/Zend/Gdata/ReminderTest.php create mode 100644 zend/tests/Zend/Gdata/SkipTests.php create mode 100644 zend/tests/Zend/Gdata/Spreadsheets/CellEntryTest.php create mode 100644 zend/tests/Zend/Gdata/Spreadsheets/CellFeedTest.php create mode 100644 zend/tests/Zend/Gdata/Spreadsheets/CellQueryTest.php create mode 100644 zend/tests/Zend/Gdata/Spreadsheets/CellTest.php create mode 100644 zend/tests/Zend/Gdata/Spreadsheets/ColCountTest.php create mode 100644 zend/tests/Zend/Gdata/Spreadsheets/CustomTest.php create mode 100644 zend/tests/Zend/Gdata/Spreadsheets/DocumentQueryTest.php create mode 100644 zend/tests/Zend/Gdata/Spreadsheets/ListEntryTest.php create mode 100644 zend/tests/Zend/Gdata/Spreadsheets/ListFeedTest.php create mode 100644 zend/tests/Zend/Gdata/Spreadsheets/ListQueryTest.php create mode 100644 zend/tests/Zend/Gdata/Spreadsheets/RowCountTest.php create mode 100644 zend/tests/Zend/Gdata/Spreadsheets/SpreadsheetFeedTest.php create mode 100644 zend/tests/Zend/Gdata/Spreadsheets/WorksheetEntryTest.php create mode 100644 zend/tests/Zend/Gdata/Spreadsheets/WorksheetFeedTest.php create mode 100644 zend/tests/Zend/Gdata/Spreadsheets/_files/TestDataCellFeedSample1.xml create mode 100644 zend/tests/Zend/Gdata/Spreadsheets/_files/TestDataListFeedSample1.xml create mode 100644 zend/tests/Zend/Gdata/Spreadsheets/_files/TestDataSpreadsheetFeedSample1.xml create mode 100644 zend/tests/Zend/Gdata/Spreadsheets/_files/TestDataWorksheetFeedSample1.xml create mode 100644 zend/tests/Zend/Gdata/SpreadsheetsOnlineTest.php create mode 100644 zend/tests/Zend/Gdata/SpreadsheetsTest.php create mode 100644 zend/tests/Zend/Gdata/TestUtility/MockHttpClient.php create mode 100644 zend/tests/Zend/Gdata/TransparencyTest.php create mode 100644 zend/tests/Zend/Gdata/VisibilityTest.php create mode 100644 zend/tests/Zend/Gdata/WhenTest.php create mode 100644 zend/tests/Zend/Gdata/WhereTest.php create mode 100644 zend/tests/Zend/Gdata/WhoTest.php create mode 100644 zend/tests/Zend/Gdata/YouTube/ActivityEntryTest.php create mode 100644 zend/tests/Zend/Gdata/YouTube/ActivityFeedTest.php create mode 100644 zend/tests/Zend/Gdata/YouTube/CommentEntryTest.php create mode 100644 zend/tests/Zend/Gdata/YouTube/CommentFeedTest.php create mode 100644 zend/tests/Zend/Gdata/YouTube/ContactEntryTest.php create mode 100644 zend/tests/Zend/Gdata/YouTube/ContactFeedTest.php create mode 100644 zend/tests/Zend/Gdata/YouTube/InboxEntryTest.php create mode 100644 zend/tests/Zend/Gdata/YouTube/InboxFeedTest.php create mode 100644 zend/tests/Zend/Gdata/YouTube/PlaylistListEntryTest.php create mode 100644 zend/tests/Zend/Gdata/YouTube/PlaylistListFeedTest.php create mode 100644 zend/tests/Zend/Gdata/YouTube/PlaylistVideoEntryTest.php create mode 100644 zend/tests/Zend/Gdata/YouTube/PlaylistVideoFeedTest.php create mode 100644 zend/tests/Zend/Gdata/YouTube/SubscriptionEntryTest.php create mode 100644 zend/tests/Zend/Gdata/YouTube/SubscriptionFeedTest.php create mode 100644 zend/tests/Zend/Gdata/YouTube/UserProfileEntryTest.php create mode 100644 zend/tests/Zend/Gdata/YouTube/VideoEntryTest.php create mode 100644 zend/tests/Zend/Gdata/YouTube/VideoFeedTest.php create mode 100644 zend/tests/Zend/Gdata/YouTube/VideoQueryTest.php create mode 100644 zend/tests/Zend/Gdata/YouTube/_files/ActivityEntryDataSample1.xml create mode 100644 zend/tests/Zend/Gdata/YouTube/_files/ActivityFeedDataSample1.xml create mode 100644 zend/tests/Zend/Gdata/YouTube/_files/CommentEntryDataSample1.xml create mode 100644 zend/tests/Zend/Gdata/YouTube/_files/CommentFeedDataSample1.xml create mode 100644 zend/tests/Zend/Gdata/YouTube/_files/ContactEntryDataSample1.xml create mode 100644 zend/tests/Zend/Gdata/YouTube/_files/ContactFeedDataSample1.xml create mode 100644 zend/tests/Zend/Gdata/YouTube/_files/FormUploadTokenResponseSample.xml create mode 100644 zend/tests/Zend/Gdata/YouTube/_files/InboxEntryDataSample1.xml create mode 100644 zend/tests/Zend/Gdata/YouTube/_files/InboxEntryDataSampleV2.xml create mode 100755 zend/tests/Zend/Gdata/YouTube/_files/InboxFeedDataSample1.xml create mode 100755 zend/tests/Zend/Gdata/YouTube/_files/InboxFeedDataSampleV2.xml create mode 100644 zend/tests/Zend/Gdata/YouTube/_files/PlaylistListEntryDataSample1.xml create mode 100644 zend/tests/Zend/Gdata/YouTube/_files/PlaylistListEntryDataSampleV2.xml create mode 100644 zend/tests/Zend/Gdata/YouTube/_files/PlaylistListFeedDataSample1.xml create mode 100644 zend/tests/Zend/Gdata/YouTube/_files/PlaylistListFeedDataSampleV2.xml create mode 100644 zend/tests/Zend/Gdata/YouTube/_files/PlaylistListVideoEntryDataSampleV2.xml create mode 100644 zend/tests/Zend/Gdata/YouTube/_files/PlaylistVideoEntryDataSample1.xml create mode 100644 zend/tests/Zend/Gdata/YouTube/_files/PlaylistVideoEntryDataSampleV2.xml create mode 100644 zend/tests/Zend/Gdata/YouTube/_files/PlaylistVideoFeedDataSample1.xml create mode 100644 zend/tests/Zend/Gdata/YouTube/_files/SubscriptionEntryDataSample1.xml create mode 100644 zend/tests/Zend/Gdata/YouTube/_files/SubscriptionEntryDataSampleV2.xml create mode 100644 zend/tests/Zend/Gdata/YouTube/_files/SubscriptionEntryDataSample_channelV2.xml create mode 100644 zend/tests/Zend/Gdata/YouTube/_files/SubscriptionEntryDataSample_favoritesV2.xml create mode 100644 zend/tests/Zend/Gdata/YouTube/_files/SubscriptionEntryDataSample_playlistV2.xml create mode 100644 zend/tests/Zend/Gdata/YouTube/_files/SubscriptionEntryDataSample_queryV2.xml create mode 100644 zend/tests/Zend/Gdata/YouTube/_files/SubscriptionFeedDataSample1.xml create mode 100644 zend/tests/Zend/Gdata/YouTube/_files/SubscriptionFeedDataSampleV2.xml create mode 100644 zend/tests/Zend/Gdata/YouTube/_files/UserProfileEntryDataSample1.xml create mode 100644 zend/tests/Zend/Gdata/YouTube/_files/UserProfileEntryDataSampleV2.xml create mode 100644 zend/tests/Zend/Gdata/YouTube/_files/VideoEntryDataSample1.xml create mode 100755 zend/tests/Zend/Gdata/YouTube/_files/VideoEntryDataSamplePrivate.xml create mode 100644 zend/tests/Zend/Gdata/YouTube/_files/VideoEntryDataSampleV2.xml create mode 100644 zend/tests/Zend/Gdata/YouTube/_files/VideoFeedDataSample1.xml create mode 100644 zend/tests/Zend/Gdata/YouTubeOnlineTest.php create mode 100644 zend/tests/Zend/Gdata/YouTubeTest.php create mode 100644 zend/tests/Zend/Gdata/_files/AppSample1.txt create mode 100644 zend/tests/Zend/Gdata/_files/AppSample2.txt create mode 100644 zend/tests/Zend/Gdata/_files/AppSample3.txt create mode 100644 zend/tests/Zend/Gdata/_files/AppSample4.txt create mode 100644 zend/tests/Zend/Gdata/_files/AttendeeStatusElementSample1.xml create mode 100644 zend/tests/Zend/Gdata/_files/AttendeeTypeElementSample1.xml create mode 100644 zend/tests/Zend/Gdata/_files/CommentsElementSample1.xml create mode 100755 zend/tests/Zend/Gdata/_files/DocsTest.csv create mode 100644 zend/tests/Zend/Gdata/_files/EntryLinkElementSample1.xml create mode 100644 zend/tests/Zend/Gdata/_files/EntrySample1.xml create mode 100644 zend/tests/Zend/Gdata/_files/EventStatusElementSample1.xml create mode 100644 zend/tests/Zend/Gdata/_files/ExtendedPropertyElementSample1.xml create mode 100644 zend/tests/Zend/Gdata/_files/FeedLinkElementSample1.xml create mode 100644 zend/tests/Zend/Gdata/_files/FeedSampleV1.xml create mode 100644 zend/tests/Zend/Gdata/_files/FeedSampleV2.xml create mode 100644 zend/tests/Zend/Gdata/_files/MediaMimeStreamSample1.txt create mode 100644 zend/tests/Zend/Gdata/_files/OpenSearchItemsPerPageElementSample1.xml create mode 100644 zend/tests/Zend/Gdata/_files/OpenSearchStartIndexElementSample1.xml create mode 100644 zend/tests/Zend/Gdata/_files/OpenSearchTotalResultsElementSample1.xml create mode 100644 zend/tests/Zend/Gdata/_files/OriginalEventElementSample1.xml create mode 100644 zend/tests/Zend/Gdata/_files/RecurrenceElementSample1.xml create mode 100644 zend/tests/Zend/Gdata/_files/RecurrenceExceptionElementSample1.xml create mode 100644 zend/tests/Zend/Gdata/_files/ReminderElementSample1.xml create mode 100644 zend/tests/Zend/Gdata/_files/RsaCert.pem create mode 100644 zend/tests/Zend/Gdata/_files/RsaKey.pem create mode 100644 zend/tests/Zend/Gdata/_files/TransparencyElementSample1.xml create mode 100644 zend/tests/Zend/Gdata/_files/VisibilityElementSample1.xml create mode 100644 zend/tests/Zend/Gdata/_files/WhenElementSample1.xml create mode 100644 zend/tests/Zend/Gdata/_files/WhereElementSample1.xml create mode 100644 zend/tests/Zend/Gdata/_files/WhoElementSample1.xml create mode 100644 zend/tests/Zend/Gdata/_files/testImage.jpg (limited to 'zend/tests/Zend') diff --git a/zend/tests/Zend/AllTests.php b/zend/tests/Zend/AllTests.php new file mode 100644 index 0000000..52e3d35 --- /dev/null +++ b/zend/tests/Zend/AllTests.php @@ -0,0 +1,97 @@ +addTest(Zend_Gdata_AllTests::suite()); + if (PHP_OS != 'AIX') { + } + + return $suite; + } +} + +if (PHPUnit_MAIN_METHOD == 'Zend_AllTests::main') { + Zend_AllTests::main(); +} diff --git a/zend/tests/Zend/Gdata/AllTests.php b/zend/tests/Zend/Gdata/AllTests.php new file mode 100644 index 0000000..c4e506d --- /dev/null +++ b/zend/tests/Zend/Gdata/AllTests.php @@ -0,0 +1,424 @@ +addTestSuite('Zend_Gdata_AuthSubTest'); + + /** + * Tests that do not require online access to servers + */ + $suite->addTestSuite('Zend_Gdata_AppTest'); + $suite->addTestSuite('Zend_Gdata_App_UtilTest'); + $suite->addTestSuite('Zend_Gdata_App_BaseTest'); + $suite->addTestSuite('Zend_Gdata_App_AuthorTest'); + $suite->addTestSuite('Zend_Gdata_App_CategoryTest'); + $suite->addTestSuite('Zend_Gdata_App_ContentTest'); + $suite->addTestSuite('Zend_Gdata_App_ControlTest'); + $suite->addTestSuite('Zend_Gdata_App_EntryTest'); + $suite->addTestSuite('Zend_Gdata_App_FeedTest'); + $suite->addTestSuite('Zend_Gdata_App_GeneratorTest'); + $suite->addTestSuite('Zend_Gdata_App_CaptchaRequiredExceptionTest'); + $suite->addTestSuite('Zend_Gdata_GdataTest'); + $suite->addTestSuite('Zend_Gdata_QueryTest'); + + $suite->addTestSuite('Zend_Gdata_AttendeeStatusTest'); + $suite->addTestSuite('Zend_Gdata_AttendeeTypeTest'); + $suite->addTestSuite('Zend_Gdata_CommentsTest'); + $suite->addTestSuite('Zend_Gdata_EntryTest'); + $suite->addTestSuite('Zend_Gdata_FeedTest'); + $suite->addTestSuite('Zend_Gdata_EntryLinkTest'); + $suite->addTestSuite('Zend_Gdata_EventStatusTest'); + $suite->addTestSuite('Zend_Gdata_ExtendedPropertyTest'); + $suite->addTestSuite('Zend_Gdata_FeedLinkTest'); + $suite->addTestSuite('Zend_Gdata_OpenSearchItemsPerPageTest'); + $suite->addTestSuite('Zend_Gdata_OpenSearchStartIndexTest'); + $suite->addTestSuite('Zend_Gdata_OpenSearchTotalResultsTest'); + $suite->addTestSuite('Zend_Gdata_OriginalEventTest'); + $suite->addTestSuite('Zend_Gdata_RecurrenceTest'); + $suite->addTestSuite('Zend_Gdata_RecurrenceExceptionTest'); + $suite->addTestSuite('Zend_Gdata_ReminderTest'); + $suite->addTestSuite('Zend_Gdata_TransparencyTest'); + $suite->addTestSuite('Zend_Gdata_VisibilityTest'); + $suite->addTestSuite('Zend_Gdata_WhenTest'); + $suite->addTestSuite('Zend_Gdata_WhereTest'); + $suite->addTestSuite('Zend_Gdata_WhoTest'); + + $suite->addTestSuite('Zend_Gdata_CalendarTest'); + $suite->addTestSuite('Zend_Gdata_CalendarFeedTest'); + $suite->addTestSuite('Zend_Gdata_CalendarEventTest'); + $suite->addTestSuite('Zend_Gdata_CalendarFeedCompositeTest'); + $suite->addTestSuite('Zend_Gdata_Calendar_EventQueryTest'); + $suite->addTestSuite('Zend_Gdata_Calendar_EventQueryExceptionTest'); + $suite->addTestSuite('Zend_Gdata_Calendar_EventEntryTest'); + $suite->addTestSuite('Zend_Gdata_Calendar_AccessLevelTest'); + $suite->addTestSuite('Zend_Gdata_Calendar_ColorTest'); + $suite->addTestSuite('Zend_Gdata_Calendar_HiddenTest'); + $suite->addTestSuite('Zend_Gdata_Calendar_LinkTest'); + $suite->addTestSuite('Zend_Gdata_Calendar_SelectedTest'); + $suite->addTestSuite('Zend_Gdata_Calendar_SendEventNotificationsTest'); + $suite->addTestSuite('Zend_Gdata_Calendar_TimezoneTest'); + $suite->addTestSuite('Zend_Gdata_Calendar_WebContentTest'); + $suite->addTestSuite('Zend_Gdata_Calendar_QuickAddTest'); + + $suite->addTestSuite('Zend_Gdata_Spreadsheets_ColCountTest'); + $suite->addTestSuite('Zend_Gdata_Spreadsheets_RowCountTest'); + $suite->addTestSuite('Zend_Gdata_Spreadsheets_CellTest'); + $suite->addTestSuite('Zend_Gdata_Spreadsheets_CustomTest'); + $suite->addTestSuite('Zend_Gdata_Spreadsheets_WorksheetEntryTest'); + $suite->addTestSuite('Zend_Gdata_Spreadsheets_CellEntryTest'); + $suite->addTestSuite('Zend_Gdata_Spreadsheets_ListEntryTest'); + $suite->addTestSuite('Zend_Gdata_Spreadsheets_SpreadsheetFeedTest'); + $suite->addTestSuite('Zend_Gdata_Spreadsheets_WorksheetFeedTest'); + $suite->addTestSuite('Zend_Gdata_Spreadsheets_CellFeedTest'); + $suite->addTestSuite('Zend_Gdata_Spreadsheets_ListFeedTest'); + $suite->addTestSuite('Zend_Gdata_Spreadsheets_DocumentQueryTest'); + $suite->addTestSuite('Zend_Gdata_Spreadsheets_CellQueryTest'); + $suite->addTestSuite('Zend_Gdata_Spreadsheets_ListQueryTest'); + + $suite->addTestSuite('Zend_Gdata_Docs_DocumentListFeedTest'); + $suite->addTestSuite('Zend_Gdata_Docs_DocumentListEntryTest'); + $suite->addTestSuite('Zend_Gdata_Docs_QueryTest'); + + $suite->addTestSuite('Zend_Gdata_Photos_PhotosAlbumEntryTest'); + $suite->addTestSuite('Zend_Gdata_Photos_PhotosAlbumFeedTest'); + $suite->addTestSuite('Zend_Gdata_Photos_PhotosAlbumQueryTest'); + $suite->addTestSuite('Zend_Gdata_Photos_PhotosCommentEntryTest'); + $suite->addTestSuite('Zend_Gdata_Photos_PhotosPhotoEntryTest'); + $suite->addTestSuite('Zend_Gdata_Photos_PhotosPhotoFeedTest'); + $suite->addTestSuite('Zend_Gdata_Photos_PhotosPhotoQueryTest'); + $suite->addTestSuite('Zend_Gdata_Photos_PhotosTagEntryTest'); + $suite->addTestSuite('Zend_Gdata_Photos_PhotosUserEntryTest'); + $suite->addTestSuite('Zend_Gdata_Photos_PhotosUserFeedTest'); + $suite->addTestSuite('Zend_Gdata_Photos_PhotosUserQueryTest'); + + $suite->addTestSuite('Zend_Gdata_GappsTest'); + $suite->addTestSuite('Zend_Gdata_Gapps_EmailListEntryTest'); + $suite->addTestSuite('Zend_Gdata_Gapps_EmailListFeedTest'); + $suite->addTestSuite('Zend_Gdata_Gapps_EmailListQueryTest'); + $suite->addTestSuite('Zend_Gdata_Gapps_EmailListRecipientEntryTest'); + $suite->addTestSuite('Zend_Gdata_Gapps_EmailListRecipientFeedTest'); + $suite->addTestSuite('Zend_Gdata_Gapps_EmailListRecipientQueryTest'); + $suite->addTestSuite('Zend_Gdata_Gapps_EmailListTest'); + $suite->addTestSuite('Zend_Gdata_Gapps_ErrorTest'); + $suite->addTestSuite('Zend_Gdata_Gapps_GroupEntryTest'); + $suite->addTestSuite('Zend_Gdata_Gapps_GroupFeedTest'); + $suite->addTestSuite('Zend_Gdata_Gapps_GroupQueryTest'); + $suite->addTestSuite('Zend_Gdata_Gapps_LoginTest'); + $suite->addTestSuite('Zend_Gdata_Gapps_MemberEntryTest'); + $suite->addTestSuite('Zend_Gdata_Gapps_MemberFeedTest'); + $suite->addTestSuite('Zend_Gdata_Gapps_MemberQueryTest'); + $suite->addTestSuite('Zend_Gdata_Gapps_NameTest'); + $suite->addTestSuite('Zend_Gdata_Gapps_NicknameEntryTest'); + $suite->addTestSuite('Zend_Gdata_Gapps_NicknameFeedTest'); + $suite->addTestSuite('Zend_Gdata_Gapps_NicknameQueryTest'); + $suite->addTestSuite('Zend_Gdata_Gapps_NicknameTest'); + $suite->addTestSuite('Zend_Gdata_Gapps_OwnerEntryTest'); + $suite->addTestSuite('Zend_Gdata_Gapps_OwnerFeedTest'); + $suite->addTestSuite('Zend_Gdata_Gapps_OwnerQueryTest'); + $suite->addTestSuite('Zend_Gdata_Gapps_PropertyTest'); + $suite->addTestSuite('Zend_Gdata_Gapps_QuotaTest'); + $suite->addTestSuite('Zend_Gdata_Gapps_ServiceExceptionTest'); + $suite->addTestSuite('Zend_Gdata_Gapps_UserEntryTest'); + $suite->addTestSuite('Zend_Gdata_Gapps_UserFeedTest'); + $suite->addTestSuite('Zend_Gdata_Gapps_UserQueryTest'); + + $suite->addTestSuite('Zend_Gdata_YouTube_PlaylistListFeedTest'); + $suite->addTestSuite('Zend_Gdata_YouTube_PlaylistListEntryTest'); + $suite->addTestSuite('Zend_Gdata_YouTube_SubscriptionFeedTest'); + $suite->addTestSuite('Zend_Gdata_YouTube_SubscriptionEntryTest'); + $suite->addTestSuite('Zend_Gdata_YouTube_PlaylistVideoEntryTest'); + $suite->addTestSuite('Zend_Gdata_YouTube_VideoEntryTest'); + $suite->addTestSuite('Zend_Gdata_YouTube_PlaylistVideoFeedTest'); + $suite->addTestSuite('Zend_Gdata_YouTube_VideoFeedTest'); + $suite->addTestSuite('Zend_Gdata_YouTube_UserProfileEntryTest'); + $suite->addTestSuite('Zend_Gdata_YouTube_CommentFeedTest'); + $suite->addTestSuite('Zend_Gdata_YouTube_CommentEntryTest'); + $suite->addTestSuite('Zend_Gdata_YouTube_ContactFeedTest'); + $suite->addTestSuite('Zend_Gdata_YouTube_ContactEntryTest'); + $suite->addTestSuite('Zend_Gdata_YouTube_ActivityEntryTest'); + $suite->addTestSuite('Zend_Gdata_YouTube_ActivityFeedTest'); + + $suite->addTestSuite('Zend_Gdata_Books_CollectionEntryTest'); + $suite->addTestSuite('Zend_Gdata_Books_CollectionFeedTest'); + $suite->addTestSuite('Zend_Gdata_Books_VolumeEntryTest'); + $suite->addTestSuite('Zend_Gdata_Books_VolumeFeedTest'); + + $skippingOnlineTests = true; + if (defined('TESTS_ZEND_GDATA_ONLINE_ENABLED') && + constant('TESTS_ZEND_GDATA_ONLINE_ENABLED') == true && + defined('TESTS_ZEND_GDATA_CLIENTLOGIN_ENABLED') && + constant('TESTS_ZEND_GDATA_CLIENTLOGIN_ENABLED') == true) { + /** + * Tests that do require online access to servers + * and authentication credentials + */ + $skippingOnlineTests = false; + if (defined('TESTS_ZEND_GDATA_BLOGGER_ONLINE_ENABLED') && + constant('TESTS_ZEND_GDATA_BLOGGER_ONLINE_ENABLED') == true) { + $suite->addTestSuite('Zend_Gdata_GdataOnlineTest'); + } + + if (defined('TESTS_ZEND_GDATA_CALENDAR_ONLINE_ENABLED') && + constant('TESTS_ZEND_GDATA_CALENDAR_ONLINE_ENABLED') == true) { + $suite->addTestSuite('Zend_Gdata_CalendarOnlineTest'); + } + + if (defined('TESTS_ZEND_GDATA_SPREADSHEETS_ONLINE_ENABLED') && + constant('TESTS_ZEND_GDATA_SPREADSHEETS_ONLINE_ENABLED') == true) { + $suite->addTestSuite('Zend_Gdata_SpreadsheetsOnlineTest'); + } + + if (defined('TESTS_ZEND_GDATA_DOCS_ONLINE_ENABLED') && + constant('TESTS_ZEND_GDATA_DOCS_ONLINE_ENABLED') == true) { + $suite->addTestSuite('Zend_Gdata_DocsOnlineTest'); + } + + if (defined('TESTS_ZEND_GDATA_PHOTOS_ONLINE_ENABLED') && + constant('TESTS_ZEND_GDATA_PHOTOS_ONLINE_ENABLED') == true) { + $suite->addTestSuite('Zend_Gdata_PhotosOnlineTest'); + } + + if (defined('TESTS_ZEND_GDATA_BOOKS_ONLINE_ENABLED') && + constant('TESTS_ZEND_GDATA_BOOKS_ONLINE_ENABLED') == true) { + $suite->addTestSuite('Zend_Gdata_BooksOnlineTest'); + } + } + if (defined('TESTS_ZEND_GDATA_ONLINE_ENABLED') && + constant('TESTS_ZEND_GDATA_ONLINE_ENABLED') == true) { + /** + * Tests that do require online access to servers, but + * don't require the standard authentication credentials + */ + $skippingOnlineTests = false; + if (defined('TESTS_ZEND_GDATA_GAPPS_ONLINE_ENABLED') && + constant('TESTS_ZEND_GDATA_GAPPS_ONLINE_ENABLED') == true) { + $suite->addTestSuite('Zend_Gdata_GappsOnlineTest'); + } + if (defined('TESTS_ZEND_GDATA_YOUTUBE_ONLINE_ENABLED') && + constant('TESTS_ZEND_GDATA_YOUTUBE_ONLINE_ENABLED') == true) { + $suite->addTestSuite('Zend_Gdata_YouTubeOnlineTest'); + } + } + if ($skippingOnlineTests) { + $suite->addTestSuite('Zend_Gdata_SkipOnlineTest'); + } + return $suite; + } + +} + +if (PHPUnit_MAIN_METHOD == 'Zend_Gdata_AllTests::main') { + Zend_Gdata_AllTests::main(); +} diff --git a/zend/tests/Zend/Gdata/Analytics/AccountFeedTest.php b/zend/tests/Zend/Gdata/Analytics/AccountFeedTest.php new file mode 100755 index 0000000..d7b4344 --- /dev/null +++ b/zend/tests/Zend/Gdata/Analytics/AccountFeedTest.php @@ -0,0 +1,71 @@ +accountFeed = new Zend_Gdata_Analytics_AccountFeed( + file_get_contents(dirname(__FILE__) . '/_files/TestAccountFeed.xml') + ); + } + + public function testAccountFeed() + { + $this->assertEquals(2, count($this->accountFeed->entries)); + + foreach ($this->accountFeed->entries as $entry) { + $this->assertInstanceOf('Zend_Gdata_Analytics_AccountEntry', $entry); + } + } + + public function testFirstAccountProperties() + { + $account = $this->accountFeed->entries[0]; + $this->assertEquals(876543, "{$account->accountId}"); + $this->assertEquals('foobarbaz', "{$account->accountName}"); + $this->assertInstanceOf('Zend_GData_App_Extension_Link', $account->link[0]); + } + + public function testSecondAccountProperties() + { + $account = $this->accountFeed->entries[1]; + $this->assertEquals(23456789, "{$account->accountId}"); + $this->assertEquals('brain dump', "{$account->accountName}"); + $this->assertInstanceOf('Zend_GData_App_Extension_Link', $account->link[0]); + } +} diff --git a/zend/tests/Zend/Gdata/Analytics/AccountQueryTest.php b/zend/tests/Zend/Gdata/Analytics/AccountQueryTest.php new file mode 100644 index 0000000..a98f48d --- /dev/null +++ b/zend/tests/Zend/Gdata/Analytics/AccountQueryTest.php @@ -0,0 +1,126 @@ +accountQuery = new Zend_GData_Analytics_AccountQuery(); + $this->queryBase = Zend_GData_Analytics_AccountQuery::ANALYTICS_FEED_URI; + } + + public function testWebpropertiesAll() + { + $this->accountQuery->webproperties(); + $allQuery = $this->accountQuery->getQueryUrl(); + + $this->assertEquals( + $this->queryBase . '/~all/webproperties', + $allQuery + ); + } + + public function testWebpropertiesSpecific() + { + $this->accountQuery->webproperties(12345678); + $specificQuery = $this->accountQuery->getQueryUrl(); + + $this->assertEquals( + $this->queryBase . '/12345678/webproperties', + $specificQuery + ); + } + + public function testProfilesAll() + { + $this->accountQuery->profiles(); + $allQuery = $this->accountQuery->getQueryUrl(); + + $this->assertEquals( + $this->queryBase . '/~all/webproperties/~all/profiles', + $allQuery + ); + } + + public function testProfilesSpecific() + { + $this->accountQuery->profiles('U-87654321-0', 87654321); + $specificQuery = $this->accountQuery->getQueryUrl(); + + $this->assertEquals( + $this->queryBase . '/87654321/webproperties/U-87654321-0/profiles', + $specificQuery + ); + } + + public function testGoalsAll() + { + $this->accountQuery->goals(); + $allQuery = $this->accountQuery->getQueryUrl(); + + $this->assertEquals( + $this->queryBase . '/~all/webproperties/~all/profiles/~all/goals', + $allQuery + ); + } + + public function testGoalsSpecific() + { + $this->accountQuery->goals(42, 'U-87654321-0', 87654321); + $specificQuery = $this->accountQuery->getQueryUrl(); + + $this->assertEquals( + $this->queryBase . '/87654321/webproperties/U-87654321-0/profiles/42/goals', + $specificQuery + ); + } + + public function testChainedProperties() + { + $this->accountQuery + ->goals(42) + ->profiles('U-87654321-0') + ->webproperties(87654321); + $specificQuery = $this->accountQuery->getQueryUrl(); + + $this->assertEquals( + $this->queryBase . '/87654321/webproperties/U-87654321-0/profiles/42/goals', + $specificQuery + ); + } +} diff --git a/zend/tests/Zend/Gdata/Analytics/DataFeedTest.php b/zend/tests/Zend/Gdata/Analytics/DataFeedTest.php new file mode 100644 index 0000000..83b9b19 --- /dev/null +++ b/zend/tests/Zend/Gdata/Analytics/DataFeedTest.php @@ -0,0 +1,80 @@ + 12, + 'foobar.de' => 3, + 'foobarbaz.ch' => 1, + 'baz.ch' => 1, + ); + /** @var DataFeed */ + public $dataFeed; + + public function setUp() + { + $this->dataFeed = new Zend_Gdata_Analytics_DataFeed( + file_get_contents(dirname(__FILE__) . '/_files/TestDataFeed.xml') + ); + } + + public function testDataFeed() + { + $count = count($this->testData); + $this->assertEquals(count($this->dataFeed->entries), $count); + $this->assertEquals($this->dataFeed->entries->count(), $count); + foreach ($this->dataFeed->entries as $entry) { + $this->assertTrue($entry instanceof Zend_Gdata_Analytics_DataEntry); + } + } + + public function testGetters() + { + $sources = array_keys($this->testData); + $values = array_values($this->testData); + + foreach ($this->dataFeed as $index => $row) { + $source = $row->getDimension(Zend_Gdata_Analytics_DataQuery::DIMENSION_SOURCE); + $medium = $row->getDimension('ga:medium'); + $visits = $row->getMetric('ga:visits'); + $visitsValue = $row->getValue('ga:visits'); + + $this->assertEquals("$medium", 'referral'); + $this->assertEquals("$source", $sources[$index]); + $this->assertEquals("$visits", $values[$index]); + $this->assertEquals("$visitsValue", $values[$index]); + } + } +} diff --git a/zend/tests/Zend/Gdata/Analytics/DataQueryTest.php b/zend/tests/Zend/Gdata/Analytics/DataQueryTest.php new file mode 100644 index 0000000..f3d4653 --- /dev/null +++ b/zend/tests/Zend/Gdata/Analytics/DataQueryTest.php @@ -0,0 +1,101 @@ +dataQuery = new Zend_GData_Analytics_DataQuery(); + } + + public function testProfileId() + { + $this->assertTrue($this->dataQuery->getProfileId() == null); + $this->dataQuery->setProfileId(123456); + $this->assertTrue($this->dataQuery->getProfileId() == 123456); + } + + public function testAddMetric() + { + $this->assertTrue(count($this->dataQuery->getMetrics()) == 0); + $this->dataQuery->addMetric(Zend_GData_Analytics_DataQuery::METRIC_BOUNCES); + $this->assertTrue(count($this->dataQuery->getMetrics()) == 1); + } + + public function testAddAndRemoveMetric() + { + $this->dataQuery->addMetric(Zend_GData_Analytics_DataQuery::METRIC_BOUNCES); + $this->dataQuery->removeMetric(Zend_GData_Analytics_DataQuery::METRIC_BOUNCES); + $this->assertTrue(count($this->dataQuery->getMetrics()) == 0); + } + + public function testAddDimension() + { + $this->assertTrue(count($this->dataQuery->getDimensions()) == 0); + $this->dataQuery->addDimension(Zend_GData_Analytics_DataQuery::DIMENSION_AD_SLOT); + $this->assertTrue(count($this->dataQuery->getDimensions()) == 1); + } + + public function testAddAndRemoveDimension() + { + $this->dataQuery->addDimension(Zend_GData_Analytics_DataQuery::DIMENSION_AD_SLOT); + $this->dataQuery->removeDimension(Zend_GData_Analytics_DataQuery::DIMENSION_AD_SLOT); + $this->assertTrue(count($this->dataQuery->getDimensions()) == 0); + } + + public function testQueryString() + { + $this->dataQuery + ->setProfileId(123456789) + ->addFilter('foo=bar') + ->addFilter('bar>2') + ->addOrFilter('baz=42') + ->addDimension(Zend_GData_Analytics_DataQuery::DIMENSION_CITY) + ->addMetric(Zend_GData_Analytics_DataQuery::METRIC_PAGEVIEWS) + ->addMetric(Zend_GData_Analytics_DataQuery::METRIC_VISITS); + $url = parse_url($this->dataQuery->getQueryUrl()); + parse_str($url['query'], $parameter); + + $this->assertEquals(count($parameter), 4); + $this->assertEquals($parameter['ids'], "ga:123456789"); + $this->assertEquals($parameter['dimensions'], "ga:city"); + $this->assertEquals($parameter['metrics'], "ga:pageviews,ga:visits"); + $this->assertEquals($parameter['filters'], 'foo=bar;bar>2,baz=42'); + } +} diff --git a/zend/tests/Zend/Gdata/Analytics/_files/TestAccountFeed.xml b/zend/tests/Zend/Gdata/Analytics/_files/TestAccountFeed.xml new file mode 100644 index 0000000..9d2b83a --- /dev/null +++ b/zend/tests/Zend/Gdata/Analytics/_files/TestAccountFeed.xml @@ -0,0 +1,32 @@ + + + https://www.googleapis.com/analytics/v2.4/management/accounts + 2012-07-13T16:53:15.150Z + Google Analytics Accounts for mail@storkki.de + + + Google Analytics + + Google Analytics + 2 + 1 + 1000 + + https://www.googleapis.com/analytics/v2.4/management/accounts/876543 + 2010-03-02T16:04:23.720Z + Google Analytics Account foobarbaz + + + + + + + https://www.googleapis.com/analytics/v2.4/management/accounts/23456789 + 2011-05-17T06:53:24.385Z + Google Analytics Account brain dump + + + + + + \ No newline at end of file diff --git a/zend/tests/Zend/Gdata/Analytics/_files/TestDataFeed.xml b/zend/tests/Zend/Gdata/Analytics/_files/TestDataFeed.xml new file mode 100644 index 0000000..3d9b647 --- /dev/null +++ b/zend/tests/Zend/Gdata/Analytics/_files/TestDataFeed.xml @@ -0,0 +1,76 @@ + + + https://www.googleapis.com/analytics/v2.4/data?ids=ga:45678912&dimensions=ga:medium,ga:source,ga:browserVersion,ga:month&metrics=ga:bounces,ga:visits&sort=-ga:visits,ga:bounces&filters=ga:browser%3D%3DFirefox&start-date=2011-05-01&end-date=2011-05-31&start-index=1&max-results=50 + 2012-07-13T17:05:16.454Z + Google Analytics Data for Profile 45678912 + + + Google Analytics + + Google Analytics + 4 + 1 + 50 + + + + + false + + + + + ga:45678912 + www.foobar.de + + 2011-05-31 + 2011-05-01 + + https://www.googleapis.com/analytics/v2.4/data?ids=ga:45678912&ga:browserVersion=4.0.1&ga:medium=referral&ga:month=05&ga:source=foobarbaz.de&filters=ga:browser%3D%3DFirefox&start-date=2011-05-01&end-date=2011-05-31 + 2012-07-13T17:05:16.454Z + ga:medium=referral | ga:source=foobarbaz.de | ga:browserVersion=4.0.1 | ga:month=05 + + + + + + + + + + https://www.googleapis.com/analytics/v2.4/data?ids=ga:45678912&ga:browserVersion=3.6.17&ga:medium=referral&ga:month=05&ga:source=foobarbaz.de&filters=ga:browser%3D%3DFirefox&start-date=2011-05-01&end-date=2011-05-31 + 2012-07-13T17:05:16.454Z + ga:medium=referral | ga:source=foobar.de | ga:browserVersion=3.6.17 | ga:month=05 + + + + + + + + + + https://www.googleapis.com/analytics/v2.4/data?ids=ga:45678912&ga:browserVersion=3.5.19&ga:medium=referral&ga:month=05&ga:source=foobarbaz.ch&filters=ga:browser%3D%3DFirefox&start-date=2011-05-01&end-date=2011-05-31 + 2012-07-13T17:05:16.454Z + ga:medium=referral | ga:source=foobarbaz.ch | ga:browserVersion=3.5.19 | ga:month=05 + + + + + + + + + + https://www.googleapis.com/analytics/v2.4/data?ids=ga:45678912&ga:browserVersion=3.6.17&ga:medium=referral&ga:month=05&ga:source=foobarbaz.ch&filters=ga:browser%3D%3DFirefox&start-date=2011-05-01&end-date=2011-05-31 + 2012-07-13T17:05:16.454Z + ga:medium=referral | ga:source=baz.ch | ga:browserVersion=3.6.17 | ga:month=05 + + + + + + + + + \ No newline at end of file diff --git a/zend/tests/Zend/Gdata/App/AuthorTest.php b/zend/tests/Zend/Gdata/App/AuthorTest.php new file mode 100644 index 0000000..b1fde22 --- /dev/null +++ b/zend/tests/Zend/Gdata/App/AuthorTest.php @@ -0,0 +1,118 @@ +authorText = file_get_contents( + 'Zend/Gdata/App/_files/AuthorElementSample1.xml', + true); + $this->author = new Zend_Gdata_App_Extension_Author(); + } + + public function testEmptyAuthorShouldHaveEmptyExtensionsList() { + $this->assertTrue(is_array($this->author->extensionElements)); + $this->assertTrue(count($this->author->extensionElements) == 0); + } + + public function testNormalAuthorShouldHaveNoExtensionElements() { + $this->author->name = new Zend_Gdata_App_Extension_Name('Jeff Scudder'); + $this->assertEquals($this->author->name->text, 'Jeff Scudder'); + $this->assertEquals(count($this->author->extensionElements), 0); + $newAuthor = new Zend_Gdata_App_Extension_Author(); + $newAuthor->transferFromXML($this->author->saveXML()); + $this->assertEquals(count($newAuthor->extensionElements), 0); + $newAuthor->extensionElements = array( + new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); + $this->assertEquals(count($newAuthor->extensionElements), 1); + $this->assertEquals($newAuthor->name->text, 'Jeff Scudder'); + + /* try constructing using magic factory */ + $app = new Zend_Gdata_App(); + $newAuthor2 = $app->newAuthor(); + $newAuthor2->transferFromXML($newAuthor->saveXML()); + $this->assertEquals(count($newAuthor2->extensionElements), 1); + $this->assertEquals($newAuthor2->name->text, 'Jeff Scudder'); + } + + public function testEmptyAuthorToAndFromStringShouldMatch() { + $authorXml = $this->author->saveXML(); + $newAuthor = new Zend_Gdata_App_Extension_Author(); + $newAuthor->transferFromXML($authorXml); + $newAuthorXml = $newAuthor->saveXML(); + $this->assertTrue($authorXml == $newAuthorXml); + } + + public function testAuthorWithNameEmailToAndFromStringShouldMatch() { + $this->author->name = new Zend_Gdata_App_Extension_Name('Jeff Scudder'); + $this->author->email = new Zend_Gdata_App_Extension_Email( + 'api.jscudder@gmail.com'); + $this->author->uri = new Zend_Gdata_App_Extension_Uri( + 'http://code.google.com/apis/gdata/'); + $authorXml = $this->author->saveXML(); + $newAuthor = new Zend_Gdata_App_Extension_Author(); + $newAuthor->transferFromXML($authorXml); + $newAuthorXml = $newAuthor->saveXML(); + $this->assertTrue($authorXml == $newAuthorXml); + $this->assertEquals('Jeff Scudder', $newAuthor->name->text); + $this->assertEquals('api.jscudder@gmail.com', $newAuthor->email->text); + $this->assertEquals('http://code.google.com/apis/gdata/', $newAuthor->uri->text); + } + + public function testExtensionAttributes() { + $extensionAttributes = $this->author->extensionAttributes; + $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); + $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); + $this->author->extensionAttributes = $extensionAttributes; + $this->assertEquals('bar', $this->author->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $this->author->extensionAttributes['foo2']['value']); + $authorXml = $this->author->saveXML(); + $newAuthor = new Zend_Gdata_App_Extension_Author(); + $newAuthor->transferFromXML($authorXml); + //var_dump($this->author); + //print $authorXml; + $this->assertEquals('bar', $newAuthor->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $newAuthor->extensionAttributes['foo2']['value']); + } + + public function testConvertFullAuthorToAndFromString() { + $this->author->transferFromXML($this->authorText); + $this->assertEquals($this->author->name->text, 'John Doe'); + $this->assertEquals($this->author->email->text, + 'johndoes@someemailadress.com'); + $this->assertEquals($this->author->uri->text, 'http://www.google.com'); + } + +} diff --git a/zend/tests/Zend/Gdata/App/BaseTest.php b/zend/tests/Zend/Gdata/App/BaseTest.php new file mode 100644 index 0000000..6fae63d --- /dev/null +++ b/zend/tests/Zend/Gdata/App/BaseTest.php @@ -0,0 +1,133 @@ +fileName = 'Zend/Gdata/App/_files/FeedSample1.xml'; + $this->base = new Zend_Gdata_App_MockBase(); + } + + public function testUnknownNamespaceReturnsInput() { + $this->assertEquals('example', + $this->base->lookupNamespace('example')); + } + public function testAtomV1NamespaceReturnedByDefault() { + $this->assertEquals('http://www.w3.org/2005/Atom', + $this->base->lookupNamespace('atom')); + } + + public function testAtomPubV1NamespaceReturnedByDefault() { + $this->assertEquals('http://purl.org/atom/app#', + $this->base->lookupNamespace('app')); + } + + public function testAtomV1NamespaceReturnedWhenSpecifyingMajorVersion() { + $this->assertEquals('http://www.w3.org/2005/Atom', + $this->base->lookupNamespace('atom', + 1)); + } + + public function testAtomV1NamespaceReturnedWhenSpecifyingMajorAndMinorVersion() { + $this->assertEquals('http://www.w3.org/2005/Atom', + $this->base->lookupNamespace('atom', + 1, 0)); + } + + public function testAtomPubV1NamespaceReturnedWhenSpecifyingMajorVersion() { + $this->assertEquals('http://purl.org/atom/app#', + $this->base->lookupNamespace('app', + 1)); + } + + public function testAtomPubV1NamespaceReturnedWhenSpecifyingMajorAndMinorVersion() { + $this->assertEquals('http://purl.org/atom/app#', + $this->base->lookupNamespace('app', + 1, 0)); + } + + public function testAtomPubV2NamespaceReturnedWhenSpecifyingMajorVersion() { + $this->assertEquals('http://www.w3.org/2007/app', + $this->base->lookupNamespace('app', + 2)); + } + + public function testAtomPubV2NamespaceReturnedWhenSpecifyingMajorAndMinorVersion() { + $this->assertEquals('http://www.w3.org/2007/app', + $this->base->lookupNamespace('app', + 2, 0)); + } + + public function testNullReturnsLatestVersion() { + $this->assertEquals('http://www.w3.org/2007/app', + $this->base->lookupNamespace('app', + null, null)); + } + + public function testRegisterNamespaceWorksWithoutVersion() { + $ns = 'http://example.net/namespaces.foo'; + $prefix = 'foo'; + $this->base->registerNamespace($prefix, $ns); + $result = $this->base->lookupNamespace($prefix); + $this->assertEquals($ns, $result); + } + + public function testRegisterNamespaceAllowsSettingMajorVersion() { + $ns = 'http://example.net/namespaces.foo'; + $prefix = 'foo'; + $this->base->registerNamespace($prefix, 'wrong-1', 1); + $this->base->registerNamespace($prefix, $ns, 2); + $this->base->registerNamespace($prefix, 'wrong-3', 3); + $this->base->registerNamespace($prefix, 'wrong-4', 4); + $result = $this->base->lookupNamespace($prefix, 2); + $this->assertEquals($ns, $result); + } + + public function testRegisterNamespaceAllowsSettingMinorVersion() { + $ns = 'http://example.net/namespaces.foo'; + $prefix = 'foo'; + $this->base->registerNamespace($prefix, 'wrong-1', 1); + $this->base->registerNamespace($prefix, 'wrong-2-0', 2,0); + $this->base->registerNamespace($prefix, 'wrong-2-1', 2,1); + $this->base->registerNamespace($prefix, 'wrong-2-2', 2,2); + $this->base->registerNamespace($prefix, $ns, 2, 3); + $this->base->registerNamespace($prefix, 'wrong-2-4', 2,4); + $this->base->registerNamespace($prefix, 'wrong-3-0', 3-0); + $this->base->registerNamespace($prefix, 'wrong-3-1', 3-1); + $this->base->registerNamespace($prefix, 'wrong-4', 4); + $result = $this->base->lookupNamespace($prefix, 2, 3); + $this->assertEquals($ns, $result); + } + +} diff --git a/zend/tests/Zend/Gdata/App/CaptchaRequiredExceptionTest.php b/zend/tests/Zend/Gdata/App/CaptchaRequiredExceptionTest.php new file mode 100644 index 0000000..c4ada6b --- /dev/null +++ b/zend/tests/Zend/Gdata/App/CaptchaRequiredExceptionTest.php @@ -0,0 +1,58 @@ +exampleException = new Zend_Gdata_App_CaptchaRequiredException('testtoken', 'Captcha?ctoken=testtoken'); + } + + public function testExceptionContainsValidInformation() { + $this->assertEquals('testtoken', $this->exampleException->getCaptchaToken()); + $this->assertEquals('https://www.google.com/accounts/Captcha?ctoken=testtoken', $this->exampleException->getCaptchaUrl()); + } + + public function testExceptionIsThrowable() { + $caught = false; + try { + throw $this->exampleException; + } + catch(Zend_Gdata_App_CaptchaRequiredException $e) { + $caught = true; + } + + $this->assertTrue($caught); + } + +} diff --git a/zend/tests/Zend/Gdata/App/CategoryTest.php b/zend/tests/Zend/Gdata/App/CategoryTest.php new file mode 100644 index 0000000..289af56 --- /dev/null +++ b/zend/tests/Zend/Gdata/App/CategoryTest.php @@ -0,0 +1,114 @@ +categoryText = file_get_contents( + 'Zend/Gdata/App/_files/CategoryElementSample1.xml', + true); + $this->category = new Zend_Gdata_App_Extension_Category(); + } + + public function testEmptyCategoryShouldHaveEmptyExtensionsList() { + $this->assertTrue(is_array($this->category->extensionElements)); + $this->assertTrue(count($this->category->extensionElements) == 0); + } + + public function testNormalCategoryShouldHaveNoExtensionElements() { + + $this->category->scheme = 'http://schemas.google.com/g/2005#kind'; + $this->assertEquals($this->category->scheme, 'http://schemas.google.com/g/2005#kind'); + $this->assertEquals(count($this->category->extensionElements), 0); + $newCategory = new Zend_Gdata_App_Extension_Category(); + $newCategory->transferFromXML($this->category->saveXML()); + $this->assertEquals(0, count($newCategory->extensionElements)); + $newCategory->extensionElements = array( + new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); + $this->assertEquals(count($newCategory->extensionElements), 1); + $this->assertEquals($newCategory->scheme, 'http://schemas.google.com/g/2005#kind'); + + /* try constructing using magic factory */ + $app = new Zend_Gdata_App(); + $newCategory2 = $app->newCategory(); + $newCategory2->transferFromXML($newCategory->saveXML()); + $this->assertEquals(count($newCategory2->extensionElements), 1); + $this->assertEquals($newCategory2->scheme, 'http://schemas.google.com/g/2005#kind'); + } + + public function testEmptyCategoryToAndFromStringShouldMatch() { + $categoryXml = $this->category->saveXML(); + $newCategory = new Zend_Gdata_App_Extension_Category(); + $newCategory->transferFromXML($categoryXml); + $newCategoryXml = $newCategory->saveXML(); + $this->assertTrue($categoryXml == $newCategoryXml); + } + + public function testCategoryWithSchemeAndTermToAndFromStringShouldMatch() { + $this->category->scheme = 'http://schemas.google.com/g/2005#kind'; + $this->category->term = 'http://schemas.google.com/g/2005#event'; + $this->category->label = 'event kind'; + $categoryXml = $this->category->saveXML(); + $newCategory = new Zend_Gdata_App_Extension_Category(); + $newCategory->transferFromXML($categoryXml); + $newCategoryXml = $newCategory->saveXML(); + $this->assertTrue($categoryXml == $newCategoryXml); + $this->assertEquals('http://schemas.google.com/g/2005#kind', $newCategory->scheme); + $this->assertEquals('http://schemas.google.com/g/2005#event', $newCategory->term); + $this->assertEquals('event kind', $newCategory->label); + } + + public function testExtensionAttributes() { + $extensionAttributes = $this->category->extensionAttributes; + $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); + $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); + $this->category->extensionAttributes = $extensionAttributes; + $this->assertEquals('bar', $this->category->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $this->category->extensionAttributes['foo2']['value']); + $categoryXml = $this->category->saveXML(); + $newCategory = new Zend_Gdata_App_Extension_Category(); + $newCategory->transferFromXML($categoryXml); + $this->assertEquals('bar', $newCategory->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $newCategory->extensionAttributes['foo2']['value']); + } + + public function testConvertFullCategoryToAndFromString() { + $this->category->transferFromXML($this->categoryText); + $this->assertEquals('http://schemas.google.com/g/2005#kind', $this->category->scheme); + $this->assertEquals('http://schemas.google.com/g/2005#event', $this->category->term); + $this->assertEquals('event kind', $this->category->label); + } + +} diff --git a/zend/tests/Zend/Gdata/App/ContentTest.php b/zend/tests/Zend/Gdata/App/ContentTest.php new file mode 100644 index 0000000..eec6d7c --- /dev/null +++ b/zend/tests/Zend/Gdata/App/ContentTest.php @@ -0,0 +1,97 @@ +contentText = file_get_contents( + 'Zend/Gdata/App/_files/ContentElementSample1.xml', + true); + $this->contentText2 = file_get_contents( + 'Zend/Gdata/App/_files/ContentElementSample2.xml', + true); + $this->content = new Zend_Gdata_App_Extension_Content(); + } + + public function testEmptyContentShouldHaveEmptyExtensionsList() { + $this->assertTrue(is_array($this->content->extensionElements)); + $this->assertTrue(count($this->content->extensionElements) == 0); + } + + public function testEmptyContentToAndFromStringShouldMatch() { + $contentXml = $this->content->saveXML(); + $newContent = new Zend_Gdata_App_Extension_Content(); + $newContent->transferFromXML($contentXml); + $newContentXml = $newContent->saveXML(); + $this->assertTrue($contentXml == $newContentXml); + } + + public function testContentWithTextAndTypeToAndFromStringShouldMatch() { + $this->content->text = ''; + $this->content->type = 'xhtml'; + $contentXml = $this->content->saveXML(); + $newContent = new Zend_Gdata_App_Extension_Content(); + $newContent->transferFromXML($contentXml); + $newContentXml = $newContent->saveXML(); + $this->assertEquals($newContentXml, $contentXml); + $this->assertEquals('', $newContent->text); + $this->assertEquals('xhtml', $newContent->type); + } + + public function testContentWithSrcAndTypeToAndFromStringShouldMatch() { + $this->content->src = 'http://www.example.com/image.png'; + $this->content->type = 'image/png'; + $contentXml = $this->content->saveXML(); + $newContent = new Zend_Gdata_App_Extension_Content(); + $newContent->transferFromXML($contentXml); + $newContentXml = $newContent->saveXML(); + $this->assertEquals($newContentXml, $contentXml); + $this->assertEquals('http://www.example.com/image.png', $newContent->src); + $this->assertEquals('image/png', $newContent->type); + } + + public function testConvertContentWithSrcAndTypeToAndFromString() { + $this->content->transferFromXML($this->contentText); + $this->assertEquals('http://www.example.com/image.png', $this->content->src); + $this->assertEquals('image/png', $this->content->type); + } + + public function testConvertContentWithTextAndTypeToAndFromString() { + $this->content->transferFromXML($this->contentText2); + $this->assertEquals('xhtml', $this->content->type); + $this->assertEquals(1, count($this->content->extensionElements)); + } + +} diff --git a/zend/tests/Zend/Gdata/App/ControlTest.php b/zend/tests/Zend/Gdata/App/ControlTest.php new file mode 100644 index 0000000..b41b361 --- /dev/null +++ b/zend/tests/Zend/Gdata/App/ControlTest.php @@ -0,0 +1,75 @@ +controlText = file_get_contents( + 'Zend/Gdata/App/_files/ControlElementSample1.xml', + true); + $this->control = new Zend_Gdata_App_Extension_Control(); + } + + public function testEmptyControlShouldHaveEmptyExtensionsList() { + $this->assertTrue(is_array($this->control->extensionElements)); + $this->assertTrue(count($this->control->extensionElements) == 0); + } + + public function testEmptyControlToAndFromStringShouldMatch() { + $controlXml = $this->control->saveXML(); + $newControl = new Zend_Gdata_App_Extension_Control(); + $newControl->transferFromXML($controlXml); + $newControlXml = $newControl->saveXML(); + $this->assertTrue($controlXml == $newControlXml); + } + + public function testControlWithDraftToAndFromStringShouldMatch() { + $draft = new Zend_Gdata_App_Extension_Draft('yes'); + $this->control->draft = $draft; + $controlXml = $this->control->saveXML(); + $newControl = new Zend_Gdata_App_Extension_Control(); + $newControl->transferFromXML($controlXml); + $newControlXml = $newControl->saveXML(); + $this->assertEquals($newControlXml, $controlXml); + $this->assertEquals('yes', $newControl->draft->text); + } + + public function testConvertControlWithDraftToAndFromString() { + $this->control->transferFromXML($this->controlText); + $this->assertEquals('yes', $this->control->draft->text); + } + +} diff --git a/zend/tests/Zend/Gdata/App/EntryTest.php b/zend/tests/Zend/Gdata/App/EntryTest.php new file mode 100644 index 0000000..5d9ed9b --- /dev/null +++ b/zend/tests/Zend/Gdata/App/EntryTest.php @@ -0,0 +1,614 @@ +enryText = file_get_contents( + 'Zend/Gdata/App/_files/EntrySample1.xml', + true); + $this->httpEntrySample = file_get_contents( + 'Zend/Gdata/App/_files/EntrySampleHttp1.txt', + true); + $this->enry = new Zend_Gdata_App_Entry(); + + $this->adapter = new Test_Zend_Gdata_MockHttpClient(); + $this->client = new Zend_Gdata_HttpClient(); + $this->client->setAdapter($this->adapter); + $this->service = new Zend_Gdata_App($this->client); + } + + public function testEmptyEntryShouldHaveEmptyExtensionsList() + { + $this->assertTrue(is_array($this->enry->extensionElements)); + $this->assertTrue(count($this->enry->extensionElements) == 0); + } + + public function testEmptyEntryToAndFromStringShouldMatch() + { + $enryXml = $this->enry->saveXML(); + $newEntry = new Zend_Gdata_App_Entry(); + $newEntry->transferFromXML($enryXml); + $newEntryXml = $newEntry->saveXML(); + $this->assertTrue($enryXml == $newEntryXml); + } + + public function testConvertEntryToAndFromString() + { + $this->enry->transferFromXML($this->enryText); + $enryXml = $this->enry->saveXML(); + $newEntry = new Zend_Gdata_App_Entry(); + $newEntry->transferFromXML($enryXml); +/* + $this->assertEquals(1, count($newEntry->entry)); + $this->assertEquals('dive into mark', $newEntry->title->text); + $this->assertEquals('text', $newEntry->title->type); + $this->assertEquals('2005-07-31T12:29:29Z', $newEntry->updated->text); + $this->assertEquals('tag:example.org,2003:3', $newEntry->id->text); + $this->assertEquals(2, count($newEntry->link)); + $this->assertEquals('http://example.org/', + $newEntry->getAlternateLink()->href); + $this->assertEquals('en', + $newEntry->getAlternateLink()->hrefLang); + $this->assertEquals('text/html', + $newEntry->getAlternateLink()->type); + $this->assertEquals('http://example.org/enry.atom', + $newEntry->getSelfLink()->href); + $this->assertEquals('application/atom+xml', + $newEntry->getSelfLink()->type); + $this->assertEquals('Copyright (c) 2003, Mark Pilgrim', + $newEntry->rights->text); + $entry = $newEntry->entry[0]; + $this->assertEquals('Atom draft-07 snapshot', $entry->title->text); + $this->assertEquals('tag:example.org,2003:3.2397', + $entry->id->text); + $this->assertEquals('2005-07-31T12:29:29Z', $entry->updated->text); + $this->assertEquals('2003-12-13T08:29:29-04:00', + $entry->published->text); + $this->assertEquals('Mark Pilgrim', + $entry->author[0]->name->text); + $this->assertEquals('http://example.org/', + $entry->author[0]->uri->text); + $this->assertEquals(2, count($entry->contributor)); + $this->assertEquals('Sam Ruby', + $entry->contributor[0]->name->text); + $this->assertEquals('Joe Gregorio', + $entry->contributor[1]->name->text); + $this->assertEquals('xhtml', $entry->content->type); +*/ + } + + public function testCanSetAndGetEtag() + { + $data = "W/&FooBarBaz&"; + $this->enry->setEtag($data); + $this->assertEquals($this->enry->getEtag(), $data); + } + + public function testCanSetAndgetService() + { + $data = new Zend_Gdata_App(); + $this->enry->setService($data); + $this->assertEquals($this->enry->getService(), $data); + + $data = null; + $this->enry->setService($data); + $this->assertEquals($this->enry->getService(), $data); + } + + public function testsetServiceProvidesFluentInterface() + { + $result = $this->enry->setService(null); + $this->assertEquals($this->enry, $result); + } + + public function testGetHttpClientPullsFromServiceInstance() + { + $s = new Zend_Gdata_App(); + $this->enry->setService($s); + + $c = new Zend_Gdata_HttpClient(); + $s->setHttpClient($c); + $this->assertEquals($this->enry->getHttpClient(), + $s->getHttpClient()); + + $c = new Zend_Http_Client(); + $s->setHttpClient($c); + $this->assertEquals($this->enry->getHttpClient(), + $s->getHttpClient($c)); + } + + public function testSetHttpClientPushesIntoServiceInstance() + { + $s = new Zend_Gdata_App(); + $this->enry->setService($s); + + $c = new Zend_Gdata_HttpClient(); + $this->enry->setHttpClient($c); + $this->assertEquals(get_class($s->getHttpClient()), + 'Zend_Gdata_HttpClient'); + + $c = new Zend_Http_Client(); + $this->enry->setHttpClient($c); + $this->assertEquals(get_class($s->getHttpClient()), + 'Zend_Http_Client'); + } + + public function testSaveSupportsGdataV2() + { + // Prepare mock response + $this->adapter->setResponse("HTTP/1.1 201 Created"); + + // Make sure that we're using protocol v2 + $this->service->setMajorProtocolVersion(2); + $this->enry->setService($this->service); + + // Set a URL for posting, so that save() will work + $editLink = new Zend_Gdata_App_extension_Link('http://example.com', + 'edit'); + $this->enry->setLink(array($editLink)); + + // Perform a (mock) save + $this->enry->save(); + + // Check to make sure that a v2 header was sent + $headers = $this->adapter->popRequest()->headers; + $found = false; + foreach ($headers as $header) { + if ($header == 'GData-Version: 2') + $found = true; + } + $this->assertTrue($found, + 'GData-Version header missing or incorrect.'); + } + + public function testDeleteSupportsGdataV2() + { + // Prepare mock response + $this->adapter->setResponse("HTTP/1.1 200 OK"); + + // Make sure that we're using protocol v2 + $this->service->setMajorProtocolVersion(2); + $this->enry->setService($this->service); + + // Set a URL for posting, so that save() will work + $editLink = new Zend_Gdata_App_extension_Link('http://example.com', + 'edit'); + $this->enry->setLink(array($editLink)); + + // Perform a (mock) save + $this->enry->delete(); + + // Check to make sure that a v2 header was sent + $headers = $this->adapter->popRequest()->headers; + $found = false; + foreach ($headers as $header) { + if ($header == 'GData-Version: 2') + $found = true; + } + $this->assertTrue($found, + 'GData-Version header missing or incorrect.'); + } + + public function testIfMatchHeaderCanBeSetOnSave() + { + $etagOverride = 'foo'; + $etag = 'ABCD1234'; + $this->service->setMajorProtocolVersion(2); + $this->adapter->setResponse($this->httpEntrySample); + $entry = $this->service->newEntry(); + $entry->link = array(new Zend_Gdata_App_Extension_Link( + 'http://www.example.com', + 'edit', + 'application/atom+xml')); + $entry->setEtag($etag); + $newEntry = $entry->save(null, null, + array('If-Match' => $etagOverride)); + $headers = $this->adapter->popRequest()->headers; + $found = false; + foreach ($headers as $header) { + if ($header == 'If-Match: ' . $etagOverride) + $found = true; + } + $this->assertTrue($found, + 'If-Match header not found or incorrect'); + } + + public function testIfNoneMatchHeaderCanBeSetOnSave() + { + $etagOverride = 'foo'; + $etag = 'ABCD1234'; + $this->service->setMajorProtocolVersion(2); + $this->adapter->setResponse($this->httpEntrySample); + $entry = $this->service->newEntry(); + $entry->link = array(new Zend_Gdata_App_Extension_Link( + 'http://www.example.com', + 'edit', + 'application/atom+xml')); + $entry->setEtag($etag); + $newEntry = $entry->save(null, null, + array('If-None-Match' => $etagOverride)); + $headers = $this->adapter->popRequest()->headers; + $found = false; + foreach ($headers as $header) { + if ($header == 'If-None-Match: ' . $etagOverride) + $found = true; + } + $this->assertTrue($found, + 'If-None-Match header not found or incorrect'); + } + + public function testCanSetUriOnSave() + { + $uri = 'http://example.net/foo/bar'; + $this->adapter->setResponse($this->httpEntrySample); + $entry = $this->service->newEntry(); + $newEntry = $entry->save($uri); + $request = $this->adapter->popRequest(); + $uriObject = Zend_Uri_Http::fromString($uri); + $uriObject->setPort('80'); + $this->assertEquals($uriObject, $request->uri); + } + + public function testCanSetClassnameOnSave() + { + $className = 'Zend_Gdata_Entry'; + $this->adapter->setResponse($this->httpEntrySample); + $entry = $this->service->newEntry(); + $entry->link = array(new Zend_Gdata_App_Extension_Link( + 'http://www.example.com', + 'edit', + 'application/atom+xml')); + $newEntry = $entry->save(null, $className); + $this->assertEquals($className, get_class($newEntry)); + } + + public function testIfNoneMatchSetOnReload() + { + $etag = 'ABCD1234'; + $this->adapter->setResponse($this->httpEntrySample); + $entry = $this->service->newEntry(); + $entry->link = array(new Zend_Gdata_App_Extension_Link( + 'http://www.example.com', + 'edit', + 'application/atom+xml')); + $entry->setEtag($etag); + $newEntry = $entry->reload(); + $headers = $this->adapter->popRequest()->headers; + $found = false; + foreach ($headers as $header) { + if ($header == 'If-None-Match: ' . $etag) + $found = true; + } + $this->assertTrue($found, + 'If-None-Match header not found or incorrect'); + } + + public function testIfNoneMatchCanBeSetOnReload() + { + $etagOverride = 'foo'; + $etag = 'ABCD1234'; + $this->adapter->setResponse($this->httpEntrySample); + $entry = $this->service->newEntry(); + $entry->link = array(new Zend_Gdata_App_Extension_Link( + 'http://www.example.com', + 'edit', + 'application/atom+xml')); + $entry->setEtag($etag); + $newEntry = $entry->reload(null, null, + array('If-None-Match' => $etagOverride)); + $headers = $this->adapter->popRequest()->headers; + $found = false; + foreach ($headers as $header) { + if ($header == 'If-None-Match: ' . $etagOverride) + $found = true; + } + $this->assertTrue($found, + 'If-None-Match header not found or incorrect'); + } + + public function testReloadReturnsEntryObject() + { + $etag = 'ABCD1234'; + $this->adapter->setResponse($this->httpEntrySample); + $entry = $this->service->newEntry(); + $entry->link = array(new Zend_Gdata_App_Extension_Link( + 'http://www.example.com', + 'edit', + 'application/atom+xml')); + $entry->setEtag($etag); + $newEntry = $entry->reload(); + $this->assertEquals('Zend_Gdata_App_Entry', get_class($newEntry)); + } + + public function testReloadPopulatesEntryObject() + { + $etag = 'ABCD1234'; + $this->adapter->setResponse($this->httpEntrySample); + $entry = $this->service->newEntry(); + $entry->link = array(new Zend_Gdata_App_Extension_Link( + 'http://www.example.com', + 'edit', + 'application/atom+xml')); + $entry->setEtag($etag); + $newEntry = $entry->reload(); + $this->assertEquals('Hello world', $newEntry->title->text); + } + + public function testReloadDoesntThrowExceptionIfNoEtag() + { + $this->adapter->setResponse($this->httpEntrySample); + $entry = $this->service->newEntry(); + $entry->link = array(new Zend_Gdata_App_Extension_Link( + 'http://www.example.com', + 'edit', + 'application/atom+xml')); + $newEntry = $entry->reload(); + $this->assertEquals('Zend_Gdata_App_Entry', get_class($newEntry)); + } + + public function testReloadExtractsURIFromEditLink() + { + $expectedUri = 'http://www.example.com'; + $etag = 'ABCD1234'; + $this->service->setMajorProtocolVersion(2); + $this->adapter->setResponse($this->httpEntrySample); + $entry = $this->service->newEntry(); + $entry->link = array(new Zend_Gdata_App_Extension_Link( + $expectedUri, + 'edit', + 'application/atom+xml')); + $entry->setEtag($etag); + $newEntry = $entry->reload(); + $requestUri = $this->adapter->popRequest()->uri; + $expectedUriObject = Zend_Uri_Http::fromString($expectedUri); + $expectedUriObject->setPort('80'); + $this->assertEquals($expectedUriObject, $requestUri); + } + + public function testReloadAllowsCustomURI() + { + $uriOverride = 'http://www.example.org'; + $etag = 'ABCD1234'; + $this->service->setMajorProtocolVersion(2); + $this->adapter->setResponse($this->httpEntrySample); + $entry = $this->service->newEntry(); + $entry->link = array(new Zend_Gdata_App_Extension_Link( + 'http://www.example.com', + 'edit', + 'application/atom+xml')); + $entry->setEtag($etag); + $newEntry = $entry->reload($uriOverride); + $requestUri = $this->adapter->popRequest()->uri; + $uriOverrideObject = Zend_Uri_Http::fromString($uriOverride); + $uriOverrideObject->setPort('80'); + $this->assertEquals($uriOverrideObject, $requestUri); + } + + public function testReloadReturnsNullIfEntryNotModified() + { + $etag = 'ABCD1234'; + $this->service->setMajorProtocolVersion(2); + $this->adapter->setResponse('HTTP/1.1 304 Not Modified'); + $entry = $this->service->newEntry(); + $entry->link = array(new Zend_Gdata_App_Extension_Link( + 'http://www.example.com', + 'edit', + 'application/atom+xml')); + $entry->setEtag($etag); + $newEntry = $entry->reload(); + $this->assertEquals(null, $newEntry); + } + + public function testCanSetReloadReturnClassname() + { + $className = 'Zend_Gdata_Entry'; + $etag = 'ABCD1234'; + $this->service->setMajorProtocolVersion(2); + $this->adapter->setResponse($this->httpEntrySample); + $entry = $this->service->newEntry(); + $entry->link = array(new Zend_Gdata_App_Extension_Link( + 'http://www.example.com', + 'edit', + 'application/atom+xml')); + $entry->setEtag($etag); + $newEntry = $entry->reload(null, $className); + $this->assertEquals($className, get_class($newEntry)); + } + + public function testReloadInheritsClassname() + { + $className = 'Zend_Gdata_Entry'; + $etag = 'ABCD1234'; + $this->service->setMajorProtocolVersion(2); + $this->adapter->setResponse($this->httpEntrySample); + $entry = new $className; + $entry->setService($this->service); + $entry->link = array(new Zend_Gdata_App_Extension_Link( + 'http://www.example.com', + 'edit', + 'application/atom+xml')); + $entry->setEtag($etag); + $newEntry = $entry->reload(); + $this->assertEquals($className, get_class($newEntry)); + } + + public function testCanSetMajorProtocolVersion() + { + $expectedVersion = 42; + $entry = $this->service->newEntry(); + $entry->setMajorProtocolVersion($expectedVersion); + $receivedVersion = $entry->getMajorProtocolVersion(); + $this->assertEquals($expectedVersion, $receivedVersion); + } + + public function testCanSetMinorProtocolVersion() + { + $expectedVersion = 42; + $entry = $this->service->newEntry(); + $entry->setMinorProtocolVersion($expectedVersion); + $receivedVersion = $entry->getMinorProtocolVersion(); + $this->assertEquals($expectedVersion, $receivedVersion); + } + + public function testMajorProtocolVersionCannotBeZero() + { + $expectedVersion = 0; + $entry = $this->service->newEntry(); + $this->setExpectedException('Zend_Gdata_App_InvalidArgumentException'); + $entry->setMajorProtocolVersion($expectedVersion); + } + + public function testMajorProtocolVersionCannotBeNegative() + { + $expectedVersion = -1; + $entry = $this->service->newEntry(); + $this->setExpectedException('Zend_Gdata_App_InvalidArgumentException'); + $entry->setMajorProtocolVersion($expectedVersion); + } + + public function testMajorProtocolVersionMayBeNull() + { + $expectedVersion = null; + $entry = $this->service->newEntry(); + $entry->setMajorProtocolVersion($expectedVersion); + $receivedVersion = $entry->getMajorProtocolVersion(); + $this->assertNull($receivedVersion); + } + + public function testMinorProtocolVersionMayBeZero() + { + $expectedVersion = 0; + $entry = $this->service->newEntry(); + $entry->setMinorProtocolVersion($expectedVersion); + $receivedVersion = $entry->getMinorProtocolVersion(); + $this->assertEquals($expectedVersion, $receivedVersion); + } + + public function testMinorProtocolVersionCannotBeNegative() + { + $expectedVersion = -1; + $entry = $this->service->newEntry(); + $this->setExpectedException('Zend_Gdata_App_InvalidArgumentException'); + $entry->setMinorProtocolVersion($expectedVersion); + } + + public function testMinorProtocolVersionMayBeNull() + { + $expectedVersion = null; + $entry = $this->service->newEntry(); + $entry->setMinorProtocolVersion($expectedVersion); + $receivedVersion = $entry->getMinorProtocolVersion(); + $this->assertNull($receivedVersion); + } + + public function testDefaultMajorProtocolVersionIs1() + { + $entry = $this->service->newEntry(); + $this->assertEquals(1, $entry->getMajorProtocolVersion()); + } + + public function testDefaultMinorProtocolVersionIsNull() + { + $entry = $this->service->newEntry(); + $this->assertNull($entry->getMinorProtocolVersion()); + } + + public function testLookupNamespaceUsesCurrentVersion() + { + $prefix = 'test'; + $v1TestString = 'TEST-v1'; + $v2TestString = 'TEST-v2'; + + Zend_Gdata_App_Base::flushNamespaceLookupCache(); + $entry = $this->service->newEntry(); + $entry->registerNamespace($prefix, $v1TestString, 1, 0); + $entry->registerNamespace($prefix, $v2TestString, 2, 0); + $entry->setMajorProtocolVersion(1); + $result = $entry->lookupNamespace($prefix); + $this->assertEquals($v1TestString, $result); + $entry->setMajorProtocolVersion(2); + $result = $entry->lookupNamespace($prefix); + $this->assertEquals($v2TestString, $result); + $entry->setMajorProtocolVersion(null); // Should default to latest + $result = $entry->lookupNamespace($prefix); + $this->assertEquals($v2TestString, $result); + } + + public function testLookupNamespaceObeysParentBehavior() + { + $prefix = 'test'; + $testString10 = 'TEST-v1-0'; + $testString20 = 'TEST-v2-0'; + $testString11 = 'TEST-v1-1'; + $testString21 = 'TEST-v2-1'; + $testString12 = 'TEST-v1-2'; + $testString22 = 'TEST-v2-2'; + + Zend_Gdata_App_Base::flushNamespaceLookupCache(); + $entry = $this->service->newEntry(); + $entry->registerNamespace($prefix, $testString10, 1, 0); + $entry->registerNamespace($prefix, $testString20, 2, 0); + $entry->registerNamespace($prefix, $testString11, 1, 1); + $entry->registerNamespace($prefix, $testString21, 2, 1); + $entry->registerNamespace($prefix, $testString12, 1, 2); + $entry->registerNamespace($prefix, $testString22, 2, 2); + + // Assumes default version (1) + $result = $entry->lookupNamespace($prefix, 1, null); + $this->assertEquals($testString12, $result); + $result = $entry->lookupNamespace($prefix, 2, null); + $this->assertEquals($testString22, $result); + $result = $entry->lookupNamespace($prefix, 1, 1); + $this->assertEquals($testString11, $result); + $result = $entry->lookupNamespace($prefix, 2, 1); + $this->assertEquals($testString21, $result); + $result = $entry->lookupNamespace($prefix, null, null); + $this->assertEquals($testString12, $result); + $result = $entry->lookupNamespace($prefix, null, 1); + $this->assertEquals($testString11, $result); + + // Override to retrieve latest version + $entry->setMajorProtocolVersion(null); + $result = $entry->lookupNamespace($prefix, null, null); + $this->assertEquals($testString22, $result); + $result = $entry->lookupNamespace($prefix, null, 1); + $this->assertEquals($testString21, $result); + } + +} diff --git a/zend/tests/Zend/Gdata/App/FeedTest.php b/zend/tests/Zend/Gdata/App/FeedTest.php new file mode 100644 index 0000000..a86b6c7 --- /dev/null +++ b/zend/tests/Zend/Gdata/App/FeedTest.php @@ -0,0 +1,282 @@ +feedText = file_get_contents( + 'Zend/Gdata/App/_files/FeedSample1.xml', + true); + $this->feed = new Zend_Gdata_App_Feed(); + } + + public function testEmptyFeedShouldHaveEmptyExtensionsList() { + $this->assertTrue(is_array($this->feed->extensionElements)); + $this->assertTrue(count($this->feed->extensionElements) == 0); + } + + public function testEmptyFeedToAndFromStringShouldMatch() { + $feedXml = $this->feed->saveXML(); + $newFeed = new Zend_Gdata_App_Feed(); + $newFeed->transferFromXML($feedXml); + $newFeedXml = $newFeed->saveXML(); + $this->assertTrue($feedXml == $newFeedXml); + } + + public function testConvertFeedToAndFromString() { + $this->feed->transferFromXML($this->feedText); + $feedXml = $this->feed->saveXML(); + $newFeed = new Zend_Gdata_App_Feed(); + $newFeed->transferFromXML($feedXml); + $this->assertEquals(1, count($newFeed->entry)); + $this->assertEquals('dive into mark', $newFeed->title->text); + $this->assertEquals('text', $newFeed->title->type); + $this->assertEquals('2005-07-31T12:29:29Z', $newFeed->updated->text); + $this->assertEquals('tag:example.org,2003:3', $newFeed->id->text); + $this->assertEquals(2, count($newFeed->link)); + $this->assertEquals('http://example.org/', + $newFeed->getAlternateLink()->href); + $this->assertEquals('en', + $newFeed->getAlternateLink()->hrefLang); + $this->assertEquals('text/html', + $newFeed->getAlternateLink()->type); + $this->assertEquals('http://example.org/feed.atom', + $newFeed->getSelfLink()->href); + $this->assertEquals('application/atom+xml', + $newFeed->getSelfLink()->type); + $this->assertEquals('Copyright (c) 2003, Mark Pilgrim', + $newFeed->rights->text); + $entry = $newFeed->entry[0]; + $this->assertEquals('Atom draft-07 snapshot', $entry->title->text); + $this->assertEquals('tag:example.org,2003:3.2397', + $entry->id->text); + $this->assertEquals('2005-07-31T12:29:29Z', $entry->updated->text); + $this->assertEquals('2003-12-13T08:29:29-04:00', + $entry->published->text); + $this->assertEquals('Mark Pilgrim', + $entry->author[0]->name->text); + $this->assertEquals('http://example.org/', + $entry->author[0]->uri->text); + $this->assertEquals(2, count($entry->contributor)); + $this->assertEquals('Sam Ruby', + $entry->contributor[0]->name->text); + $this->assertEquals('Joe Gregorio', + $entry->contributor[1]->name->text); + $this->assertEquals('xhtml', $entry->content->type); + } + + public function testCanAddIndividualEntries() { + $this->feed->transferFromXML($this->feedText); + $this->assertEquals(1, count($this->feed->entry)); + $oldTitle = $this->feed->entry[0]->title->text; + $newEntry = new Zend_Gdata_App_Entry(); + $newEntry->setTitle(new Zend_Gdata_App_Extension_Title("Foo")); + $this->feed->addEntry($newEntry); + $this->assertEquals(2, count($this->feed->entry)); + $this->assertEquals($oldTitle, $this->feed->entry[0]->title->text); + $this->assertEquals("Foo", $this->feed->entry[1]->title->text); + } + + public function testCanSetAndGetEtag() { + $data = "W/&FooBarBaz&"; + $this->feed->setEtag($data); + $this->assertEquals($this->feed->getEtag(), $data); + } + + public function testSetServicePropagatesToChildren() { + // Setup + $entries = array(new Zend_Gdata_App_Entry(), + new Zend_Gdata_App_Entry()); + foreach ($entries as $entry) { + $this->feed->addEntry($entry); + } + + // Set new service instance and test for propagation + $s = new Zend_Gdata_App(); + $this->feed->setService($s); + + $service = $this->feed->getService(); + if (!is_object($service)) { + $this->fail('No feed service received'); + } + $this->assertEquals('Zend_Gdata_App', + get_class($service)); + + foreach ($entries as $entry) { + $service = $entry->getService(); + if (!is_object($service)) { + $this->fail('No entry service received'); + } + $this->assertEquals('Zend_Gdata_App', + get_class($service)); + } + + // Set null service instance and test for propagation + $s = null; + $this->feed->setService($s); + $this->assertFalse(is_object($this->feed->getService())); + foreach ($entries as $entry) { + $service = $entry->getService(); + $this->assertFalse(is_object($service)); + } + } + + public function testCanSetMajorProtocolVersion() + { + $expectedVersion = 42; + $this->feed->setMajorProtocolVersion($expectedVersion); + $receivedVersion = $this->feed->getMajorProtocolVersion(); + $this->assertEquals($expectedVersion, $receivedVersion); + } + + public function testCanSetMinorProtocolVersion() + { + $expectedVersion = 42; + $this->feed->setMinorProtocolVersion($expectedVersion); + $receivedVersion = $this->feed->getMinorProtocolVersion(); + $this->assertEquals($expectedVersion, $receivedVersion); + } + + public function testEntriesInheritFeedVersionOnCreate() + { + $major = 98; + $minor = 12; + $this->feed->setMajorProtocolVersion($major); + $this->feed->setMinorProtocolVersion($minor); + $this->feed->transferFromXML($this->feedText); + foreach ($this->feed->entries as $entry) { + $this->assertEquals($major, $entry->getMajorProtocolVersion()); + $this->assertEquals($minor, $entry->getMinorProtocolVersion()); + } + } + + public function testEntriesInheritFeedVersionOnUpdate() + { + $major = 98; + $minor = 12; + $this->feed->transferFromXML($this->feedText); + $this->feed->setMajorProtocolVersion($major); + $this->feed->setMinorProtocolVersion($minor); + foreach ($this->feed->entries as $entry) { + $this->assertEquals($major, $entry->getMajorProtocolVersion()); + $this->assertEquals($minor, $entry->getMinorProtocolVersion()); + } + } + + public function testDefaultMajorProtocolVersionIs1() + { + $this->assertEquals(1, $this->feed->getMajorProtocolVersion()); + } + + public function testDefaultMinorProtocolVersionIsNull() + { + $this->assertNull($this->feed->getMinorProtocolVersion()); + } + + public function testLookupNamespaceUsesCurrentVersion() + { + $prefix = 'test'; + $v1TestString = 'TEST-v1'; + $v2TestString = 'TEST-v2'; + + Zend_Gdata_App_Base::flushNamespaceLookupCache(); + $feed = $this->feed; + $feed->registerNamespace($prefix, $v1TestString, 1, 0); + $feed->registerNamespace($prefix, $v2TestString, 2, 0); + $feed->setMajorProtocolVersion(1); + $result = $feed->lookupNamespace($prefix); + $this->assertEquals($v1TestString, $result); + $feed->setMajorProtocolVersion(2); + $result = $feed->lookupNamespace($prefix); + $this->assertEquals($v2TestString, $result); + $feed->setMajorProtocolVersion(null); // Should default to latest + $result = $feed->lookupNamespace($prefix); + } + + public function testLookupNamespaceObeysParentBehavior() + { + $prefix = 'test'; + $testString10 = 'TEST-v1-0'; + $testString20 = 'TEST-v2-0'; + $testString11 = 'TEST-v1-1'; + $testString21 = 'TEST-v2-1'; + $testString12 = 'TEST-v1-2'; + $testString22 = 'TEST-v2-2'; + + Zend_Gdata_App_Base::flushNamespaceLookupCache(); + $feed = $this->feed; + $feed->registerNamespace($prefix, $testString10, 1, 0); + $feed->registerNamespace($prefix, $testString20, 2, 0); + $feed->registerNamespace($prefix, $testString11, 1, 1); + $feed->registerNamespace($prefix, $testString21, 2, 1); + $feed->registerNamespace($prefix, $testString12, 1, 2); + $feed->registerNamespace($prefix, $testString22, 2, 2); + + // Assumes default version (1) + $result = $feed->lookupNamespace($prefix, 1, null); + $this->assertEquals($testString12, $result); + $result = $feed->lookupNamespace($prefix, 2, null); + $this->assertEquals($testString22, $result); + $result = $feed->lookupNamespace($prefix, 1, 1); + $this->assertEquals($testString11, $result); + $result = $feed->lookupNamespace($prefix, 2, 1); + $this->assertEquals($testString21, $result); + $result = $feed->lookupNamespace($prefix, null, null); + $this->assertEquals($testString12, $result); + $result = $feed->lookupNamespace($prefix, null, 1); + $this->assertEquals($testString11, $result); + + // Override to retrieve latest version + $feed->setMajorProtocolVersion(null); + $result = $feed->lookupNamespace($prefix, null, null); + $this->assertEquals($testString22, $result); + $result = $feed->lookupNamespace($prefix, null, 1); + $this->assertEquals($testString21, $result); + } + + /** + * @group ZF-10242 + */ + public function testCount() + { + $feed = new Zend_Gdata_App_Feed(); + $feed->addEntry('foo') + ->addEntry('bar'); + + $this->assertEquals(2, $feed->count()); + $this->assertEquals(2, count($feed)); + } +} diff --git a/zend/tests/Zend/Gdata/App/GeneratorTest.php b/zend/tests/Zend/Gdata/App/GeneratorTest.php new file mode 100644 index 0000000..ac1a02b --- /dev/null +++ b/zend/tests/Zend/Gdata/App/GeneratorTest.php @@ -0,0 +1,82 @@ +generatorText = file_get_contents( + 'Zend/Gdata/App/_files/GeneratorElementSample1.xml', + true); + $this->generator = new Zend_Gdata_App_Extension_Generator(); + } + + public function testEmptyGeneratorShouldHaveEmptyExtensionsList() { + $this->assertTrue(is_array($this->generator->extensionElements)); + $this->assertTrue(count($this->generator->extensionElements) == 0); + } + + public function testEmptyGeneratorToAndFromStringShouldMatch() { + $generatorXml = $this->generator->saveXML(); + $newGenerator = new Zend_Gdata_App_Extension_Generator(); + $newGenerator->transferFromXML($generatorXml); + $newGeneratorXml = $newGenerator->saveXML(); + $this->assertTrue($generatorXml == $newGeneratorXml); + } + + public function testGeneratorToAndFromStringShouldMatch() { + $this->generator->uri = 'http://code.google.com/apis/gdata/'; + $this->generator->version = '1.0'; + $this->generator->text = 'Google data APIs'; + $generatorXml = $this->generator->saveXML(); + $newGenerator = new Zend_Gdata_App_Extension_Generator(); + $newGenerator->transferFromXML($generatorXml); + $newGeneratorXml = $newGenerator->saveXML(); + $this->assertEquals($newGeneratorXml, $generatorXml); + $this->assertEquals('http://code.google.com/apis/gdata/', + $newGenerator->uri); + $this->assertEquals('1.0', $newGenerator->version); + $this->assertEquals('Google data APIs', $newGenerator->text); + } + + public function testConvertGeneratorWithDraftToAndFromString() { + $this->generator->transferFromXML($this->generatorText); + $this->assertEquals('http://code.google.com/apis/gdata/', + $this->generator->uri); + $this->assertEquals('1.0', $this->generator->version); + $this->assertEquals('Google data APIs', $this->generator->text); + } + +} diff --git a/zend/tests/Zend/Gdata/App/HttpExceptionTest.php b/zend/tests/Zend/Gdata/App/HttpExceptionTest.php new file mode 100755 index 0000000..eba19da --- /dev/null +++ b/zend/tests/Zend/Gdata/App/HttpExceptionTest.php @@ -0,0 +1,71 @@ +sprKey = constant('TESTS_ZEND_GDATA_SPREADSHEETS_SPREADSHEETKEY'); + $this->wksId = constant('TESTS_ZEND_GDATA_SPREADSHEETS_WORKSHEETID'); + $service = Zend_Gdata_Spreadsheets::AUTH_SERVICE_NAME; + $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service); + $this->gdata = new Zend_Gdata_Spreadsheets($client); + } + + public function testGetRawResponseBody() + { + try { + $rowData = array(); + $entry = $this->gdata->insertRow($rowData, $this->sprKey); + $this->fail('Expecting Zend_Gdata_App_HttpException'); + } catch (Zend_Gdata_App_HttpException $hExc) { + $this->assertThat($hExc, + $this->isInstanceOf('Zend_Gdata_App_HttpException'), + 'Expecting Zend_Gdata_App_HttpException, got ' + . get_class($hExc)); + + $message = $hExc->getMessage(); + $this->assertEquals($message, 'Expected response code 200, got 400'); + $body = $hExc->getRawResponseBody(); + $this->assertNotNull($body); + $this->assertNotEquals(stripos($body, + 'Blank rows cannot be written; use delete instead.'), false); + } + } +} diff --git a/zend/tests/Zend/Gdata/App/MockBase.php b/zend/tests/Zend/Gdata/App/MockBase.php new file mode 100644 index 0000000..581fc99 --- /dev/null +++ b/zend/tests/Zend/Gdata/App/MockBase.php @@ -0,0 +1,38 @@ +assertEquals('2006-12-01', $date); + } + + public function testFormatTimestampFromStringWithTimezone() + { + // assert that a correctly formatted timestamp is not modified + $date = Zend_Gdata_App_Util::formatTimestamp('2007-01-10T13:31:12-04:00'); + $this->assertEquals('2007-01-10T13:31:12-04:00', $date); + } + + public function testFormatTimestampWithMilliseconds() + { + // assert that a correctly formatted timestamp is not modified + $date = Zend_Gdata_App_Util::formatTimestamp('1956-12-14T43:09:54.52376Z'); + $this->assertEquals('1956-12-14T43:09:54.52376Z', $date); + } + + public function testFormatTimestampUsingZuluAsOffset() + { + // assert that a correctly formatted timestamp is not modified + $date = Zend_Gdata_App_Util::formatTimestamp('2024-03-19T01:38:12Z'); + $this->assertEquals('2024-03-19T01:38:12Z', $date); + } + + public function testFormatTimestampUsingLowercaseTAndZ() + { + // assert that a correctly formatted timestamp is not modified + $date = Zend_Gdata_App_Util::formatTimestamp('1945-07-19t12:19:08z'); + $this->assertEquals('1945-07-19t12:19:08z', $date); + } + + public function testFormatTimestampFromStringWithNonCompliantDate() + { + // assert that a non-compliant date is converted to RFC 3339 + $date = Zend_Gdata_App_Util::formatTimestamp('2007/07/13'); + $this->assertEquals('2007-07-13T00:00:00', $date); + } + + public function testFormatTimestampFromInteger() + { + $ts = 1164960000; // Fri Dec 1 00:00:00 PST 2006 + $date = Zend_Gdata_App_Util::formatTimestamp($ts); + $this->assertEquals('2006-12-01T08:00:00+00:00', $date); + } + + public function testExceptionFormatTimestampNonsense() + { + $util = new Zend_Gdata_App_Util(); + try { + $ts = Zend_Gdata_App_Util::formatTimestamp('nonsense string'); + } catch (Zend_Gdata_App_Exception $e) { + $this->assertEquals('Invalid timestamp: nonsense string.', $e->getMessage()); + return; + } + // Excetion not thrown, this is bad. + $this->fail("Exception not thrown."); + } + + public function testExceptionFormatTimestampSemiInvalid() + { + $util = new Zend_Gdata_App_Util(); + try { + $ts = Zend_Gdata_App_Util::formatTimestamp('2007-06-05adslfkja'); + } catch (Zend_Gdata_App_Exception $e) { + $this->assertEquals('Invalid timestamp: 2007-06-05adslfkja.', $e->getMessage()); + return; + } + // Excetion not thrown, this is bad. + $this->fail("Exception not thrown."); + } + + public function testExceptionFormatTimestampInvalidTime() + { + $util = new Zend_Gdata_App_Util(); + try { + $ts = Zend_Gdata_App_Util::formatTimestamp('2007-06-05Tadslfkja'); + } catch (Zend_Gdata_App_Exception $e) { + $this->assertEquals('Invalid timestamp: 2007-06-05Tadslfkja.', $e->getMessage()); + return; + } + // Excetion not thrown, this is bad. + $this->fail("Exception not thrown."); + } + + public function testExceptionFormatTimestampInvalidOffset() + { + $util = new Zend_Gdata_App_Util(); + try { + $ts = Zend_Gdata_App_Util::formatTimestamp('2007-06-05T02:51:12+egg'); + } catch (Zend_Gdata_App_Exception $e) { + $this->assertEquals('Invalid timestamp: 2007-06-05T02:51:12+egg.', $e->getMessage()); + return; + } + // Excetion not thrown, this is bad. + $this->fail("Exception not thrown."); + } + + public function testExceptionFormatTimestampInvalidOffsetHours() + { + $util = new Zend_Gdata_App_Util(); + try { + $ts = Zend_Gdata_App_Util::formatTimestamp('2007-06-05T02:51:12-ab:00'); + } catch (Zend_Gdata_App_Exception $e) { + $this->assertEquals('Invalid timestamp: 2007-06-05T02:51:12-ab:00.', $e->getMessage()); + return; + } + // Excetion not thrown, this is bad. + $this->fail("Exception not thrown."); + } + + /** + * @group ZF-11610 + */ + public function testFormatTimestepHandlesSmallUnixTimestampProperly() + { + $this->assertEquals( + '1970-01-01T00:02:03+00:00', + Zend_Gdata_App_Util::formatTimestamp(123) + ); + } + + public function testFindGreatestBoundedValueReturnsMax() { + $data = array(-1 => null, + 0 => null, + 1 => null, + 2 => null, + 3 => null, + 5 => null, + -2 => null); + $result = Zend_Gdata_App_Util::findGreatestBoundedValue(99, $data); + $this->assertEquals(5, $result); + } + + public function testFindGreatestBoundedValueReturnsMaxWhenBounded() { + $data = array(-1 => null, + 0 => null, + 1 => null, + 2 => null, + 3 => null, + 5 => null, + -2 => null); + $result = Zend_Gdata_App_Util::findGreatestBoundedValue(4, $data); + $this->assertEquals(3, $result); + } + + public function testFindGreatestBoundedValueReturnsMaxWhenUnbounded() { + $data = array(-1 => null, + 0 => null, + 1 => null, + 2 => null, + 3 => null, + 5 => null, + -2 => null); + $result = Zend_Gdata_App_Util::findGreatestBoundedValue(null, $data); + $this->assertEquals(5, $result); + } + + public function testFindGreatestBoundedValueReturnsZeroWhenZeroBounded() { + $data = array(-1 => null, + 0 => null, + 1 => null, + 2 => null, + 3 => null, + 5 => null, + -2 => null); + $result = Zend_Gdata_App_Util::findGreatestBoundedValue(0, $data); + $this->assertEquals(0, $result); + } + + public function testFindGreatestBoundedValueFailsWhenNegativelyBounded() { + $data = array(-1 => null, + 0 => null, + 1 => null, + 2 => null, + 3 => null, + 5 => null, + -2 => null); + try { + $result = Zend_Gdata_App_Util::findGreatestBoundedValue(-1, $data); + $failed = true; + } catch (Zend_Gdata_App_Exception $e) { + $failed = false; + } + $this->assertFalse($failed, 'Exception not raised.'); + } + +} diff --git a/zend/tests/Zend/Gdata/App/_files/AuthorElementSample1.xml b/zend/tests/Zend/Gdata/App/_files/AuthorElementSample1.xml new file mode 100644 index 0000000..772b6f5 --- /dev/null +++ b/zend/tests/Zend/Gdata/App/_files/AuthorElementSample1.xml @@ -0,0 +1,6 @@ + + + John Doe + johndoes@someemailadress.com + http://www.google.com + diff --git a/zend/tests/Zend/Gdata/App/_files/CategoryElementSample1.xml b/zend/tests/Zend/Gdata/App/_files/CategoryElementSample1.xml new file mode 100644 index 0000000..2a8b609 --- /dev/null +++ b/zend/tests/Zend/Gdata/App/_files/CategoryElementSample1.xml @@ -0,0 +1,4 @@ + + diff --git a/zend/tests/Zend/Gdata/App/_files/ContentElementSample1.xml b/zend/tests/Zend/Gdata/App/_files/ContentElementSample1.xml new file mode 100644 index 0000000..91acb5b --- /dev/null +++ b/zend/tests/Zend/Gdata/App/_files/ContentElementSample1.xml @@ -0,0 +1,3 @@ + + diff --git a/zend/tests/Zend/Gdata/App/_files/ContentElementSample2.xml b/zend/tests/Zend/Gdata/App/_files/ContentElementSample2.xml new file mode 100644 index 0000000..18cdfc1 --- /dev/null +++ b/zend/tests/Zend/Gdata/App/_files/ContentElementSample2.xml @@ -0,0 +1,2 @@ + + diff --git a/zend/tests/Zend/Gdata/App/_files/ControlElementSample1.xml b/zend/tests/Zend/Gdata/App/_files/ControlElementSample1.xml new file mode 100644 index 0000000..5fbd7ef --- /dev/null +++ b/zend/tests/Zend/Gdata/App/_files/ControlElementSample1.xml @@ -0,0 +1,4 @@ + + + yes + diff --git a/zend/tests/Zend/Gdata/App/_files/EntrySample1.xml b/zend/tests/Zend/Gdata/App/_files/EntrySample1.xml new file mode 100644 index 0000000..27de402 --- /dev/null +++ b/zend/tests/Zend/Gdata/App/_files/EntrySample1.xml @@ -0,0 +1,28 @@ + + + Atom draft-07 snapshot + + + tag:example.org,2003:3.2397 + 2005-07-31T12:29:29Z + 2003-12-13T08:29:29-04:00 + + Mark Pilgrim + http://example.org/ + f8dy@example.com + + + Sam Ruby + + + Joe Gregorio + + +
+

[Update: The Atom draft is finished.]

+
+
+
diff --git a/zend/tests/Zend/Gdata/App/_files/EntrySampleHttp1.txt b/zend/tests/Zend/Gdata/App/_files/EntrySampleHttp1.txt new file mode 100644 index 0000000..33bdd0b --- /dev/null +++ b/zend/tests/Zend/Gdata/App/_files/EntrySampleHttp1.txt @@ -0,0 +1,29 @@ +HTTP/1.1 200 OK +Content-Type: application/atom+xml; charset=UTF-8 +Last-Modified: Sun, 07 Sep 2008 17:53:51 GMT +Cache-Control: max-age=0 private +ETag: W/"CkcHQH8_fCp7ImA9WxRTGEw." +Date: Sun, 07 Sep 2008 21:23:39 GMT +Content-Length: 1450 +Server: GFE/1.3 + + + + + tag:blogger.com,1999:blog-8273578352962669317.post-6938730899689776686 + 2008-09-07T10:53:00.001-07:00 + 2008-09-07T10:53:51.144-07:00 + 2008-09-07T10:53:51.144-07:00 + Hello world + <p>Hello world!</p> + + + + + + + John Doe + http://www.blogger.com/profile/12345678901234567890 + jdoe@example.com + + diff --git a/zend/tests/Zend/Gdata/App/_files/FeedSample1.xml b/zend/tests/Zend/Gdata/App/_files/FeedSample1.xml new file mode 100644 index 0000000..b1a4b36 --- /dev/null +++ b/zend/tests/Zend/Gdata/App/_files/FeedSample1.xml @@ -0,0 +1,45 @@ + + + dive into mark + + A <em>lot</em> of effort + went into making this effortless + + 2005-07-31T12:29:29Z + tag:example.org,2003:3 + + + Copyright (c) 2003, Mark Pilgrim + + Example Toolkit + + + Atom draft-07 snapshot + + + tag:example.org,2003:3.2397 + 2005-07-31T12:29:29Z + 2003-12-13T08:29:29-04:00 + + Mark Pilgrim + http://example.org/ + f8dy@example.com + + + Sam Ruby + + + Joe Gregorio + + +
+

[Update: The Atom draft is finished.]

+
+
+
+
diff --git a/zend/tests/Zend/Gdata/App/_files/GeneratorElementSample1.xml b/zend/tests/Zend/Gdata/App/_files/GeneratorElementSample1.xml new file mode 100644 index 0000000..00ae021 --- /dev/null +++ b/zend/tests/Zend/Gdata/App/_files/GeneratorElementSample1.xml @@ -0,0 +1,2 @@ + +Google data APIs diff --git a/zend/tests/Zend/Gdata/AppTest.php b/zend/tests/Zend/Gdata/AppTest.php new file mode 100644 index 0000000..e81a66a --- /dev/null +++ b/zend/tests/Zend/Gdata/AppTest.php @@ -0,0 +1,633 @@ +fileName = 'Zend/Gdata/App/_files/FeedSample1.xml'; + $this->expectedEtag = 'W/"CkcHQH8_fCp7ImA9WxRTGEw."'; + $this->expectedMajorProtocolVersion = 1; + $this->expectedMinorProtocolVersion = 2; + $this->httpEntrySample = file_get_contents( + 'Zend/Gdata/_files/AppSample1.txt', + true); + $this->httpEntrySampleWithoutVersion = file_get_contents( + 'Zend/Gdata/_files/AppSample2.txt', + true); + $this->httpFeedSample = file_get_contents( + 'Zend/Gdata/_files/AppSample3.txt', + true); + $this->httpFeedSampleWithoutVersion = file_get_contents( + 'Zend/Gdata/_files/AppSample4.txt', + true); + + $this->adapter = new Test_Zend_Gdata_MockHttpClient(); + $this->client = new Zend_Gdata_HttpClient(); + $this->client->setAdapter($this->adapter); + $this->service = new Zend_Gdata_App($this->client); + } + + public function testImportFile() + { + $feed = Zend_Gdata_App::importFile($this->fileName, + 'Zend_Gdata_App_Feed', true); + $this->assertEquals('dive into mark', $feed->title->text); + } + + public function testSetAndGetHttpMethodOverride() + { + Zend_Gdata_App::setHttpMethodOverride(true); + $this->assertEquals(true, Zend_Gdata_App::getHttpMethodOverride()); + } + + public function testSetAndGetProtocolVersion() + { + $this->service->setMajorProtocolVersion(2); + $this->service->setMinorProtocolVersion(1); + $this->assertEquals(2, $this->service->getMajorProtocolVersion()); + $this->assertEquals(1, $this->service->getMinorProtocolVersion()); + } + + public function testDefaultProtocolVersionIs1X() + { + $this->assertEquals(1, $this->service->getMajorProtocolVersion()); + $this->assertEquals(null, $this->service->getMinorProtocolVersion()); + } + + public function testMajorProtocolVersionCannotBeLessThanOne() + { + $exceptionCaught = false; + try { + $this->service->setMajorProtocolVersion(0); + } catch (Zend_Gdata_App_InvalidArgumentException $e) { + $exceptionCaught = true; + } + $this->assertTrue($exceptionCaught, 'Expected exception not caught: ' + + 'Zend_Gdata_App_InvalidArgumentException'); + } + + public function testMajorProtocolVersionCannotBeNull() + { + $exceptionCaught = false; + try { + $this->service->setMajorProtocolVersion(null); + } catch (Zend_Gdata_App_InvalidArgumentException $e) { + $exceptionCaught = true; + } + $this->assertTrue($exceptionCaught, 'Expected exception not caught: ' + + 'Zend_Gdata_App_InvalidArgumentException'); + } + + public function testMinorProtocolVersionCannotBeLessThanZero() + { + $exceptionCaught = false; + try { + $this->service->setMinorProtocolVersion(-1); + } catch (Zend_Gdata_App_InvalidArgumentException $e) { + $exceptionCaught = true; + } + $this->assertTrue($exceptionCaught, 'Expected exception not caught: ' + + 'Zend_Gdata_App_InvalidArgumentException'); + } + + public function testNoGdataVersionHeaderSentWhenUsingV1() + { + $this->adapter->setResponse(array('HTTP/1.1 200 OK\r\n\r\n')); + + $this->service->setMajorProtocolVersion(1); + $this->service->setMinorProtocolVersion(null); + $this->service->get('http://www.example.com'); + + $headers = $this->adapter->popRequest()->headers; + $found = false; + foreach ($headers as $header) { + if (strstr($header, 'GData-Version:')) + $found = true; + } + $this->assertFalse($found, 'Version header found in V1 feed'); + } + + public function testNoGdataVersionHeaderSentWhenUsingV1X() + { + $this->adapter->setResponse(array('HTTP/1.1 200 OK\r\n\r\n')); + + $this->service->setMajorProtocolVersion(1); + $this->service->setMinorProtocolVersion(1); + $this->service->get('http://www.example.com'); + + $headers = $this->adapter->popRequest()->headers; + $found = false; + foreach ($headers as $header) { + if (strstr($header, 'GData-Version:')) + $found = true; + } + $this->assertTrue(!$found, 'Version header found in V1 feed'); + } + + public function testGdataVersionHeaderSentWhenUsingV2() + { + $this->adapter->setResponse(array('HTTP/1.1 200 OK\r\n\r\n')); + + $this->service->setMajorProtocolVersion(2); + $this->service->setMinorProtocolVersion(null); + $this->service->get('http://www.example.com'); + + $headers = $this->adapter->popRequest()->headers; + $found = false; + foreach ($headers as $header) { + if ($header == 'GData-Version: 2') + $found = true; + } + $this->assertTrue($found, 'Version header not found or incorrect'); + } + + public function testGdataVersionHeaderSentWhenUsingV2X() + { + $this->adapter->setResponse(array('HTTP/1.1 200 OK\r\n\r\n')); + + $this->service->setMajorProtocolVersion(2); + $this->service->setMinorProtocolVersion(1); + $this->service->get('http://www.example.com'); + + $headers = $this->adapter->popRequest()->headers; + $found = false; + foreach ($headers as $header) { + if ($header == 'GData-Version: 2') + $found = true; + } + $this->assertTrue($found, 'Version header not found or incorrect'); + } + + public function testHTTPETagsPropagateToEntriesOnGet() + { + $this->adapter->setResponse($this->httpEntrySample); + $entry = $this->service->getEntry('http://www.example.com'); + $this->assertEquals($this->expectedEtag, $entry->getEtag()); + } + + public function testHTTPETagsPropagateToEntriesOnUpdate() + { + $this->adapter->setResponse($this->httpEntrySample); + $entry = new Zend_Gdata_App_Entry(); + $newEntry = $this->service->updateEntry($entry, 'http://www.example.com'); + $this->assertEquals($this->expectedEtag, $newEntry->getEtag()); + } + + public function testHTTPEtagsPropagateToEntriesOnInsert() + { + $this->adapter->setResponse($this->httpEntrySample); + $entry = new Zend_Gdata_App_Entry(); + $newEntry = $this->service->insertEntry($entry, 'http://www.example.com'); + $this->assertEquals($this->expectedEtag, $newEntry->getEtag()); + } + + public function testIfMatchHTTPHeaderSetOnUpdate() + { + $etag = 'ABCD1234'; + $this->adapter->setResponse("HTTP/1.1 201 Created"); + $this->service->setMajorProtocolVersion(2); + $entry = new Zend_Gdata_App_Entry(); + $entry->link = array(new Zend_Gdata_App_Extension_Link( + 'http://www.example.com', + 'edit', + 'application/atom+xml')); + $entry->setEtag($etag); + $this->service->updateEntry($entry); + $headers = $this->adapter->popRequest()->headers; + $found = false; + foreach ($headers as $header) { + if ($header == 'If-Match: ' . $etag) + $found = true; + } + $this->assertTrue($found, 'If-Match header not found or incorrect'); + } + + public function testIfMatchHTTPHeaderSetOnUpdateIfWeak() + { + $etag = 'W/ABCD1234'; + $this->adapter->setResponse("HTTP/1.1 201 Created"); + $this->service->setMajorProtocolVersion(2); + $entry = new Zend_Gdata_App_Entry(); + $entry->link = array(new Zend_Gdata_App_Extension_Link( + 'http://www.example.com', + 'edit', + 'application/atom+xml')); + $entry->setEtag($etag); + $this->service->updateEntry($entry); + $headers = $this->adapter->popRequest()->headers; + $found = false; + foreach ($headers as $header) { + if ($header == 'If-Match: ' . $etag) + $found = true; + } + $this->assertFalse($found, 'If-Match header found'); + } + + public function testIfMatchHTTPHeaderSetOnSave() + { + $etag = 'ABCD1234'; + $this->adapter->setResponse("HTTP/1.1 201 Created"); + $this->service->setMajorProtocolVersion(2); + $entry = $this->service->newEntry(); + $entry->link = array(new Zend_Gdata_App_Extension_Link( + 'http://www.example.com', + 'edit', + 'application/atom+xml')); + $entry->setEtag($etag); + $entry->setService($this->service); + $entry->save(); + $headers = $this->adapter->popRequest()->headers; + $found = false; + foreach ($headers as $header) { + if ($header == 'If-Match: ' . $etag) + $found = true; + } + $this->assertTrue($found, 'If-Match header not found or incorrect'); + } + + public function testIfMatchHTTPHeaderNotSetOnDelete() + { + $etag = 'ABCD1234'; + $this->adapter->setResponse("HTTP/1.1 201 Created"); + $this->service->setMajorProtocolVersion(2); + $entry = $this->service->newEntry(); + $entry->link = array(new Zend_Gdata_App_Extension_Link( + 'http://www.example.com', + 'edit', + 'application/atom+xml')); + $entry->setEtag($etag); + $entry->setService($this->service); + $entry->delete(); + $headers = $this->adapter->popRequest()->headers; + $found = false; + foreach ($headers as $header) { + if ($header == 'If-Match: ' . $etag) + $found = true; + } + $this->assertFalse($found, 'If-Match header found on delete'); + } + + public function testIfMatchHTTPHeaderSetOnManualPost() + { + $etag = 'ABCD1234'; + $this->adapter->setResponse("HTTP/1.1 201 Created"); + $this->service->setMajorProtocolVersion(2); + $entry = $this->service->newEntry(); + $entry->setEtag($etag); + $entry->setService($this->service); + $this->service->post($entry, 'http://www.example.com'); + $headers = $this->adapter->popRequest()->headers; + $found = false; + foreach ($headers as $header) { + if ($header == 'If-Match: ' . $etag) + $found = true; + } + $this->assertTrue($found, 'If-Match header not found or incorrect'); + } + + public function testIfMatchHTTPHeaderSetOnManualPut() + { + $etag = 'ABCD1234'; + $this->adapter->setResponse("HTTP/1.1 201 Created"); + $this->service->setMajorProtocolVersion(2); + $entry = $this->service->newEntry(); + $entry->link = array(new Zend_Gdata_App_Extension_Link( + 'http://www.example.com', + 'edit', + 'application/atom+xml')); + $entry->setEtag($etag); + $entry->setService($this->service); + $this->service->put($entry); + $headers = $this->adapter->popRequest()->headers; + $found = false; + foreach ($headers as $header) { + if ($header == 'If-Match: ' . $etag) + $found = true; + } + $this->assertTrue($found, 'If-Match header not found or incorrect'); + } + + public function testIfMatchHTTPHeaderSetOnManualDelete() + { + $etag = 'ABCD1234'; + $this->adapter->setResponse("HTTP/1.1 201 Created"); + $this->service->setMajorProtocolVersion(2); + $entry = $this->service->newEntry(); + $entry->link = array(new Zend_Gdata_App_Extension_Link( + 'http://www.example.com', + 'edit', + 'application/atom+xml')); + $entry->setEtag($etag); + $entry->setService($this->service); + $this->service->delete($entry); + $headers = $this->adapter->popRequest()->headers; + $found = false; + foreach ($headers as $header) { + if ($header == 'If-Match: ' . $etag) + $found = true; + } + $this->assertFalse($found, 'If-Match header found on delete'); + } + + public function testIfMatchHeaderCanBeSetOnInsert() { + $etagOverride = 'foo'; + $etag = 'ABCD1234'; + $this->service->setMajorProtocolVersion(2); + $this->adapter->setResponse($this->httpEntrySample); + $entry = new Zend_Gdata_App_Entry(); + $entry->setEtag($etag); + $newEntry = $this->service->insertEntry($entry, + 'http://www.example.com', + 'Zend_Gdata_App_Entry', + array('If-Match' => $etagOverride)); + $headers = $this->adapter->popRequest()->headers; + $found = false; + foreach ($headers as $header) { + if ($header == 'If-Match: ' . $etagOverride) + $found = true; + } + $this->assertTrue($found, 'If-Match header not found or incorrect'); + } + + public function testIfNoneMatchHeaderCanBeSetOnInsert() { + $etagOverride = 'foo'; + $etag = 'ABCD1234'; + $this->service->setMajorProtocolVersion(2); + $this->adapter->setResponse($this->httpEntrySample); + $entry = new Zend_Gdata_App_Entry(); + $entry->setEtag($etag); + $newEntry = $this->service->insertEntry($entry, + 'http://www.example.com', + 'Zend_Gdata_App_Entry', + array('If-None-Match' => $etagOverride)); + $headers = $this->adapter->popRequest()->headers; + $found = false; + foreach ($headers as $header) { + if ($header == 'If-None-Match: ' . $etagOverride) + $found = true; + } + $this->assertTrue($found, 'If-None-Match header not found or incorrect '); + } + + public function testIfMatchHeaderCanBeSetOnUpdate() { + $etagOverride = 'foo'; + $etag = 'ABCD1234'; + $this->service->setMajorProtocolVersion(2); + $this->adapter->setResponse($this->httpEntrySample); + $entry = new Zend_Gdata_App_Entry(); + $entry->setEtag($etag); + $newEntry = $this->service->updateEntry($entry, + 'http://www.example.com', + 'Zend_Gdata_App_Entry', + array('If-Match' => $etagOverride)); + $headers = $this->adapter->popRequest()->headers; + $found = false; + foreach ($headers as $header) { + if ($header == 'If-Match: ' . $etagOverride) + $found = true; + } + $this->assertTrue($found, 'If-Match header not found or incorrect or incorrect'); + } + + public function testIfNoneMatchHeaderCanBeSetOnUpdate() { + $etagOverride = 'foo'; + $etag = 'ABCD1234'; + $this->service->setMajorProtocolVersion(2); + $this->adapter->setResponse($this->httpEntrySample); + $entry = new Zend_Gdata_App_Entry(); + $entry->setEtag($etag); + $newEntry = $this->service->updateEntry($entry, + 'http://www.example.com', + 'Zend_Gdata_App_Entry', + array('If-None-Match' => $etagOverride)); + $headers = $this->adapter->popRequest()->headers; + $found = false; + foreach ($headers as $header) { + if ($header == 'If-None-Match: ' . $etagOverride) + $found = true; + } + $this->assertTrue($found, 'If-None-Match header not found or incorrect'); + } + + /** + * @group ZF-8397 + */ + public function testIfMatchHTTPHeaderIsResetEachRequest() + { + // Update an entry + $etag = 'ABCD1234'; + $this->adapter->setResponse("HTTP/1.1 201 Created"); + $this->service->setMajorProtocolVersion(2); + $entry = new Zend_Gdata_App_Entry(); + $entry->link = array(new Zend_Gdata_App_Extension_Link( + 'http://www.example.com', + 'edit', + 'application/atom+xml')); + $entry->setEtag($etag); + $this->service->updateEntry($entry); + + // Get another entry without ETag set, + // Previous value of If-Match HTTP header should not be sent + $this->adapter->setResponse($this->httpEntrySample); + $entry = $this->service->getEntry('http://www.example.com'); + $headers = $this->adapter->popRequest()->headers; + $found = false; + foreach ($headers as $header) { + if ($header == 'If-Match: ' . $etag) + $found = true; + } + $this->assertFalse($found, 'If-Match header found'); + } + + public function testGenerateIfMatchHeaderDataReturnsEtagIfV2() { + $etag = 'ABCD1234'; + $this->service->setMajorProtocolVersion(2); + $entry = new Zend_Gdata_App_Entry(); + $entry->setEtag($etag); + $result = $this->service->generateIfMatchHeaderData($entry, false); + $this->assertEquals($etag, $result); + } + + public function testGenerateIfMatchHeaderDataReturnsNullIfV1() { + $etag = 'ABCD1234'; + $this->service->setMajorProtocolVersion(1); + $entry = new Zend_Gdata_App_Entry(); + $entry->setEtag($etag); + $result = $this->service->generateIfMatchHeaderData($entry, false); + $this->assertEquals(null, $result); + } + + public function testGenerateIfMatchHeaderDataReturnsNullIfNotEntry() { + $this->service->setMajorProtocolVersion(2); + $result = $this->service->generateIfMatchHeaderData("Hello world", false); + $this->assertEquals(null, $result); + } + + public function testGenerateIfMatchHeaderDataReturnsNullIfWeak() { + $etag = 'W/ABCD1234'; + $this->service->setMajorProtocolVersion(2); + $entry = new Zend_Gdata_App_Entry(); + $entry->setEtag($etag); + $result = $this->service->generateIfMatchHeaderData($entry, false); + $this->assertEquals(null, $result); + } + + public function testGenerateIfMatchHeaderDataReturnsEtagIfWeakAndFlagSet() { + $etag = 'W/ABCD1234'; + $this->service->setMajorProtocolVersion(2); + $entry = new Zend_Gdata_App_Entry(); + $entry->setEtag($etag); + $result = $this->service->generateIfMatchHeaderData($entry, true); + $this->assertEquals($etag, $result); + } + + public function testGenerateIfMatchHeaderDataReturnsEtagIfNotWeakAndFlagSet() { + $etag = 'ABCD1234'; + $this->service->setMajorProtocolVersion(2); + $entry = new Zend_Gdata_App_Entry(); + $entry->setEtag($etag); + $result = $this->service->generateIfMatchHeaderData($entry, true); + $this->assertEquals($etag, $result); + } + + public function testImportUrlSetsMajorProtocolVersionOnEntry() { + $this->adapter->setResponse($this->httpEntrySample); + $entry = $this->service->getEntry('http://www.example.com'); + $this->assertEquals($this->expectedMajorProtocolVersion, $entry->getMajorProtocolVersion()); + } + + public function testImportUrlSetsMinorProtocolVersionOnEntry() { + $this->adapter->setResponse($this->httpEntrySample); + $entry = $this->service->getEntry('http://www.example.com'); + $this->assertEquals($this->expectedMinorProtocolVersion, $entry->getMinorProtocolVersion()); + } + + public function testImportUrlSetsNullVersionIfNoVersionHeaderOnEntry() { + $this->adapter->setResponse($this->httpEntrySampleWithoutVersion); + $entry = $this->service->getEntry('http://www.example.com'); + $this->assertEquals(null, $entry->getMinorProtocolVersion()); + $this->assertEquals(null, $entry->getMinorProtocolVersion()); + } + + public function testImportUrlSetsMajorProtocolVersionOnFeed() { + $this->adapter->setResponse($this->httpFeedSample); + $feed = $this->service->getFeed('http://www.example.com'); + $this->assertEquals($this->expectedMajorProtocolVersion, $feed->getMajorProtocolVersion()); + foreach ($feed as $entry) { + $this->assertEquals($this->expectedMajorProtocolVersion, $entry->getMajorProtocolVersion()); + } + } + + public function testImportUrlSetsMinorProtocolVersionOnFeed() { + $this->adapter->setResponse($this->httpFeedSample); + $feed = $this->service->getFeed('http://www.example.com'); + $this->assertEquals($this->expectedMinorProtocolVersion, $feed->getMinorProtocolVersion()); + foreach ($feed as $entry) { + $this->assertEquals($this->expectedMinorProtocolVersion, $entry->getMinorProtocolVersion()); + } + } + + public function testImportUrlSetsNullVersionIfNoVersionHeaderOnFeed() { + $this->adapter->setResponse($this->httpFeedSampleWithoutVersion); + $feed = $this->service->getFeed('http://www.example.com'); + $this->assertEquals(null, $feed->getMajorProtocolVersion()); + $this->assertEquals(null, $feed->getMinorProtocolVersion()); + foreach ($feed as $entry) { + $this->assertEquals(null, $entry->getMajorProtocolVersion()); + $this->assertEquals(null, $entry->getMinorProtocolVersion()); + } + } + + public function testMagicConstructorsPropogateMajorVersion() { + $v = 42; + $this->service->setMajorProtocolVersion($v); + $feed = $this->service->newFeed(); + $this->assertEquals($v, $feed->getMajorProtocolVersion()); + } + + public function testMagicConstructorsPropogateMinorVersion() { + $v = 84; + $this->service->setMinorProtocolVersion($v); + $feed = $this->service->newFeed(); + $this->assertEquals($v, $feed->getMinorProtocolVersion()); + } + + /** + * When error handler is overridden to throw an ErrorException, the extension loader + * in Zend_Gdata will throw an ErrorException when the class doesn't exist in the + * first extension directory even if it exists in subsequent ones. This test + * enforces a fix that keeps this from happening + * + * @group ZF-12268 + * @group ZF-7013 + */ + public function testLoadExtensionCausesFatalErrorWhenErrorHandlerIsOverridden() + { + // Override the error handler to throw an ErrorException + set_error_handler(create_function('$a, $b, $c, $d', 'throw new ErrorException($b, 0, $a, $c, $d);'), E_ALL); + try { + $eq = $this->service->newEventQuery(); + restore_error_handler(); + $this->assertType('Zend_Gdata_Calendar_EventQuery', $eq); + } catch ( Zend_Gdata_App_Exception $ex ) { + // If we catch this exception, it means the ErrorException resulting + // from the include_once E_NOTICE was caught in the right place, + // but the extension was not found in any directory + // (Expected since we didn't load the Calendar extension dir) + restore_error_handler(); + $this->assertContains('EventQuery', $ex->getMessage()); + } catch ( ErrorException $ex ) { + restore_error_handler(); + $this->fail('Did not expect ErrorException'); + } + } + + /** + * @group ZF-10243 + */ + public function testStaticImportWithoutUsingObjectMapping() + { + $this->adapter->setResponse($this->httpEntrySample); + $feed = Zend_Gdata_App::import( + 'http://www.example.com', + $this->client, + 'Zend_Gdata_App_Feed', + false + ); + + $this->assertContains('12345678901234567890', $feed); + } +} diff --git a/zend/tests/Zend/Gdata/AttendeeStatusTest.php b/zend/tests/Zend/Gdata/AttendeeStatusTest.php new file mode 100644 index 0000000..30b23e4 --- /dev/null +++ b/zend/tests/Zend/Gdata/AttendeeStatusTest.php @@ -0,0 +1,125 @@ +attendeeStatusText = file_get_contents( + 'Zend/Gdata/_files/AttendeeStatusElementSample1.xml', + true); + $this->attendeeStatus = new Zend_Gdata_Extension_AttendeeStatus(); + } + + public function testEmptyAttendeeStatusShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->attendeeStatus->extensionElements)); + $this->assertTrue(count($this->attendeeStatus->extensionElements) == 0); + } + + public function testEmptyAttendeeStatusShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->attendeeStatus->extensionAttributes)); + $this->assertTrue(count($this->attendeeStatus->extensionAttributes) == 0); + } + + public function testSampleAttendeeStatusShouldHaveNoExtensionElements() { + $this->attendeeStatus->transferFromXML($this->attendeeStatusText); + $this->assertTrue(is_array($this->attendeeStatus->extensionElements)); + $this->assertTrue(count($this->attendeeStatus->extensionElements) == 0); + } + + public function testSampleAttendeeStatusShouldHaveNoExtensionAttributes() { + $this->attendeeStatus->transferFromXML($this->attendeeStatusText); + $this->assertTrue(is_array($this->attendeeStatus->extensionAttributes)); + $this->assertTrue(count($this->attendeeStatus->extensionAttributes) == 0); + } + + public function testNormalAttendeeStatusShouldHaveNoExtensionElements() { + $this->attendeeStatus->value = "http://schemas.google.com/g/2005#event.accepted"; + + $this->assertEquals("http://schemas.google.com/g/2005#event.accepted", $this->attendeeStatus->value); + + $this->assertEquals(0, count($this->attendeeStatus->extensionElements)); + $newAttendeeStatus = new Zend_Gdata_Extension_AttendeeStatus(); + $newAttendeeStatus->transferFromXML($this->attendeeStatus->saveXML()); + $this->assertEquals(0, count($newAttendeeStatus->extensionElements)); + $newAttendeeStatus->extensionElements = array( + new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); + $this->assertEquals(1, count($newAttendeeStatus->extensionElements)); + $this->assertEquals("http://schemas.google.com/g/2005#event.accepted", $newAttendeeStatus->value); + + /* try constructing using magic factory */ + $gdata = new Zend_Gdata(); + $newAttendeeStatus2 = $gdata->newAttendeeStatus(); + $newAttendeeStatus2->transferFromXML($newAttendeeStatus->saveXML()); + $this->assertEquals(1, count($newAttendeeStatus2->extensionElements)); + $this->assertEquals("http://schemas.google.com/g/2005#event.accepted", $newAttendeeStatus2->value); + } + + public function testEmptyAttendeeStatusToAndFromStringShouldMatch() { + $attendeeStatusXml = $this->attendeeStatus->saveXML(); + $newAttendeeStatus = new Zend_Gdata_Extension_AttendeeStatus(); + $newAttendeeStatus->transferFromXML($attendeeStatusXml); + $newAttendeeStatusXml = $newAttendeeStatus->saveXML(); + $this->assertTrue($attendeeStatusXml == $newAttendeeStatusXml); + } + + public function testAttendeeStatusWithValueToAndFromStringShouldMatch() { + $this->attendeeStatus->value = "http://schemas.google.com/g/2005#event.accepted"; + $attendeeStatusXml = $this->attendeeStatus->saveXML(); + $newAttendeeStatus = new Zend_Gdata_Extension_AttendeeStatus(); + $newAttendeeStatus->transferFromXML($attendeeStatusXml); + $newAttendeeStatusXml = $newAttendeeStatus->saveXML(); + $this->assertTrue($attendeeStatusXml == $newAttendeeStatusXml); + $this->assertEquals("http://schemas.google.com/g/2005#event.accepted", $this->attendeeStatus->value); + } + + public function testExtensionAttributes() { + $extensionAttributes = $this->attendeeStatus->extensionAttributes; + $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); + $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); + $this->attendeeStatus->extensionAttributes = $extensionAttributes; + $this->assertEquals('bar', $this->attendeeStatus->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $this->attendeeStatus->extensionAttributes['foo2']['value']); + $attendeeStatusXml = $this->attendeeStatus->saveXML(); + $newAttendeeStatus = new Zend_Gdata_Extension_AttendeeStatus(); + $newAttendeeStatus->transferFromXML($attendeeStatusXml); + $this->assertEquals('bar', $newAttendeeStatus->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $newAttendeeStatus->extensionAttributes['foo2']['value']); + } + + public function testConvertFullAttendeeStatusToAndFromString() { + $this->attendeeStatus->transferFromXML($this->attendeeStatusText); + $this->assertEquals("http://schemas.google.com/g/2005#event.invited", $this->attendeeStatus->value); + } + +} diff --git a/zend/tests/Zend/Gdata/AttendeeTypeTest.php b/zend/tests/Zend/Gdata/AttendeeTypeTest.php new file mode 100644 index 0000000..d90e2f7 --- /dev/null +++ b/zend/tests/Zend/Gdata/AttendeeTypeTest.php @@ -0,0 +1,125 @@ +attendeeTypeText = file_get_contents( + 'Zend/Gdata/_files/AttendeeTypeElementSample1.xml', + true); + $this->attendeeType = new Zend_Gdata_Extension_AttendeeType(); + } + + public function testEmptyAttendeeTypeShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->attendeeType->extensionElements)); + $this->assertTrue(count($this->attendeeType->extensionElements) == 0); + } + + public function testEmptyAttendeeTypeShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->attendeeType->extensionAttributes)); + $this->assertTrue(count($this->attendeeType->extensionAttributes) == 0); + } + + public function testSampleAttendeeTypeShouldHaveNoExtensionElements() { + $this->attendeeType->transferFromXML($this->attendeeTypeText); + $this->assertTrue(is_array($this->attendeeType->extensionElements)); + $this->assertTrue(count($this->attendeeType->extensionElements) == 0); + } + + public function testSampleAttendeeTypeShouldHaveNoExtensionAttributes() { + $this->attendeeType->transferFromXML($this->attendeeTypeText); + $this->assertTrue(is_array($this->attendeeType->extensionAttributes)); + $this->assertTrue(count($this->attendeeType->extensionAttributes) == 0); + } + + public function testNormalAttendeeTypeShouldHaveNoExtensionElements() { + $this->attendeeType->value = "http://schemas.google.com/g/2005#event.optional"; + + $this->assertEquals("http://schemas.google.com/g/2005#event.optional", $this->attendeeType->value); + + $this->assertEquals(0, count($this->attendeeType->extensionElements)); + $newAttendeeType = new Zend_Gdata_Extension_AttendeeType(); + $newAttendeeType->transferFromXML($this->attendeeType->saveXML()); + $this->assertEquals(0, count($newAttendeeType->extensionElements)); + $newAttendeeType->extensionElements = array( + new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); + $this->assertEquals(1, count($newAttendeeType->extensionElements)); + $this->assertEquals("http://schemas.google.com/g/2005#event.optional", $newAttendeeType->value); + + /* try constructing using magic factory */ + $gdata = new Zend_Gdata(); + $newAttendeeType2 = $gdata->newAttendeeType(); + $newAttendeeType2->transferFromXML($newAttendeeType->saveXML()); + $this->assertEquals(1, count($newAttendeeType2->extensionElements)); + $this->assertEquals("http://schemas.google.com/g/2005#event.optional", $newAttendeeType2->value); + } + + public function testEmptyAttendeeTypeToAndFromStringShouldMatch() { + $attendeeTypeXml = $this->attendeeType->saveXML(); + $newAttendeeType = new Zend_Gdata_Extension_AttendeeType(); + $newAttendeeType->transferFromXML($attendeeTypeXml); + $newAttendeeTypeXml = $newAttendeeType->saveXML(); + $this->assertTrue($attendeeTypeXml == $newAttendeeTypeXml); + } + + public function testAttendeeTypeWithValueToAndFromStringShouldMatch() { + $this->attendeeType->value = "http://schemas.google.com/g/2005#event.optional"; + $attendeeTypeXml = $this->attendeeType->saveXML(); + $newAttendeeType = new Zend_Gdata_Extension_AttendeeType(); + $newAttendeeType->transferFromXML($attendeeTypeXml); + $newAttendeeTypeXml = $newAttendeeType->saveXML(); + $this->assertTrue($attendeeTypeXml == $newAttendeeTypeXml); + $this->assertEquals("http://schemas.google.com/g/2005#event.optional", $this->attendeeType->value); + } + + public function testExtensionAttributes() { + $extensionAttributes = $this->attendeeType->extensionAttributes; + $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); + $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); + $this->attendeeType->extensionAttributes = $extensionAttributes; + $this->assertEquals('bar', $this->attendeeType->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $this->attendeeType->extensionAttributes['foo2']['value']); + $attendeeTypeXml = $this->attendeeType->saveXML(); + $newAttendeeType = new Zend_Gdata_Extension_AttendeeType(); + $newAttendeeType->transferFromXML($attendeeTypeXml); + $this->assertEquals('bar', $newAttendeeType->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $newAttendeeType->extensionAttributes['foo2']['value']); + } + + public function testConvertFullAttendeeTypeToAndFromString() { + $this->attendeeType->transferFromXML($this->attendeeTypeText); + $this->assertEquals("http://schemas.google.com/g/2005#event.required", $this->attendeeType->value); + } + +} diff --git a/zend/tests/Zend/Gdata/AuthSubTest.php b/zend/tests/Zend/Gdata/AuthSubTest.php new file mode 100755 index 0000000..b7140b2 --- /dev/null +++ b/zend/tests/Zend/Gdata/AuthSubTest.php @@ -0,0 +1,275 @@ +assertEquals('https://www.google.com/accounts/AuthSubRequest?next=http%3A%2F%2Fwww.example.com%2Ffoo.php&scope=http://www.google.com/calendar/feeds&secure=0&session=1', $uri); + } + + public function testGetAuthSubTokenUriModifiedBase() + { + $uri = Zend_Gdata_AuthSub::getAuthSubTokenUri( + 'http://www.example.com/foo.php', //next + 'http://www.google.com/calendar/feeds', //scope + 0, //secure + 1, //session + 'http://www.otherauthservice.com/accounts/AuthSubRequest'); + + // Note: the scope here is not encoded. It should be encoded, + // but the method getAuthSubTokenUri calls urldecode($scope). + // This currently works (no reported bugs) as web browsers will + // handle the encoding in most cases. + $this->assertEquals('http://www.otherauthservice.com/accounts/AuthSubRequest?next=http%3A%2F%2Fwww.example.com%2Ffoo.php&scope=http://www.google.com/calendar/feeds&secure=0&session=1', $uri); + } + + public function testSecureAuthSubSigning() + { + if (!extension_loaded('openssl')) { + $this->markTestSkipped('The openssl extension is not available'); + } else { + $c = new Zend_Gdata_HttpClient(); + $c->setAuthSubPrivateKeyFile("Zend/Gdata/_files/RsaKey.pem", + null, true); + $c->setAuthSubToken('abcdefg'); + $requestData = $c->filterHttpRequest('POST', + 'http://www.example.com/feed', + array(), + 'foo bar', + 'text/plain'); + + $authHeaderCheckPassed = false; + $headers = $requestData['headers']; + foreach ($headers as $headerName => $headerValue) { + if (strtolower($headerName) == 'authorization') { + preg_match('/data="([^"]*)"/', $headerValue, $matches); + $dataToSign = $matches[1]; + preg_match('/sig="([^"]*)"/', $headerValue, $matches); + $sig = $matches[1]; + if (function_exists('openssl_verify')) { + $fp = fopen('Zend/Gdata/_files/RsaCert.pem', 'r', true); + $cert = ''; + while (!feof($fp)) { + $cert .= fread($fp, 8192); + } + fclose($fp); + $pubkeyid = openssl_get_publickey($cert); + $verified = openssl_verify($dataToSign, + base64_decode($sig), $pubkeyid); + $this->assertEquals( + 1, $verified, + 'The generated signature was unable ' . + 'to be verified.'); + $authHeaderCheckPassed = true; + } + } + } + $this->assertEquals(true, $authHeaderCheckPassed, + 'Auth header not found for sig verification.'); + } + } + + public function testPrivateKeyNotFound() + { + $this->setExpectedException('Zend_Gdata_App_InvalidArgumentException'); + + if (!extension_loaded('openssl')) { + $this->markTestSkipped('The openssl extension is not available'); + } else { + $c = new Zend_Gdata_HttpClient(); + $c->setAuthSubPrivateKeyFile("zendauthsubfilenotfound", null, true); + } + } + + public function testAuthSubSessionTokenReceivesSuccessfulResult() + { + $adapter = new Zend_Http_Client_Adapter_Test(); + $adapter->setResponse("HTTP/1.1 200 OK\r\n\r\nToken={$this->token}\r\nExpiration=20201004T123456Z"); + + $client = new Zend_Gdata_HttpClient(); + $client->setUri('http://example.com/AuthSub'); + $client->setAdapter($adapter); + + $respToken = Zend_Gdata_AuthSub::getAuthSubSessionToken($this->token, $client); + $this->assertEquals($this->token, $respToken); + } + + /** + * @expectedException Zend_Gdata_App_AuthException + */ + public function testAuthSubSessionTokenCatchesFailedResult() + { + $adapter = new Zend_Http_Client_Adapter_Test(); + $adapter->setResponse("HTTP/1.1 500 Internal Server Error\r\n\r\nInternal Server Error"); + + $client = new Zend_Gdata_HttpClient(); + $client->setUri('http://example.com/AuthSub'); + $client->setAdapter($adapter); + + $newtok = Zend_Gdata_AuthSub::getAuthSubSessionToken($this->token, $client); + } + + /** + * @expectedException Zend_Gdata_App_HttpException + */ + public function testAuthSubSessionTokenCatchesHttpClientException() + { + $adapter = new Zend_Http_Client_Adapter_Test(); + $adapter->setNextRequestWillFail(true); + + $client = new Zend_Gdata_HttpClient(); + $client->setUri('http://example.com/AuthSub'); + $client->setAdapter($adapter); + + $newtok = Zend_Gdata_AuthSub::getAuthSubSessionToken($this->token, $client); + } + + public function testAuthSubRevokeTokenReceivesSuccessfulResult() + { + $adapter = new Zend_Http_Client_Adapter_Test(); + $adapter->setResponse("HTTP/1.1 200 OK"); + + $client = new Zend_Gdata_HttpClient(); + $client->setUri('http://example.com/AuthSub'); + $client->setAdapter($adapter); + + $revoked = Zend_Gdata_AuthSub::AuthSubRevokeToken($this->token, $client); + $this->assertTrue($revoked); + } + + public function testAuthSubRevokeTokenCatchesFailedResult() + { + $adapter = new Zend_Http_Client_Adapter_Test(); + $adapter->setResponse("HTTP/1.1 500 Not Successful"); + + $client = new Zend_Gdata_HttpClient(); + $client->setUri('http://example.com/AuthSub'); + $client->setAdapter($adapter); + + $revoked = Zend_Gdata_AuthSub::AuthSubRevokeToken($this->token, $client); + $this->assertFalse($revoked); + } + + /** + * @expectedException Zend_Gdata_App_HttpException + */ + public function testAuthSubRevokeTokenCatchesHttpClientException() + { + $adapter = new Zend_Http_Client_Adapter_Test(); + $adapter->setNextRequestWillFail(true); + + $client = new Zend_Gdata_HttpClient(); + $client->setUri('http://example.com/AuthSub'); + $client->setAdapter($adapter); + + $revoked = Zend_Gdata_AuthSub::AuthSubRevokeToken($this->token, $client); + } + + public function testGetAuthSubTokenInfoReceivesSuccessfulResult() + { + $adapter = new Zend_Http_Client_Adapter_Test(); + $adapter->setResponse("HTTP/1.1 200 OK + +Target=http://example.com +Scope=http://example.com +Secure=false"); + + $client = new Zend_Gdata_HttpClient(); + $client->setUri('http://example.com/AuthSub'); + $client->setAdapter($adapter); + + $respBody = Zend_Gdata_AuthSub::getAuthSubTokenInfo($this->token, $client); + + $this->assertContains("Target=http://example.com", $respBody); + $this->assertContains("Scope=http://example.com", $respBody); + $this->assertContains("Secure=false", $respBody); + } + + /** + * @expectedException Zend_Gdata_App_HttpException + */ + public function testGetAuthSubTokenInfoCatchesHttpClientException() + { + $adapter = new Zend_Http_Client_Adapter_Test(); + $adapter->setNextRequestWillFail(true); + + $client = new Zend_Gdata_HttpClient(); + $client->setUri('http://example.com/AuthSub'); + $client->setAdapter($adapter); + + $revoked = Zend_Gdata_AuthSub::getAuthSubTokenInfo($this->token, $client); + } + + public function testGetHttpClientProvidesNewClientWhenNullPassed() + { + $client = Zend_Gdata_AuthSub::getHttpClient($this->token); + $this->assertTrue($client instanceof Zend_Gdata_HttpClient ); + $this->assertEquals($this->token, $client->getAuthSubToken()); + } + + /** + * @group ZF-11351 + * @expectedException Zend_Gdata_App_HttpException + */ + public function testAuthSubGetHttpClientShouldThrowExceptionOnVanillaHttpClient() + { + $client = new Zend_Http_Client(); + $client->setUri('http://example.com/AuthSub'); + $gdclient = Zend_Gdata_AuthSub::getHttpClient('FakeToken', $client); + $this->fail('Expected exception Zend_Gdata_App_HttpException not raised!'); + } + +} diff --git a/zend/tests/Zend/Gdata/Books/CollectionEntryTest.php b/zend/tests/Zend/Gdata/Books/CollectionEntryTest.php new file mode 100644 index 0000000..d53826a --- /dev/null +++ b/zend/tests/Zend/Gdata/Books/CollectionEntryTest.php @@ -0,0 +1,48 @@ +gdata = new Zend_Gdata_Books_CollectionEntry(); + } + + public function testCollectionEntry() + { + $this->assertTrue(true); + } + +} diff --git a/zend/tests/Zend/Gdata/Books/CollectionFeedTest.php b/zend/tests/Zend/Gdata/Books/CollectionFeedTest.php new file mode 100644 index 0000000..b30adee --- /dev/null +++ b/zend/tests/Zend/Gdata/Books/CollectionFeedTest.php @@ -0,0 +1,48 @@ +gdata = new Zend_Gdata_Books_CollectionFeed(); + } + + public function testCollectionFeed() + { + $this->assertTrue(true); + } + +} diff --git a/zend/tests/Zend/Gdata/Books/VolumeEntryTest.php b/zend/tests/Zend/Gdata/Books/VolumeEntryTest.php new file mode 100644 index 0000000..8532122 --- /dev/null +++ b/zend/tests/Zend/Gdata/Books/VolumeEntryTest.php @@ -0,0 +1,125 @@ +entryText = file_get_contents( + 'Zend/Gdata/Books/_files/VolumeEntryDataSample1.xml', + true); + $this->entry = new Zend_Gdata_Books_VolumeEntry(); + } + + private function verifySamplePropertiesAreCorrect ($volumeEntry) { + $this->assertEquals('http://www.google.com/books/feeds/volumes/Mfer_MFwQrkC', + $volumeEntry->id->text); + $this->assertEquals('2008-10-07T15:28:15.000Z', $volumeEntry->updated->text); + $this->assertEquals('http://schemas.google.com/g/2005#kind', $volumeEntry->category[0]->scheme); + $this->assertEquals('http://schemas.google.com/books/2008#volume', $volumeEntry->category[0]->term); + $this->assertEquals('http://bks1.books.google.com/books?id=Mfer_MFwQrkC&printsec=frontcover&img=1&zoom=5&sig=ACfU3U1o90VpMryPI7WKSyIhmAWdC1uDtw&source=gbs_gdata', $volumeEntry->getThumbnailLink()->href); + $this->assertEquals('http://books.google.com/books?id=Mfer_MFwQrkC&ie=ISO-8859-1&source=gbs_gdata', $volumeEntry->getInfoLink()->href); + $this->assertEquals(null, $volumeEntry->getPreviewLink()); + $creators = $volumeEntry->getCreators(); + $this->assertEquals('William Shakespeare', $creators[0]->text); + $titles = $volumeEntry->getTitles(); + $this->assertEquals('Hamlet', $titles[0]->text); + $dates = $volumeEntry->getDates(); + $this->assertEquals('2002-02', $dates[0]->text); + $identifiers = $volumeEntry->getIdentifiers(); + $this->assertEquals('Mfer_MFwQrkC', $identifiers[0]->text); + $this->assertEquals('ISBN:0198320493', $identifiers[1]->text); + $languages = $volumeEntry->getLanguages(); + $this->assertEquals('en', $languages[0]->text); + $formats = $volumeEntry->getFormats(); + $this->assertEquals('178 pages', $formats[0]->text); + $publishers = $volumeEntry->getPublishers(); + $this->assertEquals('Oxford University Press', $publishers[0]->text); + $subjects = $volumeEntry->getSubjects(); + $this->assertEquals('Denmark', $subjects[0]->text); + $this->assertEquals(null, $volumeEntry->getPreviewLink()); + $this->assertEquals('http://www.google.com/books/feeds/users/me/volumes', $volumeEntry->getAnnotationLink()->href); + $this->assertEquals('http://books.google.com/books?id=Mfer_MFwQrkC&ie=ISO-8859-1&source=gbs_gdata', $volumeEntry->getInfoLink()->href); + $this->assertEquals('http://bks1.books.google.com/books?id=Mfer_MFwQrkC&printsec=frontcover&img=1&zoom=5&sig=ACfU3U1o90VpMryPI7WKSyIhmAWdC1uDtw&source=gbs_gdata', $volumeEntry->getThumbnailLink()->href); + $this->assertEquals('Denmark', $subjects[0]->text); + $this->assertEquals('http://schemas.google.com/books/2008#view_partial', $volumeEntry->getViewability()->value); + $this->assertEquals('Mfer_MFwQrkC', $volumeEntry->getVolumeId()); + } + + public function testEmptyEntryShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->entry->extensionElements)); + $this->assertEquals(0, count($this->entry->extensionElements)); + } + + public function testEmptyEntryShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->entry->extensionAttributes)); + $this->assertEquals(0, count($this->entry->extensionAttributes)); + } + + public function testSampleEntryShouldHaveNoExtensionElements() { + $this->entry->transferFromXML($this->entryText); + $this->assertTrue(is_array($this->entry->extensionElements)); + $this->assertEquals(0, count($this->entry->extensionElements)); + } + + public function testSampleEntryShouldHaveNoExtensionAttributes() { + $this->entry->transferFromXML($this->entryText); + $this->assertTrue(is_array($this->entry->extensionAttributes)); + $this->assertEquals(0, count($this->entry->extensionAttributes)); + } + + public function testEmptyVolumeEntryToAndFromStringShouldMatch() { + $entryXml = $this->entry->saveXML(); + $newVolumeEntry = new Zend_Gdata_Books_VolumeEntry(); + $newVolumeEntry->transferFromXML($entryXml); + $newVolumeEntryXml = $newVolumeEntry->saveXML(); + $this->assertEquals($entryXml, $newVolumeEntryXml); + } + + public function testSamplePropertiesAreCorrect () { + $this->entry->transferFromXML($this->entryText); + $this->verifySamplePropertiesAreCorrect($this->entry); + } + + public function testConvertVolumeEntryToAndFromString() { + $this->entry->transferFromXML($this->entryText); + $entryXml = $this->entry->saveXML(); + $newVolumeEntry = new Zend_Gdata_Books_VolumeEntry(); + $newVolumeEntry->transferFromXML($entryXml); + $this->verifySamplePropertiesAreCorrect($newVolumeEntry); + $newVolumeEntryXml = $newVolumeEntry->saveXML(); + $this->assertEquals($entryXml, $newVolumeEntryXml); + } + +} diff --git a/zend/tests/Zend/Gdata/Books/VolumeFeedTest.php b/zend/tests/Zend/Gdata/Books/VolumeFeedTest.php new file mode 100644 index 0000000..423602c --- /dev/null +++ b/zend/tests/Zend/Gdata/Books/VolumeFeedTest.php @@ -0,0 +1,108 @@ +feedText = file_get_contents( + 'Zend/Gdata/Books/_files/VolumeFeedDataSample1.xml', + true); + $this->feed = new Zend_Gdata_Books_VolumeFeed(); + } + + private function verifyAllSamplePropertiesAreCorrect ($volumeFeed) { + $this->assertEquals('http://www.google.com/books/feeds/volumes', + $volumeFeed->id->text); + $this->assertEquals('2008-10-07T16:41:52.000Z', $volumeFeed->updated->text); + $this->assertEquals('http://schemas.google.com/g/2005#kind', $volumeFeed->category[0]->scheme); + $this->assertEquals('http://schemas.google.com/books/2008#volume', $volumeFeed->category[0]->term); + $this->assertEquals('text', $volumeFeed->title->type); + $this->assertEquals('Search results for Hamlet', $volumeFeed->title->text);; + $this->assertEquals('self', $volumeFeed->getLink('self')->rel); + $this->assertEquals('application/atom+xml', $volumeFeed->getLink('self')->type); + $this->assertEquals('http://www.google.com/books/feeds/volumes?q=Hamlet&start-index=3&max-results=5', $volumeFeed->getLink('self')->href); + $this->assertEquals('Google Books Search', $volumeFeed->author[0]->name->text); + $this->assertEquals('http://www.google.com', $volumeFeed->author[0]->uri->text); + $this->assertEquals(512, $volumeFeed->totalResults->text); + $this->assertEquals(3, $volumeFeed->startIndex->text); + $this->assertEquals(5, $volumeFeed->itemsPerPage->text); + } + + public function testEmptyEntryShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->feed->extensionElements)); + $this->assertEquals(0, count($this->feed->extensionElements)); + } + + public function testEmptyEntryShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->feed->extensionAttributes)); + $this->assertEquals(0, count($this->feed->extensionAttributes)); + } + + public function testSampleEntryShouldHaveNoExtensionElements() { + $this->feed->transferFromXML($this->feedText); + $this->assertTrue(is_array($this->feed->extensionElements)); + $this->assertEquals(0, count($this->feed->extensionElements)); + } + + public function testSampleEntryShouldHaveNoExtensionAttributes() { + $this->feed->transferFromXML($this->feedText); + $this->assertTrue(is_array($this->feed->extensionAttributes)); + $this->assertEquals(0, count($this->feed->extensionAttributes)); + } + + public function testEmptyVolumeFeedToAndFromStringShouldMatch() { + $entryXml = $this->feed->saveXML(); + $newVolumeFeed = new Zend_Gdata_Books_VolumeFeed(); + $newVolumeFeed->transferFromXML($entryXml); + $newVolumeFeedXml = $newVolumeFeed->saveXML(); + $this->assertEquals($entryXml, $newVolumeFeedXml); + } + + public function testSamplePropertiesAreCorrect () { + $this->feed->transferFromXML($this->feedText); + $this->verifyAllSamplePropertiesAreCorrect($this->feed); + } + + public function testConvertVolumeFeedToAndFromString() { + $this->feed->transferFromXML($this->feedText); + $entryXml = $this->feed->saveXML(); + $newVolumeFeed = new Zend_Gdata_Books_VolumeFeed(); + $newVolumeFeed->transferFromXML($entryXml); + $this->verifyAllSamplePropertiesAreCorrect($newVolumeFeed); + $newVolumeFeedXml = $newVolumeFeed->saveXML(); + $this->assertEquals($entryXml, $newVolumeFeedXml); + } + +} diff --git a/zend/tests/Zend/Gdata/Books/_files/VolumeEntryDataSample1.xml b/zend/tests/Zend/Gdata/Books/_files/VolumeEntryDataSample1.xml new file mode 100644 index 0000000..0b6cd95 --- /dev/null +++ b/zend/tests/Zend/Gdata/Books/_files/VolumeEntryDataSample1.xml @@ -0,0 +1,32 @@ + + + http://www.google.com/books/feeds/volumes/Mfer_MFwQrkC + 2008-10-07T15:28:15.000Z + + Hamlet + + + + + + + + + Bad review... + William Shakespeare + Roma Gill + 2002-02 + Featuring the images of some of the world's most famous stage and film actors, these additions to the all-new Oxford School Shakespeare introduce--and enthrall--young people to one of the greatest writers of all time. This season brings revised editions of five of the Bard's most famous plays--As You Like It, Othello, Hamlet, Love's Labour Lost and The Taming of the Shrew. Designed specifically for students unfamiliar with Shakespeare's rich literary legacy, these new editions present Shakespeare's sometimes-intimidating Middle English in a way that is easy-to-read and engaging for ages twelve and up. The notes and introductions have been completely revised, allowing unprecedented clarity and accessibility. Featuring new covers and new illustrations--including photos from recent productions of Shakespeare's plays from around the world--Oxford School Shakespeare brings all the pleasure of these literary treasures to life. + 178 pages + Mfer_MFwQrkC + ISBN:0198320493 + en + Oxford University Press + Denmark + Hamlet (Legendary character)/ Drama + Murder victims' families/ Drama + Juvenile Nonfiction / Drama + Drama / English, Irish, Scottish, Welsh + Drama / Shakespeare + Hamlet + diff --git a/zend/tests/Zend/Gdata/Books/_files/VolumeFeedDataSample1.xml b/zend/tests/Zend/Gdata/Books/_files/VolumeFeedDataSample1.xml new file mode 100644 index 0000000..5f17aaa --- /dev/null +++ b/zend/tests/Zend/Gdata/Books/_files/VolumeFeedDataSample1.xml @@ -0,0 +1,139 @@ + + + http://www.google.com/books/feeds/volumes + 2008-10-07T16:41:52.000Z + + Search results for Hamlet + + + + + + + Google Books Search + http://www.google.com + + Google Book Search data API + 512 + 3 + 5 + + http://www.google.com/books/feeds/volumes/aCI_v2-QH04C + 2008-10-07T16:41:52.000Z + + Hamlet + + + + + + + + + William Shakespeare + Barbara Mowat + Paul Werstine + 2003-07-01 + Each edition includes:• Freshly edited text based on the best early printed version of the play• Full explanatory notes conveniently placed on pages facing... + 400 pages + aCI_v2-QH04C + ISBN:074347712X + Washington Square Press + Fiction + Hamlet + Prince of Denmark + + + http://www.google.com/books/feeds/volumes/VBoVAAAAYAAJ + 2008-10-07T16:41:52.000Z + + Hamlet + + + + + + + + + William Shakespeare + George Pierce Baker + 1913 + 219 pages + VBoVAAAAYAAJ + HARVARD:32044100887074 + Hamlet (Legendary character) + Hamlet + Prince of Denmark + + + http://www.google.com/books/feeds/volumes/S5YvAgAACAAJ + 2008-10-07T16:41:52.000Z + + Hamlet + + + + + + + + William Shakespeare + 1995-05-01 + Among Shakespeare&#39;s plays, &quot;Hamlet&quot; is considered by many hismasterpiece. + S5YvAgAACAAJ + ISBN:0811468259 + Heinemann/Raintree + Juvenile Fiction + Hamlet + + + http://www.google.com/books/feeds/volumes/Hxk3SFdOJr4C + 2008-10-07T16:41:52.000Z + + Hamlet + + + + + + + + + William Shakespeare + Alan Durband + 1987-05-01 + The significance of the plays is reinforced by sections discussing Shakespeare&#39;s life, works and theatre. + 336 pages + Hxk3SFdOJr4C + ISBN:0748703462 + Nelson Thornes Ltd + Drama + Hamlet + Shakespeare Made Easy + + + http://www.google.com/books/feeds/volumes/lZE0AAAAMAAJ + 2008-10-07T16:41:52.000Z + + Julius Caesar + + + + + + + + + William Shakespeare + Samuel Thurber + Arthur Wilson Verity + 1895 + Tan leather binding, gold-embossed, with gilt pattern insert and coat of arms on cover. + 123 pages + lZE0AAAAMAAJ + UOM:39015063516275 + Conspiracies + Julius Caesar + + diff --git a/zend/tests/Zend/Gdata/BooksOnlineTest.php b/zend/tests/Zend/Gdata/BooksOnlineTest.php new file mode 100644 index 0000000..561b78a --- /dev/null +++ b/zend/tests/Zend/Gdata/BooksOnlineTest.php @@ -0,0 +1,108 @@ +gdata = new Zend_Gdata_Books($client); + } + + public function testGetVolumeFeed() + { + $query = $this->gdata->newVolumeQuery(); + $query->setQuery('Hamlet'); + $query->setStartIndex(5); + $query->setMaxResults(8); + $query->setMinViewability('partial_view'); + $feed = $this->gdata->getVolumeFeed($query); + + $this->assertTrue($feed instanceof Zend_Gdata_Books_VolumeFeed); + foreach ($feed->entries as $entry) { + $this->assertTrue($entry instanceof Zend_Gdata_Books_VolumeEntry); + $this->assertEquals($feed->getHttpClient(), $entry->getHttpClient()); + } + + $this->assertEquals(5, $feed->startIndex->text); + $this->assertEquals(8, $feed->itemsPerPage->text); + } + + public function testGetVolumetEntry() + { + $entry = $this->gdata->getVolumeEntry('Mfer_MFwQrkC'); + $this->assertTrue($entry instanceof Zend_Gdata_Books_VolumeEntry); + } + + public function testUserLibraryFeed() + { + $feed = $this->gdata->getUserLibraryFeed(); + $this->assertTrue($feed instanceof Zend_Gdata_Books_VolumeFeed); + foreach ($feed->entries as $entry) { + $this->assertTrue($entry instanceof Zend_Gdata_Books_VolumeEntry); + $this->assertEquals( + $feed->getHttpClient(), $entry->getHttpClient()); + } + + $entry = new Zend_Gdata_Books_VolumeEntry(); + $entry->setId(new Zend_Gdata_App_Extension_Id('Mfer_MFwQrkC')); + $newEntry = $this->gdata->insertVolume($entry); + $this->assertTrue($newEntry instanceof Zend_Gdata_Books_VolumeEntry); + $this->gdata->deleteVolume($newEntry); + } + + public function testUserAnnotationFeed() + { + $feed = $this->gdata->getUserAnnotationFeed(); + $this->assertTrue($feed instanceof Zend_Gdata_Books_VolumeFeed); + foreach ($feed->entries as $entry) { + $this->assertTrue($entry instanceof Zend_Gdata_Books_VolumeEntry); + $this->assertEquals( + $feed->getHttpClient(), $entry->getHttpClient()); + } + + $entry = new Zend_Gdata_Books_VolumeEntry(); + $entry->setId(new Zend_Gdata_App_Extension_Id('Mfer_MFwQrkC')); + $entry->setRating(new Zend_Gdata_Extension_Rating(3, 1, 5, 1)); + $newEntry = $this->gdata->insertVolume($entry, + Zend_Gdata_Books::MY_ANNOTATION_FEED_URI); + $this->assertTrue($newEntry instanceof Zend_Gdata_Books_VolumeEntry); + $this->gdata->deleteVolume($newEntry); + } +} diff --git a/zend/tests/Zend/Gdata/BooksTest.php b/zend/tests/Zend/Gdata/BooksTest.php new file mode 100644 index 0000000..a90c9fc --- /dev/null +++ b/zend/tests/Zend/Gdata/BooksTest.php @@ -0,0 +1,48 @@ +gdata = new Zend_Gdata_Books(new Zend_Http_Client()); + } + + public function testBooks() + { + $this->assertTrue(true); + } + +} diff --git a/zend/tests/Zend/Gdata/Calendar/AccessLevelTest.php b/zend/tests/Zend/Gdata/Calendar/AccessLevelTest.php new file mode 100644 index 0000000..44803fd --- /dev/null +++ b/zend/tests/Zend/Gdata/Calendar/AccessLevelTest.php @@ -0,0 +1,124 @@ +accessLevelText = file_get_contents( + 'Zend/Gdata/Calendar/_files/AccessLevelElementSample1.xml', + true); + $this->accessLevel = new Zend_Gdata_Calendar_Extension_AccessLevel(); + } + + public function testEmptyAccessLevelShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->accessLevel->extensionElements)); + $this->assertTrue(count($this->accessLevel->extensionElements) == 0); + } + + public function testEmptyAccessLevelShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->accessLevel->extensionAttributes)); + $this->assertTrue(count($this->accessLevel->extensionAttributes) == 0); + } + + public function testSampleAccessLevelShouldHaveNoExtensionElements() { + $this->accessLevel->transferFromXML($this->accessLevelText); + $this->assertTrue(is_array($this->accessLevel->extensionElements)); + $this->assertTrue(count($this->accessLevel->extensionElements) == 0); + } + + public function testSampleAccessLevelShouldHaveNoExtensionAttributes() { + $this->accessLevel->transferFromXML($this->accessLevelText); + $this->assertTrue(is_array($this->accessLevel->extensionAttributes)); + $this->assertTrue(count($this->accessLevel->extensionAttributes) == 0); + } + + public function testNormalAccessLevelShouldHaveNoExtensionElements() { + $this->accessLevel->value = 'freebusy'; + $this->assertEquals($this->accessLevel->value, 'freebusy'); + $this->assertEquals(count($this->accessLevel->extensionElements), 0); + $newAccessLevel = new Zend_Gdata_Calendar_Extension_AccessLevel(); + $newAccessLevel->transferFromXML($this->accessLevel->saveXML()); + $this->assertEquals(count($newAccessLevel->extensionElements), 0); + $newAccessLevel->extensionElements = array( + new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); + $this->assertEquals(count($newAccessLevel->extensionElements), 1); + $this->assertEquals($newAccessLevel->value, 'freebusy'); + + /* try constructing using magic factory */ + $cal = new Zend_Gdata_Calendar(); + $newAccessLevel2 = $cal->newAccessLevel(); + $newAccessLevel2->transferFromXML($newAccessLevel->saveXML()); + $this->assertEquals(count($newAccessLevel2->extensionElements), 1); + $this->assertEquals($newAccessLevel2->value, 'freebusy'); + } + + public function testEmptyAccessLevelToAndFromStringShouldMatch() { + $accessLevelXml = $this->accessLevel->saveXML(); + $newAccessLevel = new Zend_Gdata_Calendar_Extension_AccessLevel(); + $newAccessLevel->transferFromXML($accessLevelXml); + $newAccessLevelXml = $newAccessLevel->saveXML(); + $this->assertTrue($accessLevelXml == $newAccessLevelXml); + } + + public function testAccessLevelWithValueToAndFromStringShouldMatch() { + $this->accessLevel->value = 'freebusy'; + $accessLevelXml = $this->accessLevel->saveXML(); + $newAccessLevel = new Zend_Gdata_Calendar_Extension_AccessLevel(); + $newAccessLevel->transferFromXML($accessLevelXml); + $newAccessLevelXml = $newAccessLevel->saveXML(); + $this->assertTrue($accessLevelXml == $newAccessLevelXml); + $this->assertEquals('freebusy', $newAccessLevel->value); + } + + public function testExtensionAttributes() { + $extensionAttributes = $this->accessLevel->extensionAttributes; + $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); + $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); + $this->accessLevel->extensionAttributes = $extensionAttributes; + $this->assertEquals('bar', $this->accessLevel->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $this->accessLevel->extensionAttributes['foo2']['value']); + $accessLevelXml = $this->accessLevel->saveXML(); + $newAccessLevel = new Zend_Gdata_Calendar_Extension_AccessLevel(); + $newAccessLevel->transferFromXML($accessLevelXml); + $this->assertEquals('bar', $newAccessLevel->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $newAccessLevel->extensionAttributes['foo2']['value']); + } + + public function testConvertFullAccessLevelToAndFromString() { + $this->accessLevel->transferFromXML($this->accessLevelText); + $this->assertEquals($this->accessLevel->value, 'owner'); + } + +} diff --git a/zend/tests/Zend/Gdata/Calendar/ColorTest.php b/zend/tests/Zend/Gdata/Calendar/ColorTest.php new file mode 100644 index 0000000..84695e4 --- /dev/null +++ b/zend/tests/Zend/Gdata/Calendar/ColorTest.php @@ -0,0 +1,124 @@ +colorText = file_get_contents( + 'Zend/Gdata/Calendar/_files/ColorElementSample1.xml', + true); + $this->color = new Zend_Gdata_Calendar_Extension_Color(); + } + + public function testEmptyColorShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->color->extensionElements)); + $this->assertTrue(count($this->color->extensionElements) == 0); + } + + public function testEmptyColorShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->color->extensionAttributes)); + $this->assertTrue(count($this->color->extensionAttributes) == 0); + } + + public function testSampleColorShouldHaveNoExtensionElements() { + $this->color->transferFromXML($this->colorText); + $this->assertTrue(is_array($this->color->extensionElements)); + $this->assertTrue(count($this->color->extensionElements) == 0); + } + + public function testSampleColorShouldHaveNoExtensionAttributes() { + $this->color->transferFromXML($this->colorText); + $this->assertTrue(is_array($this->color->extensionAttributes)); + $this->assertTrue(count($this->color->extensionAttributes) == 0); + } + + public function testNormalColorShouldHaveNoExtensionElements() { + $this->color->value = '#abcdef'; + $this->assertEquals($this->color->value, '#abcdef'); + $this->assertEquals(count($this->color->extensionElements), 0); + $newColor = new Zend_Gdata_Calendar_Extension_Color(); + $newColor->transferFromXML($this->color->saveXML()); + $this->assertEquals(count($newColor->extensionElements), 0); + $newColor->extensionElements = array( + new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); + $this->assertEquals(count($newColor->extensionElements), 1); + $this->assertEquals($newColor->value, '#abcdef'); + + /* try constructing using magic factory */ + $cal = new Zend_Gdata_Calendar(); + $newColor2 = $cal->newColor(); + $newColor2->transferFromXML($newColor->saveXML()); + $this->assertEquals(count($newColor2->extensionElements), 1); + $this->assertEquals($newColor2->value, '#abcdef'); + } + + public function testEmptyColorToAndFromStringShouldMatch() { + $colorXml = $this->color->saveXML(); + $newColor = new Zend_Gdata_Calendar_Extension_Color(); + $newColor->transferFromXML($colorXml); + $newColorXml = $newColor->saveXML(); + $this->assertTrue($colorXml == $newColorXml); + } + + public function testColorWithValueToAndFromStringShouldMatch() { + $this->color->value = '#abcdef'; + $colorXml = $this->color->saveXML(); + $newColor = new Zend_Gdata_Calendar_Extension_Color(); + $newColor->transferFromXML($colorXml); + $newColorXml = $newColor->saveXML(); + $this->assertTrue($colorXml == $newColorXml); + $this->assertEquals('#abcdef', $newColor->value); + } + + public function testExtensionAttributes() { + $extensionAttributes = $this->color->extensionAttributes; + $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); + $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); + $this->color->extensionAttributes = $extensionAttributes; + $this->assertEquals('bar', $this->color->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $this->color->extensionAttributes['foo2']['value']); + $colorXml = $this->color->saveXML(); + $newColor = new Zend_Gdata_Calendar_Extension_Color(); + $newColor->transferFromXML($colorXml); + $this->assertEquals('bar', $newColor->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $newColor->extensionAttributes['foo2']['value']); + } + + public function testConvertFullColorToAndFromString() { + $this->color->transferFromXML($this->colorText); + $this->assertEquals($this->color->value, '#5A6986'); + } + +} diff --git a/zend/tests/Zend/Gdata/Calendar/EventEntryTest.php b/zend/tests/Zend/Gdata/Calendar/EventEntryTest.php new file mode 100644 index 0000000..7d6e0c9 --- /dev/null +++ b/zend/tests/Zend/Gdata/Calendar/EventEntryTest.php @@ -0,0 +1,138 @@ +entryText = file_get_contents( + 'Zend/Gdata/Calendar/_files/EventEntrySample1.xml', + true); + $this->entry = new Zend_Gdata_Calendar_EventEntry(); + } + + public function testSetters() { + $entry = new Zend_Gdata_Calendar_EventEntry(); + $who = new Zend_Gdata_Extension_Who(); + $who->setValueString("John Doe"); + $who->setEmail("john@doe.com"); + $entry->setWho($who); + $whoRetrieved = $entry->getWho(); + $this->assertEquals("john@doe.com", $whoRetrieved->getEmail()); + $this->assertEquals("John Doe", $whoRetrieved->getValueString()); + } + + public function testEmptyEntryShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->entry->extensionElements)); + $this->assertTrue(count($this->entry->extensionElements) == 0); + } + + public function testEmptyEntryShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->entry->extensionAttributes)); + $this->assertTrue(count($this->entry->extensionAttributes) == 0); + } + + public function testSampleEntryShouldHaveNoExtensionElements() { + $this->entry->transferFromXML($this->entryText); + $this->assertTrue(is_array($this->entry->extensionElements)); + $this->assertTrue(count($this->entry->extensionElements) == 0); + } + + public function testSampleEntryShouldHaveNoExtensionAttributes() { + $this->entry->transferFromXML($this->entryText); + $this->assertTrue(is_array($this->entry->extensionAttributes)); + $this->assertTrue(count($this->entry->extensionAttributes) == 0); + } + + public function testEmptyEventEntryToAndFromStringShouldMatch() { + $entryXml = $this->entry->saveXML(); + $newEventEntry = new Zend_Gdata_Calendar_EventEntry(); + $newEventEntry->transferFromXML($entryXml); + $newEventEntryXml = $newEventEntry->saveXML(); + $this->assertTrue($entryXml == $newEventEntryXml); + } + + public function testConvertEventEntryToAndFromString() { + $this->entry->transferFromXML($this->entryText); + $entryXml = $this->entry->saveXML(); + $newEventEntry = new Zend_Gdata_Calendar_EventEntry(); + $newEventEntry->transferFromXML($entryXml); + $newEventEntryXml = $newEventEntry->saveXML(); + $this->assertEquals($entryXml, $newEventEntryXml); + $this->assertEquals('http://www.google.com/calendar/feeds/default/private/full/s0dtsvq4pe15ku09jideg67fv4_20070509T193000Z', + $newEventEntry->id->text); + $this->assertEquals('Mantek', + $newEventEntry->extendedProperty[0]->value); + $this->assertEquals('s0dtsvq4pe15ku09jideg67fv4', + $newEventEntry->originalEvent->id); + $this->assertEquals('s0dtsvq4pe15ku09jideg67fv4', + $newEventEntry->originalEvent->id); + $this->assertEquals('http://www.google.com/calendar/feeds/default/private/full/s0dtsvq4pe15ku09jideg67fv4_20070509T193000Z/comments', + $newEventEntry->comments->feedLink->href); + } + +/* + public function testEventEntryWithTextAndTypeToAndFromStringShouldMatch() { + $this->feed->text = ''; + $this->feed->type = 'xhtml'; + $feedXml = $this->feed->saveXML(); + $newEventEntry = new Zend_Gdata_App_EventEntry(); + $newEventEntry->transferFromXML($feedXml); + $newEventEntryXml = $newEventEntry->saveXML(); + $this->assertEquals($newEventEntryXml, $feedXml); + $this->assertEquals('', $newEventEntry->text); + $this->assertEquals('xhtml', $newEventEntry->type); + } + + public function testEventEntryWithSrcAndTypeToAndFromStringShouldMatch() { + $this->feed->src = 'http://www.example.com/image.png'; + $this->feed->type = 'image/png'; + $feedXml = $this->feed->saveXML(); + $newEventEntry = new Zend_Gdata_App_EventEntry(); + $newEventEntry->transferFromXML($feedXml); + $newEventEntryXml = $newEventEntry->saveXML(); + $this->assertEquals($newEventEntryXml, $feedXml); + $this->assertEquals('http://www.example.com/image.png', $newEventEntry->src); + $this->assertEquals('image/png', $newEventEntry->type); + } + + public function testConvertEventEntryWithSrcAndTypeToAndFromString() { + $this->feed->transferFromXML($this->feedText); + $this->assertEquals('http://www.example.com/image.png', $this->feed->src); + $this->assertEquals('image/png', $this->feed->type); + } +*/ + +} diff --git a/zend/tests/Zend/Gdata/Calendar/EventQueryExceptionTest.php b/zend/tests/Zend/Gdata/Calendar/EventQueryExceptionTest.php new file mode 100644 index 0000000..ad78f17 --- /dev/null +++ b/zend/tests/Zend/Gdata/Calendar/EventQueryExceptionTest.php @@ -0,0 +1,68 @@ +query = new Zend_Gdata_Calendar_EventQuery(); + } + + /** + * @expectedException Zend_Gdata_App_Exception + */ + public function testSingleEventsThrowsExceptionOnSetInvalidValue() + { + $this->query->resetParameters(); + $singleEvents = 'puppy'; + $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); + $this->query->setSingleEvents($singleEvents); + } + + /** + * @expectedException Zend_Gdata_App_Exception + */ + public function testFutureEventsThrowsExceptionOnSetInvalidValue() + { + $this->query->resetParameters(); + $futureEvents = 'puppy'; + $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); + $this->query->setFutureEvents($futureEvents); + } + +} diff --git a/zend/tests/Zend/Gdata/Calendar/EventQueryTest.php b/zend/tests/Zend/Gdata/Calendar/EventQueryTest.php new file mode 100644 index 0000000..7e4e834 --- /dev/null +++ b/zend/tests/Zend/Gdata/Calendar/EventQueryTest.php @@ -0,0 +1,270 @@ +query = new Zend_Gdata_Calendar_EventQuery(); + } + + public function testDefaultBaseUrlForQuery() + { + $queryUrl = $this->query->getQueryUrl(); + $this->assertEquals('https://www.google.com/calendar/feeds/default/public/full', + $queryUrl); + } + + public function testAlternateBaseUrlForQuery() + { + $this->query = new Zend_Gdata_Calendar_EventQuery('http://www.foo.com'); + $queryUrl = $this->query->getQueryUrl(); + // the URL passed in the constructor has the user, visibility + // projection appended for the return value of $query->getQueryUrl() + $this->assertEquals('http://www.foo.com/default/public/full', $queryUrl); + } + + public function testUpdatedMinMaxParam() + { + $updatedMin = '2006-09-20'; + $updatedMax = '2006-11-05'; + $this->query->resetParameters(); + $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); + $this->query->setUpdatedMin($updatedMin); + $this->query->setUpdatedMax($updatedMax); + $this->assertTrue($this->query->updatedMin != null); + $this->assertTrue($this->query->updatedMax != null); + $this->assertTrue($this->query->user != null); + $this->assertEquals(Zend_Gdata_App_Util::formatTimestamp($updatedMin), $this->query->getUpdatedMin()); + $this->assertEquals(Zend_Gdata_App_Util::formatTimestamp($updatedMax), $this->query->getUpdatedMax()); + $this->assertEquals(self::GOOGLE_DEVELOPER_CALENDAR, $this->query->getUser()); + + $this->query->updatedMin = null; + $this->assertFalse($this->query->updatedMin != null); + $this->query->updatedMax = null; + $this->assertFalse($this->query->updatedMax != null); + $this->query->user = null; + $this->assertFalse($this->query->user != null); + } + + public function testStartMinMaxParam() + { + $this->query->resetParameters(); + $startMin = '2006-10-30'; + $startMax = '2006-11-01'; + $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); + $this->query->setStartMin($startMin); + $this->query->setStartMax($startMax); + $this->assertTrue($this->query->startMin != null); + $this->assertTrue($this->query->startMax != null); + $this->assertEquals(Zend_Gdata_App_Util::formatTimestamp($startMin), $this->query->getStartMin()); + $this->assertEquals(Zend_Gdata_App_Util::formatTimestamp($startMax), $this->query->getStartMax()); + + $this->query->startMin = null; + $this->assertFalse($this->query->startMin != null); + $this->query->startMax = null; + $this->assertFalse($this->query->startMax != null); + $this->query->user = null; + $this->assertFalse($this->query->user != null); + } + + public function testVisibilityParam() + { + $this->query->resetParameters(); + $visibility = 'private'; + $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); + $this->query->setVisibility($visibility); + $this->assertTrue($this->query->visibility != null); + $this->assertEquals($visibility, $this->query->getVisibility()); + $this->query->visibility = null; + $this->assertFalse($this->query->visibility != null); + } + + public function testProjectionParam() + { + $this->query->resetParameters(); + $projection = 'composite'; + $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); + $this->query->setProjection($projection); + $this->assertTrue($this->query->projection != null); + $this->assertEquals($projection, $this->query->getProjection()); + $this->query->projection = null; + $this->assertFalse($this->query->projection != null); + } + + public function testOrderbyParam() + { + $this->query->resetParameters(); + $orderby = 'starttime'; + $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); + $this->query->setOrderby($orderby); + $this->assertTrue($this->query->orderby != null); + $this->assertEquals($orderby, $this->query->getOrderby()); + $this->query->orderby = null; + $this->assertFalse($this->query->orderby != null); + } + + public function testEventParam() + { + $this->query->resetParameters(); + $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); + $this->query->setEvent(self::ZEND_CONFERENCE_EVENT); + $this->assertTrue($this->query->event != null); + $this->assertEquals(self::ZEND_CONFERENCE_EVENT, $this->query->getEvent()); + $this->query->event = null; + $this->assertFalse($this->query->event != null); + } + + public function testCommentsParam() + { + $this->query->resetParameters(); + $comment = 'we need to reschedule'; + $this->query->setComments($comment); + $this->assertTrue($this->query->comments != null); + $this->assertEquals($comment, $this->query->getComments()); + $this->query->comments = null; + $this->assertFalse(isset($this->query->comments)); + } + + public function testSortOrder() + { + $this->query->resetParameters(); + $sortOrder = 'ascending'; + $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); + $this->query->setSortOrder($sortOrder); + $this->assertTrue($this->query->sortOrder != null); + $this->assertEquals($sortOrder, $this->query->getSortOrder()); + $this->query->sortOrder = null; + $this->assertFalse($this->query->sortOrder != null); + } + + public function testRecurrenceExpansionStart() + { + $this->query->resetParameters(); + $res = self::SAMPLE_RFC3339; + $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); + $this->query->setRecurrenceExpansionStart($res); + $this->assertTrue($this->query->recurrenceExpansionStart != null); + $this->assertEquals($res, $this->query->getRecurrenceExpansionStart()); + $this->query->recurrenceExpansionStart = null; + $this->assertFalse($this->query->recurrenceExpansionStart != null); + } + + public function testRecurrenceExpansionEnd() + { + $this->query->resetParameters(); + $ree = self::SAMPLE_RFC3339; + $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); + $this->query->setRecurrenceExpansionEnd($ree); + $this->assertTrue($this->query->recurrenceExpansionEnd != null); + $this->assertEquals($ree, $this->query->getRecurrenceExpansionEnd()); + $this->query->recurrenceExpansionEnd = null; + $this->assertFalse($this->query->recurrenceExpansionEnd != null); + } + + public function testSingleEvents() + { + $this->query->resetParameters(); + // Test string handling + $singleEvents = 'true'; + $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); + $this->query->setSingleEvents($singleEvents); + $this->assertTrue($this->query->singleEvents === true); + // Test bool handling + $singleEvents = false; + $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); + $this->query->setSingleEvents($singleEvents); + $this->assertTrue($this->query->singleEvents === false); + // Test unsetting + $this->assertEquals($singleEvents, $this->query->getSingleEvents()); + $this->query->setSingleEvents(null); + $this->assertFalse($this->query->singleEvents != null); + } + + public function testFutureEvents() + { + $this->query->resetParameters(); + // Test string handling + $singleEvents = 'true'; + $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); + $this->query->setFutureEvents($singleEvents); + $this->assertTrue($this->query->futureEvents === true); + // Test bool handling + $singleEvents = false; + $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); + $this->query->setFutureEvents($singleEvents); + $this->assertTrue($this->query->futureEvents === false); + // Test unsetting + $this->query->futureEvents = null; + $this->assertFalse($this->query->futureEvents != null); + + } + + public function testCustomQueryURIGeneration() + { + $this->query->resetParameters(); + $this->query->setUser(self::GOOGLE_DEVELOPER_CALENDAR); + $this->query->setVisibility("private"); + $this->query->setProjection("composite"); + $this->query->setEvent(self::ZEND_CONFERENCE_EVENT); + $this->query->setComments(self::ZEND_CONFERENCE_EVENT_COMMENT); + $this->assertEquals("https://www.google.com/calendar/feeds/developer-calendar@google.com/private/composite/" . + self::ZEND_CONFERENCE_EVENT . "/comments/" . self::ZEND_CONFERENCE_EVENT_COMMENT, + $this->query->getQueryUrl()); + } + + public function testDefaultQueryURIGeneration() + { + $this->query->resetParameters(); + $this->assertEquals("https://www.google.com/calendar/feeds/default/public/full", + $this->query->getQueryUrl()); + } + + public function testCanNullifyParameters() + { + $testURI = "http://www.google.com/calendar/feeds/foo%40group.calendar.google.com/private/full"; + $this->query = new Zend_Gdata_Calendar_EventQuery($testURI); + $this->query->setUser(null); + $this->query->setVisibility(null); + $this->query->setProjection(null); + $result = $this->query->getQueryUrl(); + $this->assertEquals($testURI, $result); + } +} diff --git a/zend/tests/Zend/Gdata/Calendar/HiddenTest.php b/zend/tests/Zend/Gdata/Calendar/HiddenTest.php new file mode 100644 index 0000000..a2a5592 --- /dev/null +++ b/zend/tests/Zend/Gdata/Calendar/HiddenTest.php @@ -0,0 +1,124 @@ +hiddenText = file_get_contents( + 'Zend/Gdata/Calendar/_files/HiddenElementSample1.xml', + true); + $this->hidden = new Zend_Gdata_Calendar_Extension_Hidden(); + } + + public function testEmptyHiddenShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->hidden->extensionElements)); + $this->assertTrue(count($this->hidden->extensionElements) == 0); + } + + public function testEmptyHiddenShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->hidden->extensionAttributes)); + $this->assertTrue(count($this->hidden->extensionAttributes) == 0); + } + + public function testSampleHiddenShouldHaveNoExtensionElements() { + $this->hidden->transferFromXML($this->hiddenText); + $this->assertTrue(is_array($this->hidden->extensionElements)); + $this->assertTrue(count($this->hidden->extensionElements) == 0); + } + + public function testSampleHiddenShouldHaveNoExtensionAttributes() { + $this->hidden->transferFromXML($this->hiddenText); + $this->assertTrue(is_array($this->hidden->extensionAttributes)); + $this->assertTrue(count($this->hidden->extensionAttributes) == 0); + } + + public function testNormalHiddenShouldHaveNoExtensionElements() { + $this->hidden->value = true; + $this->assertEquals($this->hidden->value, true); + $this->assertEquals(count($this->hidden->extensionElements), 0); + $newHidden = new Zend_Gdata_Calendar_Extension_Hidden(); + $newHidden->transferFromXML($this->hidden->saveXML()); + $this->assertEquals(count($newHidden->extensionElements), 0); + $newHidden->extensionElements = array( + new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); + $this->assertEquals(count($newHidden->extensionElements), 1); + $this->assertEquals($newHidden->value, true); + + /* try constructing using magic factory */ + $cal = new Zend_Gdata_Calendar(); + $newHidden2 = $cal->newHidden(); + $newHidden2->transferFromXML($newHidden->saveXML()); + $this->assertEquals(count($newHidden2->extensionElements), 1); + $this->assertEquals($newHidden2->value, true); + } + + public function testEmptyHiddenToAndFromStringShouldMatch() { + $hiddenXml = $this->hidden->saveXML(); + $newHidden = new Zend_Gdata_Calendar_Extension_Hidden(); + $newHidden->transferFromXML($hiddenXml); + $newHiddenXml = $newHidden->saveXML(); + $this->assertTrue($hiddenXml == $newHiddenXml); + } + + public function testHiddenWithValueToAndFromStringShouldMatch() { + $this->hidden->value = true; + $hiddenXml = $this->hidden->saveXML(); + $newHidden = new Zend_Gdata_Calendar_Extension_Hidden(); + $newHidden->transferFromXML($hiddenXml); + $newHiddenXml = $newHidden->saveXML(); + $this->assertTrue($hiddenXml == $newHiddenXml); + $this->assertEquals(true, $newHidden->value); + } + + public function testExtensionAttributes() { + $extensionAttributes = $this->hidden->extensionAttributes; + $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); + $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); + $this->hidden->extensionAttributes = $extensionAttributes; + $this->assertEquals('bar', $this->hidden->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $this->hidden->extensionAttributes['foo2']['value']); + $hiddenXml = $this->hidden->saveXML(); + $newHidden = new Zend_Gdata_Calendar_Extension_Hidden(); + $newHidden->transferFromXML($hiddenXml); + $this->assertEquals('bar', $newHidden->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $newHidden->extensionAttributes['foo2']['value']); + } + + public function testConvertFullHiddenToAndFromString() { + $this->hidden->transferFromXML($this->hiddenText); + $this->assertEquals($this->hidden->value, false); + } + +} diff --git a/zend/tests/Zend/Gdata/Calendar/LinkTest.php b/zend/tests/Zend/Gdata/Calendar/LinkTest.php new file mode 100644 index 0000000..cd171ce --- /dev/null +++ b/zend/tests/Zend/Gdata/Calendar/LinkTest.php @@ -0,0 +1,165 @@ +linkText = file_get_contents( + 'Zend/Gdata/Calendar/_files/LinkElementSample1.xml', + true); + $this->link = new Zend_Gdata_Calendar_Extension_Link(); + } + + public function testEmptyLinkShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->link->extensionElements)); + $this->assertTrue(count($this->link->extensionElements) == 0); + } + + public function testEmptyLinkShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->link->extensionAttributes)); + $this->assertTrue(count($this->link->extensionAttributes) == 0); + } + + public function testSampleLinkShouldHaveNoExtensionElements() { + $this->link->transferFromXML($this->linkText); + $this->assertTrue(is_array($this->link->extensionElements)); + $this->assertTrue(count($this->link->extensionElements) == 0); + } + + public function testSampleLinkShouldHaveNoExtensionAttributes() { + $this->link->transferFromXML($this->linkText); + $this->assertTrue(is_array($this->link->extensionAttributes)); + $this->assertTrue(count($this->link->extensionAttributes) == 0); + } + + public function testNormalLinkShouldHaveNoExtensionElements() { + $this->link->rel = "http://nowhere.invalid/"; + $this->link->title = "Somewhere"; + $this->link->href = "http://somewhere.invalid/"; + $this->link->type = "text/plain"; + $this->link->webContent = new Zend_Gdata_Calendar_Extension_WebContent("a", "1", "2"); + + $this->assertEquals($this->link->rel, "http://nowhere.invalid/"); + $this->assertEquals($this->link->title, "Somewhere"); + $this->assertEquals($this->link->href, "http://somewhere.invalid/"); + $this->assertEquals($this->link->type, "text/plain"); + $this->assertEquals($this->link->webcontent->url, "a"); + $this->assertEquals($this->link->webcontent->height, "1"); + $this->assertEquals($this->link->webcontent->width, "2"); + + $this->assertEquals(count($this->link->extensionElements), 0); + $newLink = new Zend_Gdata_Calendar_Extension_Link(); + $newLink->transferFromXML($this->link->saveXML()); + $this->assertEquals(count($newLink->extensionElements), 0); + $newLink->extensionElements = array( + new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); + $this->assertEquals(count($newLink->extensionElements), 1); + $this->assertEquals($newLink->rel, "http://nowhere.invalid/"); + $this->assertEquals($newLink->title, "Somewhere"); + $this->assertEquals($newLink->href, "http://somewhere.invalid/"); + $this->assertEquals($newLink->type, "text/plain"); + $this->assertEquals($newLink->webcontent->url, "a"); + $this->assertEquals($newLink->webcontent->height, "1"); + $this->assertEquals($newLink->webcontent->width, "2"); + + /* try constructing using magic factory */ + $cal = new Zend_Gdata_Calendar(); + $newLink2 = $cal->newLink(); + $newLink2->transferFromXML($newLink->saveXML()); + $this->assertEquals(count($newLink2->extensionElements), 1); + $this->assertEquals($newLink2->rel, "http://nowhere.invalid/"); + $this->assertEquals($newLink2->title, "Somewhere"); + $this->assertEquals($newLink2->href, "http://somewhere.invalid/"); + $this->assertEquals($newLink2->type, "text/plain"); + $this->assertEquals($newLink2->webcontent->url, "a"); + $this->assertEquals($newLink2->webcontent->height, "1"); + $this->assertEquals($newLink2->webcontent->width, "2"); + } + + public function testEmptyLinkToAndFromStringShouldMatch() { + $linkXml = $this->link->saveXML(); + $newLink = new Zend_Gdata_Calendar_Extension_Link(); + $newLink->transferFromXML($linkXml); + $newLinkXml = $newLink->saveXML(); + $this->assertTrue($linkXml == $newLinkXml); + } + + public function testLinkWithValueToAndFromStringShouldMatch() { + $this->link->rel = "http://nowhere.invalid/"; + $this->link->title = "Somewhere"; + $this->link->href = "http://somewhere.invalid/"; + $this->link->type = "text/plain"; + $this->link->webContent = new Zend_Gdata_Calendar_Extension_WebContent("a", "1", "2"); + $linkXml = $this->link->saveXML(); + $newLink = new Zend_Gdata_Calendar_Extension_Link(); + $newLink->transferFromXML($linkXml); + $newLinkXml = $newLink->saveXML(); + $this->assertTrue($linkXml == $newLinkXml); + $this->assertEquals($this->link->rel, "http://nowhere.invalid/"); + $this->assertEquals($this->link->title, "Somewhere"); + $this->assertEquals($this->link->href, "http://somewhere.invalid/"); + $this->assertEquals($this->link->type, "text/plain"); + $this->assertEquals($this->link->webcontent->url, "a"); + $this->assertEquals($this->link->webcontent->height, "1"); + $this->assertEquals($this->link->webcontent->width, "2"); + } + + public function testExtensionAttributes() { + $extensionAttributes = $this->link->extensionAttributes; + $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); + $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); + $this->link->extensionAttributes = $extensionAttributes; + $this->assertEquals('bar', $this->link->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $this->link->extensionAttributes['foo2']['value']); + $linkXml = $this->link->saveXML(); + $newLink = new Zend_Gdata_Calendar_Extension_Link(); + $newLink->transferFromXML($linkXml); + $this->assertEquals('bar', $newLink->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $newLink->extensionAttributes['foo2']['value']); + } + + public function testConvertFullLinkToAndFromString() { + $this->link->transferFromXML($this->linkText); + $this->assertEquals($this->link->rel, "http://schemas.google.com/gCal/2005/webContent"); + $this->assertEquals($this->link->title, "Independence Day"); + $this->assertEquals($this->link->href, "http://www.google.com/calendar/images/google-holiday.gif"); + $this->assertEquals($this->link->type, "image/gif"); + $this->assertEquals($this->link->webcontent->url, "http://www.google.com/logos/july4th06.gif"); + $this->assertEquals($this->link->webcontent->height, "120"); + $this->assertEquals($this->link->webcontent->width, "276"); + } + +} diff --git a/zend/tests/Zend/Gdata/Calendar/QuickAddTest.php b/zend/tests/Zend/Gdata/Calendar/QuickAddTest.php new file mode 100644 index 0000000..bbeb472 --- /dev/null +++ b/zend/tests/Zend/Gdata/Calendar/QuickAddTest.php @@ -0,0 +1,124 @@ +quickAddText = file_get_contents( + 'Zend/Gdata/Calendar/_files/QuickAddElementSample1.xml', + true); + $this->quickAdd = new Zend_Gdata_Calendar_Extension_QuickAdd(); + } + + public function testEmptyQuickAddShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->quickAdd->extensionElements)); + $this->assertTrue(count($this->quickAdd->extensionElements) == 0); + } + + public function testEmptyQuickAddShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->quickAdd->extensionAttributes)); + $this->assertTrue(count($this->quickAdd->extensionAttributes) == 0); + } + + public function testSampleQuickAddShouldHaveNoExtensionElements() { + $this->quickAdd->transferFromXML($this->quickAddText); + $this->assertTrue(is_array($this->quickAdd->extensionElements)); + $this->assertTrue(count($this->quickAdd->extensionElements) == 0); + } + + public function testSampleQuickAddShouldHaveNoExtensionAttributes() { + $this->quickAdd->transferFromXML($this->quickAddText); + $this->assertTrue(is_array($this->quickAdd->extensionAttributes)); + $this->assertTrue(count($this->quickAdd->extensionAttributes) == 0); + } + + public function testNormalQuickAddShouldHaveNoExtensionElements() { + $this->quickAdd->value = false; + $this->assertEquals($this->quickAdd->value, false); + $this->assertEquals(count($this->quickAdd->extensionElements), 0); + $newQuickAdd = new Zend_Gdata_Calendar_Extension_QuickAdd(); + $newQuickAdd->transferFromXML($this->quickAdd->saveXML()); + $this->assertEquals(count($newQuickAdd->extensionElements), 0); + $newQuickAdd->extensionElements = array( + new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); + $this->assertEquals(count($newQuickAdd->extensionElements), 1); + $this->assertEquals($newQuickAdd->value, false); + + /* try constructing using magic factory */ + $cal = new Zend_Gdata_Calendar(); + $newQuickAdd2 = $cal->newQuickAdd(); + $newQuickAdd2->transferFromXML($newQuickAdd->saveXML()); + $this->assertEquals(count($newQuickAdd2->extensionElements), 1); + $this->assertEquals($newQuickAdd2->value, false); + } + + public function testEmptyQuickAddToAndFromStringShouldMatch() { + $quickAddXml = $this->quickAdd->saveXML(); + $newQuickAdd = new Zend_Gdata_Calendar_Extension_QuickAdd(); + $newQuickAdd->transferFromXML($quickAddXml); + $newQuickAddXml = $newQuickAdd->saveXML(); + $this->assertTrue($quickAddXml == $newQuickAddXml); + } + + public function testQuickAddWithValueToAndFromStringShouldMatch() { + $this->quickAdd->value = false; + $quickAddXml = $this->quickAdd->saveXML(); + $newQuickAdd = new Zend_Gdata_Calendar_Extension_QuickAdd(); + $newQuickAdd->transferFromXML($quickAddXml); + $newQuickAddXml = $newQuickAdd->saveXML(); + $this->assertTrue($quickAddXml == $newQuickAddXml); + $this->assertEquals(false, $newQuickAdd->value); + } + + public function testExtensionAttributes() { + $extensionAttributes = $this->quickAdd->extensionAttributes; + $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); + $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); + $this->quickAdd->extensionAttributes = $extensionAttributes; + $this->assertEquals('bar', $this->quickAdd->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $this->quickAdd->extensionAttributes['foo2']['value']); + $quickAddXml = $this->quickAdd->saveXML(); + $newQuickAdd = new Zend_Gdata_Calendar_Extension_QuickAdd(); + $newQuickAdd->transferFromXML($quickAddXml); + $this->assertEquals('bar', $newQuickAdd->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $newQuickAdd->extensionAttributes['foo2']['value']); + } + + public function testConvertFullQuickAddToAndFromString() { + $this->quickAdd->transferFromXML($this->quickAddText); + $this->assertEquals($this->quickAdd->value, true); + } + +} diff --git a/zend/tests/Zend/Gdata/Calendar/SelectedTest.php b/zend/tests/Zend/Gdata/Calendar/SelectedTest.php new file mode 100644 index 0000000..1abc205 --- /dev/null +++ b/zend/tests/Zend/Gdata/Calendar/SelectedTest.php @@ -0,0 +1,124 @@ +selectedText = file_get_contents( + 'Zend/Gdata/Calendar/_files/SelectedElementSample1.xml', + true); + $this->selected = new Zend_Gdata_Calendar_Extension_Selected(); + } + + public function testEmptySelectedShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->selected->extensionElements)); + $this->assertTrue(count($this->selected->extensionElements) == 0); + } + + public function testEmptySelectedShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->selected->extensionAttributes)); + $this->assertTrue(count($this->selected->extensionAttributes) == 0); + } + + public function testSampleSelectedShouldHaveNoExtensionElements() { + $this->selected->transferFromXML($this->selectedText); + $this->assertTrue(is_array($this->selected->extensionElements)); + $this->assertTrue(count($this->selected->extensionElements) == 0); + } + + public function testSampleSelectedShouldHaveNoExtensionAttributes() { + $this->selected->transferFromXML($this->selectedText); + $this->assertTrue(is_array($this->selected->extensionAttributes)); + $this->assertTrue(count($this->selected->extensionAttributes) == 0); + } + + public function testNormalSelectedShouldHaveNoExtensionElements() { + $this->selected->value = true; + $this->assertEquals($this->selected->value, true); + $this->assertEquals(count($this->selected->extensionElements), 0); + $newSelected = new Zend_Gdata_Calendar_Extension_Selected(); + $newSelected->transferFromXML($this->selected->saveXML()); + $this->assertEquals(count($newSelected->extensionElements), 0); + $newSelected->extensionElements = array( + new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); + $this->assertEquals(count($newSelected->extensionElements), 1); + $this->assertEquals($newSelected->value, true); + + /* try constructing using magic factory */ + $cal = new Zend_Gdata_Calendar(); + $newSelected2 = $cal->newSelected(); + $newSelected2->transferFromXML($newSelected->saveXML()); + $this->assertEquals(count($newSelected2->extensionElements), 1); + $this->assertEquals($newSelected2->value, true); + } + + public function testEmptySelectedToAndFromStringShouldMatch() { + $selectedXml = $this->selected->saveXML(); + $newSelected = new Zend_Gdata_Calendar_Extension_Selected(); + $newSelected->transferFromXML($selectedXml); + $newSelectedXml = $newSelected->saveXML(); + $this->assertTrue($selectedXml == $newSelectedXml); + } + + public function testSelectedWithValueToAndFromStringShouldMatch() { + $this->selected->value = true; + $selectedXml = $this->selected->saveXML(); + $newSelected = new Zend_Gdata_Calendar_Extension_Selected(); + $newSelected->transferFromXML($selectedXml); + $newSelectedXml = $newSelected->saveXML(); + $this->assertTrue($selectedXml == $newSelectedXml); + $this->assertEquals(true, $newSelected->value); + } + + public function testExtensionAttributes() { + $extensionAttributes = $this->selected->extensionAttributes; + $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); + $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); + $this->selected->extensionAttributes = $extensionAttributes; + $this->assertEquals('bar', $this->selected->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $this->selected->extensionAttributes['foo2']['value']); + $selectedXml = $this->selected->saveXML(); + $newSelected = new Zend_Gdata_Calendar_Extension_Selected(); + $newSelected->transferFromXML($selectedXml); + $this->assertEquals('bar', $newSelected->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $newSelected->extensionAttributes['foo2']['value']); + } + + public function testConvertFullSelectedToAndFromString() { + $this->selected->transferFromXML($this->selectedText); + $this->assertEquals($this->selected->value, false); + } + +} diff --git a/zend/tests/Zend/Gdata/Calendar/SendEventNotificationsTest.php b/zend/tests/Zend/Gdata/Calendar/SendEventNotificationsTest.php new file mode 100644 index 0000000..e8d3890 --- /dev/null +++ b/zend/tests/Zend/Gdata/Calendar/SendEventNotificationsTest.php @@ -0,0 +1,124 @@ +sendEventNotificationsText = file_get_contents( + 'Zend/Gdata/Calendar/_files/SendEventNotificationsElementSample1.xml', + true); + $this->sendEventNotifications = new Zend_Gdata_Calendar_Extension_SendEventNotifications(); + } + + public function testEmptySendEventNotificationsShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->sendEventNotifications->extensionElements)); + $this->assertTrue(count($this->sendEventNotifications->extensionElements) == 0); + } + + public function testEmptySendEventNotificationsShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->sendEventNotifications->extensionAttributes)); + $this->assertTrue(count($this->sendEventNotifications->extensionAttributes) == 0); + } + + public function testSampleSendEventNotificationsShouldHaveNoExtensionElements() { + $this->sendEventNotifications->transferFromXML($this->sendEventNotificationsText); + $this->assertTrue(is_array($this->sendEventNotifications->extensionElements)); + $this->assertTrue(count($this->sendEventNotifications->extensionElements) == 0); + } + + public function testSampleSendEventNotificationsShouldHaveNoExtensionAttributes() { + $this->sendEventNotifications->transferFromXML($this->sendEventNotificationsText); + $this->assertTrue(is_array($this->sendEventNotifications->extensionAttributes)); + $this->assertTrue(count($this->sendEventNotifications->extensionAttributes) == 0); + } + + public function testNormalSendEventNotificationsShouldHaveNoExtensionElements() { + $this->sendEventNotifications->value = true; + $this->assertEquals($this->sendEventNotifications->value, true); + $this->assertEquals(count($this->sendEventNotifications->extensionElements), 0); + $newSendEventNotifications = new Zend_Gdata_Calendar_Extension_SendEventNotifications(); + $newSendEventNotifications->transferFromXML($this->sendEventNotifications->saveXML()); + $this->assertEquals(count($newSendEventNotifications->extensionElements), 0); + $newSendEventNotifications->extensionElements = array( + new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); + $this->assertEquals(count($newSendEventNotifications->extensionElements), 1); + $this->assertEquals($newSendEventNotifications->value, true); + + /* try constructing using magic factory */ + $cal = new Zend_Gdata_Calendar(); + $newSendEventNotifications2 = $cal->newSendEventNotifications(); + $newSendEventNotifications2->transferFromXML($newSendEventNotifications->saveXML()); + $this->assertEquals(count($newSendEventNotifications2->extensionElements), 1); + $this->assertEquals($newSendEventNotifications2->value, true); + } + + public function testEmptySendEventNotificationsToAndFromStringShouldMatch() { + $sendEventNotificationsXml = $this->sendEventNotifications->saveXML(); + $newSendEventNotifications = new Zend_Gdata_Calendar_Extension_SendEventNotifications(); + $newSendEventNotifications->transferFromXML($sendEventNotificationsXml); + $newSendEventNotificationsXml = $newSendEventNotifications->saveXML(); + $this->assertTrue($sendEventNotificationsXml == $newSendEventNotificationsXml); + } + + public function testSendEventNotificationsWithValueToAndFromStringShouldMatch() { + $this->sendEventNotifications->value = true; + $sendEventNotificationsXml = $this->sendEventNotifications->saveXML(); + $newSendEventNotifications = new Zend_Gdata_Calendar_Extension_SendEventNotifications(); + $newSendEventNotifications->transferFromXML($sendEventNotificationsXml); + $newSendEventNotificationsXml = $newSendEventNotifications->saveXML(); + $this->assertTrue($sendEventNotificationsXml == $newSendEventNotificationsXml); + $this->assertEquals(true, $newSendEventNotifications->value); + } + + public function testExtensionAttributes() { + $extensionAttributes = $this->sendEventNotifications->extensionAttributes; + $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); + $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); + $this->sendEventNotifications->extensionAttributes = $extensionAttributes; + $this->assertEquals('bar', $this->sendEventNotifications->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $this->sendEventNotifications->extensionAttributes['foo2']['value']); + $sendEventNotificationsXml = $this->sendEventNotifications->saveXML(); + $newSendEventNotifications = new Zend_Gdata_Calendar_Extension_SendEventNotifications(); + $newSendEventNotifications->transferFromXML($sendEventNotificationsXml); + $this->assertEquals('bar', $newSendEventNotifications->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $newSendEventNotifications->extensionAttributes['foo2']['value']); + } + + public function testConvertFullSendEventNotificationsToAndFromString() { + $this->sendEventNotifications->transferFromXML($this->sendEventNotificationsText); + $this->assertEquals($this->sendEventNotifications->value, false); + } + +} diff --git a/zend/tests/Zend/Gdata/Calendar/TimezoneTest.php b/zend/tests/Zend/Gdata/Calendar/TimezoneTest.php new file mode 100644 index 0000000..1ec29a0 --- /dev/null +++ b/zend/tests/Zend/Gdata/Calendar/TimezoneTest.php @@ -0,0 +1,124 @@ +timezoneText = file_get_contents( + 'Zend/Gdata/Calendar/_files/TimezoneElementSample1.xml', + true); + $this->timezone = new Zend_Gdata_Calendar_Extension_Timezone(); + } + + public function testEmptyTimezoneShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->timezone->extensionElements)); + $this->assertTrue(count($this->timezone->extensionElements) == 0); + } + + public function testEmptyTimezoneShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->timezone->extensionAttributes)); + $this->assertTrue(count($this->timezone->extensionAttributes) == 0); + } + + public function testSampleTimezoneShouldHaveNoExtensionElements() { + $this->timezone->transferFromXML($this->timezoneText); + $this->assertTrue(is_array($this->timezone->extensionElements)); + $this->assertTrue(count($this->timezone->extensionElements) == 0); + } + + public function testSampleTimezoneShouldHaveNoExtensionAttributes() { + $this->timezone->transferFromXML($this->timezoneText); + $this->assertTrue(is_array($this->timezone->extensionAttributes)); + $this->assertTrue(count($this->timezone->extensionAttributes) == 0); + } + + public function testNormalTimezoneShouldHaveNoExtensionElements() { + $this->timezone->value = "America/Chicago"; + $this->assertEquals($this->timezone->value, "America/Chicago"); + $this->assertEquals(count($this->timezone->extensionElements), 0); + $newTimezone = new Zend_Gdata_Calendar_Extension_Timezone(); + $newTimezone->transferFromXML($this->timezone->saveXML()); + $this->assertEquals(count($newTimezone->extensionElements), 0); + $newTimezone->extensionElements = array( + new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); + $this->assertEquals(count($newTimezone->extensionElements), 1); + $this->assertEquals($newTimezone->value, "America/Chicago"); + + /* try constructing using magic factory */ + $cal = new Zend_Gdata_Calendar(); + $newTimezone2 = $cal->newTimezone(); + $newTimezone2->transferFromXML($newTimezone->saveXML()); + $this->assertEquals(count($newTimezone2->extensionElements), 1); + $this->assertEquals($newTimezone2->value, "America/Chicago"); + } + + public function testEmptyTimezoneToAndFromStringShouldMatch() { + $timezoneXml = $this->timezone->saveXML(); + $newTimezone = new Zend_Gdata_Calendar_Extension_Timezone(); + $newTimezone->transferFromXML($timezoneXml); + $newTimezoneXml = $newTimezone->saveXML(); + $this->assertTrue($timezoneXml == $newTimezoneXml); + } + + public function testTimezoneWithValueToAndFromStringShouldMatch() { + $this->timezone->value = "America/Chicago"; + $timezoneXml = $this->timezone->saveXML(); + $newTimezone = new Zend_Gdata_Calendar_Extension_Timezone(); + $newTimezone->transferFromXML($timezoneXml); + $newTimezoneXml = $newTimezone->saveXML(); + $this->assertTrue($timezoneXml == $newTimezoneXml); + $this->assertEquals("America/Chicago", $newTimezone->value); + } + + public function testExtensionAttributes() { + $extensionAttributes = $this->timezone->extensionAttributes; + $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); + $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); + $this->timezone->extensionAttributes = $extensionAttributes; + $this->assertEquals('bar', $this->timezone->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $this->timezone->extensionAttributes['foo2']['value']); + $timezoneXml = $this->timezone->saveXML(); + $newTimezone = new Zend_Gdata_Calendar_Extension_Timezone(); + $newTimezone->transferFromXML($timezoneXml); + $this->assertEquals('bar', $newTimezone->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $newTimezone->extensionAttributes['foo2']['value']); + } + + public function testConvertFullTimezoneToAndFromString() { + $this->timezone->transferFromXML($this->timezoneText); + $this->assertEquals($this->timezone->value, "America/Los_Angeles"); + } + +} diff --git a/zend/tests/Zend/Gdata/Calendar/WebContentTest.php b/zend/tests/Zend/Gdata/Calendar/WebContentTest.php new file mode 100644 index 0000000..ab959a5 --- /dev/null +++ b/zend/tests/Zend/Gdata/Calendar/WebContentTest.php @@ -0,0 +1,140 @@ +webContentText = file_get_contents( + 'Zend/Gdata/Calendar/_files/WebContentElementSample1.xml', + true); + $this->webContent = new Zend_Gdata_Calendar_Extension_WebContent(); + } + + public function testEmptyWebContentShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->webContent->extensionElements)); + $this->assertTrue(count($this->webContent->extensionElements) == 0); + } + + public function testEmptyWebContentShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->webContent->extensionAttributes)); + $this->assertTrue(count($this->webContent->extensionAttributes) == 0); + } + + public function testSampleWebContentShouldHaveNoExtensionElements() { + $this->webContent->transferFromXML($this->webContentText); + $this->assertTrue(is_array($this->webContent->extensionElements)); + $this->assertTrue(count($this->webContent->extensionElements) == 0); + } + + public function testSampleWebContentShouldHaveNoExtensionAttributes() { + $this->webContent->transferFromXML($this->webContentText); + $this->assertTrue(is_array($this->webContent->extensionAttributes)); + $this->assertTrue(count($this->webContent->extensionAttributes) == 0); + } + + public function testNormalWebContentShouldHaveNoExtensionElements() { + $this->webContent->url = "http://nowhere.invalid/"; + $this->webContent->height = "100"; + $this->webContent->width = "200"; + + $this->assertEquals($this->webContent->url, "http://nowhere.invalid/"); + $this->assertEquals($this->webContent->height, "100"); + $this->assertEquals($this->webContent->width, "200"); + + $this->assertEquals(count($this->webContent->extensionElements), 0); + $newWebContent = new Zend_Gdata_Calendar_Extension_WebContent(); + $newWebContent->transferFromXML($this->webContent->saveXML()); + $this->assertEquals(count($newWebContent->extensionElements), 0); + $newWebContent->extensionElements = array( + new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); + $this->assertEquals(count($newWebContent->extensionElements), 1); + $this->assertEquals($newWebContent->url, "http://nowhere.invalid/"); + $this->assertEquals($newWebContent->height, "100"); + $this->assertEquals($newWebContent->width, "200"); + + /* try constructing using magic factory */ + $cal = new Zend_Gdata_Calendar(); + $newWebContent2 = $cal->newWebContent(); + $newWebContent2->transferFromXML($newWebContent->saveXML()); + $this->assertEquals(count($newWebContent2->extensionElements), 1); + $this->assertEquals($newWebContent2->url, "http://nowhere.invalid/"); + $this->assertEquals($newWebContent2->height, "100"); + $this->assertEquals($newWebContent2->width, "200"); + } + + public function testEmptyWebContentToAndFromStringShouldMatch() { + $webContentXml = $this->webContent->saveXML(); + $newWebContent = new Zend_Gdata_Calendar_Extension_WebContent(); + $newWebContent->transferFromXML($webContentXml); + $newWebContentXml = $newWebContent->saveXML(); + $this->assertTrue($webContentXml == $newWebContentXml); + } + + public function testWebContentWithValueToAndFromStringShouldMatch() { + $this->webContent->url = "http://nowhere.invalid/"; + $this->webContent->height = "100"; + $this->webContent->width = "200"; + $webContentXml = $this->webContent->saveXML(); + $newWebContent = new Zend_Gdata_Calendar_Extension_WebContent(); + $newWebContent->transferFromXML($webContentXml); + $newWebContentXml = $newWebContent->saveXML(); + $this->assertTrue($webContentXml == $newWebContentXml); + $this->assertEquals($this->webContent->url, "http://nowhere.invalid/"); + $this->assertEquals($this->webContent->height, "100"); + $this->assertEquals($this->webContent->width, "200"); + } + + public function testExtensionAttributes() { + $extensionAttributes = $this->webContent->extensionAttributes; + $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); + $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); + $this->webContent->extensionAttributes = $extensionAttributes; + $this->assertEquals('bar', $this->webContent->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $this->webContent->extensionAttributes['foo2']['value']); + $webContentXml = $this->webContent->saveXML(); + $newWebContent = new Zend_Gdata_Calendar_Extension_WebContent(); + $newWebContent->transferFromXML($webContentXml); + $this->assertEquals('bar', $newWebContent->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $newWebContent->extensionAttributes['foo2']['value']); + } + + public function testConvertFullWebContentToAndFromString() { + $this->webContent->transferFromXML($this->webContentText); + $this->assertEquals($this->webContent->url, "http://www.google.com/logos/july4th06.gif"); + $this->assertEquals($this->webContent->height, "120"); + $this->assertEquals($this->webContent->width, "276"); + } + +} diff --git a/zend/tests/Zend/Gdata/Calendar/_files/AccessLevelElementSample1.xml b/zend/tests/Zend/Gdata/Calendar/_files/AccessLevelElementSample1.xml new file mode 100644 index 0000000..47843bc --- /dev/null +++ b/zend/tests/Zend/Gdata/Calendar/_files/AccessLevelElementSample1.xml @@ -0,0 +1,2 @@ + + diff --git a/zend/tests/Zend/Gdata/Calendar/_files/ColorElementSample1.xml b/zend/tests/Zend/Gdata/Calendar/_files/ColorElementSample1.xml new file mode 100644 index 0000000..8e9f29b --- /dev/null +++ b/zend/tests/Zend/Gdata/Calendar/_files/ColorElementSample1.xml @@ -0,0 +1,2 @@ + + diff --git a/zend/tests/Zend/Gdata/Calendar/_files/EventEntrySample1.xml b/zend/tests/Zend/Gdata/Calendar/_files/EventEntrySample1.xml new file mode 100644 index 0000000..8c4763b --- /dev/null +++ b/zend/tests/Zend/Gdata/Calendar/_files/EventEntrySample1.xml @@ -0,0 +1,51 @@ + + + + http://www.google.com/calendar/feeds/default/private/full/s0dtsvq4pe15ku09jideg67fv4_20070509T193000Z + 2007-05-09T16:32:03.000Z + 2007-05-09T16:34:33.000Z + + www2007 recurring + + + + + + + + gdata ops + gdata.ops.test@gmail.com + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/zend/tests/Zend/Gdata/Calendar/_files/EventFeedCompositeSample1.xml b/zend/tests/Zend/Gdata/Calendar/_files/EventFeedCompositeSample1.xml new file mode 100644 index 0000000..32eb50c --- /dev/null +++ b/zend/tests/Zend/Gdata/Calendar/_files/EventFeedCompositeSample1.xml @@ -0,0 +1,362 @@ + + + http://www.google.com/calendar/feeds/default/private/composite + 2007-05-31T01:15:00.000Z + + GData Ops Demo's Composite View + GData Is Awesome + + + + GData Ops Demo + gdata.ops.demo@gmail.com + + Google Calendar + 7 + 1 + 25 + + + + http://www.google.com/calendar/feeds/default/private/composite/5v9l3sqdqt0b7mg1nhnmgdfup8 + 2007-09-14T15:37:53.000Z + 2007-09-14T15:37:53.000Z + + Specialized Event + + + + + GData Ops Demo + gdata.ops.demo@gmail.com + + DTSTART;TZID=America/Los_Angeles:20070913T080000 + DTEND;TZID=America/Los_Angeles:20070913T090000 + RRULE:FREQ=DAILY;UNTIL=20070920T150000Z;WKST=SU BEGIN:VTIMEZONE + TZID:America/Los_Angeles X-LIC-LOCATION:America/Los_Angeles + BEGIN:DAYLIGHT TZOFFSETFROM:-0800 TZOFFSETTO:-0700 TZNAME:PDT + DTSTART:19700308T020000 RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU + END:DAYLIGHT BEGIN:STANDARD TZOFFSETFROM:-0700 TZOFFSETTO:-0800 + TZNAME:PST DTSTART:19701101T020000 + RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU END:STANDARD + END:VTIMEZONE + + + + + + + + + + + + 5v9l3sqdqt0b7mg1nhnmgdfup8_20070914T150000Z + 2007-09-14T15:37:53.000Z + 2007-09-14T15:41:06.000Z + + Specialized Event + + + + GData Ops Demo + gdata.ops.demo@gmail.com + + + + + + + + + + + http://www.google.com/calendar/feeds/default/private/full/5v9l3sqdqt0b7mg1nhnmgdfup8_20070914T150000Z/comments + 2007-09-14T15:42:41.390Z + + Comments for: Specialized + Event + + + + + + + + + + + + + + + + + + + + + + + + + + + + + http://www.google.com/calendar/feeds/default/private/composite/sh6kv08egsls7mc5tf6np8hi9c + 2007-05-24T20:49:14.000Z + 2007-05-24T20:49:14.000Z + + + Tennis Game + Meet for a quick lesson. + + + + GData Ops Demo + gdata.ops.demo@gmail.com + + DTSTART;VALUE=DATE:20070501 DTEND;VALUE=DATE:20070502 RRULE:FREQ=WEEKLY;BYDAY=Tu;UNTIL=20070904 + + + + + + + + http://www.google.com/calendar/feeds/default/private/composite/lq2ai6imsbq209q3aeturho50g + 2007-05-09T16:44:38.000Z + 2007-05-17T10:33:49.000Z + + all day event may 24 + + + + + GData Ops Demo + gdata.ops.demo@gmail.com + + + + + 2007-05-31T01:15:13.249Z + + Comments for: all day event may 24 + + + dfr2c8pbtb8g6uphrsrlpao7mc + 2007-05-23T20:38:08.000Z + 2007-05-23T20:38:08.000Z + + <p>This is my comments!</p> + + User 1 + user1@nowhere.invalid + + + + i9q87onko1uphfs7i21elnnb4g + 2007-06-01T21:21:47.000Z + 2007-06-01T21:21:47.000Z + + <p>This is a user supplied comment.</p> + + User 2 + user2@nowhere.invalid + + + + + + + + + + + + + + + + + http://www.google.com/calendar/feeds/default/private/composite/4v2a4eddoqja2727ptkq78euq8 + 2007-05-09T16:43:58.000Z + 2007-05-17T10:33:49.000Z + + all day event may 23 + + + + + GData Ops Demo + gdata.ops.demo@gmail.com + + + + + 2007-05-31T01:15:13.250Z + + Comments for: all day event may 23 + + + + + + + + + + + + + + + + http://www.google.com/calendar/feeds/default/private/composite/14gfovd20fqvtj1d1np7ei9tbg + 2007-05-09T16:43:53.000Z + 2007-05-17T10:33:49.000Z + + all day event may 22 + + + + + GData Ops Demo + gdata.ops.demo@gmail.com + + + + + 2007-05-31T01:15:13.250Z + + Comments for: all day event may 22 + + + + + + + + + + + + + + + + http://www.google.com/calendar/feeds/default/private/composite/s0dtsvq4pe15ku09jideg67fv4_20070509T193000Z + 2007-05-09T16:32:03.000Z + 2007-05-09T16:34:33.000Z + + www2007 recurring + + + + + GData Ops Demo + gdata.ops.demo@gmail.com + + + + + + + + 2007-05-31T01:15:13.251Z + + Comments for: www2007 recurring + + + + + + + + + + + + + + + + http://www.google.com/calendar/feeds/default/private/composite/s0dtsvq4pe15ku09jideg67fv4 + 2007-05-09T16:32:03.000Z + 2007-05-09T16:32:03.000Z + + www2007 recurring + + + + + GData Ops Demo + gdata.ops.demo@gmail.com + + DTSTART;TZID=America/Anchorage:20070508T113000 DTEND;TZID=America/Anchorage:20070508T123000 RRULE:FREQ=DAILY;UNTIL=20070513T193000Z;WKST=SU BEGIN:VTIMEZONE TZID:America/Anchorage X-LIC-LOCATION:America/Anchorage BEGIN:DAYLIGHT TZOFFSETFROM:-0900 TZOFFSETTO:-0800 TZNAME:AKDT DTSTART:19700308T020000 RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU END:DAYLIGHT BEGIN:STANDARD TZOFFSETFROM:-0800 TZOFFSETTO:-0900 TZNAME:AKST DTSTART:19701101T020000 RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU END:STANDARD END:VTIMEZONE + + + + + + + + + + s0dtsvq4pe15ku09jideg67fv4_20070509T193000Z + 2007-05-09T16:32:03.000Z + 2007-05-09T16:34:33.000Z + + www2007 recurring + + + + GData Ops Demo + gdata.ops.demo@gmail.com + + + + + + + + 2007-05-31T01:15:13.259Z + + Comments for: www2007 recurring + + + + + + + + + + + + + + + + + + + + diff --git a/zend/tests/Zend/Gdata/Calendar/_files/HiddenElementSample1.xml b/zend/tests/Zend/Gdata/Calendar/_files/HiddenElementSample1.xml new file mode 100644 index 0000000..21c03d7 --- /dev/null +++ b/zend/tests/Zend/Gdata/Calendar/_files/HiddenElementSample1.xml @@ -0,0 +1,2 @@ + + diff --git a/zend/tests/Zend/Gdata/Calendar/_files/LinkElementSample1.xml b/zend/tests/Zend/Gdata/Calendar/_files/LinkElementSample1.xml new file mode 100644 index 0000000..a39056f --- /dev/null +++ b/zend/tests/Zend/Gdata/Calendar/_files/LinkElementSample1.xml @@ -0,0 +1,10 @@ + + + + \ No newline at end of file diff --git a/zend/tests/Zend/Gdata/Calendar/_files/ListFeedSample1.xml b/zend/tests/Zend/Gdata/Calendar/_files/ListFeedSample1.xml new file mode 100644 index 0000000..3919a78 --- /dev/null +++ b/zend/tests/Zend/Gdata/Calendar/_files/ListFeedSample1.xml @@ -0,0 +1,192 @@ + + + http://www.google.com/calendar/feeds/default + 2007-05-30T00:23:26.998Z + GData Ops Demo's Calendar List + + + + + GData Ops Demo + gdata.ops.demo@gmail.com + http://test.address.invalid/ + + Google Calendar + 1 + + http://www.google.com/calendar/feeds/default/gdata.ops.demo%40gmail.com + 2007-05-30T00:23:27.006Z + 2007-05-30T00:20:38.000Z + GData Ops Demo + + + + + GData Ops Demo + gdata.ops.demo@gmail.com + + + + + + + + + http://www.google.com/calendar/feeds/default/ri3u1buho56d1k2papoec4c16s%40group.calendar.google.com + 2007-05-30T00:23:27.005Z + 2007-05-30T00:20:38.000Z + My Other Awesome Calendar + This is my other calendar. + + + + + GData Ops Demo + gdata.ops.demo@gmail.com + + + + + + + + + + http://www.google.com/calendar/feeds/default/5fcmq8mrd633rulib1jgtuuk90%40group.calendar.google.com + 2007-05-30T00:23:27.005Z + 2007-05-22T05:35:47.000Z + Sample Calendar A + + + + + + GData Ops Demo + gdata.ops.demo@gmail.com + + + + + + + + + + http://www.google.com/calendar/feeds/default/a2f8cl1m7ottkhmoita51gu9cc%40group.calendar.google.com + 2007-05-30T00:23:27.005Z + 2007-05-21T07:31:41.000Z + Sample Calendar B + + + + + + GData Ops Demo + gdata.ops.demo@gmail.com + + + + + + + + + + http://www.google.com/calendar/feeds/default/rndpkbg35nhelu9fbp63u9sgp0%40group.calendar.google.com + 2007-05-30T00:23:27.006Z + 2007-05-22T21:02:34.000Z + Sample Calendar C + + + + + + GData Ops Demo + gdata.ops.demo@gmail.com + + + + + + + + + + http://www.google.com/calendar/feeds/default/u4u5cksnpp1vufdarpupn5um5s%40group.calendar.google.com + 2007-05-30T00:23:27.006Z + 2007-05-17T10:12:36.000Z + Sample Calendar D + + + + + + GData Ops Demo + gdata.ops.demo@gmail.com + + + + + + + + + + http://www.google.com/calendar/feeds/default/ibdlf33v6fj62rgfucib6s181s%40group.calendar.google.com + 2007-05-30T00:23:27.006Z + 2007-05-17T10:52:01.000Z + Sample Calender E + + + + + + GData Ops Demo + gdata.ops.demo@gmail.com + + + + + + + + + + http://www.google.com/calendar/feeds/default/usa__en%40holiday.calendar.google.com + 2007-05-30T00:23:27.006Z + 2007-05-17T09:48:29.000Z + US Holidays + + + + GData Ops Demo + gdata.ops.demo@gmail.com + + + + + + + + + http://www.google.com/calendar/feeds/default/7u5mocvk4et2vgtjte1dtcff2o%40group.calendar.google.com + 2007-05-30T00:23:27.005Z + 2007-05-30T00:20:02.000Z + My Awesome Calendar + This is my awesome calendar + + + + + GData Ops Demo + gdata.ops.demo@gmail.com + + + + + + + + + + diff --git a/zend/tests/Zend/Gdata/Calendar/_files/QuickAddElementSample1.xml b/zend/tests/Zend/Gdata/Calendar/_files/QuickAddElementSample1.xml new file mode 100644 index 0000000..2eaa496 --- /dev/null +++ b/zend/tests/Zend/Gdata/Calendar/_files/QuickAddElementSample1.xml @@ -0,0 +1,2 @@ + + diff --git a/zend/tests/Zend/Gdata/Calendar/_files/SelectedElementSample1.xml b/zend/tests/Zend/Gdata/Calendar/_files/SelectedElementSample1.xml new file mode 100644 index 0000000..8f8179c --- /dev/null +++ b/zend/tests/Zend/Gdata/Calendar/_files/SelectedElementSample1.xml @@ -0,0 +1,2 @@ + + diff --git a/zend/tests/Zend/Gdata/Calendar/_files/SendEventNotificationsElementSample1.xml b/zend/tests/Zend/Gdata/Calendar/_files/SendEventNotificationsElementSample1.xml new file mode 100644 index 0000000..3173035 --- /dev/null +++ b/zend/tests/Zend/Gdata/Calendar/_files/SendEventNotificationsElementSample1.xml @@ -0,0 +1,2 @@ + + diff --git a/zend/tests/Zend/Gdata/Calendar/_files/TestDataEventFeedSample1.xml b/zend/tests/Zend/Gdata/Calendar/_files/TestDataEventFeedSample1.xml new file mode 100644 index 0000000..08bb95a --- /dev/null +++ b/zend/tests/Zend/Gdata/Calendar/_files/TestDataEventFeedSample1.xml @@ -0,0 +1,460 @@ + + + + http://www.google.com/calendar/feeds/default/private/full + 2007-03-20T21:29:57.000Z + + GData Ops Demo + Demo Feed + + + + + + + + GData Ops Demo + gdata.ops.demo@gmail.com + http://test.address.invalid/ + + + Google Calendar + 10 + 1 + 25 + + + + http://www.google.com/calendar/feeds/default/private/full/o99flmgmkfkfrr8u745ghr3100 + 2007-03-20T21:29:52.000Z + 2007-03-20T21:29:57.000Z + + test deleted + + + + + + + + GData Ops Demo + gdata.ops.demo@gmail.com + + + + + + + + + + + + + + + + + + + + + http://www.google.com/calendar/feeds/default/private/full/2qt3ao5hbaq7m9igr5ak9esjo0 + 2007-03-20T21:26:04.000Z + 2007-03-20T21:28:46.000Z + + Afternoon at Dolores Park with Kim + This will be fun. + + + + + + + GData Ops Demo + gdata.ops.demo@gmail.com + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + http://www.google.com/calendar/feeds/default/private/full/uvsqhg7klnae40v50vihr1pvos + 2007-03-20T21:28:37.000Z + 2007-03-20T21:28:37.000Z + + Team meeting + + + + + + + + GData Ops Demo + gdata.ops.demo@gmail.com + + DTSTART;TZID=America/Los_Angeles:20070323T090000 + DTEND;TZID=America/Los_Angeles:20070323T100000 + RRULE:FREQ=WEEKLY;BYDAY=FR;UNTIL=20070817T160000Z;WKST=SU + BEGIN:VTIMEZONE TZID:America/Los_Angeles + X-LIC-LOCATION:America/Los_Angeles BEGIN:STANDARD + TZOFFSETFROM:-0700 TZOFFSETTO:-0800 TZNAME:PST + DTSTART:19701025T020000 RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU + END:STANDARD BEGIN:DAYLIGHT TZOFFSETFROM:-0800 TZOFFSETTO:-0700 + TZNAME:PDT DTSTART:19700405T020000 + RRULE:FREQ=YEARLY;BYMONTH=4;BYDAY=1SU END:DAYLIGHT + END:VTIMEZONE + + + + + + + + + + + + + + http://www.google.com/calendar/feeds/default/private/full/st4vk9kiffs6rasrl32e4a7alo + 2007-03-20T21:25:46.000Z + 2007-03-20T21:25:46.000Z + + Movie with Kim and danah + + + + + + + + GData Ops Demo + gdata.ops.demo@gmail.com + + + + + + + + + + + + + + + + + + + + + http://www.google.com/calendar/feeds/default/private/full/ofl1e45ubtsoh6gtu127cls2oo + 2007-03-20T21:24:43.000Z + 2007-03-20T21:25:08.000Z + + Dinner with Kim and Sarah + + + + + + + + GData Ops Demo + gdata.ops.demo@gmail.com + + + + + + + + + + + + + + + + + + + + + http://www.google.com/calendar/feeds/default/private/full/b69s2avfi2joigsclecvjlc91g + 2007-03-20T21:24:19.000Z + 2007-03-20T21:25:05.000Z + + Dinner with Jane and John + + + + + + + + GData Ops Demo + gdata.ops.demo@gmail.com + + + + + + + + + + + + + + + + + + + + + http://www.google.com/calendar/feeds/default/private/full/u9p66kkiotn8bqh9k7j4rcnjjc + 2007-03-20T21:24:33.000Z + 2007-03-20T21:24:33.000Z + + Tennis with Elizabeth + + + + + + + + GData Ops Demo + gdata.ops.demo@gmail.com + + + + + + + + + + + + + + + + + + + + + http://www.google.com/calendar/feeds/default/private/full/76oj2kceidob3s708tvfnuaq3c + 2007-03-20T21:24:00.000Z + 2007-03-20T21:24:00.000Z + + Lunch with Jenn + + + + + + + + GData Ops Demo + gdata.ops.demo@gmail.com + + + + + + + + + + + + + + + + + + + + + http://www.google.com/calendar/feeds/default/private/full/5np9ec8m7uoauk1vedh5mhodco + 2007-03-20T07:50:02.000Z + 2007-03-20T20:39:26.000Z + + test entry + test desc + + + + + + + GData Ops Demo + gdata.ops.demo@gmail.com + + + + + + + + + + + + + + + + + + + + + + + + + + + + + http://www.google.com/calendar/feeds/default/private/full/fu6sl0rqakf3o0a13oo1i1a1mg + 2007-02-14T23:23:37.000Z + 2007-02-14T23:25:30.000Z + + test + + + + + + + + GData Ops Demo + gdata.ops.demo@gmail.com + + + + + + + + + + + + + + + + + + + diff --git a/zend/tests/Zend/Gdata/Calendar/_files/TimezoneElementSample1.xml b/zend/tests/Zend/Gdata/Calendar/_files/TimezoneElementSample1.xml new file mode 100644 index 0000000..f0792d6 --- /dev/null +++ b/zend/tests/Zend/Gdata/Calendar/_files/TimezoneElementSample1.xml @@ -0,0 +1,2 @@ + + diff --git a/zend/tests/Zend/Gdata/Calendar/_files/WebContentElementSample1.xml b/zend/tests/Zend/Gdata/Calendar/_files/WebContentElementSample1.xml new file mode 100644 index 0000000..bea486d --- /dev/null +++ b/zend/tests/Zend/Gdata/Calendar/_files/WebContentElementSample1.xml @@ -0,0 +1,4 @@ + + diff --git a/zend/tests/Zend/Gdata/CalendarEventTest.php b/zend/tests/Zend/Gdata/CalendarEventTest.php new file mode 100644 index 0000000..140c381 --- /dev/null +++ b/zend/tests/Zend/Gdata/CalendarEventTest.php @@ -0,0 +1,494 @@ +eventFeed = new Zend_Gdata_Calendar_EventFeed($eventFeedText); + } + + /** + * 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()); + } + + /** + * Convert sample feed to XML then back to objects. Ensure that + * all objects are instances of EventEntry and object count matches. + */ + public function testEventFeedToAndFromString() + { + $entryCount = 0; + foreach ($this->eventFeed as $entry) { + $entryCount++; + $this->assertTrue($entry instanceof Zend_Gdata_Calendar_EventEntry); + } + $this->assertTrue($entryCount > 0); + + /* Grab XML from $this->eventFeed and convert back to objects */ + $newEventFeed = new Zend_Gdata_Calendar_EventFeed( + $this->eventFeed->saveXML()); + $newEntryCount = 0; + foreach ($newEventFeed as $entry) { + $newEntryCount++; + $this->assertTrue($entry instanceof Zend_Gdata_Calendar_EventEntry); + } + $this->assertEquals($entryCount, $newEntryCount); + } + + /** + * Ensure that there number of lsit feeds equals the number + * of calendars defined in the sample file. + */ + public function testEntryCount() + { + //TODO feeds implementing ArrayAccess would be helpful here + $entryCount = 0; + foreach ($this->eventFeed as $entry) { + $entryCount++; + } + $this->assertEquals(10, $entryCount); + } + + /** + * Check for the existence of an and verify that they + * contain the expected values. + */ + public function testAuthor() + { + $feed = $this->eventFeed; + + // 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", "GData Ops Demo"); + $this->verifyProperty2($feedAuthor[0], "email", "text", "gdata.ops.demo@gmail.com"); + $this->assertTrue($feedAuthor[0]->getUri() instanceof Zend_Gdata_App_Extension_Uri); + $this->verifyProperty2($feedAuthor[0], "uri", "text", "http://test.address.invalid/"); + + // Assert that each entry has valid author data + foreach ($feed as $entry) { + $entryAuthor = $entry->getAuthor(); + $this->assertEquals(1, count($entryAuthor)); + $this->verifyProperty2($entryAuthor[0], "name", "text", "GData Ops Demo"); + $this->verifyProperty2($entryAuthor[0], "email", "text", "gdata.ops.demo@gmail.com"); + $this->verifyProperty($entryAuthor[0], "uri", null); + } + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testId() + { + $feed = $this->eventFeed; + + // Assert that the feed's ID is correct + $this->assertTrue($feed->getId() instanceof Zend_Gdata_App_Extension_Id); + $this->verifyProperty2($feed, "id", "text", + "http://www.google.com/calendar/feeds/default/private/full"); + + // Assert that all entry's 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[1]; + $this->verifyProperty2($entry, "id", "text", + "http://www.google.com/calendar/feeds/default/private/full/2qt3ao5hbaq7m9igr5ak9esjo0"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testPublished() + { + $feed = $this->eventFeed; + + // Assert that all entry's 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[1]; + $this->verifyProperty2($entry, "published", "text", "2007-03-20T21:26:04.000Z"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testUpdated() + { + $feed = $this->eventFeed; + + // 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-03-20T21:29:57.000Z"); + + // Assert that all entry's have an Atom Published object + foreach ($feed as $entry) { + $this->assertTrue($entry->getUpdated() instanceof Zend_Gdata_App_Extension_Updated); + } + + // Assert one of the entry's Published dates + $entry = $feed[1]; + $this->verifyProperty2($entry, "updated", "text", "2007-03-20T21:28:46.000Z"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testTitle() + { + $feed = $this->eventFeed; + + // Assert that the feed's title is correct + $this->assertTrue($feed->getTitle() instanceof Zend_Gdata_App_Extension_Title); + $this->verifyProperty2($feed, "title", "text", + "GData Ops Demo"); + + // Assert that all entry's 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[1]; + $this->verifyProperty2($entry, "title", "text", "Afternoon at Dolores Park with Kim"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testSubtitle() + { + $feed = $this->eventFeed; + + // Assert that the feed's title is correct + $this->assertTrue($feed->getSubtitle() instanceof Zend_Gdata_App_Extension_Subtitle); + $this->verifyProperty2($feed, "subtitle", "text", + "Demo Feed"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testTimezone() + { + $feed = $this->eventFeed; + + // Assert that the feed's timezone is correct + $this->assertTrue($feed->getTimezone() instanceof Zend_Gdata_Calendar_Extension_Timezone); + $this->verifyProperty2($feed, "timezone", "value", + "America/Los_Angeles"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testStartIndex() + { + $feed = $this->eventFeed; + + // Assert that the feed's startIndex is correct + $this->assertTrue($feed->getStartIndex() instanceof Zend_Gdata_Extension_OpenSearchStartIndex); + $this->verifyProperty2($feed, "startIndex", "text", "1"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testItemsPerPage() + { + $feed = $this->eventFeed; + + // Assert that the feed's itemsPerPage is correct + $this->assertTrue($feed->getItemsPerPage() instanceof Zend_Gdata_Extension_OpenSearchItemsPerPage); + $this->verifyProperty2($feed, "itemsPerPage", "text", "25"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testContent() + { + $feed = $this->eventFeed; + + // Assert that all entry's have a content object + foreach ($feed as $entry) { + $this->assertTrue($entry->getContent() instanceof Zend_Gdata_App_Extension_Content); + } + + // Assert one of the entry's values + $entry = $feed[1]; + $this->verifyProperty2($entry, "content", "text", "This will be fun."); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testSendEventNotifications() + { + $feed = $this->eventFeed; + + // Assert that all entry's have a sendEventNotifications object + foreach ($feed as $entry) { + $this->assertTrue($entry->getSendEventNotifications() instanceof Zend_Gdata_Calendar_Extension_SendEventNotifications); + } + + // Assert one of the entry's values + $entry = $feed[1]; + $this->verifyProperty2($entry, "sendEventNotifications", "value", false); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testEventStatus() + { + $feed = $this->eventFeed; + + // Assert that all entry's have a eventStatus object + foreach ($feed as $entry) { + $this->assertTrue($entry->getEventStatus() instanceof Zend_Gdata_Extension_EventStatus); + } + + // Assert one of the entry's values + $entry = $feed[1]; + $this->verifyProperty2($entry, "eventStatus", "value", "http://schemas.google.com/g/2005#event.confirmed"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testComments() + { + $feed = $this->eventFeed; + + // Assert one of the entry's commments links + $entry = $feed[1]; + $this->assertTrue($entry->getComments() instanceof Zend_Gdata_Extension_Comments); + $this->verifyProperty2($entry->getComments(), "feedLink", "href", "http://www.google.com/calendar/feeds/default/private/full/2qt3ao5hbaq7m9igr5ak9esjo0/comments"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testVisibility() + { + $feed = $this->eventFeed; + + // Assert that all entry's have a visibility object + foreach ($feed as $entry) { + $this->assertTrue($entry->getVisibility() instanceof Zend_Gdata_Extension_Visibility); + } + + // Assert one of the entries values + $entry = $feed[1]; + $this->verifyProperty2($entry, "visibility", "value", "http://schemas.google.com/g/2005#event.private"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testTransparency() + { + $feed = $this->eventFeed; + + // Assert that all entry's have a transparency object + foreach ($feed as $entry) { + $this->assertTrue($entry->getTransparency() instanceof Zend_Gdata_Extension_Transparency); + } + + // Assert one of the entries values + $entry = $feed[1]; + $this->verifyProperty2($entry, "transparency", "value", "http://schemas.google.com/g/2005#event.opaque"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testWhen() + { + $feed = $this->eventFeed; + + // Assert one of the entry's values + $entry = $feed[1]; + $when = $entry->getWhen(); + $this->assertEquals($entry->getWhen(), $entry->when); + $this->assertEquals(1, count($when)); + $w = $when[0]; + $this->assertTrue($w instanceof Zend_Gdata_Extension_When); + $this->verifyProperty($w, "startTime", "2007-03-24T12:00:00.000-07:00"); + $this->verifyProperty($w, "endTime", "2007-03-24T15:00:00.000-07:00"); + + // Assert that the associated reminders are correct + $reminders = $w->getReminders(); + $this->assertEquals(1, count($reminders)); + $this->verifyProperty($reminders[0], "minutes", "20"); + $this->verifyProperty($reminders[0], "method", "alert"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testWhere() + { + $feed = $this->eventFeed; + + // Assert one of the entry's values + $entry = $feed[1]; + $where = $entry->getWhere(); + $this->assertEquals(1, count($where)); + $this->assertTrue($where[0] instanceof Zend_Gdata_Extension_Where); + $this->verifyProperty($where[0], "valueString", "Dolores Park with Kim"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testWho() + { + $feed = $this->eventFeed; + + // For one of the entries, make sure that all who entries are of the + // right kind + $entry = $feed[1]; + $who = $entry->getWho(); + foreach ($who as $w) { + $this->assertTrue($w instanceof Zend_Gdata_Extension_Who); + } + $this->assertEquals(2, count($who)); + + // Check one of the who entries to make sure the values are valid + $this->verifyProperty($who[0], "rel", "http://schemas.google.com/g/2005#event.organizer"); + $this->verifyProperty($who[0], "valueString", "GData Ops Demo"); + $this->verifyProperty($who[0], "email", "gdata.ops.demo@gmail.com"); + $this->verifyProperty2($who[0], "attendeeStatus", "value", "http://schemas.google.com/g/2005#event.accepted"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGenerator() + { + $feed = $this->eventFeed; + + // Assert that the feed's generator is correct + $this->assertTrue($feed->getGenerator() instanceof Zend_Gdata_App_Extension_Generator); + $this->verifyProperty2($feed, "generator", "version", "1.0"); + $this->verifyProperty2($feed, "generator", "uri", "http://www.google.com/calendar"); + $this->verifyProperty2($feed, "generator", "text", "Google Calendar"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testQuickAdd() + { + $feed = $this->eventFeed; + + // Assert that one of the event's QuickAdd entries is correct + $quickAdd = $feed->entry[1]->getQuickAdd(); + $this->assertTrue($quickAdd instanceof Zend_Gdata_Calendar_Extension_QuickAdd); + $this->verifyProperty($quickAdd, "value", true); + } + +} diff --git a/zend/tests/Zend/Gdata/CalendarFeedCompositeTest.php b/zend/tests/Zend/Gdata/CalendarFeedCompositeTest.php new file mode 100644 index 0000000..3d3d3c6 --- /dev/null +++ b/zend/tests/Zend/Gdata/CalendarFeedCompositeTest.php @@ -0,0 +1,509 @@ +eventFeed = new Zend_Gdata_Calendar_EventFeed($eventFeedText); + } + + /** + * 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($obj->$propGetter(), $value); + } + + /** + * 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($obj->$propGetter()->$secondGetter(), $value); + } + + /** + * Convert sample feed to XML then back to objects. Ensure that + * all objects are instances of EventEntry and object count matches. + */ + public function testEventFeedToAndFromString() + { + $entryCount = 0; + foreach ($this->eventFeed as $entry) { + $entryCount++; + $this->assertTrue($entry instanceof Zend_Gdata_Calendar_EventEntry); + } + $this->assertTrue($entryCount > 0); + + /* Grab XML from $this->eventFeed and convert back to objects */ + $newEventFeed = new Zend_Gdata_Calendar_EventFeed( + $this->eventFeed->saveXML()); + $newEntryCount = 0; + foreach ($newEventFeed as $entry) { + $newEntryCount++; + $this->assertTrue($entry instanceof Zend_Gdata_Calendar_EventEntry); + } + $this->assertEquals($entryCount, $newEntryCount); + } + + /** + * Ensure that there number of lsit feeds equals the number + * of calendars defined in the sample file. + */ + public function testEntryCount() + { + //TODO feeds implementing ArrayAccess would be helpful here + $entryCount = 0; + foreach ($this->eventFeed as $entry) { + $entryCount++; + } + $this->assertEquals(7, $entryCount); + $this->assertEquals($entryCount, $this->eventFeed->totalResults->text); + } + + /** + * Check for the existence of an and verify that they + * contain the expected values. + */ + public function testAuthor() + { + $feed = $this->eventFeed; + + // 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", "GData Ops Demo"); + $this->verifyProperty2($feedAuthor[0], "email", "text", "gdata.ops.demo@gmail.com"); + + // Assert that each entry has valid author data + foreach ($feed as $entry) { + $entryAuthor = $entry->getAuthor(); + $this->assertEquals(1, count($entryAuthor)); + $this->verifyProperty2($entryAuthor[0], "name", "text", "GData Ops Demo"); + $this->verifyProperty2($entryAuthor[0], "email", "text", "gdata.ops.demo@gmail.com"); + $this->verifyProperty($entryAuthor[0], "uri", null); + } + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testId() + { + $feed = $this->eventFeed; + + // Assert that the feed's ID is correct + $this->assertTrue($feed->getId() instanceof Zend_Gdata_App_Extension_Id); + $this->verifyProperty2($feed, "id", "text", + "http://www.google.com/calendar/feeds/default/private/composite"); + + // Assert that all entry's 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[2]; + $this->verifyProperty2($entry, "id", "text", + "http://www.google.com/calendar/feeds/default/private/composite/lq2ai6imsbq209q3aeturho50g"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testPublished() + { + $feed = $this->eventFeed; + + // Assert that all entry's 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[2]; + $this->verifyProperty2($entry, "published", "text", "2007-05-09T16:44:38.000Z"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testUpdated() + { + $feed = $this->eventFeed; + + // 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-05-31T01:15:00.000Z"); + + // Assert that all entry's have an Atom Published object + foreach ($feed as $entry) { + $this->assertTrue($entry->getUpdated() instanceof Zend_Gdata_App_Extension_Updated); + } + + // Assert one of the entry's Published dates + $entry = $feed[2]; + $this->verifyProperty2($entry, "updated", "text", "2007-05-17T10:33:49.000Z"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testTitle() + { + $feed = $this->eventFeed; + + // Assert that the feed's title is correct + $this->assertTrue($feed->getTitle() instanceof Zend_Gdata_App_Extension_Title); + $this->verifyProperty2($feed, "title", "text", + "GData Ops Demo's Composite View"); + + // Assert that all entry's 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[2]; + $this->verifyProperty2($entry, "title", "text", "all day event may 24"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testSubtitle() + { + $feed = $this->eventFeed; + + // Assert that the feed's title is correct + $this->assertTrue($feed->getSubtitle() instanceof Zend_Gdata_App_Extension_Subtitle); + $this->verifyProperty2($feed, "subtitle", "text", + "GData Is Awesome"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testTimezone() + { + $feed = $this->eventFeed; + + // Assert that the feed's title is correct + $this->assertTrue($feed->getTimezone() instanceof Zend_Gdata_Calendar_Extension_Timezone); + $this->verifyProperty2($feed, "timezone", "value", + "America/Chicago"); + } + + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testEventStatus() + { + $feed = $this->eventFeed; + + // Assert that all entry's have an eventStatus object + foreach ($feed as $entry) { + $this->assertTrue($entry->getEventStatus() instanceof Zend_Gdata_Extension_EventStatus); + } + + // Assert one of the entries values + $entry = $feed[2]; + $this->verifyProperty2($entry, "eventStatus", "value", "http://schemas.google.com/g/2005#event.confirmed"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testVisibility() + { + $feed = $this->eventFeed; + + // Assert that all entry's have a visibility object + foreach ($feed as $entry) { + $this->assertTrue($entry->getVisibility() instanceof Zend_Gdata_Extension_Visibility); + } + + // Assert one of the entries values + $entry = $feed[2]; + $this->verifyProperty2($entry, "visibility", "value", "http://schemas.google.com/g/2005#event.default"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testTransparency() + { + $feed = $this->eventFeed; + + // Assert that all entry's have a transparency object + foreach ($feed as $entry) { + $this->assertTrue($entry->getTransparency() instanceof Zend_Gdata_Extension_Transparency); + } + + // Assert one of the entries values + $entry = $feed[2]; + $this->verifyProperty2($entry, "transparency", "value", "http://schemas.google.com/g/2005#event.transparent"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testSendEventNotifications() + { + $feed = $this->eventFeed; + + // Assert that all entry's have a sendEventNotifications object + foreach ($feed as $entry) { + $this->assertTrue($entry->getSendEventNotifications() instanceof Zend_Gdata_Calendar_Extension_SendEventNotifications); + } + + // Assert one of the entry's values + $entry = $feed[2]; + $this->verifyProperty2($entry, "sendEventNotifications", "value", false); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testWhen() + { + $feed = $this->eventFeed; + + // Assert one of the entry's values + $entry = $feed[2]; + $when = $entry->getWhen(); + $this->assertEquals($entry->getWhen(), $entry->when); + $this->assertEquals(1, count($when)); + $this->assertTrue($when[0] instanceof Zend_Gdata_Extension_When); + $this->verifyProperty($when[0], "startTime", "2007-05-24"); + $this->verifyProperty($when[0], "endTime", "2007-05-25"); + + // Verify that the reminders show up + $reminders = $when[0]->getReminders(); + $this->assertEquals(2, count($reminders)); + $this->assertTrue($reminders[0] instanceof Zend_Gdata_Extension_Reminder); + $this->assertTrue($reminders[1] instanceof Zend_Gdata_Extension_Reminder); + $this->verifyProperty($reminders[0], "minutes", "10"); + $this->verifyProperty($reminders[0], "method", "alert"); + $this->verifyProperty($reminders[1], "minutes", "10"); + $this->verifyProperty($reminders[1], "method", "email"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testWhere() + { + $feed = $this->eventFeed; + + // Assert one of the entry's values + $entry = $feed[2]; + $where = $entry->getWhere(); + $this->assertEquals(1, count($where)); + $this->assertTrue($where[0] instanceof Zend_Gdata_Extension_Where); + $this->verifyProperty($where[0], "valueString", "Mountain View, California"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testComments() + { + $feed = $this->eventFeed; + + + // Assert one of the entries has the correct values + // Make sure the comment element looks right + $entry = $feed[2]; + $c = $entry->getComments(); + $this->assertEquals($c, $entry->comments); + $this->assertTrue($c instanceof Zend_Gdata_Extension_Comments); + + // Make sure that the feedLink looks right + $fl = $c->getFeedLink(); + $this->assertTrue($fl instanceof Zend_Gdata_Extension_FeedLink); + $this->assertEquals($fl, $c->feedLink); + $this->verifyProperty($fl, "href", "http://www.google.com/calendar/feeds/default/private/full/lq2ai6imsbq209q3aeturho50g/comments"); + + // Make sure the embedded feed looks right + $cFeed = $fl->getFeed(); + $this->assertTrue($cFeed instanceof Zend_Gdata_App_Feed); + $this->assertEquals($cFeed, $fl->feed); + + // Verify the remainder of the comment feed metadata + $this->assertTrue($cFeed->getUpdated() instanceof Zend_Gdata_App_Extension_Updated); + $this->verifyProperty2($cFeed, "updated", "text", "2007-05-31T01:15:13.249Z"); + + $this->assertTrue($cFeed->getTitle() instanceof Zend_Gdata_App_Extension_Title); + $this->verifyProperty2($cFeed, "title", "text", "Comments for: all day event may 24"); + + // Verify that the comments appear to be good + $commentCount = 0; + foreach ($cFeed as $entry) + { + $this->assertTrue($entry instanceof Zend_Gdata_Entry); + $commentCount++; + } + $this->assertEquals(2, $commentCount); + + // Closely examine one of the comments + $comment = $cFeed[1]; + + $this->assertTrue($comment->getId() instanceof Zend_Gdata_App_Extension_Id); + $this->verifyProperty2($comment, "id", "text", "i9q87onko1uphfs7i21elnnb4g"); + + $this->assertTrue($comment->getPublished() instanceof Zend_Gdata_App_Extension_Published); + $this->verifyProperty2($comment, "published", "text", "2007-06-01T21:21:47.000Z"); + + $this->assertTrue($comment->getUpdated() instanceof Zend_Gdata_App_Extension_Updated); + $this->verifyProperty2($comment, "updated", "text", "2007-06-01T21:21:47.000Z"); + + $this->assertEquals(1, count($comment->author)); + $this->assertTrue($comment->author[0] instanceof Zend_Gdata_App_Extension_Author); + $this->assertTrue($comment->author[0]->getName() instanceof Zend_Gdata_App_Extension_Name); + $this->assertTrue($comment->author[0]->getEmail() instanceof Zend_Gdata_App_Extension_Email); + $this->verifyProperty2($comment->author[0], "name", "text", "User 2"); + $this->verifyProperty2($comment->author[0], "email", "text", "user2@nowhere.invalid"); + + $this->assertTrue($comment->getContent() instanceof Zend_Gdata_App_Extension_Content); + $this->verifyProperty($comment->getContent(), "type", "html"); + $this->assertEquals('

This is a user supplied comment.

', $comment->getContent()->text); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testRecurrence() + { + $feed = $this->eventFeed; + + // Assert one of the entry's values + $entry = $feed[1]; + $this->assertTrue($entry->getRecurrence() instanceof Zend_Gdata_Extension_Recurrence); + $this->verifyProperty2($entry, "recurrence", "text", + "DTSTART;VALUE=DATE:20070501 DTEND;VALUE=DATE:20070502 RRULE:FREQ=WEEKLY;BYDAY=Tu;UNTIL=20070904"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testStartIndex() + { + $feed = $this->eventFeed; + + // Assert that the feed's startIndex is correct + $this->assertTrue($feed->getStartIndex() instanceof Zend_Gdata_Extension_OpenSearchStartIndex); + $this->verifyProperty2($feed, "startIndex", "text", "1"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testItemsPerPage() + { + $feed = $this->eventFeed; + + // Assert that the feed's itemsPerPage is correct + $this->assertTrue($feed->getItemsPerPage() instanceof Zend_Gdata_Extension_OpenSearchItemsPerPage); + $this->verifyProperty2($feed, "itemsPerPage", "text", "25"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGenerator() + { + $feed = $this->eventFeed; + + // Assert that the feed's generator is correct + $this->assertTrue($feed->getGenerator() instanceof Zend_Gdata_App_Extension_Generator); + $this->verifyProperty2($feed, "generator", "version", "1.0"); + $this->verifyProperty2($feed, "generator", "uri", "http://www.google.com/calendar"); + } + + +} diff --git a/zend/tests/Zend/Gdata/CalendarFeedTest.php b/zend/tests/Zend/Gdata/CalendarFeedTest.php new file mode 100644 index 0000000..0ea45da --- /dev/null +++ b/zend/tests/Zend/Gdata/CalendarFeedTest.php @@ -0,0 +1,388 @@ +listFeed = new Zend_Gdata_Calendar_ListFeed($listFeedText); + } + + /** + * 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()); + } + + /** + * Convert sample feed to XML then back to objects. Ensure that + * all objects are instances of EventEntry and object count matches. + */ + public function testEventFeedToAndFromString() + { + $entryCount = 0; + foreach ($this->listFeed as $entry) { + $entryCount++; + $this->assertTrue($entry instanceof Zend_Gdata_Calendar_ListEntry); + } + $this->assertTrue($entryCount > 0); + + /* Grab XML from $this->listFeed and convert back to objects */ + $newListFeed = new Zend_Gdata_Calendar_ListFeed( + $this->listFeed->saveXML()); + $newEntryCount = 0; + foreach ($newListFeed as $entry) { + $newEntryCount++; + $this->assertTrue($entry instanceof Zend_Gdata_Calendar_ListEntry); + } + $this->assertEquals($entryCount, $newEntryCount); + } + + /** + * Ensure that there number of lsit feeds equals the number + * of calendars defined in the sample file. + */ + public function testEntryCount() + { + //TODO feeds implementing ArrayAccess would be helpful here + $entryCount = 0; + foreach ($this->listFeed as $entry) { + $entryCount++; + } + $this->assertEquals(9, $entryCount); + } + + /** + * Check for the existence of an and verify that they + * contain the expected values. + */ + public function testAuthor() + { + $feed = $this->listFeed; + + // 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", "GData Ops Demo"); + $this->verifyProperty2($feedAuthor[0], "email", "text", "gdata.ops.demo@gmail.com"); + $this->assertTrue($feedAuthor[0]->getUri() instanceof Zend_Gdata_App_Extension_Uri); + $this->verifyProperty2($feedAuthor[0], "uri", "text", "http://test.address.invalid/"); + + // Assert that each entry has valid author data + foreach ($feed as $entry) { + $entryAuthor = $entry->getAuthor(); + $this->assertEquals(1, count($entryAuthor)); + $this->verifyProperty2($entryAuthor[0], "name", "text", "GData Ops Demo"); + $this->verifyProperty2($entryAuthor[0], "email", "text", "gdata.ops.demo@gmail.com"); + $this->verifyProperty($entryAuthor[0], "uri", null); + } + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testId() + { + $feed = $this->listFeed; + + // Assert that the feed's ID is correct + $this->assertTrue($feed->getId() instanceof Zend_Gdata_App_Extension_Id); + $this->verifyProperty2($feed, "id", "text", + "http://www.google.com/calendar/feeds/default"); + + // Assert that all entry's 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[1]; + $this->verifyProperty2($entry, "id", "text", + "http://www.google.com/calendar/feeds/default/ri3u1buho56d1k2papoec4c16s%40group.calendar.google.com"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testPublished() + { + $feed = $this->listFeed; + + // Assert that all entry's 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[1]; + $this->verifyProperty2($entry, "published", "text", "2007-05-30T00:23:27.005Z"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testUpdated() + { + $feed = $this->listFeed; + + // 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-05-30T00:23:26.998Z"); + + // Assert that all entry's have an Atom Published object + foreach ($feed as $entry) { + $this->assertTrue($entry->getUpdated() instanceof Zend_Gdata_App_Extension_Updated); + } + + // Assert one of the entry's Published dates + $entry = $feed[1]; + $this->verifyProperty2($entry, "updated", "text", "2007-05-30T00:20:38.000Z"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testTitle() + { + $feed = $this->listFeed; + + // Assert that the feed's title is correct + $this->assertTrue($feed->getTitle() instanceof Zend_Gdata_App_Extension_Title); + $this->verifyProperty2($feed, "title", "text", + "GData Ops Demo's Calendar List"); + + // Assert that all entry's 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[1]; + $this->verifyProperty2($entry, "title", "text", "My Other Awesome Calendar"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testColor() + { + $feed = $this->listFeed; + + // Assert that all entry's have an color object + foreach ($feed as $entry) { + $this->assertTrue($entry->getColor() instanceof Zend_Gdata_Calendar_Extension_Color); + } + + // Assert one of the entry's Titles + $entry = $feed[1]; + $this->verifyProperty2($entry, "color", "value", "#A32929"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testAccessLevel() + { + $feed = $this->listFeed; + + // Assert that all entry's have an accessLevel object + foreach ($feed as $entry) { + $this->assertTrue($entry->getAccessLevel() instanceof Zend_Gdata_Calendar_Extension_AccessLevel); + } + + // Assert one of the entry's Titles + $entry = $feed[1]; + $this->verifyProperty2($entry, "accessLevel", "value", "owner"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testTimezone() + { + $feed = $this->listFeed; + + // Assert that all entry's have an accessLevel object + foreach ($feed as $entry) { + $this->assertTrue($entry->getTimezone() instanceof Zend_Gdata_Calendar_Extension_Timezone); + } + + // Assert one of the entry's Titles + $entry = $feed[1]; + $this->verifyProperty2($entry, "timezone", "value", "America/Chicago"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testHidden() + { + $feed = $this->listFeed; + + // Assert that all entry's have an accessLevel object + foreach ($feed as $entry) { + $this->assertTrue($entry->getHidden() instanceof Zend_Gdata_Calendar_Extension_Hidden); + } + + // Assert one of the entry's Titles + $entry = $feed[1]; + $this->verifyProperty2($entry, "hidden", "value", false); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testSelected() + { + $feed = $this->listFeed; + + // Assert that all entry's have a selected object + foreach ($feed as $entry) { + $this->assertTrue($entry->getSelected() instanceof Zend_Gdata_Calendar_Extension_Selected); + } + + // Assert one of the entry's Titles + $entry = $feed[1]; + $this->verifyProperty2($entry, "selected", "value", true); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testStartIndex() + { + $feed = $this->listFeed; + + // Assert that the feed's startIndex is correct + $this->assertTrue($feed->getStartIndex() instanceof Zend_Gdata_Extension_OpenSearchStartIndex); + $this->verifyProperty2($feed, "startIndex", "text", "1"); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testWhere() + { + $feed = $this->listFeed; + + // Assert one of the entry's where values + $entry = $feed[1]; + $this->assertEquals($entry->getWhere(), $entry->where); + $this->assertTrue($entry->where[0] instanceof Zend_Gdata_Extension_Where); + $this->assertEquals("Palo Alto, California", $entry->where[0]->getValueString()); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testSummary() + { + $feed = $this->listFeed; + + // Assert one of the entry's summaries + $entry = $feed[1]; + $this->assertTrue($entry->getSummary() instanceof Zend_Gdata_App_Extension_Summary); + $this->verifyProperty2($entry, "summary", "text", "This is my other calendar."); + } + + /** + * Check for the existence of an and verify that it contains + * the expected value. + */ + public function testGenerator() + { + $feed = $this->listFeed; + + // Assert that the feed's generator is correct + $this->assertTrue($feed->getGenerator() instanceof Zend_Gdata_App_Extension_Generator); + $this->verifyProperty2($feed, "generator", "version", "1.0"); + $this->verifyProperty2($feed, "generator", "uri", "http://www.google.com/calendar"); + } + +} diff --git a/zend/tests/Zend/Gdata/CalendarOnlineTest.php b/zend/tests/Zend/Gdata/CalendarOnlineTest.php new file mode 100644 index 0000000..223de50 --- /dev/null +++ b/zend/tests/Zend/Gdata/CalendarOnlineTest.php @@ -0,0 +1,172 @@ +gdata = new Zend_Gdata_Calendar($client); + } + + public function testCalendarListFeed() + { + $calFeed = $this->gdata->getCalendarListFeed(); + $this->assertTrue(strpos($calFeed->title->text, 'Calendar List') + !== false); + $calCount = 0; + foreach ($calFeed as $calendar) { + $calCount++; + } + $this->assertTrue($calCount > 0); + } + + /** + * @group ZF-1701 + */ + public function testCalendarOnlineFeed() + { + $eventFeed = $this->gdata->getCalendarEventFeed(); + $this->assertTrue(strpos($eventFeed->title->text, TESTS_ZEND_GDATA_CLIENTLOGIN_EMAIL) + !== false); + $eventCount = 0; + foreach ( $eventFeed as $event ) { + $this->assertType('Zend_Gdata_Calendar_EventEntry', $event); + $eventCount++; + } + $this->assertTrue($eventCount > 0 ); + $this->assertTrue(count($eventFeed) == $eventCount); + } + + function getEvent($eventId) + { + $query = $this->gdata->newEventQuery(); + $query->setUser('default'); + $query->setVisibility('private'); + $query->setProjection('full'); + $query->setEvent($eventId); + + $eventEntry = $this->gdata->getCalendarEventEntry($query); + $this->assertTrue( + $eventEntry instanceof Zend_Gdata_Calendar_EventEntry); + return $eventEntry; + } + + public function createEvent( + $title = 'Tennis with Beth', + $desc='Meet for a quick lesson', $where = 'On the courts', + $startDate = '2008-01-20', $startTime = '10:00', + $endDate = '2008-01-20', $endTime = '11:00', $tzOffset = '-08') + { + $newEntry = $this->gdata->newEventEntry(); + $newEntry->title = $this->gdata->newTitle(trim($title)); + $newEntry->where = array($this->gdata->newWhere($where)); + + $newEntry->content = $this->gdata->newContent($desc); + $newEntry->content->type = 'text'; + + $when = $this->gdata->newWhen(); + $when->startTime = "{$startDate}T{$startTime}:00.000{$tzOffset}:00"; + $when->endTime = "{$endDate}T{$endTime}:00.000{$tzOffset}:00"; + $reminder = $this->gdata->newReminder(); + $reminder->minutes = '30'; + $reminder->method = 'email'; + $when->reminders = array($reminder); + $newEntry->when = array($when); + + $createdEntry = $this->gdata->insertEvent($newEntry); + + $this->assertEquals('email in 30 minutes', $reminder->__toString()); + $this->assertEquals($title, $createdEntry->title->text); + $this->assertEquals($desc, $createdEntry->content->text); + $this->assertEquals(strtotime($when->startTime), + strtotime($createdEntry->when[0]->startTime)); + $this->assertEquals(strtotime($when->endTime), + strtotime($createdEntry->when[0]->endTime)); + $this->assertEquals($reminder->method, + $createdEntry->when[0]->reminders[0]->method); + $this->assertEquals($reminder->minutes, + $createdEntry->when[0]->reminders[0]->minutes); + $this->assertEquals($where, $createdEntry->where[0]->valueString); + + return $createdEntry; + } + + function updateEvent ($eventId, $newTitle) + { + $eventOld = $this->getEvent($eventId); + $eventOld->title = $this->gdata->newTitle($newTitle); + $eventOld->save(); + $eventNew = $this->getEvent($eventId); + $this->assertEquals($newTitle, $eventNew->title->text); + return $eventNew; + } + + public function testCreateEvent() + { + $createdEntry = $this->createEvent(); + } + + public function testCreateAndUpdateEvent() + { + $newTitle = 'my new title'; + $createdEntry = $this->createEvent(); + preg_match('#.*/([A-Za-z0-9]+)$#', $createdEntry->id->text, $matches); + $id = $matches[1]; + $updatedEvent = $this->updateEvent($id, $newTitle); + $this->assertEquals($newTitle, $updatedEvent->title->text); + } + + public function testCreateAndDeleteEvent() + { + /* deletion can be performed in several different ways-- test all */ + $createdEntry = $this->createEvent(); + $createdEntry->delete(); + + $createdEntry2 = $this->createEvent(); + $this->gdata->delete($createdEntry2); + + $createdEntry3 = $this->createEvent(); + $this->gdata->delete($createdEntry3->getEditLink()->href); + } +} diff --git a/zend/tests/Zend/Gdata/CalendarTest.php b/zend/tests/Zend/Gdata/CalendarTest.php new file mode 100644 index 0000000..9616129 --- /dev/null +++ b/zend/tests/Zend/Gdata/CalendarTest.php @@ -0,0 +1,102 @@ +eventFeedText = file_get_contents( + 'Zend/Gdata/Calendar/_files/TestDataEventFeedSample1.xml', + true); + $this->eventFeed = new Zend_Gdata_Calendar_EventFeed(); + } + + public function testEmptyEventFeedShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->eventFeed->extensionElements)); + $this->assertTrue(count($this->eventFeed->extensionElements) == 0); + } + + public function testEmptyEventFeedShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->eventFeed->extensionAttributes)); + $this->assertTrue(count($this->eventFeed->extensionAttributes) == 0); + } + + public function testSampleEventFeedShouldHaveNoExtensionElements() { + $this->eventFeed->transferFromXML($this->eventFeedText); + $this->assertTrue(is_array($this->eventFeed->extensionElements)); + $this->assertTrue(count($this->eventFeed->extensionElements) == 0); + } + + public function testSampleEventFeedShouldHaveNoExtensionAttributes() { + $this->eventFeed->transferFromXML($this->eventFeedText); + $this->assertTrue(is_array($this->eventFeed->extensionAttributes)); + $this->assertTrue(count($this->eventFeed->extensionAttributes) == 0); + } + + public function testEventFeedToAndFromString() + { + $this->eventFeed->transferFromXML($this->eventFeedText); + $entryCount = 0; + foreach ($this->eventFeed as $entry) { + $entryCount++; + $this->assertTrue($entry instanceof Zend_Gdata_Calendar_EventEntry); + } + $this->assertTrue($entryCount > 0); + + /* Grab XML from $this->eventFeed and convert back to objects */ + $newEventFeed = new Zend_Gdata_Calendar_EventFeed( + $this->eventFeed->saveXML()); + $newEntryCount = 0; + foreach ($newEventFeed as $entry) { + $newEntryCount++; + $this->assertTrue($entry instanceof Zend_Gdata_Calendar_EventEntry); + } + $this->assertEquals($entryCount, $newEntryCount); + } + + public function testEntryCount() + { + $this->eventFeed->transferFromXML($this->eventFeedText); + //TODO feeds implementing ArrayAccess would be helpful here + $entryCount = 0; + foreach ($this->eventFeed as $entry) { + $entryCount++; + } + $this->assertEquals($entryCount, 10); + $this->assertEquals($entryCount, $this->eventFeed->totalResults->text); + } + +} diff --git a/zend/tests/Zend/Gdata/CommentsTest.php b/zend/tests/Zend/Gdata/CommentsTest.php new file mode 100644 index 0000000..16d6f2e --- /dev/null +++ b/zend/tests/Zend/Gdata/CommentsTest.php @@ -0,0 +1,127 @@ +commentsText = file_get_contents( + 'Zend/Gdata/_files/CommentsElementSample1.xml', + true); + $this->comments = new Zend_Gdata_Extension_Comments(); + } + + public function testEmptyCommentsShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->comments->extensionElements)); + $this->assertTrue(count($this->comments->extensionElements) == 0); + } + + public function testEmptyCommentsShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->comments->extensionAttributes)); + $this->assertTrue(count($this->comments->extensionAttributes) == 0); + } + + public function testSampleCommentsShouldHaveNoExtensionElements() { + $this->comments->transferFromXML($this->commentsText); + $this->assertTrue(is_array($this->comments->extensionElements)); + $this->assertTrue(count($this->comments->extensionElements) == 0); + } + + public function testSampleCommentsShouldHaveNoExtensionAttributes() { + $this->comments->transferFromXML($this->commentsText); + $this->assertTrue(is_array($this->comments->extensionAttributes)); + $this->assertTrue(count($this->comments->extensionAttributes) == 0); + } + + public function testNormalCommentsShouldHaveNoExtensionElements() { + $this->comments->rel = "http://schemas.google.com/g/2005#regular"; + + $this->assertEquals("http://schemas.google.com/g/2005#regular", $this->comments->rel); + + $this->assertEquals(0, count($this->comments->extensionElements)); + $newComments = new Zend_Gdata_Extension_Comments(); + $newComments->transferFromXML($this->comments->saveXML()); + $this->assertEquals(0, count($newComments->extensionElements)); + $newComments->extensionElements = array( + new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); + $this->assertEquals(1, count($newComments->extensionElements)); + $this->assertEquals("http://schemas.google.com/g/2005#regular", $newComments->rel); + + /* try constructing using magic factory */ + $gdata = new Zend_Gdata(); + $newComments2 = $gdata->newComments(); + $newComments2->transferFromXML($newComments->saveXML()); + $this->assertEquals(1, count($newComments2->extensionElements)); + $this->assertEquals("http://schemas.google.com/g/2005#regular", $newComments2->rel); + } + + public function testEmptyCommentsToAndFromStringShouldMatch() { + $commentsXml = $this->comments->saveXML(); + $newComments = new Zend_Gdata_Extension_Comments(); + $newComments->transferFromXML($commentsXml); + $newCommentsXml = $newComments->saveXML(); + $this->assertTrue($commentsXml == $newCommentsXml); + } + + public function testCommentsWithValueToAndFromStringShouldMatch() { + $this->comments->rel = "http://schemas.google.com/g/2005#regular"; + $commentsXml = $this->comments->saveXML(); + $newComments = new Zend_Gdata_Extension_Comments(); + $newComments->transferFromXML($commentsXml); + $newCommentsXml = $newComments->saveXML(); + $this->assertTrue($commentsXml == $newCommentsXml); + $this->assertEquals("http://schemas.google.com/g/2005#regular", $this->comments->rel); + } + + public function testExtensionAttributes() { + $extensionAttributes = $this->comments->extensionAttributes; + $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); + $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); + $this->comments->extensionAttributes = $extensionAttributes; + $this->assertEquals('bar', $this->comments->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $this->comments->extensionAttributes['foo2']['value']); + $commentsXml = $this->comments->saveXML(); + $newComments = new Zend_Gdata_Extension_Comments(); + $newComments->transferFromXML($commentsXml); + $this->assertEquals('bar', $newComments->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $newComments->extensionAttributes['foo2']['value']); + } + + public function testConvertFullCommentsToAndFromString() { + $this->comments->transferFromXML($this->commentsText); + $this->assertEquals("http://schemas.google.com/g/2005#reviews", $this->comments->rel); + $this->assertTrue($this->comments->feedLink instanceof Zend_Gdata_Extension_FeedLink); + $this->assertEquals("http://example.com/restaurants/SanFrancisco/432432/reviews", $this->comments->feedLink->href); + } + +} diff --git a/zend/tests/Zend/Gdata/Docs/DocumentListEntryTest.php b/zend/tests/Zend/Gdata/Docs/DocumentListEntryTest.php new file mode 100755 index 0000000..3f50148 --- /dev/null +++ b/zend/tests/Zend/Gdata/Docs/DocumentListEntryTest.php @@ -0,0 +1,72 @@ +doc = new Zend_Gdata_Docs_DocumentListEntry( + file_get_contents('Zend/Gdata/Docs/_files/TestDataDocumentListEntrySample.xml', true)); + } + + public function testToAndFromString() + { + $this->assertTrue($this->doc instanceof Zend_Gdata_Docs_DocumentListEntry); + $this->assertTrue($this->doc->title->text === 'Test Spreadsheet'); + + $newDoc = new Zend_Gdata_Docs_DocumentListEntry(); + $doc = new DOMDocument(); + $doc->loadXML($this->doc->saveXML()); + $newDoc->transferFromDom($doc->documentElement); + + $this->assertTrue($newDoc->title == $this->doc->title); + } + + public function testSetMediaSource() + { + // Service object to create the media file source. + $this->docsClient = new Zend_Gdata_Docs(null); + $mediaSource = $this->docsClient->newMediaFileSource('test_file_name'); + $mediaSource->setSlug('test slug'); + $mediaSource->setContentType('test content type'); + $this->doc->setMediaSource($mediaSource); + $this->assertTrue($this->doc->getMediaSource()->getContentType() === + 'test content type'); + $this->assertTrue($this->doc->getMediaSource()->getSlug() === + 'test slug'); + } + +} diff --git a/zend/tests/Zend/Gdata/Docs/DocumentListFeedTest.php b/zend/tests/Zend/Gdata/Docs/DocumentListFeedTest.php new file mode 100755 index 0000000..69b911b --- /dev/null +++ b/zend/tests/Zend/Gdata/Docs/DocumentListFeedTest.php @@ -0,0 +1,67 @@ +docFeed = new Zend_Gdata_Docs_DocumentListFeed( + file_get_contents(dirname(__FILE__) . '/_files/TestDataDocumentListFeedSample.xml'), + true); + } + + public function testToAndFromString() + { + // There should be 2 entries in the feed. + $this->assertTrue(count($this->docFeed->entries) == 2); + $this->assertTrue($this->docFeed->entries->count() == 2); + foreach($this->docFeed->entries as $entry) + { + $this->assertTrue($entry instanceof Zend_Gdata_Docs_DocumentListEntry); + } + + $newDocFeed = new Zend_Gdata_Docs_DocumentListFeed(); + $doc = new DOMDocument(); + $doc->loadXML($this->docFeed->saveXML()); + $newDocFeed->transferFromDom($doc->documentElement); + + $this->assertTrue(count($newDocFeed->entries) == count($this->docFeed->entries)); + foreach($newDocFeed->entries as $entry) + { + $this->assertTrue($entry instanceof Zend_Gdata_Docs_DocumentListEntry); + } + } + +} diff --git a/zend/tests/Zend/Gdata/Docs/QueryTest.php b/zend/tests/Zend/Gdata/Docs/QueryTest.php new file mode 100755 index 0000000..37efa24 --- /dev/null +++ b/zend/tests/Zend/Gdata/Docs/QueryTest.php @@ -0,0 +1,77 @@ +docQuery = new Zend_Gdata_Docs_Query(); + } + + public function testTitle() + { + $this->assertTrue($this->docQuery->getTitle() == null); + $this->docQuery->setTitle('test title'); + $this->assertTrue($this->docQuery->getTitle() == 'test title'); + $this->assertTrue($this->docQuery->getQueryString() == '?title=test+title'); + $this->docQuery->setTitle(null); + $this->assertTrue($this->docQuery->getTitle() == null); + } + + public function testTitleExact() + { + $this->assertTrue($this->docQuery->getTitleExact() == null); + $this->docQuery->setTitleExact('test title'); + $this->assertTrue($this->docQuery->getTitleExact() == 'test title'); + $this->assertTrue($this->docQuery->getQueryString() == '?title-exact=test+title'); + $this->docQuery->setTitleExact(null); + $this->assertTrue($this->docQuery->getTitleExact() == null); + } + + public function testProjection() + { + $this->assertTrue($this->docQuery->getProjection() == 'full'); + $this->docQuery->setProjection('abc'); + $this->assertTrue($this->docQuery->getProjection() == 'abc'); + } + + public function testVisibility() + { + $this->assertTrue($this->docQuery->getVisibility() == 'private'); + $this->docQuery->setVisibility('xyz'); + $this->assertTrue($this->docQuery->getVisibility() == 'xyz'); + } +} diff --git a/zend/tests/Zend/Gdata/Docs/_files/TestDataDocumentListEntrySample.xml b/zend/tests/Zend/Gdata/Docs/_files/TestDataDocumentListEntrySample.xml new file mode 100755 index 0000000..1860425 --- /dev/null +++ b/zend/tests/Zend/Gdata/Docs/_files/TestDataDocumentListEntrySample.xml @@ -0,0 +1,14 @@ + + + + test.user + test.user@gmail.com + + + http://docs.google.com/feeds/documents/private/full/spreadsheet%3Asupercalifragilisticexpealidocious + + + + Test Spreadsheet + 2007-07-03T18:03:32.045Z + diff --git a/zend/tests/Zend/Gdata/Docs/_files/TestDataDocumentListFeedSample.xml b/zend/tests/Zend/Gdata/Docs/_files/TestDataDocumentListFeedSample.xml new file mode 100755 index 0000000..d19a2f2 --- /dev/null +++ b/zend/tests/Zend/Gdata/Docs/_files/TestDataDocumentListFeedSample.xml @@ -0,0 +1,38 @@ + + 2 + 1 + + + + test.user + test.user@gmail.com + + + http://docs.google.com/feeds/documents/private/full/spreadsheet%3Asupercalifragilisticexpeadocious + + + + Test Spreadsheet + 2007-07-03T18:03:32.045Z + + + + + test.user + test.user@gmail.com + + + http://docs.google.com/feeds/documents/private/full/document%3Agr00vy + + + Test Document + 2007-07-03T18:02:50.338Z + + http://docs.google.com/feeds/documents/private/full + + + + + Available Documents - test.user@gmail.com + 2007-07-09T23:07:21.898Z + diff --git a/zend/tests/Zend/Gdata/DocsOnlineTest.php b/zend/tests/Zend/Gdata/DocsOnlineTest.php new file mode 100755 index 0000000..f573f19 --- /dev/null +++ b/zend/tests/Zend/Gdata/DocsOnlineTest.php @@ -0,0 +1,129 @@ +docTitle = constant('TESTS_ZEND_GDATA_DOCS_DOCUMENTTITLE'); + $service = Zend_Gdata_Docs::AUTH_SERVICE_NAME; + $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service); + $this->gdata = new Zend_Gdata_Docs($client); + } + + public function testGetSpreadsheetFeed() + { + $feed = $this->gdata->getDocumentListFeed(); + $this->assertTrue($feed instanceof Zend_Gdata_Docs_DocumentListFeed); + foreach ($feed->entries as $entry) { + $this->assertTrue($entry instanceof Zend_Gdata_Docs_DocumentListEntry); + $this->assertTrue($entry->getHttpClient() == $feed->getHttpClient()); + } + + $query = new Zend_Gdata_Docs_Query(); + $feed = $this->gdata->getDocumentListFeed($query); + $this->assertTrue($feed instanceof Zend_Gdata_Docs_DocumentListFeed); + foreach ($feed->entries as $entry) { + $this->assertTrue($entry instanceof Zend_Gdata_Docs_DocumentListEntry); + $this->assertTrue($entry->getHttpClient() == $feed->getHttpClient()); + } + + $uri = $query->getQueryUrl(); + $feed = $this->gdata->getDocumentListFeed($uri); + $this->assertTrue($feed instanceof Zend_Gdata_Docs_DocumentListFeed); + foreach ($feed->entries as $entry) { + $this->assertTrue($entry instanceof Zend_Gdata_Docs_DocumentListEntry); + $this->assertTrue($entry->getHttpClient() == $feed->getHttpClient()); + } + } + + public function testQueryForTitle() + { + $query = new Zend_Gdata_Docs_Query(); + $query->title = $this->docTitle; + $feed = $this->gdata->getDocumentListFeed($query); + $this->assertTrue(strpos(strtolower($feed->entries[0]->title), strtolower($this->docTitle)) !== FALSE); + } + + public function testGetDocumentListEntry() + { + $query = new Zend_Gdata_Docs_Query(); + $feed = $this->gdata->getDocumentListFeed($query); + $selfLinkHref = $feed->entries[0]->getSelfLink()->href; + $entry = $this->gdata->getDocumentListEntry($selfLinkHref); + $this->assertTrue($entry instanceof Zend_Gdata_Docs_DocumentListEntry); + } + + public function testUploadFindAndDelete() + { + $documentTitle = 'spreadsheet_upload_test.csv'; + $newDocumentEntry = $this->gdata->uploadFile( + 'Zend/Gdata/_files/DocsTest.csv', $documentTitle, + $this->gdata->lookupMimeType('CSV'), + Zend_Gdata_Docs::DOCUMENTS_LIST_FEED_URI); + $this->assertTrue($newDocumentEntry->title->text === $documentTitle); + + // Get the newly created document. + // First extract the document's ID key from the Atom id. + $idParts = explode('/', $newDocumentEntry->id->text); + $keyParts = explode('%3A', end($idParts)); + $documentFromGetDoc = $this->gdata->getDoc($keyParts[1], $keyParts[0]); + $this->assertTrue($documentFromGetDoc->title->text === $documentTitle); + if ($keyParts[0] == 'document') { + $documentFromGetDocument = $this->gdata->getDocument($keyParts[1]); + $this->assertTrue( + $documentFromGetDocument->title->text === $documentTitle); + } + if ($keyParts[0] == 'spreadsheet') { + $documentFromGetSpreadsheet = $this->gdata->getSpreadsheet( + $keyParts[1]); + $this->assertTrue( + $documentFromGetSpreadsheet->title->text === $documentTitle); + } + if ($keyParts[0] == 'presentation') { + $documentFromGetPresentation = $this->gdata->getPresentation( + $keyParts[1]); + $this->assertTrue( + $documentFromGetPresentation->title->text === $documentTitle); + } + + // Cleanup and remove the new document. + $newDocumentEntry->delete(); + } + +} diff --git a/zend/tests/Zend/Gdata/DocsTest.php b/zend/tests/Zend/Gdata/DocsTest.php new file mode 100755 index 0000000..682a8d1 --- /dev/null +++ b/zend/tests/Zend/Gdata/DocsTest.php @@ -0,0 +1,95 @@ +adapter = new Test_Zend_Gdata_MockHttpClient(); + $this->client = new Zend_Gdata_HttpClient(); + $this->client->setAdapter($this->adapter); + $this->gdata = new Zend_Gdata_Docs($this->client); + } + + public function testCreateFolder() + { + $this->adapter->setResponse(array('HTTP/1.1 200 OK\r\n\r\n')); + $this->gdata->createFolder("Test Folder"); + $request = $this->adapter->popRequest(); + + // Check to make sure the correct URI is in use + $this->assertEquals( + "docs.google.com", + $request->uri->getHost()); + $this->assertEquals( + "/feeds/documents/private/full", + $request->uri->getPath()); + + // Check to make sure that this is a folder + $this->assertNotEquals( false, strpos($request->body, + "assertNotEquals(false, strpos($request->body, + "Test Folder")); + } + + public function testCreateSubfolder() + { + $subfolderName = "MySubfolder"; + $this->adapter->setResponse(array('HTTP/1.1 200 OK\r\n\r\n')); + $this->gdata->createFolder("Test Folder", $subfolderName); + $request = $this->adapter->popRequest(); + + // Check to make sure the correct URI is in use + $this->assertEquals( + "docs.google.com", + $request->uri->getHost()); + $this->assertEquals( + "/feeds/folders/private/full/" . $subfolderName, + $request->uri->getPath()); + + // Check to make sure that this is a folder + $this->assertNotEquals( false, strpos($request->body, + "assertNotEquals(false, strpos($request->body, + "Test Folder")); + } + + +} diff --git a/zend/tests/Zend/Gdata/EntryLinkTest.php b/zend/tests/Zend/Gdata/EntryLinkTest.php new file mode 100644 index 0000000..8f4b651 --- /dev/null +++ b/zend/tests/Zend/Gdata/EntryLinkTest.php @@ -0,0 +1,141 @@ +entryLinkText = file_get_contents( + 'Zend/Gdata/_files/EntryLinkElementSample1.xml', + true); + $this->entryLink = new Zend_Gdata_Extension_EntryLink(); + } + + public function testEmptyEntryLinkShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->entryLink->extensionElements)); + $this->assertTrue(count($this->entryLink->extensionElements) == 0); + } + + public function testEmptyEntryLinkShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->entryLink->extensionAttributes)); + $this->assertTrue(count($this->entryLink->extensionAttributes) == 0); + } + + public function testSampleEntryLinkShouldHaveNoExtensionElements() { + $this->entryLink->transferFromXML($this->entryLinkText); + $this->assertTrue(is_array($this->entryLink->extensionElements)); + $this->assertTrue(count($this->entryLink->extensionElements) == 0); + } + + public function testSampleEntryLinkShouldHaveNoExtensionAttributes() { + $this->entryLink->transferFromXML($this->entryLinkText); + $this->assertTrue(is_array($this->entryLink->extensionAttributes)); + $this->assertTrue(count($this->entryLink->extensionAttributes) == 0); + } + + public function testNormalEntryLinkShouldHaveNoExtensionElements() { + $this->entryLink->href = "http://gmail.com/jo/contacts/Bob"; + $this->entryLink->rel = "self"; + $this->entryLink->readOnly = "false"; + + $this->assertEquals("http://gmail.com/jo/contacts/Bob", $this->entryLink->href); + $this->assertEquals("self", $this->entryLink->rel); + $this->assertEquals("false", $this->entryLink->readOnly); + + $this->assertEquals(0, count($this->entryLink->extensionElements)); + $newEntryLink = new Zend_Gdata_Extension_EntryLink(); + $newEntryLink->transferFromXML($this->entryLink->saveXML()); + $this->assertEquals(0, count($newEntryLink->extensionElements)); + $newEntryLink->extensionElements = array( + new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); + $this->assertEquals(1, count($newEntryLink->extensionElements)); + $this->assertEquals("http://gmail.com/jo/contacts/Bob", $newEntryLink->href); + $this->assertEquals("self", $newEntryLink->rel); + $this->assertEquals("false", $newEntryLink->readOnly); + + /* try constructing using magic factory */ + $gdata = new Zend_Gdata(); + $newEntryLink2 = $gdata->newEntryLink(); + $newEntryLink2->transferFromXML($newEntryLink->saveXML()); + $this->assertEquals(1, count($newEntryLink2->extensionElements)); + $this->assertEquals("http://gmail.com/jo/contacts/Bob", $newEntryLink2->href); + $this->assertEquals("self", $newEntryLink2->rel); + $this->assertEquals("false", $newEntryLink2->readOnly); + } + + public function testEmptyEntryLinkToAndFromStringShouldMatch() { + $entryLinkXml = $this->entryLink->saveXML(); + $newEntryLink = new Zend_Gdata_Extension_EntryLink(); + $newEntryLink->transferFromXML($entryLinkXml); + $newEntryLinkXml = $newEntryLink->saveXML(); + $this->assertTrue($entryLinkXml == $newEntryLinkXml); + } + + public function testEntryLinkWithValueToAndFromStringShouldMatch() { + $this->entryLink->href = "http://gmail.com/jo/contacts/Bob"; + $this->entryLink->rel = "self"; + $this->entryLink->readOnly = "false"; + $entryLinkXml = $this->entryLink->saveXML(); + $newEntryLink = new Zend_Gdata_Extension_EntryLink(); + $newEntryLink->transferFromXML($entryLinkXml); + $newEntryLinkXml = $newEntryLink->saveXML(); + $this->assertTrue($entryLinkXml == $newEntryLinkXml); + $this->assertEquals("http://gmail.com/jo/contacts/Bob", $this->entryLink->href); + $this->assertEquals("self", $this->entryLink->rel); + $this->assertEquals("false", $this->entryLink->readOnly); + } + + public function testExtensionAttributes() { + $extensionAttributes = $this->entryLink->extensionAttributes; + $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); + $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); + $this->entryLink->extensionAttributes = $extensionAttributes; + $this->assertEquals('bar', $this->entryLink->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $this->entryLink->extensionAttributes['foo2']['value']); + $entryLinkXml = $this->entryLink->saveXML(); + $newEntryLink = new Zend_Gdata_Extension_EntryLink(); + $newEntryLink->transferFromXML($entryLinkXml); + $this->assertEquals('bar', $newEntryLink->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $newEntryLink->extensionAttributes['foo2']['value']); + } + + public function testConvertFullEntryLinkToAndFromString() { + $this->entryLink->transferFromXML($this->entryLinkText); + $this->assertEquals("http://gmail.com/jo/contacts/Jo", $this->entryLink->href); + $this->assertEquals("via", $this->entryLink->rel); + $this->assertEquals("true", $this->entryLink->readOnly); + $this->assertTrue($this->entryLink->entry instanceof Zend_Gdata_App_Entry); + $this->assertEquals("Jo March", $this->entryLink->entry->title->text); + } + +} diff --git a/zend/tests/Zend/Gdata/EntryTest.php b/zend/tests/Zend/Gdata/EntryTest.php new file mode 100644 index 0000000..9810feb --- /dev/null +++ b/zend/tests/Zend/Gdata/EntryTest.php @@ -0,0 +1,126 @@ +entry = new Zend_Gdata_Entry(); + $this->entryText = file_get_contents( + 'Zend/Gdata/_files/EntrySample1.xml', + true); + $this->etagLocalName = 'etag'; + $this->expectedEtag = 'W/"CkcHQH8_fCp7ImA9WxRTGEw."'; + $this->expectedMismatchExceptionMessage = "ETag mismatch"; + $this->gdNamespace = 'http://schemas.google.com/g/2005'; + $this->openSearchNamespacev1 = 'http://a9.com/-/spec/opensearchrss/1.0/'; + $this->openSearchNamespacev2 = 'http://a9.com/-/spec/opensearch/1.1/'; + + } + + public function testXMLHasNoEtagsWhenUsingV1() { + $etagData = 'Quux'; + $this->entry->setEtag($etagData); + $domNode = $this->entry->getDOM(null, 1, null); + $this->assertNull($domNode->attributes->getNamedItemNS($this->gdNamespace, $this->etagLocalName)); + } + + public function testXMLHasNoEtagsWhenUsingV1X() { + $etagData = 'Quux'; + $this->entry->setEtag($etagData); + $domNode = $this->entry->getDOM(null, 1, 1); + $this->assertNull($domNode->attributes->getNamedItemNS($this->gdNamespace, $this->etagLocalName)); + } + + public function testXMLHasEtagsWhenUsingV2() { + $etagData = 'Quux'; + $this->entry->setEtag($etagData); + $domNode = $this->entry->getDOM(null, 2, null); + $this->assertEquals($etagData, $domNode->attributes->getNamedItemNS($this->gdNamespace, $this->etagLocalName)->nodeValue); + } + + public function testXMLHasEtagsWhenUsingV2X() { + $etagData = 'Quux'; + $this->entry->setEtag($etagData); + $domNode = $this->entry->getDOM(null, 2, 1); + $this->assertEquals($etagData, $domNode->attributes->getNamedItemNS($this->gdNamespace, $this->etagLocalName)->nodeValue); + } + + public function testXMLETagsPropagateToEntry() { + $this->entry->transferFromXML($this->entryText); + $this->assertEquals($this->expectedEtag, $this->entry->getEtag()); + } + + public function testXMLandHTMLEtagsDifferingThrowsException() { + $exceptionCaught = false; + $this->entry->setEtag("Foo"); + try { + $this->entry->transferFromXML($this->entryText); + } catch (Zend_Gdata_App_IOException $e) { + $exceptionCaught = true; + } + $this->assertTrue($exceptionCaught, "Exception Zend_Gdata_IO_Exception expected"); + } + + public function testHttpAndXmlEtagsDifferingThrowsExceptionWithMessage() { + $messageCorrect = false; + $this->entry->setEtag("Foo"); + try { + $this->entry->transferFromXML($this->entryText); + } catch (Zend_Gdata_App_IOException $e) { + if ($e->getMessage() == $this->expectedMismatchExceptionMessage) + $messageCorrect = true; + } + $this->assertTrue($messageCorrect, "Exception Zend_Gdata_IO_Exception message incorrect"); + } + + public function testNothingBadHappensWhenHttpAndXmlEtagsMatch() { + $this->entry->setEtag($this->expectedEtag); + $this->entry->transferFromXML($this->entryText); + $this->assertEquals($this->expectedEtag, $this->entry->getEtag()); + } + + public function testLookUpOpenSearchv1Namespace() { + $this->assertEquals($this->openSearchNamespacev1, + $this->entry->lookupNamespace('openSearch', 1, 0)); + $this->assertEquals($this->openSearchNamespacev1, + $this->entry->lookupNamespace('openSearch', 1, null)); + } + + public function testLookupOpenSearchv2Namespace() { + $this->assertEquals($this->openSearchNamespacev2, + $this->entry->lookupNamespace('openSearch', 2, 0)); + $this->assertEquals($this->openSearchNamespacev2, + $this->entry->lookupNamespace('openSearch', 2, null)); + } + +} diff --git a/zend/tests/Zend/Gdata/EventStatusTest.php b/zend/tests/Zend/Gdata/EventStatusTest.php new file mode 100644 index 0000000..6e8243f --- /dev/null +++ b/zend/tests/Zend/Gdata/EventStatusTest.php @@ -0,0 +1,125 @@ +eventStatusText = file_get_contents( + 'Zend/Gdata/_files/EventStatusElementSample1.xml', + true); + $this->eventStatus = new Zend_Gdata_Extension_EventStatus(); + } + + public function testEmptyEventStatusShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->eventStatus->extensionElements)); + $this->assertTrue(count($this->eventStatus->extensionElements) == 0); + } + + public function testEmptyEventStatusShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->eventStatus->extensionAttributes)); + $this->assertTrue(count($this->eventStatus->extensionAttributes) == 0); + } + + public function testSampleEventStatusShouldHaveNoExtensionElements() { + $this->eventStatus->transferFromXML($this->eventStatusText); + $this->assertTrue(is_array($this->eventStatus->extensionElements)); + $this->assertTrue(count($this->eventStatus->extensionElements) == 0); + } + + public function testSampleEventStatusShouldHaveNoExtensionAttributes() { + $this->eventStatus->transferFromXML($this->eventStatusText); + $this->assertTrue(is_array($this->eventStatus->extensionAttributes)); + $this->assertTrue(count($this->eventStatus->extensionAttributes) == 0); + } + + public function testNormalEventStatusShouldHaveNoExtensionElements() { + $this->eventStatus->value = "http://schemas.google.com/g/2005#event.tentative"; + + $this->assertEquals("http://schemas.google.com/g/2005#event.tentative", $this->eventStatus->value); + + $this->assertEquals(0, count($this->eventStatus->extensionElements)); + $newEventStatus = new Zend_Gdata_Extension_EventStatus(); + $newEventStatus->transferFromXML($this->eventStatus->saveXML()); + $this->assertEquals(0, count($newEventStatus->extensionElements)); + $newEventStatus->extensionElements = array( + new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); + $this->assertEquals(1, count($newEventStatus->extensionElements)); + $this->assertEquals("http://schemas.google.com/g/2005#event.tentative", $newEventStatus->value); + + /* try constructing using magic factory */ + $gdata = new Zend_Gdata(); + $newEventStatus2 = $gdata->newEventStatus(); + $newEventStatus2->transferFromXML($newEventStatus->saveXML()); + $this->assertEquals(1, count($newEventStatus2->extensionElements)); + $this->assertEquals("http://schemas.google.com/g/2005#event.tentative", $newEventStatus2->value); + } + + public function testEmptyEventStatusToAndFromStringShouldMatch() { + $eventStatusXml = $this->eventStatus->saveXML(); + $newEventStatus = new Zend_Gdata_Extension_EventStatus(); + $newEventStatus->transferFromXML($eventStatusXml); + $newEventStatusXml = $newEventStatus->saveXML(); + $this->assertTrue($eventStatusXml == $newEventStatusXml); + } + + public function testEventStatusWithValueToAndFromStringShouldMatch() { + $this->eventStatus->value = "http://schemas.google.com/g/2005#event.tentative"; + $eventStatusXml = $this->eventStatus->saveXML(); + $newEventStatus = new Zend_Gdata_Extension_EventStatus(); + $newEventStatus->transferFromXML($eventStatusXml); + $newEventStatusXml = $newEventStatus->saveXML(); + $this->assertTrue($eventStatusXml == $newEventStatusXml); + $this->assertEquals("http://schemas.google.com/g/2005#event.tentative", $this->eventStatus->value); + } + + public function testExtensionAttributes() { + $extensionAttributes = $this->eventStatus->extensionAttributes; + $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); + $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); + $this->eventStatus->extensionAttributes = $extensionAttributes; + $this->assertEquals('bar', $this->eventStatus->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $this->eventStatus->extensionAttributes['foo2']['value']); + $eventStatusXml = $this->eventStatus->saveXML(); + $newEventStatus = new Zend_Gdata_Extension_EventStatus(); + $newEventStatus->transferFromXML($eventStatusXml); + $this->assertEquals('bar', $newEventStatus->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $newEventStatus->extensionAttributes['foo2']['value']); + } + + public function testConvertFullEventStatusToAndFromString() { + $this->eventStatus->transferFromXML($this->eventStatusText); + $this->assertEquals("http://schemas.google.com/g/2005#event.confirmed", $this->eventStatus->value); + } + +} diff --git a/zend/tests/Zend/Gdata/ExtendedPropertyTest.php b/zend/tests/Zend/Gdata/ExtendedPropertyTest.php new file mode 100644 index 0000000..cd1f0e3 --- /dev/null +++ b/zend/tests/Zend/Gdata/ExtendedPropertyTest.php @@ -0,0 +1,132 @@ +extendedPropertyText = file_get_contents( + 'Zend/Gdata/_files/ExtendedPropertyElementSample1.xml', + true); + $this->extendedProperty = new Zend_Gdata_Extension_ExtendedProperty(); + } + + public function testEmptyExtendedPropertyShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->extendedProperty->extensionElements)); + $this->assertTrue(count($this->extendedProperty->extensionElements) == 0); + } + + public function testEmptyExtendedPropertyShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->extendedProperty->extensionAttributes)); + $this->assertTrue(count($this->extendedProperty->extensionAttributes) == 0); + } + + public function testSampleExtendedPropertyShouldHaveNoExtensionElements() { + $this->extendedProperty->transferFromXML($this->extendedPropertyText); + $this->assertTrue(is_array($this->extendedProperty->extensionElements)); + $this->assertTrue(count($this->extendedProperty->extensionElements) == 0); + } + + public function testSampleExtendedPropertyShouldHaveNoExtensionAttributes() { + $this->extendedProperty->transferFromXML($this->extendedPropertyText); + $this->assertTrue(is_array($this->extendedProperty->extensionAttributes)); + $this->assertTrue(count($this->extendedProperty->extensionAttributes) == 0); + } + + public function testNormalExtendedPropertyShouldHaveNoExtensionElements() { + $this->extendedProperty->name = "http://www.example.com/schemas/2007#mycal.foo"; + $this->extendedProperty->value = "5678"; + + $this->assertEquals("http://www.example.com/schemas/2007#mycal.foo", $this->extendedProperty->name); + $this->assertEquals("5678", $this->extendedProperty->value); + + $this->assertEquals(0, count($this->extendedProperty->extensionElements)); + $newExtendedProperty = new Zend_Gdata_Extension_ExtendedProperty(); + $newExtendedProperty->transferFromXML($this->extendedProperty->saveXML()); + $this->assertEquals(0, count($newExtendedProperty->extensionElements)); + $newExtendedProperty->extensionElements = array( + new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); + $this->assertEquals(1, count($newExtendedProperty->extensionElements)); + $this->assertEquals("http://www.example.com/schemas/2007#mycal.foo", $newExtendedProperty->name); + $this->assertEquals("5678", $newExtendedProperty->value); + + /* try constructing using magic factory */ + $gdata = new Zend_Gdata(); + $newExtendedProperty2 = $gdata->newExtendedProperty(); + $newExtendedProperty2->transferFromXML($newExtendedProperty->saveXML()); + $this->assertEquals(1, count($newExtendedProperty2->extensionElements)); + $this->assertEquals("http://www.example.com/schemas/2007#mycal.foo", $newExtendedProperty2->name); + $this->assertEquals("5678", $newExtendedProperty2->value); + } + + public function testEmptyExtendedPropertyToAndFromStringShouldMatch() { + $extendedPropertyXml = $this->extendedProperty->saveXML(); + $newExtendedProperty = new Zend_Gdata_Extension_ExtendedProperty(); + $newExtendedProperty->transferFromXML($extendedPropertyXml); + $newExtendedPropertyXml = $newExtendedProperty->saveXML(); + $this->assertTrue($extendedPropertyXml == $newExtendedPropertyXml); + } + + public function testExtendedPropertyWithValueToAndFromStringShouldMatch() { + $this->extendedProperty->name = "http://www.example.com/schemas/2007#mycal.foo"; + $this->extendedProperty->value = "5678"; + $extendedPropertyXml = $this->extendedProperty->saveXML(); + $newExtendedProperty = new Zend_Gdata_Extension_ExtendedProperty(); + $newExtendedProperty->transferFromXML($extendedPropertyXml); + $newExtendedPropertyXml = $newExtendedProperty->saveXML(); + $this->assertTrue($extendedPropertyXml == $newExtendedPropertyXml); + $this->assertEquals("http://www.example.com/schemas/2007#mycal.foo", $this->extendedProperty->name); + $this->assertEquals("5678", $this->extendedProperty->value); + } + + public function testExtensionAttributes() { + $extensionAttributes = $this->extendedProperty->extensionAttributes; + $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); + $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); + $this->extendedProperty->extensionAttributes = $extensionAttributes; + $this->assertEquals('bar', $this->extendedProperty->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $this->extendedProperty->extensionAttributes['foo2']['value']); + $extendedPropertyXml = $this->extendedProperty->saveXML(); + $newExtendedProperty = new Zend_Gdata_Extension_ExtendedProperty(); + $newExtendedProperty->transferFromXML($extendedPropertyXml); + $this->assertEquals('bar', $newExtendedProperty->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $newExtendedProperty->extensionAttributes['foo2']['value']); + } + + public function testConvertFullExtendedPropertyToAndFromString() { + $this->extendedProperty->transferFromXML($this->extendedPropertyText); + $this->assertEquals("http://www.example.com/schemas/2007#mycal.id", $this->extendedProperty->name); + $this->assertEquals("1234", $this->extendedProperty->value); + } + +} diff --git a/zend/tests/Zend/Gdata/FeedLinkTest.php b/zend/tests/Zend/Gdata/FeedLinkTest.php new file mode 100644 index 0000000..1aaa6a5 --- /dev/null +++ b/zend/tests/Zend/Gdata/FeedLinkTest.php @@ -0,0 +1,148 @@ +feedLinkText = file_get_contents( + 'Zend/Gdata/_files/FeedLinkElementSample1.xml', + true); + $this->feedLink = new Zend_Gdata_Extension_FeedLink(); + } + + public function testEmptyFeedLinkShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->feedLink->extensionElements)); + $this->assertTrue(count($this->feedLink->extensionElements) == 0); + } + + public function testEmptyFeedLinkShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->feedLink->extensionAttributes)); + $this->assertTrue(count($this->feedLink->extensionAttributes) == 0); + } + + public function testSampleFeedLinkShouldHaveNoExtensionElements() { + $this->feedLink->transferFromXML($this->feedLinkText); + $this->assertTrue(is_array($this->feedLink->extensionElements)); + $this->assertTrue(count($this->feedLink->extensionElements) == 0); + } + + public function testSampleFeedLinkShouldHaveNoExtensionAttributes() { + $this->feedLink->transferFromXML($this->feedLinkText); + $this->assertTrue(is_array($this->feedLink->extensionAttributes)); + $this->assertTrue(count($this->feedLink->extensionAttributes) == 0); + } + + public function testNormalFeedLinkShouldHaveNoExtensionElements() { + $this->feedLink->href = "http://www.google.com/calendar/feeds/default/private/full"; + $this->feedLink->rel = "via"; + $this->feedLink->countHint = "5"; + $this->feedLink->readOnly = "false"; + + $this->assertEquals("http://www.google.com/calendar/feeds/default/private/full", $this->feedLink->href); + $this->assertEquals("via", $this->feedLink->rel); + $this->assertEquals("5", $this->feedLink->countHint); + $this->assertEquals("false", $this->feedLink->readOnly); + + $this->assertEquals(0, count($this->feedLink->extensionElements)); + $newFeedLink = new Zend_Gdata_Extension_FeedLink(); + $newFeedLink->transferFromXML($this->feedLink->saveXML()); + $this->assertEquals(0, count($newFeedLink->extensionElements)); + $newFeedLink->extensionElements = array( + new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); + $this->assertEquals(1, count($newFeedLink->extensionElements)); + $this->assertEquals("http://www.google.com/calendar/feeds/default/private/full", $newFeedLink->href); + $this->assertEquals("via", $newFeedLink->rel); + $this->assertEquals("5", $newFeedLink->countHint); + $this->assertEquals("false", $newFeedLink->readOnly); + + /* try constructing using magic factory */ + $gdata = new Zend_Gdata(); + $newFeedLink2 = $gdata->newFeedLink(); + $newFeedLink2->transferFromXML($newFeedLink->saveXML()); + $this->assertEquals(1, count($newFeedLink2->extensionElements)); + $this->assertEquals("http://www.google.com/calendar/feeds/default/private/full", $newFeedLink2->href); + $this->assertEquals("via", $newFeedLink2->rel); + $this->assertEquals("5", $newFeedLink2->countHint); + $this->assertEquals("false", $newFeedLink2->readOnly); + } + + public function testEmptyFeedLinkToAndFromStringShouldMatch() { + $feedLinkXml = $this->feedLink->saveXML(); + $newFeedLink = new Zend_Gdata_Extension_FeedLink(); + $newFeedLink->transferFromXML($feedLinkXml); + $newFeedLinkXml = $newFeedLink->saveXML(); + $this->assertTrue($feedLinkXml == $newFeedLinkXml); + } + + public function testFeedLinkWithValueToAndFromStringShouldMatch() { + $this->feedLink->href = "http://www.google.com/calendar/feeds/default/private/full"; + $this->feedLink->rel = "via"; + $this->feedLink->countHint = "5"; + $this->feedLink->readOnly = "false"; + $feedLinkXml = $this->feedLink->saveXML(); + $newFeedLink = new Zend_Gdata_Extension_FeedLink(); + $newFeedLink->transferFromXML($feedLinkXml); + $newFeedLinkXml = $newFeedLink->saveXML(); + $this->assertTrue($feedLinkXml == $newFeedLinkXml); + $this->assertEquals("http://www.google.com/calendar/feeds/default/private/full", $this->feedLink->href); + $this->assertEquals("via", $this->feedLink->rel); + $this->assertEquals("5", $this->feedLink->countHint); + $this->assertEquals("false", $this->feedLink->readOnly); + } + + public function testExtensionAttributes() { + $extensionAttributes = $this->feedLink->extensionAttributes; + $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); + $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); + $this->feedLink->extensionAttributes = $extensionAttributes; + $this->assertEquals('bar', $this->feedLink->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $this->feedLink->extensionAttributes['foo2']['value']); + $feedLinkXml = $this->feedLink->saveXML(); + $newFeedLink = new Zend_Gdata_Extension_FeedLink(); + $newFeedLink->transferFromXML($feedLinkXml); + $this->assertEquals('bar', $newFeedLink->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $newFeedLink->extensionAttributes['foo2']['value']); + } + + public function testConvertFullFeedLinkToAndFromString() { + $this->feedLink->transferFromXML($this->feedLinkText); + $this->assertEquals("http://www.google.com/calendar/feeds/default/private/full/3tsi3ag1q40bnsik88k25sgpss/comments", $this->feedLink->href); + $this->assertEquals("http://schemas.google.com/g/2005#feed", $this->feedLink->rel); + $this->assertEquals("0", $this->feedLink->countHint); + $this->assertEquals("true", $this->feedLink->readOnly); + $this->assertTrue($this->feedLink->feed instanceof Zend_Gdata_App_Feed); + $this->assertEquals("Comments for: Sample Event", $this->feedLink->feed->title->text); + } + +} diff --git a/zend/tests/Zend/Gdata/FeedTest.php b/zend/tests/Zend/Gdata/FeedTest.php new file mode 100644 index 0000000..c00bb0d --- /dev/null +++ b/zend/tests/Zend/Gdata/FeedTest.php @@ -0,0 +1,158 @@ +etagLocalName = 'etag'; + $this->expectedEtag = 'W/"CE4BRXw4cCp7ImA9WxRVFEs."'; + $this->expectedMismatchExceptionMessage = "ETag mismatch"; + $this->feed = new Zend_Gdata_Feed(); + $this->feedTextV1 = file_get_contents( + 'Zend/Gdata/_files/FeedSampleV1.xml', + true); + $this->feedTextV2 = file_get_contents( + 'Zend/Gdata/_files/FeedSampleV2.xml', + true); + $this->gdNamespace = 'http://schemas.google.com/g/2005'; + $this->openSearchNamespacev1 = 'http://a9.com/-/spec/opensearchrss/1.0/'; + $this->openSearchNamespacev2 = 'http://a9.com/-/spec/opensearch/1.1/'; + } + + public function testXMLHasNoEtagsWhenUsingV1() { + $etagData = 'Quux'; + $this->feed->setEtag($etagData); + $domNode = $this->feed->getDOM(null, 1, null); + $this->assertNull( + $domNode->attributes->getNamedItemNS( + $this->gdNamespace, $this->etagLocalName)); + } + + public function testXMLHasNoEtagsWhenUsingV1X() { + $etagData = 'Quux'; + $this->feed->setEtag($etagData); + $domNode = $this->feed->getDOM(null, 1, 1); + $this->assertNull( + $domNode->attributes->getNamedItemNS( + $this->gdNamespace, $this->etagLocalName)); + } + + public function testXMLHasEtagsWhenUsingV2() { + $etagData = 'Quux'; + $this->feed->setEtag($etagData); + $domNode = $this->feed->getDOM(null, 2, null); + $this->assertEquals( + $etagData, + $domNode->attributes->getNamedItemNS( + $this->gdNamespace, $this->etagLocalName)->nodeValue); + } + + public function testXMLHasEtagsWhenUsingV2X() { + $etagData = 'Quux'; + $this->feed->setEtag($etagData); + $domNode = $this->feed->getDOM(null, 2, 1); + $this->assertEquals( + $etagData, + $domNode->attributes->getNamedItemNS( + $this->gdNamespace, $this->etagLocalName)->nodeValue); + } + + public function testXMLETagsPropagateToFeed() { + $this->feed->transferFromXML($this->feedTextV2); + $etagValue = $this->feed->getEtag(); + $this->assertEquals($this->expectedEtag, $this->feed->getEtag()); + } + + public function testXMLandHTMLEtagsDifferingThrowsException() { + $exceptionCaught = false; + $this->feed->setEtag("Foo"); + try { + $this->feed->transferFromXML($this->feedTextV2); + } catch (Zend_Gdata_App_IOException $e) { + $exceptionCaught = true; + } + $this->assertTrue($exceptionCaught, "Exception Zend_Gdata_IO_Exception expected"); + } + + public function testHttpAndXmlEtagsDifferingThrowsExceptionWithMessage() { + $messageCorrect = false; + $this->feed->setEtag("Foo"); + try { + $this->feed->transferFromXML($this->feedTextV2); + } catch (Zend_Gdata_App_IOException $e) { + if ($e->getMessage() == $this->expectedMismatchExceptionMessage) + $messageCorrect = true; + } + $this->assertTrue($messageCorrect, "Exception Zend_Gdata_IO_Exception message incorrect"); + } + + public function testNothingBadHappensWhenHttpAndXmlEtagsMatch() { + $this->feed->setEtag($this->expectedEtag); + $this->feed->transferFromXML($this->feedTextV2); + $this->assertEquals($this->expectedEtag, $this->feed->getEtag()); + } + + public function testLookUpOpenSearchv1Namespace() { + $this->feed->setMajorProtocolVersion(1); + $this->feed->setMinorProtocolVersion(0); + $this->assertEquals($this->openSearchNamespacev1, + $this->feed->lookupNamespace('openSearch', 1)); + $this->feed->setMinorProtocolVersion(null); + $this->assertEquals($this->openSearchNamespacev1, + $this->feed->lookupNamespace('openSearch', 1)); + } + + public function testLookupOpenSearchv2Namespace() { + $this->feed->setMajorProtocolVersion(2); + $this->feed->setMinorProtocolVersion(0); + $this->assertEquals($this->openSearchNamespacev2, + $this->feed->lookupNamespace('openSearch')); + $this->feed->setMinorProtocolVersion(null); + $this->assertEquals($this->openSearchNamespacev2, + $this->feed->lookupNamespace('openSearch')); + } + + public function testNoExtensionElementsInV1Feed() { + $this->feed->setMajorProtocolVersion(1); + $this->feed->transferFromXML($this->feedTextV1); + $this->assertEquals(0, sizeof($this->feed->extensionElements)); + } + + public function testNoExtensionElementsInV2Feed() { + $this->feed->setMajorProtocolVersion(2); + $this->feed->transferFromXML($this->feedTextV2); + $this->assertEquals(0, sizeof($this->feed->extensionElements)); + } +} diff --git a/zend/tests/Zend/Gdata/Gapps/EmailListEntryTest.php b/zend/tests/Zend/Gdata/Gapps/EmailListEntryTest.php new file mode 100644 index 0000000..f410e83 --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/EmailListEntryTest.php @@ -0,0 +1,140 @@ +entryText = file_get_contents( + 'Zend/Gdata/Gapps/_files/EmailListEntryDataSample1.xml', + true); + $this->entry = new Zend_Gdata_Gapps_EmailListEntry(); + } + + private function verifyAllSamplePropertiesAreCorrect ($emailListEntry) { + $this->assertEquals('https://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-sales', + $emailListEntry->id->text); + $this->assertEquals('1970-01-01T00:00:00.000Z', $emailListEntry->updated->text); + $this->assertEquals('http://schemas.google.com/g/2005#kind', $emailListEntry->category[0]->scheme); + $this->assertEquals('http://schemas.google.com/apps/2006#emailList', $emailListEntry->category[0]->term); + $this->assertEquals('text', $emailListEntry->title->type); + $this->assertEquals('us-sales', $emailListEntry->title->text);; + $this->assertEquals('self', $emailListEntry->getLink('self')->rel); + $this->assertEquals('application/atom+xml', $emailListEntry->getLink('self')->type); + $this->assertEquals('https://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-sales', $emailListEntry->getLink('self')->href); + $this->assertEquals('edit', $emailListEntry->getLink('edit')->rel); + $this->assertEquals('application/atom+xml', $emailListEntry->getLink('edit')->type); + $this->assertEquals('https://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-sales', $emailListEntry->getLink('edit')->href); + $this->assertEquals('us-sales', $emailListEntry->emailList->name); + $this->assertEquals('http://schemas.google.com/apps/2006#emailList.recipients', $emailListEntry->getFeedLink('http://schemas.google.com/apps/2006#emailList.recipients')->rel); + $this->assertEquals('http://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient/', $emailListEntry->getFeedLink('http://schemas.google.com/apps/2006#emailList.recipients')->href); + } + + public function testEmptyEntryShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->entry->extensionElements)); + $this->assertTrue(count($this->entry->extensionElements) == 0); + } + + public function testEmptyEntryShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->entry->extensionAttributes)); + $this->assertTrue(count($this->entry->extensionAttributes) == 0); + } + + public function testSampleEntryShouldHaveNoExtensionElements() { + $this->entry->transferFromXML($this->entryText); + $this->assertTrue(is_array($this->entry->extensionElements)); + $this->assertTrue(count($this->entry->extensionElements) == 0); + } + + public function testSampleEntryShouldHaveNoExtensionAttributes() { + $this->entry->transferFromXML($this->entryText); + $this->assertTrue(is_array($this->entry->extensionAttributes)); + $this->assertTrue(count($this->entry->extensionAttributes) == 0); + } + + public function testEmptyEmailListEntryToAndFromStringShouldMatch() { + $entryXml = $this->entry->saveXML(); + $newEmailListEntry = new Zend_Gdata_Gapps_EmailListEntry(); + $newEmailListEntry->transferFromXML($entryXml); + $newEmailListEntryXml = $newEmailListEntry->saveXML(); + $this->assertTrue($entryXml == $newEmailListEntryXml); + } + + public function testGetFeedLinkReturnsAllStoredEntriesWhenUsedWithNoParameters() { + // Prepare test data + $entry1 = new Zend_Gdata_Extension_FeedLink(); + $entry1->rel = "first"; + $entry1->href= "foo"; + $entry2 = new Zend_Gdata_Extension_FeedLink(); + $entry2->rel = "second"; + $entry2->href= "bar"; + $data = array($entry1, $entry2); + + // Load test data and run test + $this->entry->feedLink = $data; + $this->assertEquals(2, count($this->entry->feedLink)); + } + + public function testGetFeedLinkCanReturnEntriesByRelValue() { + // Prepare test data + $entry1 = new Zend_Gdata_Extension_FeedLink(); + $entry1->rel = "first"; + $entry1->href= "foo"; + $entry2 = new Zend_Gdata_Extension_FeedLink(); + $entry2->rel = "second"; + $entry2->href= "bar"; + $data = array($entry1, $entry2); + + // Load test data and run test + $this->entry->feedLink = $data; + $this->assertEquals($entry1, $this->entry->getFeedLink('first')); + $this->assertEquals($entry2, $this->entry->getFeedLink('second')); + } + + public function testSamplePropertiesAreCorrect () { + $this->entry->transferFromXML($this->entryText); + $this->verifyAllSamplePropertiesAreCorrect($this->entry); + } + + public function testConvertEmailListEntryToAndFromString() { + $this->entry->transferFromXML($this->entryText); + $entryXml = $this->entry->saveXML(); + $newEmailListEntry = new Zend_Gdata_Gapps_EmailListEntry(); + $newEmailListEntry->transferFromXML($entryXml); + $this->verifyAllSamplePropertiesAreCorrect($newEmailListEntry); + $newEmailListEntryXml = $newEmailListEntry->saveXML(); + $this->assertEquals($entryXml, $newEmailListEntryXml); + } + +} diff --git a/zend/tests/Zend/Gdata/Gapps/EmailListFeedTest.php b/zend/tests/Zend/Gdata/Gapps/EmailListFeedTest.php new file mode 100644 index 0000000..bcacfe8 --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/EmailListFeedTest.php @@ -0,0 +1,109 @@ +emailListFeed = new Zend_Gdata_Gapps_EmailListFeed($emailListFeedText); + $this->emptyEmailListFeed = new Zend_Gdata_Gapps_EmailListFeed(); + } + + public function testEmptyFeedShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->emptyEmailListFeed->extensionElements)); + $this->assertTrue(count($this->emptyEmailListFeed->extensionElements) == 0); + } + + public function testEmptyFeedShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->emptyEmailListFeed->extensionAttributes)); + $this->assertTrue(count($this->emptyEmailListFeed->extensionAttributes) == 0); + } + + public function testSampleFeedShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->emailListFeed->extensionElements)); + $this->assertTrue(count($this->emailListFeed->extensionElements) == 0); + } + + public function testSampleFeedShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->emailListFeed->extensionAttributes)); + $this->assertTrue(count($this->emailListFeed->extensionAttributes) == 0); + } + + /** + * Convert sample feed to XML then back to objects. Ensure that + * all objects are instances of EventEntry and object count matches. + */ + public function testXmlImportAndOutputAreNonDestructive() + { + $entryCount = 0; + foreach ($this->emailListFeed as $entry) { + $entryCount++; + $this->assertTrue($entry instanceof Zend_Gdata_Gapps_EmailListEntry); + } + $this->assertTrue($entryCount > 0); + + /* Grab XML from $this->emailListFeed and convert back to objects */ + $newEmailListFeed = new Zend_Gdata_Gapps_EmailListFeed( + $this->emailListFeed->saveXML()); + $newEntryCount = 0; + foreach ($newEmailListFeed as $entry) { + $newEntryCount++; + $this->assertTrue($entry instanceof Zend_Gdata_Gapps_EmailListEntry); + } + $this->assertEquals($entryCount, $newEntryCount); + } + + /** + * Ensure that there number of lsit feeds equals the number + * of calendars defined in the sample file. + */ + public function testAllEntriesInFeedAreInstantiated() + { + //TODO feeds implementing ArrayAccess would be helpful here + $entryCount = 0; + foreach ($this->emailListFeed as $entry) { + $entryCount++; + } + $this->assertEquals(2, $entryCount); + } + +} diff --git a/zend/tests/Zend/Gdata/Gapps/EmailListQueryTest.php b/zend/tests/Zend/Gdata/Gapps/EmailListQueryTest.php new file mode 100644 index 0000000..a4337c1 --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/EmailListQueryTest.php @@ -0,0 +1,138 @@ +query = new Zend_Gdata_Gapps_EmailListQuery(); + } + + // Test to make sure that URI generation works + public function testDefaultQueryURIGeneration() + { + $this->query->setDomain("foo.bar.invalid"); + $this->assertEquals("https://apps-apis.google.com/a/feeds/foo.bar.invalid/emailList/2.0", + $this->query->getQueryUrl()); + } + + // Test to make sure that the domain accessor methods work and propagate + // to the query URI. + public function testCanSetQueryDomain() + { + $this->query->setDomain("my.domain.com"); + $this->assertEquals("my.domain.com", $this->query->getDomain()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/emailList/2.0", + $this->query->getQueryUrl()); + + $this->query->setDomain("hello.world.baz"); + $this->assertEquals("hello.world.baz", $this->query->getDomain()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/hello.world.baz/emailList/2.0", + $this->query->getQueryUrl()); + } + + // Test to make sure that the emailListName accessor methods work and propagate + // to the query URI. + public function testCanSetEmailListNameProperty() + { + $this->query->setDomain("my.domain.com"); + $this->query->setEmailListName("foo"); + $this->assertEquals("foo", $this->query->getEmailListName()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/emailList/2.0/foo", + $this->query->getQueryUrl()); + + $this->query->setEmailListName("bar"); + $this->assertEquals("bar", $this->query->getEmailListName()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/emailList/2.0/bar", + $this->query->getQueryUrl()); + } + + // Test to make sure that the recipient accessor methods work and propagate + // to the query URI. + public function testCanSetRecipientProperty() + { + $this->query->setDomain("my.domain.com"); + $this->query->setRecipient("bar@qux.com"); + $this->assertEquals("bar@qux.com", $this->query->getRecipient()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/emailList/2.0?recipient=bar%40qux.com", + $this->query->getQueryUrl()); + + $this->query->setRecipient(null); + $this->assertEquals(null, $this->query->getRecipient()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/emailList/2.0", + $this->query->getQueryUrl()); + } + + // Test to make sure that the startUsername accessor methods work and + // propagate to the query URI. + public function testCanSetStartEmailListNameProperty() + { + $this->query->setDomain("my.domain.com"); + $this->query->setStartEmailListName("foo"); + $this->assertEquals("foo", $this->query->getStartEmailListName()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/emailList/2.0?startEmailListName=foo", + $this->query->getQueryUrl()); + + $this->query->setStartEmailListName(null); + $this->assertEquals(null, $this->query->getStartEmailListName()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/emailList/2.0", + $this->query->getQueryUrl()); + } + + // Test to make sure that all parameters can be set simultaneously with no + // ill effects. + public function testCanSetAllParameters() + { + $this->query->setDomain("my.domain.com"); + $this->query->setEmailListName("foo"); + $this->query->setRecipient("bar@qux.com"); + $this->query->setStartEmailListName("wibble"); + $this->assertEquals("foo", $this->query->getEmailListName()); + $this->assertEquals("bar@qux.com", $this->query->getRecipient()); + $this->assertEquals("wibble", $this->query->getStartEmailListName()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/emailList/2.0/foo?recipient=bar%40qux.com&startEmailListName=wibble", + $this->query->getQueryUrl()); + + $this->query->setRecipient("baz@blah.com"); + $this->query->setEmailListName("xyzzy"); + $this->query->setStartEmailListName("woof"); + $this->assertEquals("xyzzy", $this->query->getEmailListName()); + $this->assertEquals("baz@blah.com", $this->query->getRecipient()); + $this->assertEquals("woof", $this->query->getStartEmailListName()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/emailList/2.0/xyzzy?recipient=baz%40blah.com&startEmailListName=woof", + $this->query->getQueryUrl()); + } + +} diff --git a/zend/tests/Zend/Gdata/Gapps/EmailListRecipientEntryTest.php b/zend/tests/Zend/Gdata/Gapps/EmailListRecipientEntryTest.php new file mode 100644 index 0000000..c0cd784 --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/EmailListRecipientEntryTest.php @@ -0,0 +1,107 @@ +entryText = file_get_contents( + 'Zend/Gdata/Gapps/_files/EmailListRecipientEntryDataSample1.xml', + true); + $this->entry = new Zend_Gdata_Gapps_EmailListRecipientEntry(); + } + + private function verifyAllSamplePropertiesAreCorrect ($emailListRecipientEntry) { + $this->assertEquals('https://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient/SusanJones%40example.com', + $emailListRecipientEntry->id->text); + $this->assertEquals('1970-01-01T00:00:00.000Z', $emailListRecipientEntry->updated->text); + $this->assertEquals('http://schemas.google.com/g/2005#kind', $emailListRecipientEntry->category[0]->scheme); + $this->assertEquals('http://schemas.google.com/apps/2006#emailList.recipient', $emailListRecipientEntry->category[0]->term); + $this->assertEquals('text', $emailListRecipientEntry->title->type); + $this->assertEquals('SusanJones', $emailListRecipientEntry->title->text);; + $this->assertEquals('self', $emailListRecipientEntry->getLink('self')->rel); + $this->assertEquals('application/atom+xml', $emailListRecipientEntry->getLink('self')->type); + $this->assertEquals('https://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient/SusanJones%40example.com', $emailListRecipientEntry->getLink('self')->href); + $this->assertEquals('edit', $emailListRecipientEntry->getLink('edit')->rel); + $this->assertEquals('application/atom+xml', $emailListRecipientEntry->getLink('edit')->type); + $this->assertEquals('https://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient/SusanJones%40example.com', $emailListRecipientEntry->getLink('edit')->href); + $this->assertEquals('SusanJones@example.com', $emailListRecipientEntry->who->email); + } + + public function testEmptyEntryShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->entry->extensionElements)); + $this->assertTrue(count($this->entry->extensionElements) == 0); + } + + public function testEmptyEntryShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->entry->extensionAttributes)); + $this->assertTrue(count($this->entry->extensionAttributes) == 0); + } + + public function testSampleEntryShouldHaveNoExtensionElements() { + $this->entry->transferFromXML($this->entryText); + $this->assertTrue(is_array($this->entry->extensionElements)); + $this->assertTrue(count($this->entry->extensionElements) == 0); + } + + public function testSampleEntryShouldHaveNoExtensionAttributes() { + $this->entry->transferFromXML($this->entryText); + $this->assertTrue(is_array($this->entry->extensionAttributes)); + $this->assertTrue(count($this->entry->extensionAttributes) == 0); + } + + public function testEmptyEmailListRecipientEntryToAndFromStringShouldMatch() { + $entryXml = $this->entry->saveXML(); + $newEmailListRecipientEntry = new Zend_Gdata_Gapps_EmailListRecipientEntry(); + $newEmailListRecipientEntry->transferFromXML($entryXml); + $newEmailListRecipientEntryXml = $newEmailListRecipientEntry->saveXML(); + $this->assertTrue($entryXml == $newEmailListRecipientEntryXml); + } + + public function testSamplePropertiesAreCorrect () { + $this->entry->transferFromXML($this->entryText); + $this->verifyAllSamplePropertiesAreCorrect($this->entry); + } + + public function testConvertEmailListRecipientEntryToAndFromString() { + $this->entry->transferFromXML($this->entryText); + $entryXml = $this->entry->saveXML(); + $newEmailListRecipientEntry = new Zend_Gdata_Gapps_EmailListRecipientEntry(); + $newEmailListRecipientEntry->transferFromXML($entryXml); + $this->verifyAllSamplePropertiesAreCorrect($newEmailListRecipientEntry); + $newEmailListRecipientEntryXml = $newEmailListRecipientEntry->saveXML(); + $this->assertEquals($entryXml, $newEmailListRecipientEntryXml); + } + +} diff --git a/zend/tests/Zend/Gdata/Gapps/EmailListRecipientFeedTest.php b/zend/tests/Zend/Gdata/Gapps/EmailListRecipientFeedTest.php new file mode 100644 index 0000000..e60b267 --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/EmailListRecipientFeedTest.php @@ -0,0 +1,109 @@ +emailListRecipientFeed = new Zend_Gdata_Gapps_EmailListRecipientFeed($emailListRecipientFeedText); + $this->emptyEmailListRecipientFeed = new Zend_Gdata_Gapps_EmailListRecipientFeed(); + } + + public function testEmptyFeedShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->emptyEmailListRecipientFeed->extensionElements)); + $this->assertTrue(count($this->emptyEmailListRecipientFeed->extensionElements) == 0); + } + + public function testEmptyFeedShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->emptyEmailListRecipientFeed->extensionAttributes)); + $this->assertTrue(count($this->emptyEmailListRecipientFeed->extensionAttributes) == 0); + } + + public function testSampleFeedShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->emailListRecipientFeed->extensionElements)); + $this->assertTrue(count($this->emailListRecipientFeed->extensionElements) == 0); + } + + public function testSampleFeedShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->emailListRecipientFeed->extensionAttributes)); + $this->assertTrue(count($this->emailListRecipientFeed->extensionAttributes) == 0); + } + + /** + * Convert sample feed to XML then back to objects. Ensure that + * all objects are instances of EventEntry and object count matches. + */ + public function testXmlImportAndOutputAreNonDestructive() + { + $entryCount = 0; + foreach ($this->emailListRecipientFeed as $entry) { + $entryCount++; + $this->assertTrue($entry instanceof Zend_Gdata_Gapps_EmailListRecipientEntry); + } + $this->assertTrue($entryCount > 0); + + /* Grab XML from $this->emailListRecipientFeed and convert back to objects */ + $newEmailListRecipientFeed = new Zend_Gdata_Gapps_EmailListRecipientFeed( + $this->emailListRecipientFeed->saveXML()); + $newEntryCount = 0; + foreach ($newEmailListRecipientFeed as $entry) { + $newEntryCount++; + $this->assertTrue($entry instanceof Zend_Gdata_Gapps_EmailListRecipientEntry); + } + $this->assertEquals($entryCount, $newEntryCount); + } + + /** + * Ensure that there number of lsit feeds equals the number + * of calendars defined in the sample file. + */ + public function testAllEntriesInFeedAreInstantiated() + { + //TODO feeds implementing ArrayAccess would be helpful here + $entryCount = 0; + foreach ($this->emailListRecipientFeed as $entry) { + $entryCount++; + } + $this->assertEquals(2, $entryCount); + } + +} diff --git a/zend/tests/Zend/Gdata/Gapps/EmailListRecipientQueryTest.php b/zend/tests/Zend/Gdata/Gapps/EmailListRecipientQueryTest.php new file mode 100644 index 0000000..18d4e89 --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/EmailListRecipientQueryTest.php @@ -0,0 +1,90 @@ +query = new Zend_Gdata_Gapps_EmailListRecipientQuery(); + } + + // Test to make sure that the domain accessor methods work and propagate + // to the query URI. + public function testCanSetQueryDomain() + { + $this->query->setEmailListName("something"); + $this->query->setDomain("my.domain.com"); + $this->assertEquals("my.domain.com", $this->query->getDomain()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/emailList/2.0/something/recipient/", + $this->query->getQueryUrl()); + + $this->query->setDomain("hello.world.baz"); + $this->assertEquals("hello.world.baz", $this->query->getDomain()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/hello.world.baz/emailList/2.0/something/recipient/", + $this->query->getQueryUrl()); + } + + // Test to make sure that the emailListName accessor methods work and propagate + // to the query URI. + public function testCanSetEmailListNameProperty() + { + $this->query->setDomain("my.domain.com"); + $this->query->setEmailListName("foo"); + $this->assertEquals("foo", $this->query->getEmailListName()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/emailList/2.0/foo/recipient/", + $this->query->getQueryUrl()); + + $this->query->setEmailListName("bar"); + $this->assertEquals("bar", $this->query->getEmailListName()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/emailList/2.0/bar/recipient/", + $this->query->getQueryUrl()); + } + + public function testCanSetStartRecipientProperty() + { + $this->query->setDomain("my.domain.com"); + $this->query->setEmailListName("foo"); + $this->query->setStartRecipient("bar"); + $this->assertEquals("bar", $this->query->getStartRecipient()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/emailList/2.0/foo/recipient/?startRecipient=bar", + $this->query->getQueryUrl()); + + $this->query->setStartRecipient(null); + $this->assertEquals(null, $this->query->getStartRecipient()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/emailList/2.0/foo/recipient/", + $this->query->getQueryUrl()); + } + +} diff --git a/zend/tests/Zend/Gdata/Gapps/EmailListTest.php b/zend/tests/Zend/Gdata/Gapps/EmailListTest.php new file mode 100644 index 0000000..d404d82 --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/EmailListTest.php @@ -0,0 +1,126 @@ +emailListText = file_get_contents( + 'Zend/Gdata/Gapps/_files/EmailListElementSample1.xml', + true); + $this->emailList = new Zend_Gdata_Gapps_Extension_EmailList(); + } + + public function testEmptyEmailListShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->emailList->extensionElements)); + $this->assertTrue(count($this->emailList->extensionElements) == 0); + } + + public function testEmptyEmailListShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->emailList->extensionAttributes)); + $this->assertTrue(count($this->emailList->extensionAttributes) == 0); + } + + public function testSampleEmailListShouldHaveNoExtensionElements() { + $this->emailList->transferFromXML($this->emailListText); + $this->assertTrue(is_array($this->emailList->extensionElements)); + $this->assertTrue(count($this->emailList->extensionElements) == 0); + } + + public function testSampleEmailListShouldHaveNoExtensionAttributes() { + $this->emailList->transferFromXML($this->emailListText); + $this->assertTrue(is_array($this->emailList->extensionAttributes)); + $this->assertTrue(count($this->emailList->extensionAttributes) == 0); + } + + public function testNormalEmailListShouldHaveNoExtensionElements() { + $this->emailList->name = "test-name"; + + $this->assertEquals("test-name", $this->emailList->name); + + $this->assertEquals(0, count($this->emailList->extensionElements)); + $newEmailList = new Zend_Gdata_Gapps_Extension_EmailList(); + $newEmailList->transferFromXML($this->emailList->saveXML()); + $this->assertEquals(0, count($newEmailList->extensionElements)); + $newEmailList->extensionElements = array( + new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); + $this->assertEquals(1, count($newEmailList->extensionElements)); + $this->assertEquals("test-name", $newEmailList->name); + + /* try constructing using magic factory */ + $gdata = new Zend_Gdata_Gapps(); + $newEmailList2 = $gdata->newEmailList(); + $newEmailList2->transferFromXML($newEmailList->saveXML()); + $this->assertEquals(1, count($newEmailList2->extensionElements)); + $this->assertEquals("test-name", $newEmailList2->name); + } + + public function testEmptyEmailListToAndFromStringShouldMatch() { + $emailListXml = $this->emailList->saveXML(); + $newEmailList = new Zend_Gdata_Gapps_Extension_EmailList(); + $newEmailList->transferFromXML($emailListXml); + $newEmailListXml = $newEmailList->saveXML(); + $this->assertTrue($emailListXml == $newEmailListXml); + } + + public function testEmailListWithValueToAndFromStringShouldMatch() { + $this->emailList->name = "test-name"; + $emailListXml = $this->emailList->saveXML(); + $newEmailList = new Zend_Gdata_Gapps_Extension_EmailList(); + $newEmailList->transferFromXML($emailListXml); + $newEmailListXml = $newEmailList->saveXML(); + $this->assertTrue($emailListXml == $newEmailListXml); + $this->assertEquals("test-name", $this->emailList->name); + } + + public function testExtensionAttributes() { + $extensionAttributes = $this->emailList->extensionAttributes; + $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); + $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); + $this->emailList->extensionAttributes = $extensionAttributes; + $this->assertEquals('bar', $this->emailList->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $this->emailList->extensionAttributes['foo2']['value']); + $emailListXml = $this->emailList->saveXML(); + $newEmailList = new Zend_Gdata_Gapps_Extension_EmailList(); + $newEmailList->transferFromXML($emailListXml); + $this->assertEquals('bar', $newEmailList->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $newEmailList->extensionAttributes['foo2']['value']); + } + + public function testConvertFullEmailListToAndFromString() { + $this->emailList->transferFromXML($this->emailListText); + $this->assertEquals("us-sales", $this->emailList->name); + } + +} diff --git a/zend/tests/Zend/Gdata/Gapps/ErrorTest.php b/zend/tests/Zend/Gdata/Gapps/ErrorTest.php new file mode 100644 index 0000000..9985d5e --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/ErrorTest.php @@ -0,0 +1,88 @@ +error = new Zend_Gdata_Gapps_Error(); + } + + public function testCanSetAndGetErrorCodeUsingConstant() { + $this->error->setErrorCode( + Zend_Gdata_Gapps_Error::INVALID_EMAIL_ADDRESS); + $this->assertEquals(Zend_Gdata_Gapps_Error::INVALID_EMAIL_ADDRESS, + $this->error->getErrorCode()); + } + + public function testCanSetAndGetErrorCodeUsingInteger() { + $this->error->setErrorCode(123); + $this->assertEquals(123, $this->error->getErrorCode()); + } + + public function testCanSetAndGetReason() { + $text = "The foo is missing a bar."; + $this->error->setReason($text); + $this->assertEquals($text, $this->error->getReason()); + } + + public function testCanSetAndGetInvalidInput() { + $text = "for___baz"; + $this->error->setInvalidInput($text); + $this->assertEquals($text, $this->error->getInvalidInput()); + } + + public function testContstructorAllowsSettingAllVariables() { + $this->error = new Zend_Gdata_Gapps_Error( + Zend_Gdata_Gapps_Error::USER_DELETED_RECENTLY, + "foo", "bar"); + $this->assertEquals(Zend_Gdata_Gapps_Error::USER_DELETED_RECENTLY, + $this->error->getErrorCode()); + $this->assertEquals("foo", $this->error->getReason()); + $this->assertEquals("bar", $this->error->getInvalidInput()); + } + + public function testToStringProvidesHelpfulMessage() { + $this->error->setErrorCode(Zend_Gdata_Gapps_Error::USER_SUSPENDED); + $this->error->setReason("The foo is missing a bar."); + $this->error->setInvalidInput("for___baz"); + $this->assertEquals("Error 1101: The foo is missing a bar.\n\tInvalid Input: \"for___baz\"", $this->error->__toString()); + + $this->error->setErrorCode(Zend_Gdata_Gapps_Error::UNKNOWN_ERROR); + $this->error->setReason("Unknown error."); + $this->error->setInvalidInput("blah"); + $this->assertEquals("Error 1000: Unknown error.\n\tInvalid Input: \"blah\"", $this->error->__toString()); + } + +} diff --git a/zend/tests/Zend/Gdata/Gapps/GroupEntryTest.php b/zend/tests/Zend/Gdata/Gapps/GroupEntryTest.php new file mode 100644 index 0000000..ad8876f --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/GroupEntryTest.php @@ -0,0 +1,110 @@ +entryText = file_get_contents( + 'Zend/Gdata/Gapps/_files/GroupEntryDataSample1.xml', + true); + $this->entry = new Zend_Gdata_Gapps_GroupEntry(); + } + + private function verifyAllSamplePropertiesAreCorrect ($groupEntry) { + $this->assertEquals('https://www.google.com/a/feeds/group/2.0/example.com/us-sales', + $groupEntry->id->text); + $this->assertEquals('1970-01-01T00:00:00.000Z', $groupEntry->updated->text); + $this->assertEquals('self', $groupEntry->getLink('self')->rel); + $this->assertEquals('application/atom+xml', $groupEntry->getLink('self')->type); + $this->assertEquals('https://www.google.com/a/feeds/group/2.0/example.com/us-sales', $groupEntry->getLink('self')->href); + $this->assertEquals('edit', $groupEntry->getLink('edit')->rel); + $this->assertEquals('application/atom+xml', $groupEntry->getLink('edit')->type); + $this->assertEquals('https://www.google.com/a/feeds/group/2.0/example.com/us-sales', $groupEntry->getLink('edit')->href); + $this->assertEquals('groupId', $groupEntry->property[0]->name); + $this->assertEquals('us-sales', $groupEntry->property[0]->value); + $this->assertEquals('groupName', $groupEntry->property[1]->name); + $this->assertEquals('us-sales', $groupEntry->property[1]->value); + $this->assertEquals('description', $groupEntry->property[2]->name); + $this->assertEquals('UnitedStatesSalesTeam', $groupEntry->property[2]->value); + $this->assertEquals('emailPermission', $groupEntry->property[3]->name); + $this->assertEquals('Domain', $groupEntry->property[3]->value); + } + + public function testEmptyEntryShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->entry->extensionElements)); + $this->assertTrue(count($this->entry->extensionElements) == 0); + } + + public function testEmptyEntryShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->entry->extensionAttributes)); + $this->assertTrue(count($this->entry->extensionAttributes) == 0); + } + + public function testSampleEntryShouldHaveNoExtensionElements() { + $this->entry->transferFromXML($this->entryText); + $this->assertTrue(is_array($this->entry->extensionElements)); + $this->assertTrue(count($this->entry->extensionElements) == 0); + } + + public function testSampleEntryShouldHaveNoExtensionAttributes() { + $this->entry->transferFromXML($this->entryText); + $this->assertTrue(is_array($this->entry->extensionAttributes)); + $this->assertTrue(count($this->entry->extensionAttributes) == 0); + } + + public function testEmptyGroupEntryToAndFromStringShouldMatch() { + $entryXml = $this->entry->saveXML(); + $newGroupEntry = new Zend_Gdata_Gapps_GroupEntry(); + $newGroupEntry->transferFromXML($entryXml); + $newGroupEntryXml = $newGroupEntry->saveXML(); + $this->assertTrue($entryXml == $newGroupEntryXml); + } + + public function testSamplePropertiesAreCorrect () { + $this->entry->transferFromXML($this->entryText); + $this->verifyAllSamplePropertiesAreCorrect($this->entry); + } + + public function testConvertGroupEntryToAndFromString() { + $this->entry->transferFromXML($this->entryText); + $entryXml = $this->entry->saveXML(); + $newGroupEntry = new Zend_Gdata_Gapps_GroupEntry(); + $newGroupEntry->transferFromXML($entryXml); + $this->verifyAllSamplePropertiesAreCorrect($newGroupEntry); + $newGroupEntryXml = $newGroupEntry->saveXML(); + $this->assertEquals($entryXml, $newGroupEntryXml); + } + +} diff --git a/zend/tests/Zend/Gdata/Gapps/GroupFeedTest.php b/zend/tests/Zend/Gdata/Gapps/GroupFeedTest.php new file mode 100644 index 0000000..0bbbf19 --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/GroupFeedTest.php @@ -0,0 +1,109 @@ +groupFeed = new Zend_Gdata_Gapps_GroupFeed($groupFeedText); + $this->emptyGroupFeed = new Zend_Gdata_Gapps_GroupFeed(); + } + + public function testEmptyFeedShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->emptyGroupFeed->extensionElements)); + $this->assertTrue(count($this->emptyGroupFeed->extensionElements) == 0); + } + + public function testEmptyFeedShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->emptyGroupFeed->extensionAttributes)); + $this->assertTrue(count($this->emptyGroupFeed->extensionAttributes) == 0); + } + + public function testSampleFeedShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->groupFeed->extensionElements)); + $this->assertTrue(count($this->groupFeed->extensionElements) == 0); + } + + public function testSampleFeedShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->groupFeed->extensionAttributes)); + $this->assertTrue(count($this->groupFeed->extensionAttributes) == 0); + } + + /** + * Convert sample feed to XML then back to objects. Ensure that + * all objects are instances of GroupEntry and object count matches. + */ + public function testXmlImportAndOutputAreNonDestructive() + { + $entryCount = 0; + foreach ($this->groupFeed as $entry) { + $entryCount++; + $this->assertTrue($entry instanceof Zend_Gdata_Gapps_GroupEntry); + } + $this->assertTrue($entryCount > 0); + + /* Grab XML from $this->groupFeed and convert back to objects */ + $newGroupFeed = new Zend_Gdata_Gapps_GroupFeed( + $this->groupFeed->saveXML()); + $newEntryCount = 0; + foreach ($newGroupFeed as $entry) { + $newEntryCount++; + $this->assertTrue($entry instanceof Zend_Gdata_Gapps_GroupEntry); + } + $this->assertEquals($entryCount, $newEntryCount); + } + + /** + * Ensure that there number of group entries equals the number + * of groups defined in the sample file. + */ + public function testAllEntriesInFeedAreInstantiated() + { + //TODO feeds implementing ArrayAccess would be helpful here + $entryCount = 0; + foreach ($this->groupFeed as $entry) { + $entryCount++; + } + $this->assertEquals(2, $entryCount); + } + +} diff --git a/zend/tests/Zend/Gdata/Gapps/GroupQueryTest.php b/zend/tests/Zend/Gdata/Gapps/GroupQueryTest.php new file mode 100644 index 0000000..c613e8d --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/GroupQueryTest.php @@ -0,0 +1,168 @@ +query = new Zend_Gdata_Gapps_GroupQuery(); + } + + // Test to make sure that URI generation works + public function testDefaultQueryURIGeneration() + { + $this->query->setDomain("foo.bar.invalid"); + $this->assertEquals("https://apps-apis.google.com/a/feeds/group/2.0/foo.bar.invalid", + $this->query->getQueryUrl()); + } + + // Test to make sure that the domain accessor methods work and propagate + // to the query URI. + public function testCanSetQueryDomain() + { + $this->query->setDomain("my.domain.com"); + $this->assertEquals("my.domain.com", $this->query->getDomain()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/group/2.0/my.domain.com", + $this->query->getQueryUrl()); + + $this->query->setDomain("hello.world.baz"); + $this->assertEquals("hello.world.baz", $this->query->getDomain()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/group/2.0/hello.world.baz", + $this->query->getQueryUrl()); + } + + // Test to make sure that the groupId accessor methods work and propagate + // to the query URI. + public function testCanSetGroupIdProperty() + { + $this->query->setDomain("my.domain.com"); + $this->query->setGroupId("foo"); + $this->assertEquals("foo", $this->query->getGroupId()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/group/2.0/my.domain.com/foo", + $this->query->getQueryUrl()); + + $this->query->setGroupId("bar"); + $this->assertEquals("bar", $this->query->getGroupId()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/group/2.0/my.domain.com/bar", + $this->query->getQueryUrl()); + } + + // Test to make sure that the member accessor methods work and propagate + // to the query URI. + public function testCanSetMemberProperty() + { + $this->query->setDomain("my.domain.com"); + $this->query->setMember("bar@qux.com"); + $this->assertEquals("bar@qux.com", $this->query->getMember()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/group/2.0/my.domain.com/?member=bar%40qux.com", + $this->query->getQueryUrl()); + + $this->query->setMember(null); + $this->assertEquals(null, $this->query->getMember()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/group/2.0/my.domain.com", + $this->query->getQueryUrl()); + } + + // Test to make sure that the startUsername accessor methods work and + // propagate to the query URI. + public function testCanSetStartGroupIdProperty() + { + $this->query->setDomain("my.domain.com"); + $this->query->setStartGroupId("foo"); + $this->assertEquals("foo", $this->query->getStartGroupId()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/group/2.0/my.domain.com?start=foo", + $this->query->getQueryUrl()); + + $this->query->setStartGroupId(null); + $this->assertEquals(null, $this->query->getStartGroupId()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/group/2.0/my.domain.com", + $this->query->getQueryUrl()); + } + + public function testCanSetDirectOnlyProperty() + { + $this->query->setDomain("my.domain.com"); + $this->query->setMember("bar@qux.com"); + $this->query->setDirectOnly(true); + $this->assertEquals(true, $this->query->getDirectOnly()); + $expected_url = "https://apps-apis.google.com/a/feeds/group/2.0/my.domain.com/"; + $expected_url .= "?member=bar%40qux.com&directOnly=true"; + $this->assertEquals($expected_url, $this->query->getQueryUrl()); + + $this->query->setDirectOnly(false); + $this->assertEquals(false, $this->query->getDirectOnly()); + $expected_url = "https://apps-apis.google.com/a/feeds/group/2.0/my.domain.com/"; + $expected_url .= "?member=bar%40qux.com&directOnly=false"; + $this->assertEquals($expected_url, $this->query->getQueryUrl()); + + $this->query->setDirectOnly(null); + $this->assertEquals(null, $this->query->getDirectOnly()); + $expected_url = "https://apps-apis.google.com/a/feeds/group/2.0/my.domain.com/"; + $expected_url .= "?member=bar%40qux.com"; + $this->assertEquals($expected_url, $this->query->getQueryUrl()); + } + + // Test to make sure that all parameters can be set simultaneously with no + // ill effects. + public function testCanSetAllParameters() + { + $this->query->setDomain("my.domain.com"); + $this->query->setGroupId("foo"); + $this->query->setMember("bar@qux.com"); + $this->query->setStartGroupId("wibble"); + $this->query->setDirectOnly(true); + $this->assertEquals("foo", $this->query->getGroupId()); + $this->assertEquals("bar@qux.com", $this->query->getMember()); + $this->assertEquals("wibble", $this->query->getStartGroupId()); + $this->assertEquals(true, $this->query->getDirectOnly()); + $expected_url = "https://apps-apis.google.com/a/feeds/group/2.0/my.domain.com/"; + $expected_url .= "foo/?member=bar%40qux.com&start=wibble&directOnly=true"; + $this->assertEquals($expected_url, $this->query->getQueryUrl()); + + $this->query->setMember("baz@blah.com"); + $this->query->setGroupId("xyzzy"); + $this->query->setStartGroupId("woof"); + $this->query->setDirectOnly(false); + $this->assertEquals("xyzzy", $this->query->getGroupId()); + $this->assertEquals("baz@blah.com", $this->query->getMember()); + $this->assertEquals("woof", $this->query->getStartGroupId()); + $this->assertEquals(false, $this->query->getDirectOnly()); + $expected_url = "https://apps-apis.google.com/a/feeds/group/2.0/my.domain.com/"; + $expected_url .= "xyzzy/?member=baz%40blah.com&start=woof&directOnly=false"; + $this->assertEquals($expected_url, $this->query->getQueryUrl()); + } + +} + diff --git a/zend/tests/Zend/Gdata/Gapps/LoginTest.php b/zend/tests/Zend/Gdata/Gapps/LoginTest.php new file mode 100644 index 0000000..4847427 --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/LoginTest.php @@ -0,0 +1,169 @@ +loginText = file_get_contents( + 'Zend/Gdata/Gapps/_files/LoginElementSample1.xml', + true); + $this->login = new Zend_Gdata_Gapps_Extension_Login(); + } + + public function testEmptyLoginShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->login->extensionElements)); + $this->assertTrue(count($this->login->extensionElements) == 0); + } + + public function testEmptyLoginShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->login->extensionAttributes)); + $this->assertTrue(count($this->login->extensionAttributes) == 0); + } + + public function testSampleLoginShouldHaveNoExtensionElements() { + $this->login->transferFromXML($this->loginText); + $this->assertTrue(is_array($this->login->extensionElements)); + $this->assertTrue(count($this->login->extensionElements) == 0); + } + + public function testSampleLoginShouldHaveNoExtensionAttributes() { + $this->login->transferFromXML($this->loginText); + $this->assertTrue(is_array($this->login->extensionAttributes)); + $this->assertTrue(count($this->login->extensionAttributes) == 0); + } + + public function testNormalLoginShouldHaveNoExtensionElements() { + $this->login->username = "johndoe"; + $this->login->password = "abcdefg1234567890"; + $this->login->hashFunctionName = "Foo"; + $this->login->suspended = true; + $this->login->admin = true; + $this->login->changePasswordAtNextLogin = true; + $this->login->agreedToTerms = false; + + $this->assertEquals("johndoe", $this->login->username); + $this->assertEquals("abcdefg1234567890", $this->login->password); + $this->assertEquals("Foo", $this->login->hashFunctionName); + $this->assertEquals(true, $this->login->suspended); + $this->assertEquals(true, $this->login->admin); + $this->assertEquals(true, $this->login->changePasswordAtNextLogin); + $this->assertEquals(false, $this->login->agreedToTerms); + + $this->assertEquals(0, count($this->login->extensionElements)); + $newLogin = new Zend_Gdata_Gapps_Extension_Login(); + $newLogin->transferFromXML($this->login->saveXML()); + $this->assertEquals(0, count($newLogin->extensionElements)); + $newLogin->extensionElements = array( + new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); + $this->assertEquals(1, count($newLogin->extensionElements)); + $this->assertEquals("johndoe", $newLogin->username); + $this->assertEquals("abcdefg1234567890", $newLogin->password); + $this->assertEquals("Foo", $newLogin->hashFunctionName); + $this->assertEquals(true, $newLogin->suspended); + $this->assertEquals(true, $newLogin->admin); + $this->assertEquals(true, $newLogin->changePasswordAtNextLogin); + $this->assertEquals(false, $newLogin->agreedToTerms); + + /* try constructing using magic factory */ + $gdata = new Zend_Gdata_Gapps(); + $newLogin2 = $gdata->newLogin(); + $newLogin2->transferFromXML($newLogin->saveXML()); + $this->assertEquals(1, count($newLogin2->extensionElements)); + $this->assertEquals("johndoe", $newLogin2->username); + $this->assertEquals("abcdefg1234567890", $newLogin2->password); + $this->assertEquals("Foo", $newLogin2->hashFunctionName); + $this->assertEquals(true, $newLogin2->suspended); + $this->assertEquals(true, $newLogin2->admin); + $this->assertEquals(true, $newLogin2->changePasswordAtNextLogin); + $this->assertEquals(false, $newLogin2->agreedToTerms); + } + + public function testEmptyLoginToAndFromStringShouldMatch() { + $loginXml = $this->login->saveXML(); + $newLogin = new Zend_Gdata_Gapps_Extension_Login(); + $newLogin->transferFromXML($loginXml); + $newLoginXml = $newLogin->saveXML(); + $this->assertTrue($loginXml == $newLoginXml); + } + + public function testLoginWithValueToAndFromStringShouldMatch() { + $this->login->username = "johndoe"; + $this->login->password = "abcdefg1234567890"; + $this->login->hashFunctionName = "Foo"; + $this->login->suspended = true; + $this->login->admin = true; + $this->login->changePasswordAtNextLogin = true; + $this->login->agreedToTerms = false; + $loginXml = $this->login->saveXML(); + $newLogin = new Zend_Gdata_Gapps_Extension_Login(); + $newLogin->transferFromXML($loginXml); + $newLoginXml = $newLogin->saveXML(); + $this->assertTrue($loginXml == $newLoginXml); + $this->assertEquals("johndoe", $this->login->username); + $this->assertEquals("abcdefg1234567890", $this->login->password); + $this->assertEquals("Foo", $this->login->hashFunctionName); + $this->assertEquals(true, $this->login->suspended); + $this->assertEquals(true, $this->login->admin); + $this->assertEquals(true, $this->login->changePasswordAtNextLogin); + $this->assertEquals(false, $this->login->agreedToTerms); + + } + + public function testExtensionAttributes() { + $extensionAttributes = $this->login->extensionAttributes; + $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); + $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); + $this->login->extensionAttributes = $extensionAttributes; + $this->assertEquals('bar', $this->login->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $this->login->extensionAttributes['foo2']['value']); + $loginXml = $this->login->saveXML(); + $newLogin = new Zend_Gdata_Gapps_Extension_Login(); + $newLogin->transferFromXML($loginXml); + $this->assertEquals('bar', $newLogin->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $newLogin->extensionAttributes['foo2']['value']); + } + + public function testConvertFullLoginToAndFromString() { + $this->login->transferFromXML($this->loginText); + $this->assertEquals("SusanJones-1321", $this->login->username); + $this->assertEquals("123\$\$abc", $this->login->password); + $this->assertEquals("SHA-1", $this->login->hashFunctionName); + $this->assertEquals(false, $this->login->suspended); + $this->assertEquals(false, $this->login->admin); + $this->assertEquals(false, $this->login->changePasswordAtNextLogin); + $this->assertEquals(true, $this->login->agreedToTerms); + } + +} diff --git a/zend/tests/Zend/Gdata/Gapps/MemberEntryTest.php b/zend/tests/Zend/Gdata/Gapps/MemberEntryTest.php new file mode 100644 index 0000000..f428792 --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/MemberEntryTest.php @@ -0,0 +1,108 @@ +entryText = file_get_contents( + 'Zend/Gdata/Gapps/_files/MemberEntryDataSample1.xml', + true); + $this->entry = new Zend_Gdata_Gapps_MemberEntry(); + } + + private function verifyAllSamplePropertiesAreCorrect ($memberEntry) { + $this->assertEquals('https://www.google.com/a/feeds/group/2.0/example.com/us-sales/member/suejones%40example.com', + $memberEntry->id->text); + $this->assertEquals('1970-01-01T00:00:00.000Z', $memberEntry->updated->text); + $this->assertEquals('self', $memberEntry->getLink('self')->rel); + $this->assertEquals('application/atom+xml', $memberEntry->getLink('self')->type); + $this->assertEquals('https://www.google.com/a/feeds/group/2.0/example.com/us-sales/member/suejones%40example.com', $memberEntry->getLink('self')->href); + $this->assertEquals('edit', $memberEntry->getLink('edit')->rel); + $this->assertEquals('application/atom+xml', $memberEntry->getLink('edit')->type); + $this->assertEquals('https://www.google.com/a/feeds/group/2.0/example.com/us-sales/member/suejones%40example.com', $memberEntry->getLink('edit')->href); + $this->assertEquals('memberId', $memberEntry->property[0]->name); + $this->assertEquals('suejones@example.com', $memberEntry->property[0]->value); + $this->assertEquals('memberType', $memberEntry->property[1]->name); + $this->assertEquals('User', $memberEntry->property[1]->value); + $this->assertEquals('directMember', $memberEntry->property[2]->name); + $this->assertEquals('true', $memberEntry->property[2]->value); + } + + public function testEmptyEntryShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->entry->extensionElements)); + $this->assertTrue(count($this->entry->extensionElements) == 0); + } + + public function testEmptyEntryShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->entry->extensionAttributes)); + $this->assertTrue(count($this->entry->extensionAttributes) == 0); + } + + public function testSampleEntryShouldHaveNoExtensionElements() { + $this->entry->transferFromXML($this->entryText); + $this->assertTrue(is_array($this->entry->extensionElements)); + $this->assertTrue(count($this->entry->extensionElements) == 0); + } + + public function testSampleEntryShouldHaveNoExtensionAttributes() { + $this->entry->transferFromXML($this->entryText); + $this->assertTrue(is_array($this->entry->extensionAttributes)); + $this->assertTrue(count($this->entry->extensionAttributes) == 0); + } + + public function testEmptyMemberEntryToAndFromStringShouldMatch() { + $entryXml = $this->entry->saveXML(); + $newMemberEntry = new Zend_Gdata_Gapps_MemberEntry(); + $newMemberEntry->transferFromXML($entryXml); + $newMemberEntryXml = $newMemberEntry->saveXML(); + $this->assertTrue($entryXml == $newMemberEntryXml); + } + + public function testSamplePropertiesAreCorrect () { + $this->entry->transferFromXML($this->entryText); + $this->verifyAllSamplePropertiesAreCorrect($this->entry); + } + + public function testConvertMemberEntryToAndFromString() { + $this->entry->transferFromXML($this->entryText); + $entryXml = $this->entry->saveXML(); + $newMemberEntry = new Zend_Gdata_Gapps_MemberEntry(); + $newMemberEntry->transferFromXML($entryXml); + $this->verifyAllSamplePropertiesAreCorrect($newMemberEntry); + $newMemberEntryXml = $newMemberEntry->saveXML(); + $this->assertEquals($entryXml, $newMemberEntryXml); + } + +} diff --git a/zend/tests/Zend/Gdata/Gapps/MemberFeedTest.php b/zend/tests/Zend/Gdata/Gapps/MemberFeedTest.php new file mode 100644 index 0000000..cb43cfe --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/MemberFeedTest.php @@ -0,0 +1,109 @@ +memberFeed = new Zend_Gdata_Gapps_MemberFeed($memberFeedText); + $this->emptyMemberFeed = new Zend_Gdata_Gapps_MemberFeed(); + } + + public function testEmptyFeedShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->emptyMemberFeed->extensionElements)); + $this->assertTrue(count($this->emptyMemberFeed->extensionElements) == 0); + } + + public function testEmptyFeedShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->emptyMemberFeed->extensionAttributes)); + $this->assertTrue(count($this->emptyMemberFeed->extensionAttributes) == 0); + } + + public function testSampleFeedShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->memberFeed->extensionElements)); + $this->assertTrue(count($this->memberFeed->extensionElements) == 0); + } + + public function testSampleFeedShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->memberFeed->extensionAttributes)); + $this->assertTrue(count($this->memberFeed->extensionAttributes) == 0); + } + + /** + * Convert sample feed to XML then back to objects. Ensure that + * all objects are instances of MemberEntry and object count matches. + */ + public function testXmlImportAndOutputAreNonDestructive() + { + $entryCount = 0; + foreach ($this->memberFeed as $entry) { + $entryCount++; + $this->assertTrue($entry instanceof Zend_Gdata_Gapps_MemberEntry); + } + $this->assertTrue($entryCount > 0); + + /* Grab XML from $this->memberFeed and convert back to objects */ + $newMemberFeed = new Zend_Gdata_Gapps_MemberFeed( + $this->memberFeed->saveXML()); + $newEntryCount = 0; + foreach ($newMemberFeed as $entry) { + $newEntryCount++; + $this->assertTrue($entry instanceof Zend_Gdata_Gapps_MemberEntry); + } + $this->assertEquals($entryCount, $newEntryCount); + } + + /** + * Ensure that there number of member entries equals the number + * of members defined in the sample file. + */ + public function testAllEntriesInFeedAreInstantiated() + { + //TODO feeds implementing ArrayAccess would be helpful here + $entryCount = 0; + foreach ($this->memberFeed as $entry) { + $entryCount++; + } + $this->assertEquals(2, $entryCount); + } + +} diff --git a/zend/tests/Zend/Gdata/Gapps/MemberQueryTest.php b/zend/tests/Zend/Gdata/Gapps/MemberQueryTest.php new file mode 100644 index 0000000..e7fc2b9 --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/MemberQueryTest.php @@ -0,0 +1,109 @@ +query = new Zend_Gdata_Gapps_MemberQuery(); + } + + // Test to make sure that the domain accessor methods work and propagate + // to the query URI. + public function testCanSetQueryDomain() + { + $this->query->setGroupId("something"); + $this->query->setDomain("my.domain.com"); + $this->assertEquals("my.domain.com", $this->query->getDomain()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/group/2.0/my.domain.com/something/member", + $this->query->getQueryUrl()); + + $this->query->setDomain("hello.world.baz"); + $this->assertEquals("hello.world.baz", $this->query->getDomain()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/group/2.0/hello.world.baz/something/member", + $this->query->getQueryUrl()); + } + + // Test to make sure that the groupId accessor methods work and propagate + // to the query URI. + public function testCanSetGroupIdProperty() + { + $this->query->setDomain("my.domain.com"); + $this->query->setGroupId("foo"); + $this->assertEquals("foo", $this->query->getGroupId()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/group/2.0/my.domain.com/foo/member", + $this->query->getQueryUrl()); + + $this->query->setGroupId("bar"); + $this->assertEquals("bar", $this->query->getGroupId()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/group/2.0/my.domain.com/bar/member", + $this->query->getQueryUrl()); + } + + // Test to make sure that the memberId accessor methods work and propagate + // to the query URI. + public function testCanSetMemberIdProperty() + { + $this->query->setDomain("my.domain.com"); + $this->query->setGroupId("foo"); + $this->query->setMemberId("bar"); + $this->assertEquals("bar", $this->query->getMemberId()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/group/2.0/my.domain.com/foo/member/bar", + $this->query->getQueryUrl()); + + $this->query->setGroupId("baz"); + $this->query->setMemberId(null); + $this->assertEquals(null, $this->query->getMemberId()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/group/2.0/my.domain.com/baz/member", + $this->query->getQueryUrl()); + } + + public function testCanSetStartMemberIdProperty() + { + $this->query->setDomain("my.domain.com"); + $this->query->setGroupId("foo"); + $this->query->setStartMemberId("bar"); + $this->assertEquals("bar", $this->query->getStartMemberId()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/group/2.0/my.domain.com/foo/member?start=bar", + $this->query->getQueryUrl()); + + $this->query->setStartMemberId(null); + $this->assertEquals(null, $this->query->getStartMemberId()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/group/2.0/my.domain.com/foo/member", + $this->query->getQueryUrl()); + } + +} + diff --git a/zend/tests/Zend/Gdata/Gapps/NameTest.php b/zend/tests/Zend/Gdata/Gapps/NameTest.php new file mode 100644 index 0000000..9c0ca3b --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/NameTest.php @@ -0,0 +1,133 @@ +theNameText = file_get_contents( + 'Zend/Gdata/Gapps/_files/NameElementSample1.xml', + true); + $this->theName = new Zend_Gdata_Gapps_Extension_Name(); + } + + public function testEmptyNameShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->theName->extensionElements)); + $this->assertTrue(count($this->theName->extensionElements) == 0); + } + + public function testEmptyNameShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->theName->extensionAttributes)); + $this->assertTrue(count($this->theName->extensionAttributes) == 0); + } + + public function testSampleNameShouldHaveNoExtensionElements() { + $this->theName->transferFromXML($this->theNameText); + $this->assertTrue(is_array($this->theName->extensionElements)); + $this->assertTrue(count($this->theName->extensionElements) == 0); + } + + public function testSampleNameShouldHaveNoExtensionAttributes() { + $this->theName->transferFromXML($this->theNameText); + $this->assertTrue(is_array($this->theName->extensionAttributes)); + $this->assertTrue(count($this->theName->extensionAttributes) == 0); + } + + public function testNormalNameShouldHaveNoExtensionElements() { + $this->theName->givenName = "John"; + $this->theName->familyName = "Doe"; + + $this->assertEquals("John", $this->theName->givenName); + $this->assertEquals("Doe", $this->theName->familyName); + + $this->assertEquals(0, count($this->theName->extensionElements)); + $newName = new Zend_Gdata_Gapps_Extension_Name(); + $newName->transferFromXML($this->theName->saveXML()); + $this->assertEquals(0, count($newName->extensionElements)); + $newName->extensionElements = array( + new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); + $this->assertEquals(1, count($newName->extensionElements)); + $this->assertEquals("John", $newName->givenName); + $this->assertEquals("Doe", $newName->familyName); + + /* try constructing using magic factory */ + $gdata = new Zend_Gdata_Gapps(); + $newName2 = $gdata->newName(); + $newName2->transferFromXML($newName->saveXML()); + $this->assertEquals(1, count($newName2->extensionElements)); + $this->assertEquals("John", $newName2->givenName); + $this->assertEquals("Doe", $newName2->familyName); + } + + public function testEmptyNameToAndFromStringShouldMatch() { + $nameXml = $this->theName->saveXML(); + $newName = new Zend_Gdata_Gapps_Extension_Name(); + $newName->transferFromXML($nameXml); + $newNameXml = $newName->saveXML(); + $this->assertTrue($nameXml == $newNameXml); + } + + public function testNameWithValueToAndFromStringShouldMatch() { + $this->theName->givenName = "John"; + $this->theName->familyName = "Doe"; + $nameXml = $this->theName->saveXML(); + $newName = new Zend_Gdata_Gapps_Extension_Name(); + $newName->transferFromXML($nameXml); + $newNameXml = $newName->saveXML(); + $this->assertTrue($nameXml == $newNameXml); + $this->assertEquals("John", $this->theName->givenName); + $this->assertEquals("Doe", $this->theName->familyName); + } + + public function testExtensionAttributes() { + $extensionAttributes = $this->theName->extensionAttributes; + $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); + $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); + $this->theName->extensionAttributes = $extensionAttributes; + $this->assertEquals('bar', $this->theName->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $this->theName->extensionAttributes['foo2']['value']); + $nameXml = $this->theName->saveXML(); + $newName = new Zend_Gdata_Gapps_Extension_Name(); + $newName->transferFromXML($nameXml); + $this->assertEquals('bar', $newName->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $newName->extensionAttributes['foo2']['value']); + } + + public function testConvertFullNameToAndFromString() { + $this->theName->transferFromXML($this->theNameText); + $this->assertEquals("Susan", $this->theName->givenName); + $this->assertEquals("Jones", $this->theName->familyName); + } + +} diff --git a/zend/tests/Zend/Gdata/Gapps/NicknameEntryTest.php b/zend/tests/Zend/Gdata/Gapps/NicknameEntryTest.php new file mode 100644 index 0000000..e49ee25 --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/NicknameEntryTest.php @@ -0,0 +1,112 @@ +entryText = file_get_contents( + 'Zend/Gdata/Gapps/_files/NicknameEntryDataSample1.xml', + true); + $this->entry = new Zend_Gdata_Gapps_NicknameEntry(); + } + + private function verifyAllSamplePropertiesAreCorrect ($nicknameEntry) { + $this->assertEquals('https://apps-apis.google.com/a/feeds/example.com/nickname/2.0/Susy', + $nicknameEntry->id->text); + $this->assertEquals('1970-01-01T00:00:00.000Z', $nicknameEntry->updated->text); + $this->assertEquals('http://schemas.google.com/g/2005#kind', $nicknameEntry->category[0]->scheme); + $this->assertEquals('http://schemas.google.com/apps/2006#nickname', $nicknameEntry->category[0]->term); + $this->assertEquals('text', $nicknameEntry->title->type); + $this->assertEquals('Susy', $nicknameEntry->title->text);; + $this->assertEquals('self', $nicknameEntry->getLink('self')->rel); + $this->assertEquals('application/atom+xml', $nicknameEntry->getLink('self')->type); + $this->assertEquals('https://apps-apis.google.com/a/feeds/example.com/nickname/2.0/Susy', $nicknameEntry->getLink('self')->href); + $this->assertEquals('edit', $nicknameEntry->getLink('edit')->rel); + $this->assertEquals('application/atom+xml', $nicknameEntry->getLink('edit')->type); + $this->assertEquals('https://apps-apis.google.com/a/feeds/example.com/nickname/2.0/Susy', $nicknameEntry->getLink('edit')->href); + $this->assertEquals('Susy', $nicknameEntry->nickname->name); + $this->assertEquals('SusanJones', $nicknameEntry->login->username); + $this->assertEquals(false, $nicknameEntry->login->suspended); + $this->assertEquals(false, $nicknameEntry->login->admin); + $this->assertEquals(false, $nicknameEntry->login->changePasswordAtNextLogin); + $this->assertEquals(true, $nicknameEntry->login->agreedToTerms); + } + + public function testEmptyEntryShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->entry->extensionElements)); + $this->assertTrue(count($this->entry->extensionElements) == 0); + } + + public function testEmptyEntryShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->entry->extensionAttributes)); + $this->assertTrue(count($this->entry->extensionAttributes) == 0); + } + + public function testSampleEntryShouldHaveNoExtensionElements() { + $this->entry->transferFromXML($this->entryText); + $this->assertTrue(is_array($this->entry->extensionElements)); + $this->assertTrue(count($this->entry->extensionElements) == 0); + } + + public function testSampleEntryShouldHaveNoExtensionAttributes() { + $this->entry->transferFromXML($this->entryText); + $this->assertTrue(is_array($this->entry->extensionAttributes)); + $this->assertTrue(count($this->entry->extensionAttributes) == 0); + } + + public function testEmptyNicknameEntryToAndFromStringShouldMatch() { + $entryXml = $this->entry->saveXML(); + $newNicknameEntry = new Zend_Gdata_Gapps_NicknameEntry(); + $newNicknameEntry->transferFromXML($entryXml); + $newNicknameEntryXml = $newNicknameEntry->saveXML(); + $this->assertTrue($entryXml == $newNicknameEntryXml); + } + + public function testSamplePropertiesAreCorrect () { + $this->entry->transferFromXML($this->entryText); + $this->verifyAllSamplePropertiesAreCorrect($this->entry); + } + + public function testConvertNicknameEntryToAndFromString() { + $this->entry->transferFromXML($this->entryText); + $entryXml = $this->entry->saveXML(); + $newNicknameEntry = new Zend_Gdata_Gapps_NicknameEntry(); + $newNicknameEntry->transferFromXML($entryXml); + $this->verifyAllSamplePropertiesAreCorrect($newNicknameEntry); + $newNicknameEntryXml = $newNicknameEntry->saveXML(); + $this->assertEquals($entryXml, $newNicknameEntryXml); + } + +} diff --git a/zend/tests/Zend/Gdata/Gapps/NicknameFeedTest.php b/zend/tests/Zend/Gdata/Gapps/NicknameFeedTest.php new file mode 100644 index 0000000..3bb9953 --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/NicknameFeedTest.php @@ -0,0 +1,109 @@ +nicknameFeed = new Zend_Gdata_Gapps_NicknameFeed($nicknameFeedText); + $this->emptyNicknameFeed = new Zend_Gdata_Gapps_NicknameFeed(); + } + + public function testEmptyFeedShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->emptyNicknameFeed->extensionElements)); + $this->assertTrue(count($this->emptyNicknameFeed->extensionElements) == 0); + } + + public function testEmptyFeedShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->emptyNicknameFeed->extensionAttributes)); + $this->assertTrue(count($this->emptyNicknameFeed->extensionAttributes) == 0); + } + + public function testSampleFeedShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->nicknameFeed->extensionElements)); + $this->assertTrue(count($this->nicknameFeed->extensionElements) == 0); + } + + public function testSampleFeedShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->nicknameFeed->extensionAttributes)); + $this->assertTrue(count($this->nicknameFeed->extensionAttributes) == 0); + } + + /** + * Convert sample feed to XML then back to objects. Ensure that + * all objects are instances of EventEntry and object count matches. + */ + public function testXmlImportAndOutputAreNonDestructive() + { + $entryCount = 0; + foreach ($this->nicknameFeed as $entry) { + $entryCount++; + $this->assertTrue($entry instanceof Zend_Gdata_Gapps_NicknameEntry); + } + $this->assertTrue($entryCount > 0); + + /* Grab XML from $this->nicknameFeed and convert back to objects */ + $newNicknameFeed = new Zend_Gdata_Gapps_NicknameFeed( + $this->nicknameFeed->saveXML()); + $newEntryCount = 0; + foreach ($newNicknameFeed as $entry) { + $newEntryCount++; + $this->assertTrue($entry instanceof Zend_Gdata_Gapps_NicknameEntry); + } + $this->assertEquals($entryCount, $newEntryCount); + } + + /** + * Ensure that there number of lsit feeds equals the number + * of calendars defined in the sample file. + */ + public function testAllEntriesInFeedAreInstantiated() + { + //TODO feeds implementing ArrayAccess would be helpful here + $entryCount = 0; + foreach ($this->nicknameFeed as $entry) { + $entryCount++; + } + $this->assertEquals(2, $entryCount); + } + +} diff --git a/zend/tests/Zend/Gdata/Gapps/NicknameQueryTest.php b/zend/tests/Zend/Gdata/Gapps/NicknameQueryTest.php new file mode 100644 index 0000000..2730c62 --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/NicknameQueryTest.php @@ -0,0 +1,140 @@ +query = new Zend_Gdata_Gapps_NicknameQuery(); + } + + // Test to make sure that URI generation works + public function testDefaultQueryURIGeneration() + { + $this->query->setDomain("foo.bar.invalid"); + $this->assertEquals("https://apps-apis.google.com/a/feeds/foo.bar.invalid/nickname/2.0", + $this->query->getQueryUrl()); + } + + // Test to make sure that the domain accessor methods work and propagate + // to the query URI. + public function testCanSetQueryDomain() + { + $this->query->setDomain("my.domain.com"); + $this->assertEquals("my.domain.com", $this->query->getDomain()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/nickname/2.0", + $this->query->getQueryUrl()); + + $this->query->setDomain("hello.world.baz"); + $this->assertEquals("hello.world.baz", $this->query->getDomain()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/hello.world.baz/nickname/2.0", + $this->query->getQueryUrl()); + } + + // Test to make sure that the username accessor methods work and propagate + // to the query URI. + public function testCanSetUsernameProperty() + { + $this->query->setDomain("my.domain.com"); + $this->query->setUsername("foo"); + $this->assertEquals("foo", $this->query->getUsername()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/nickname/2.0?username=foo", + $this->query->getQueryUrl()); + + $this->query->setUsername(null); + $this->assertEquals(null, $this->query->getUsername()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/nickname/2.0", + $this->query->getQueryUrl()); + } + + // Test to make sure that the nickname accessor methods work and propagate + // to the query URI. + public function testCanSetNicknameProperty() + { + $this->query->setDomain("my.domain.com"); + $this->query->setNickname("foo"); + $this->assertEquals("foo", $this->query->getNickname()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/nickname/2.0/foo", + $this->query->getQueryUrl()); + + $this->query->setNickname("bar"); + $this->assertEquals("bar", $this->query->getNickname()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/nickname/2.0/bar", + $this->query->getQueryUrl()); + } + + // Test to make sure that the startNickname accessor methods work and + // propagate to the query URI. + public function testCanSetStartNicknameProperty() + { + $this->query->setDomain("my.domain.com"); + $this->query->setNickname("foo"); + $this->query->setStartNickname("bar"); + $this->assertEquals("bar", $this->query->getStartNickname()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/nickname/2.0/foo?startNickname=bar", + $this->query->getQueryUrl()); + + $this->query->setStartNickname(null); + $this->assertEquals(null, $this->query->getStartNickname()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/nickname/2.0/foo", + $this->query->getQueryUrl()); + } + + + // Test to make sure that all parameters can be set simultaneously with no + // ill effects. + public function testCanSetAllParameters() + { + $this->query->setDomain("my.domain.com"); + $this->query->setNickname("foo"); + $this->query->setUsername("bar"); + $this->query->setStartNickname("baz"); + $this->assertEquals("foo", $this->query->getNickname()); + $this->assertEquals("bar", $this->query->getUsername()); + $this->assertEquals("baz", $this->query->getStartNickname()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/nickname/2.0/foo?username=bar&startNickname=baz", + $this->query->getQueryUrl()); + + $this->query->setUsername("qux"); + $this->query->setNickname("baz"); + $this->query->setStartNickname("wibble"); + $this->assertEquals("baz", $this->query->getNickname()); + $this->assertEquals("qux", $this->query->getUsername()); + $this->assertEquals("wibble", $this->query->getStartNickname()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/nickname/2.0/baz?username=qux&startNickname=wibble", + $this->query->getQueryUrl()); + } + +} diff --git a/zend/tests/Zend/Gdata/Gapps/NicknameTest.php b/zend/tests/Zend/Gdata/Gapps/NicknameTest.php new file mode 100644 index 0000000..c668c22 --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/NicknameTest.php @@ -0,0 +1,126 @@ +nicknameText = file_get_contents( + 'Zend/Gdata/Gapps/_files/NicknameElementSample1.xml', + true); + $this->nickname = new Zend_Gdata_Gapps_Extension_Nickname(); + } + + public function testEmptyNicknameShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->nickname->extensionElements)); + $this->assertTrue(count($this->nickname->extensionElements) == 0); + } + + public function testEmptyNicknameShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->nickname->extensionAttributes)); + $this->assertTrue(count($this->nickname->extensionAttributes) == 0); + } + + public function testSampleNicknameShouldHaveNoExtensionElements() { + $this->nickname->transferFromXML($this->nicknameText); + $this->assertTrue(is_array($this->nickname->extensionElements)); + $this->assertTrue(count($this->nickname->extensionElements) == 0); + } + + public function testSampleNicknameShouldHaveNoExtensionAttributes() { + $this->nickname->transferFromXML($this->nicknameText); + $this->assertTrue(is_array($this->nickname->extensionAttributes)); + $this->assertTrue(count($this->nickname->extensionAttributes) == 0); + } + + public function testNormalNicknameShouldHaveNoExtensionElements() { + $this->nickname->name = "Trogdor"; + + $this->assertEquals("Trogdor", $this->nickname->name); + + $this->assertEquals(0, count($this->nickname->extensionElements)); + $newNickname = new Zend_Gdata_Gapps_Extension_Nickname(); + $newNickname->transferFromXML($this->nickname->saveXML()); + $this->assertEquals(0, count($newNickname->extensionElements)); + $newNickname->extensionElements = array( + new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); + $this->assertEquals(1, count($newNickname->extensionElements)); + $this->assertEquals("Trogdor", $newNickname->name); + + /* try constructing using magic factory */ + $gdata = new Zend_Gdata_Gapps(); + $newNickname2 = $gdata->newNickname(); + $newNickname2->transferFromXML($newNickname->saveXML()); + $this->assertEquals(1, count($newNickname2->extensionElements)); + $this->assertEquals("Trogdor", $newNickname2->name); + } + + public function testEmptyNicknameToAndFromStringShouldMatch() { + $nicknameXml = $this->nickname->saveXML(); + $newNickname = new Zend_Gdata_Gapps_Extension_Nickname(); + $newNickname->transferFromXML($nicknameXml); + $newNicknameXml = $newNickname->saveXML(); + $this->assertTrue($nicknameXml == $newNicknameXml); + } + + public function testNicknameWithValueToAndFromStringShouldMatch() { + $this->nickname->name = "Trogdor"; + $nicknameXml = $this->nickname->saveXML(); + $newNickname = new Zend_Gdata_Gapps_Extension_Nickname(); + $newNickname->transferFromXML($nicknameXml); + $newNicknameXml = $newNickname->saveXML(); + $this->assertTrue($nicknameXml == $newNicknameXml); + $this->assertEquals("Trogdor", $this->nickname->name); + } + + public function testExtensionAttributes() { + $extensionAttributes = $this->nickname->extensionAttributes; + $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); + $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); + $this->nickname->extensionAttributes = $extensionAttributes; + $this->assertEquals('bar', $this->nickname->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $this->nickname->extensionAttributes['foo2']['value']); + $nicknameXml = $this->nickname->saveXML(); + $newNickname = new Zend_Gdata_Gapps_Extension_Nickname(); + $newNickname->transferFromXML($nicknameXml); + $this->assertEquals('bar', $newNickname->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $newNickname->extensionAttributes['foo2']['value']); + } + + public function testConvertFullNicknameToAndFromString() { + $this->nickname->transferFromXML($this->nicknameText); + $this->assertEquals("Jones", $this->nickname->name); + } + +} diff --git a/zend/tests/Zend/Gdata/Gapps/OwnerEntryTest.php b/zend/tests/Zend/Gdata/Gapps/OwnerEntryTest.php new file mode 100644 index 0000000..1e20636 --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/OwnerEntryTest.php @@ -0,0 +1,104 @@ +entryText = file_get_contents( + 'Zend/Gdata/Gapps/_files/OwnerEntryDataSample1.xml', + true); + $this->entry = new Zend_Gdata_Gapps_OwnerEntry(); + } + + private function verifyAllSamplePropertiesAreCorrect ($ownerEntry) { + $this->assertEquals('https://www.google.com/a/feeds/group/2.0/example.com/us-sales/owner/joe%40example.com', + $ownerEntry->id->text); + $this->assertEquals('1970-01-01T00:00:00.000Z', $ownerEntry->updated->text); + $this->assertEquals('self', $ownerEntry->getLink('self')->rel); + $this->assertEquals('application/atom+xml', $ownerEntry->getLink('self')->type); + $this->assertEquals('https://www.google.com/a/feeds/group/2.0/example.com/us-sales/owner/joe%40example.com', $ownerEntry->getLink('self')->href); + $this->assertEquals('edit', $ownerEntry->getLink('edit')->rel); + $this->assertEquals('application/atom+xml', $ownerEntry->getLink('edit')->type); + $this->assertEquals('https://www.google.com/a/feeds/group/2.0/example.com/us-sales/owner/joe%40example.com', $ownerEntry->getLink('edit')->href); + $this->assertEquals('email', $ownerEntry->property[0]->name); + $this->assertEquals('joe@example.com', $ownerEntry->property[0]->value); + } + + public function testEmptyEntryShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->entry->extensionElements)); + $this->assertTrue(count($this->entry->extensionElements) == 0); + } + + public function testEmptyEntryShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->entry->extensionAttributes)); + $this->assertTrue(count($this->entry->extensionAttributes) == 0); + } + + public function testSampleEntryShouldHaveNoExtensionElements() { + $this->entry->transferFromXML($this->entryText); + $this->assertTrue(is_array($this->entry->extensionElements)); + $this->assertTrue(count($this->entry->extensionElements) == 0); + } + + public function testSampleEntryShouldHaveNoExtensionAttributes() { + $this->entry->transferFromXML($this->entryText); + $this->assertTrue(is_array($this->entry->extensionAttributes)); + $this->assertTrue(count($this->entry->extensionAttributes) == 0); + } + + public function testEmptyOwnerEntryToAndFromStringShouldMatch() { + $entryXml = $this->entry->saveXML(); + $newOwnerEntry = new Zend_Gdata_Gapps_OwnerEntry(); + $newOwnerEntry->transferFromXML($entryXml); + $newOwnerEntryXml = $newOwnerEntry->saveXML(); + $this->assertTrue($entryXml == $newOwnerEntryXml); + } + + public function testSamplePropertiesAreCorrect () { + $this->entry->transferFromXML($this->entryText); + $this->verifyAllSamplePropertiesAreCorrect($this->entry); + } + + public function testConvertOwnerEntryToAndFromString() { + $this->entry->transferFromXML($this->entryText); + $entryXml = $this->entry->saveXML(); + $newOwnerEntry = new Zend_Gdata_Gapps_OwnerEntry(); + $newOwnerEntry->transferFromXML($entryXml); + $this->verifyAllSamplePropertiesAreCorrect($newOwnerEntry); + $newOwnerEntryXml = $newOwnerEntry->saveXML(); + $this->assertEquals($entryXml, $newOwnerEntryXml); + } + +} diff --git a/zend/tests/Zend/Gdata/Gapps/OwnerFeedTest.php b/zend/tests/Zend/Gdata/Gapps/OwnerFeedTest.php new file mode 100644 index 0000000..eb0810b --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/OwnerFeedTest.php @@ -0,0 +1,109 @@ +ownerFeed = new Zend_Gdata_Gapps_OwnerFeed($ownerFeedText); + $this->emptyOwnerFeed = new Zend_Gdata_Gapps_OwnerFeed(); + } + + public function testEmptyFeedShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->emptyOwnerFeed->extensionElements)); + $this->assertTrue(count($this->emptyOwnerFeed->extensionElements) == 0); + } + + public function testEmptyFeedShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->emptyOwnerFeed->extensionAttributes)); + $this->assertTrue(count($this->emptyOwnerFeed->extensionAttributes) == 0); + } + + public function testSampleFeedShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->ownerFeed->extensionElements)); + $this->assertTrue(count($this->ownerFeed->extensionElements) == 0); + } + + public function testSampleFeedShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->ownerFeed->extensionAttributes)); + $this->assertTrue(count($this->ownerFeed->extensionAttributes) == 0); + } + + /** + * Convert sample feed to XML then back to objects. Ensure that + * all objects are instances of OwnerEntry and object count matches. + */ + public function testXmlImportAndOutputAreNonDestructive() + { + $entryCount = 0; + foreach ($this->ownerFeed as $entry) { + $entryCount++; + $this->assertTrue($entry instanceof Zend_Gdata_Gapps_OwnerEntry); + } + $this->assertTrue($entryCount > 0); + + /* Grab XML from $this->ownerFeed and convert back to objects */ + $newOwnerFeed = new Zend_Gdata_Gapps_OwnerFeed( + $this->ownerFeed->saveXML()); + $newEntryCount = 0; + foreach ($newOwnerFeed as $entry) { + $newEntryCount++; + $this->assertTrue($entry instanceof Zend_Gdata_Gapps_OwnerEntry); + } + $this->assertEquals($entryCount, $newEntryCount); + } + + /** + * Ensure that there number of owner entries equals the number + * of owners defined in the sample file. + */ + public function testAllEntriesInFeedAreInstantiated() + { + //TODO feeds implementing ArrayAccess would be helpful here + $entryCount = 0; + foreach ($this->ownerFeed as $entry) { + $entryCount++; + } + $this->assertEquals(2, $entryCount); + } + +} diff --git a/zend/tests/Zend/Gdata/Gapps/OwnerQueryTest.php b/zend/tests/Zend/Gdata/Gapps/OwnerQueryTest.php new file mode 100644 index 0000000..69342aa --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/OwnerQueryTest.php @@ -0,0 +1,91 @@ +query = new Zend_Gdata_Gapps_OwnerQuery(); + } + + // Test to make sure that the domain accessor methods work and propagate + // to the query URI. + public function testCanSetQueryDomain() + { + $this->query->setGroupId("something"); + $this->query->setDomain("my.domain.com"); + $this->assertEquals("my.domain.com", $this->query->getDomain()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/group/2.0/my.domain.com/something/owner", + $this->query->getQueryUrl()); + + $this->query->setDomain("hello.world.baz"); + $this->assertEquals("hello.world.baz", $this->query->getDomain()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/group/2.0/hello.world.baz/something/owner", + $this->query->getQueryUrl()); + } + + // Test to make sure that the groupId accessor methods work and propagate + // to the query URI. + public function testCanSetGroupIdProperty() + { + $this->query->setDomain("my.domain.com"); + $this->query->setGroupId("foo"); + $this->assertEquals("foo", $this->query->getGroupId()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/group/2.0/my.domain.com/foo/owner", + $this->query->getQueryUrl()); + + $this->query->setGroupId("bar"); + $this->assertEquals("bar", $this->query->getGroupId()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/group/2.0/my.domain.com/bar/owner", + $this->query->getQueryUrl()); + } + + public function testCanSetOwnerEmailProperty() + { + $this->query->setDomain("my.domain.com"); + $this->query->setGroupId("foo"); + $this->query->setOwnerEmail("bar@blah.com"); + $this->assertEquals("bar@blah.com", $this->query->getOwnerEmail()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/group/2.0/my.domain.com/foo/owner/bar@blah.com", + $this->query->getQueryUrl()); + + $this->query->setOwnerEmail('baz@blah.com'); + $this->assertEquals('baz@blah.com', $this->query->getOwnerEmail()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/group/2.0/my.domain.com/foo/owner/baz@blah.com", + $this->query->getQueryUrl()); + } + +} + diff --git a/zend/tests/Zend/Gdata/Gapps/PropertyTest.php b/zend/tests/Zend/Gdata/Gapps/PropertyTest.php new file mode 100644 index 0000000..b16abf6 --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/PropertyTest.php @@ -0,0 +1,133 @@ +thePropertyText = file_get_contents( + 'Zend/Gdata/Gapps/_files/PropertyElementSample1.xml', + true); + $this->theProperty = new Zend_Gdata_Gapps_Extension_Property(); + } + + public function testEmptyPropertyShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->theProperty->extensionElements)); + $this->assertTrue(count($this->theProperty->extensionElements) == 0); + } + + public function testEmptyPropertyShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->theProperty->extensionAttributes)); + $this->assertTrue(count($this->theProperty->extensionAttributes) == 0); + } + + public function testSamplePropertyShouldHaveNoExtensionElements() { + $this->theProperty->transferFromXML($this->thePropertyText); + $this->assertTrue(is_array($this->theProperty->extensionElements)); + $this->assertTrue(count($this->theProperty->extensionElements) == 0); + } + + public function testSamplePropertyShouldHaveNoExtensionAttributes() { + $this->theProperty->transferFromXML($this->thePropertyText); + $this->assertTrue(is_array($this->theProperty->extensionAttributes)); + $this->assertTrue(count($this->theProperty->extensionAttributes) == 0); + } + + public function testNormalPropertyShouldHaveNoExtensionElements() { + $this->theProperty->name = "foo"; + $this->theProperty->value = "bar"; + + $this->assertEquals("foo", $this->theProperty->name); + $this->assertEquals("bar", $this->theProperty->value); + + $this->assertEquals(0, count($this->theProperty->extensionElements)); + $newProperty = new Zend_Gdata_Gapps_Extension_Property(); + $newProperty->transferFromXML($this->theProperty->saveXML()); + $this->assertEquals(0, count($newProperty->extensionElements)); + $newProperty->extensionElements = array( + new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); + $this->assertEquals(1, count($newProperty->extensionElements)); + $this->assertEquals("foo", $newProperty->name); + $this->assertEquals("bar", $newProperty->value); + + /* try constructing using magic factory */ + $gdata = new Zend_Gdata_Gapps(); + $newProperty2 = $gdata->newProperty(); + $newProperty2->transferFromXML($newProperty->saveXML()); + $this->assertEquals(1, count($newProperty2->extensionElements)); + $this->assertEquals("foo", $newProperty2->name); + $this->assertEquals("bar", $newProperty2->value); + } + + public function testEmptyPropertyToAndFromStringShouldMatch() { + $propertyXml = $this->theProperty->saveXML(); + $newProperty = new Zend_Gdata_Gapps_Extension_Property(); + $newProperty->transferFromXML($propertyXml); + $newPropertyXml = $newProperty->saveXML(); + $this->assertTrue($propertyXml == $newPropertyXml); + } + + public function testPropertyWithValueToAndFromStringShouldMatch() { + $this->theProperty->name = "foo2"; + $this->theProperty->value = "bar2"; + $propertyXml = $this->theProperty->saveXML(); + $newProperty = new Zend_Gdata_Gapps_Extension_Property(); + $newProperty->transferFromXML($propertyXml); + $newPropertyXml = $newProperty->saveXML(); + $this->assertTrue($propertyXml == $newPropertyXml); + $this->assertEquals("foo2", $this->theProperty->name); + $this->assertEquals("bar2", $this->theProperty->value); + } + + public function testExtensionAttributes() { + $extensionAttributes = $this->theProperty->extensionAttributes; + $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); + $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); + $this->theProperty->extensionAttributes = $extensionAttributes; + $this->assertEquals('bar', $this->theProperty->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $this->theProperty->extensionAttributes['foo2']['value']); + $propertyXml = $this->theProperty->saveXML(); + $newProperty = new Zend_Gdata_Gapps_Extension_Property(); + $newProperty->transferFromXML($propertyXml); + $this->assertEquals('bar', $newProperty->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $newProperty->extensionAttributes['foo2']['value']); + } + + public function testConvertFullNameToAndFromString() { + $this->theProperty->transferFromXML($this->thePropertyText); + $this->assertEquals("Some Name", $this->theProperty->name); + $this->assertEquals("Some Value", $this->theProperty->value); + } + +} diff --git a/zend/tests/Zend/Gdata/Gapps/QuotaTest.php b/zend/tests/Zend/Gdata/Gapps/QuotaTest.php new file mode 100644 index 0000000..040a160 --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/QuotaTest.php @@ -0,0 +1,126 @@ +quotaText = file_get_contents( + 'Zend/Gdata/Gapps/_files/QuotaElementSample1.xml', + true); + $this->quota = new Zend_Gdata_Gapps_Extension_Quota(); + } + + public function testEmptyQuotaShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->quota->extensionElements)); + $this->assertTrue(count($this->quota->extensionElements) == 0); + } + + public function testEmptyQuotaShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->quota->extensionAttributes)); + $this->assertTrue(count($this->quota->extensionAttributes) == 0); + } + + public function testSampleQuotaShouldHaveNoExtensionElements() { + $this->quota->transferFromXML($this->quotaText); + $this->assertTrue(is_array($this->quota->extensionElements)); + $this->assertTrue(count($this->quota->extensionElements) == 0); + } + + public function testSampleQuotaShouldHaveNoExtensionAttributes() { + $this->quota->transferFromXML($this->quotaText); + $this->assertTrue(is_array($this->quota->extensionAttributes)); + $this->assertTrue(count($this->quota->extensionAttributes) == 0); + } + + public function testNormalQuotaShouldHaveNoExtensionElements() { + $this->quota->limit = "123456789"; + + $this->assertEquals("123456789", $this->quota->limit); + + $this->assertEquals(0, count($this->quota->extensionElements)); + $newQuota = new Zend_Gdata_Gapps_Extension_Quota(); + $newQuota->transferFromXML($this->quota->saveXML()); + $this->assertEquals(0, count($newQuota->extensionElements)); + $newQuota->extensionElements = array( + new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); + $this->assertEquals(1, count($newQuota->extensionElements)); + $this->assertEquals("123456789", $newQuota->limit); + + /* try constructing using magic factory */ + $gdata = new Zend_Gdata_Gapps(); + $newQuota2 = $gdata->newQuota(); + $newQuota2->transferFromXML($newQuota->saveXML()); + $this->assertEquals(1, count($newQuota2->extensionElements)); + $this->assertEquals("123456789", $newQuota2->limit); + } + + public function testEmptyQuotaToAndFromStringShouldMatch() { + $quotaXml = $this->quota->saveXML(); + $newQuota = new Zend_Gdata_Gapps_Extension_Quota(); + $newQuota->transferFromXML($quotaXml); + $newQuotaXml = $newQuota->saveXML(); + $this->assertTrue($quotaXml == $newQuotaXml); + } + + public function testQuotaWithValueToAndFromStringShouldMatch() { + $this->quota->limit = "123456789"; + $quotaXml = $this->quota->saveXML(); + $newQuota = new Zend_Gdata_Gapps_Extension_Quota(); + $newQuota->transferFromXML($quotaXml); + $newQuotaXml = $newQuota->saveXML(); + $this->assertTrue($quotaXml == $newQuotaXml); + $this->assertEquals("123456789", $this->quota->limit); + } + + public function testExtensionAttributes() { + $extensionAttributes = $this->quota->extensionAttributes; + $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); + $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); + $this->quota->extensionAttributes = $extensionAttributes; + $this->assertEquals('bar', $this->quota->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $this->quota->extensionAttributes['foo2']['value']); + $quotaXml = $this->quota->saveXML(); + $newQuota = new Zend_Gdata_Gapps_Extension_Quota(); + $newQuota->transferFromXML($quotaXml); + $this->assertEquals('bar', $newQuota->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $newQuota->extensionAttributes['foo2']['value']); + } + + public function testConvertFullQuotaToAndFromString() { + $this->quota->transferFromXML($this->quotaText); + $this->assertEquals("2048", $this->quota->limit); + } + +} diff --git a/zend/tests/Zend/Gdata/Gapps/ServiceExceptionTest.php b/zend/tests/Zend/Gdata/Gapps/ServiceExceptionTest.php new file mode 100644 index 0000000..5a96290 --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/ServiceExceptionTest.php @@ -0,0 +1,128 @@ +xmlSample = file_get_contents( + 'Zend/Gdata/Gapps/_files/AppsForYourDomainElementSample1.xml', + true); + $this->fixture = new Zend_Gdata_Gapps_ServiceException(); + $this->data[1] = new Zend_Gdata_Gapps_Error(1234, "foo", "bar"); + $this->data[2] = new Zend_Gdata_Gapps_Error(4317, "blah", "woof"); + $this->data[3] = new Zend_Gdata_Gapps_Error(5978, "blue", "puppy"); + $this->data[4] = new Zend_Gdata_Gapps_Error(2398, "red", "kitten"); + } + + /** + * @expectedException Zend_Gdata_Gapps_ServiceException + */ + public function testCanThrowServiceException() { + throw $this->fixture; + } + + public function testCanSetAndGetErrorArray() { + $this->fixture->setErrors($this->data); + $incoming = $this->fixture->getErrors(); + $this->assertTrue(is_array($incoming)); + $this->assertEquals(count($this->data), count($incoming)); + foreach ($this->data as $i) { + $this->assertEquals($i, $incoming[$i->getErrorCode()]); + } + } + + public function testCanInsertSingleError() { + $this->fixture->setErrors($this->data); + $outgoing = new Zend_Gdata_Gapps_Error(1111, "a", "b"); + $this->fixture->addError($outgoing); + $result = $this->fixture->getError(1111); + $this->assertEquals($outgoing, $result); + } + + public function testCanSetPropertiesViaConstructor() { + $this->fixture = new Zend_Gdata_Gapps_ServiceException($this->data); + $incoming = $this->fixture->getErrors(); + $this->assertTrue(is_array($incoming)); + $this->assertEquals(count($this->data), count($incoming)); + foreach($this->data as $i) { + $this->assertEquals($i, $incoming[$i->getErrorCode()]); + } + } + + public function testCanRetrieveASpecificErrorByCode() { + $this->fixture->setErrors($this->data); + $result = $this->fixture->getError(5978); + $this->assertEquals($this->data[3], $result); + } + + public function testRetrievingNonexistantErrorCodeReturnsNull() { + $this->fixture->setErrors($this->data); + $result = $this->fixture->getError(0000); + $this->assertEquals(null, $result); + } + + public function testCanCheckIfAKeyExists() { + $this->fixture->setErrors($this->data); + $this->assertTrue($this->fixture->hasError(2398)); + $this->assertFalse($this->fixture->hasError(0000)); + } + + public function testCanConvertFromXML() { + $this->fixture->importFromString($this->xmlSample); + $incoming = $this->fixture->getErrors(); + $this->assertTrue(is_array($incoming)); + $this->assertEquals(3, count($incoming)); + $this->assertEquals("9925", $incoming[9925]->errorCode); + $this->assertEquals("Foo", $incoming[9925]->invalidInput); + $this->assertEquals("Bar", $incoming[9925]->reason); + } + + public function testCanConvertToString() { + $this->fixture->setErrors($this->data); + $this->assertEquals("The server encountered the following errors processing the request: +Error 1234: foo +\tInvalid Input: \"bar\" +Error 4317: blah +\tInvalid Input: \"woof\" +Error 5978: blue +\tInvalid Input: \"puppy\" +Error 2398: red +\tInvalid Input: \"kitten\"", $this->fixture->__toString()); + } + +} diff --git a/zend/tests/Zend/Gdata/Gapps/UserEntryTest.php b/zend/tests/Zend/Gdata/Gapps/UserEntryTest.php new file mode 100644 index 0000000..971d56b --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/UserEntryTest.php @@ -0,0 +1,145 @@ +entryText = file_get_contents( + 'Zend/Gdata/Gapps/_files/UserEntryDataSample1.xml', + true); + $this->entry = new Zend_Gdata_Gapps_UserEntry(); + } + + private function verifyAllSamplePropertiesAreCorrect ($userEntry) { + $this->assertEquals('https://apps-apis.google.com/a/feeds/example.com/user/2.0/SusanJones', + $userEntry->id->text); + $this->assertEquals('1970-01-01T00:00:00.000Z', $userEntry->updated->text); + $this->assertEquals('http://schemas.google.com/g/2005#kind', $userEntry->category[0]->scheme); + $this->assertEquals('http://schemas.google.com/apps/2006#user', $userEntry->category[0]->term); + $this->assertEquals('text', $userEntry->title->type); + $this->assertEquals('SusanJones', $userEntry->title->text);; + $this->assertEquals('self', $userEntry->getLink('self')->rel); + $this->assertEquals('application/atom+xml', $userEntry->getLink('self')->type); + $this->assertEquals('https://apps-apis.google.com/a/feeds/example.com/user/2.0/SusanJones', $userEntry->getLink('self')->href); + $this->assertEquals('edit', $userEntry->getLink('edit')->rel); + $this->assertEquals('application/atom+xml', $userEntry->getLink('edit')->type); + $this->assertEquals('https://apps-apis.google.com/a/feeds/example.com/user/2.0/SusanJones', $userEntry->getLink('edit')->href); + $this->assertEquals('SusanJones', $userEntry->login->username); + $this->assertEquals('Jones', $userEntry->name->familyName); + $this->assertEquals('Susan', $userEntry->name->givenName); + $this->assertEquals('http://schemas.google.com/apps/2006#user.nicknames', $userEntry->getFeedLink('http://schemas.google.com/apps/2006#user.nicknames')->rel); + $this->assertEquals('https://apps-apis.google.com/a/feeds/example.com/nickname/2.0?username=Susy-1321', $userEntry->getFeedLink('http://schemas.google.com/apps/2006#user.nicknames')->href); + $this->assertEquals('http://schemas.google.com/apps/2006#user.emailLists', $userEntry->getFeedLink('http://schemas.google.com/apps/2006#user.emailLists')->rel); + $this->assertEquals('https://apps-apis.google.com/a/feeds/example.com/emailList/2.0?recipient=us-sales@example.com', $userEntry->getFeedLink('http://schemas.google.com/apps/2006#user.emailLists')->href); + $this->assertEquals('2048', $userEntry->quota->limit); + } + + public function testEmptyEntryShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->entry->extensionElements)); + $this->assertTrue(count($this->entry->extensionElements) == 0); + } + + public function testEmptyEntryShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->entry->extensionAttributes)); + $this->assertTrue(count($this->entry->extensionAttributes) == 0); + } + + public function testSampleEntryShouldHaveNoExtensionElements() { + $this->entry->transferFromXML($this->entryText); + $this->assertTrue(is_array($this->entry->extensionElements)); + $this->assertTrue(count($this->entry->extensionElements) == 0); + } + + public function testSampleEntryShouldHaveNoExtensionAttributes() { + $this->entry->transferFromXML($this->entryText); + $this->assertTrue(is_array($this->entry->extensionAttributes)); + $this->assertTrue(count($this->entry->extensionAttributes) == 0); + } + + public function testEmptyUserEntryToAndFromStringShouldMatch() { + $entryXml = $this->entry->saveXML(); + $newUserEntry = new Zend_Gdata_Gapps_UserEntry(); + $newUserEntry->transferFromXML($entryXml); + $newUserEntryXml = $newUserEntry->saveXML(); + $this->assertTrue($entryXml == $newUserEntryXml); + } + + public function testGetFeedLinkReturnsAllStoredEntriesWhenUsedWithNoParameters() { + // Prepare test data + $entry1 = new Zend_Gdata_Extension_FeedLink(); + $entry1->rel = "first"; + $entry1->href= "foo"; + $entry2 = new Zend_Gdata_Extension_FeedLink(); + $entry2->rel = "second"; + $entry2->href= "bar"; + $data = array($entry1, $entry2); + + // Load test data and run test + $this->entry->feedLink = $data; + $this->assertEquals(2, count($this->entry->feedLink)); + } + + public function testGetFeedLinkCanReturnEntriesByRelValue() { + // Prepare test data + $entry1 = new Zend_Gdata_Extension_FeedLink(); + $entry1->rel = "first"; + $entry1->href= "foo"; + $entry2 = new Zend_Gdata_Extension_FeedLink(); + $entry2->rel = "second"; + $entry2->href= "bar"; + $data = array($entry1, $entry2); + + // Load test data and run test + $this->entry->feedLink = $data; + $this->assertEquals($entry1, $this->entry->getFeedLink('first')); + $this->assertEquals($entry2, $this->entry->getFeedLink('second')); + } + + public function testSamplePropertiesAreCorrect () { + $this->entry->transferFromXML($this->entryText); + $this->verifyAllSamplePropertiesAreCorrect($this->entry); + } + + public function testConvertUserEntryToAndFromString() { + $this->entry->transferFromXML($this->entryText); + $entryXml = $this->entry->saveXML(); + $newUserEntry = new Zend_Gdata_Gapps_UserEntry(); + $newUserEntry->transferFromXML($entryXml); + $this->verifyAllSamplePropertiesAreCorrect($newUserEntry); + $newUserEntryXml = $newUserEntry->saveXML(); + $this->assertEquals($entryXml, $newUserEntryXml); + } + +} diff --git a/zend/tests/Zend/Gdata/Gapps/UserFeedTest.php b/zend/tests/Zend/Gdata/Gapps/UserFeedTest.php new file mode 100644 index 0000000..1fc4793 --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/UserFeedTest.php @@ -0,0 +1,109 @@ +userFeed = new Zend_Gdata_Gapps_UserFeed($userFeedText); + $this->emptyUserFeed = new Zend_Gdata_Gapps_UserFeed(); + } + + public function testEmptyFeedShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->emptyUserFeed->extensionElements)); + $this->assertTrue(count($this->emptyUserFeed->extensionElements) == 0); + } + + public function testEmptyFeedShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->emptyUserFeed->extensionAttributes)); + $this->assertTrue(count($this->emptyUserFeed->extensionAttributes) == 0); + } + + public function testSampleFeedShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->userFeed->extensionElements)); + $this->assertTrue(count($this->userFeed->extensionElements) == 0); + } + + public function testSampleFeedShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->userFeed->extensionAttributes)); + $this->assertTrue(count($this->userFeed->extensionAttributes) == 0); + } + + /** + * Convert sample feed to XML then back to objects. Ensure that + * all objects are instances of EventEntry and object count matches. + */ + public function testXmlImportAndOutputAreNonDestructive() + { + $entryCount = 0; + foreach ($this->userFeed as $entry) { + $entryCount++; + $this->assertTrue($entry instanceof Zend_Gdata_Gapps_UserEntry); + } + $this->assertTrue($entryCount > 0); + + /* Grab XML from $this->userFeed and convert back to objects */ + $newUserFeed = new Zend_Gdata_Gapps_UserFeed( + $this->userFeed->saveXML()); + $newEntryCount = 0; + foreach ($newUserFeed as $entry) { + $newEntryCount++; + $this->assertTrue($entry instanceof Zend_Gdata_Gapps_UserEntry); + } + $this->assertEquals($entryCount, $newEntryCount); + } + + /** + * Ensure that there number of lsit feeds equals the number + * of calendars defined in the sample file. + */ + public function testAllEntriesInFeedAreInstantiated() + { + //TODO feeds implementing ArrayAccess would be helpful here + $entryCount = 0; + foreach ($this->userFeed as $entry) { + $entryCount++; + } + $this->assertEquals(2, $entryCount); + } + +} diff --git a/zend/tests/Zend/Gdata/Gapps/UserQueryTest.php b/zend/tests/Zend/Gdata/Gapps/UserQueryTest.php new file mode 100644 index 0000000..7a94f31 --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/UserQueryTest.php @@ -0,0 +1,98 @@ +query = new Zend_Gdata_Gapps_UserQuery(); + } + + // Test to make sure that URI generation works + public function testDefaultQueryURIGeneration() + { + $this->query->setDomain("foo.bar.invalid"); + $this->assertEquals("https://apps-apis.google.com/a/feeds/foo.bar.invalid/user/2.0", + $this->query->getQueryUrl()); + } + + // Test to make sure that the domain accessor methods work and propagate + // to the query URI. + public function testCanSetQueryDomain() + { + $this->query->setDomain("my.domain.com"); + $this->assertEquals("my.domain.com", $this->query->getDomain()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/user/2.0", + $this->query->getQueryUrl()); + + $this->query->setDomain("hello.world.baz"); + $this->assertEquals("hello.world.baz", $this->query->getDomain()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/hello.world.baz/user/2.0", + $this->query->getQueryUrl()); + } + + // Test to make sure that the username accessor methods work and propagate + // to the query URI. + public function testCanSetUsernameProperty() + { + $this->query->setDomain("my.domain.com"); + $this->query->setUsername("foo"); + $this->assertEquals("foo", $this->query->getUsername()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/user/2.0/foo", + $this->query->getQueryUrl()); + + $this->query->setUsername("bar"); + $this->assertEquals("bar", $this->query->getUsername()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/user/2.0/bar", + $this->query->getQueryUrl()); + } + + // Test to make sure that the startUsername accessor methods work and + // propagate to the query URI. + public function testCanSetStartUsernameProperty() + { + $this->query->setDomain("my.domain.com"); + $this->query->setStartUsername("foo"); + $this->assertEquals("foo", $this->query->getStartUsername()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/user/2.0?startUsername=foo", + $this->query->getQueryUrl()); + + $this->query->setStartUsername(null); + $this->assertEquals(null, $this->query->getStartUsername()); + $this->assertEquals("https://apps-apis.google.com/a/feeds/my.domain.com/user/2.0", + $this->query->getQueryUrl()); + } + +} diff --git a/zend/tests/Zend/Gdata/Gapps/_files/AppsForYourDomainElementSample1.xml b/zend/tests/Zend/Gdata/Gapps/_files/AppsForYourDomainElementSample1.xml new file mode 100644 index 0000000..e4ec89f --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/_files/AppsForYourDomainElementSample1.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/zend/tests/Zend/Gdata/Gapps/_files/EmailListElementSample1.xml b/zend/tests/Zend/Gdata/Gapps/_files/EmailListElementSample1.xml new file mode 100644 index 0000000..09349e8 --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/_files/EmailListElementSample1.xml @@ -0,0 +1,2 @@ + + diff --git a/zend/tests/Zend/Gdata/Gapps/_files/EmailListEntryDataSample1.xml b/zend/tests/Zend/Gdata/Gapps/_files/EmailListEntryDataSample1.xml new file mode 100644 index 0000000..ddbd2c7 --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/_files/EmailListEntryDataSample1.xml @@ -0,0 +1,17 @@ + + + https://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-sales + 1970-01-01T00:00:00.000Z + + us-sales + + + + + diff --git a/zend/tests/Zend/Gdata/Gapps/_files/EmailListFeedDataSample1.xml b/zend/tests/Zend/Gdata/Gapps/_files/EmailListFeedDataSample1.xml new file mode 100644 index 0000000..8d779c7 --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/_files/EmailListFeedDataSample1.xml @@ -0,0 +1,55 @@ + + + + http://apps-apis.google.com/a/feeds/example.com/emailList/2.0 + + 1970-01-01T00:00:00.000Z + + EmailLists + diff --git a/zend/tests/Zend/Gdata/Gapps/_files/EmailListRecipientEntryDataSample1.xml b/zend/tests/Zend/Gdata/Gapps/_files/EmailListRecipientEntryDataSample1.xml new file mode 100644 index 0000000..8bd3c8d --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/_files/EmailListRecipientEntryDataSample1.xml @@ -0,0 +1,15 @@ + + + https://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient/SusanJones%40example.com + 1970-01-01T00:00:00.000Z + + SusanJones + + + + diff --git a/zend/tests/Zend/Gdata/Gapps/_files/EmailListRecipientFeedDataSample1.xml b/zend/tests/Zend/Gdata/Gapps/_files/EmailListRecipientFeedDataSample1.xml new file mode 100644 index 0000000..b217c0d --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/_files/EmailListRecipientFeedDataSample1.xml @@ -0,0 +1,51 @@ + + + + http://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient + + 1970-01-01T00:00:00.000Z + + Recipients for email list us-sales + diff --git a/zend/tests/Zend/Gdata/Gapps/_files/GroupEntryDataSample1.xml b/zend/tests/Zend/Gdata/Gapps/_files/GroupEntryDataSample1.xml new file mode 100644 index 0000000..a23e6b5 --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/_files/GroupEntryDataSample1.xml @@ -0,0 +1,14 @@ + + + https://www.google.com/a/feeds/group/2.0/example.com/us-sales + 1970-01-01T00:00:00.000Z + + + + + + + + diff --git a/zend/tests/Zend/Gdata/Gapps/_files/GroupFeedDataSample1.xml b/zend/tests/Zend/Gdata/Gapps/_files/GroupFeedDataSample1.xml new file mode 100644 index 0000000..c37ec26 --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/_files/GroupFeedDataSample1.xml @@ -0,0 +1,31 @@ + + + https://www.google.com/a/feeds/group/2.0/example.com + 2008-12-03T16:33:05.260Z + + + + 1 + + https://apps-apis.google.com/a/feeds/group/2.0/example.com/us-sales%40example.com + 2008-12-03T16:33:05.261Z + + + + + + + + + https://apps-apis.google.com/a/feeds/group/2.0/example.com/Staff-2435%40example.com + 2008-12-03T16:33:05.260Z + + + + + + + + \ No newline at end of file diff --git a/zend/tests/Zend/Gdata/Gapps/_files/LoginElementSample1.xml b/zend/tests/Zend/Gdata/Gapps/_files/LoginElementSample1.xml new file mode 100644 index 0000000..f6971dc --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/_files/LoginElementSample1.xml @@ -0,0 +1,2 @@ + + diff --git a/zend/tests/Zend/Gdata/Gapps/_files/MemberEntryDataSample1.xml b/zend/tests/Zend/Gdata/Gapps/_files/MemberEntryDataSample1.xml new file mode 100644 index 0000000..953fa2a --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/_files/MemberEntryDataSample1.xml @@ -0,0 +1,13 @@ + + + https://www.google.com/a/feeds/group/2.0/example.com/us-sales/member/suejones%40example.com + 1970-01-01T00:00:00.000Z + + + + + + + diff --git a/zend/tests/Zend/Gdata/Gapps/_files/MemberFeedDataSample1.xml b/zend/tests/Zend/Gdata/Gapps/_files/MemberFeedDataSample1.xml new file mode 100644 index 0000000..aa395ff --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/_files/MemberFeedDataSample1.xml @@ -0,0 +1,29 @@ + + + https://www.google.com/a/feeds/group/2.0/example.com/us-sales/member + + 1 + + https://www.google.com/a/feeds/group/2.0/example.com/us-sales/member/suejones%40example.com + + + + + + + + https://www.google.com/a/feeds/group/2.0/example.com/us-sales/member/ca-sales%40example.com + + + + + + + \ No newline at end of file diff --git a/zend/tests/Zend/Gdata/Gapps/_files/NameElementSample1.xml b/zend/tests/Zend/Gdata/Gapps/_files/NameElementSample1.xml new file mode 100644 index 0000000..4b30681 --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/_files/NameElementSample1.xml @@ -0,0 +1,2 @@ + + diff --git a/zend/tests/Zend/Gdata/Gapps/_files/NicknameElementSample1.xml b/zend/tests/Zend/Gdata/Gapps/_files/NicknameElementSample1.xml new file mode 100644 index 0000000..a986073 --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/_files/NicknameElementSample1.xml @@ -0,0 +1,2 @@ + + diff --git a/zend/tests/Zend/Gdata/Gapps/_files/NicknameEntryDataSample1.xml b/zend/tests/Zend/Gdata/Gapps/_files/NicknameEntryDataSample1.xml new file mode 100644 index 0000000..8c165ce --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/_files/NicknameEntryDataSample1.xml @@ -0,0 +1,16 @@ + + + https://apps-apis.google.com/a/feeds/example.com/nickname/2.0/Susy + 1970-01-01T00:00:00.000Z + + Susy + + + + + diff --git a/zend/tests/Zend/Gdata/Gapps/_files/NicknameFeedDataSample1.xml b/zend/tests/Zend/Gdata/Gapps/_files/NicknameFeedDataSample1.xml new file mode 100644 index 0000000..9598bf4 --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/_files/NicknameFeedDataSample1.xml @@ -0,0 +1,50 @@ + + + + http://apps-apis.google.com/a/feeds/example.com/nickname/2.0 + + 1970-01-01T00:00:00.000Z + + Nicknames for user SusanJones + + + + 1 + 2 + + + http://apps-apis.google.com/a/feeds/example.com/nickname/2.0/susy + + + susy + + + + + + + + http://apps-apis.google.com/a/feeds/example.com/nickname/2.0/suse + + + suse + + + + + + diff --git a/zend/tests/Zend/Gdata/Gapps/_files/OwnerEntryDataSample1.xml b/zend/tests/Zend/Gdata/Gapps/_files/OwnerEntryDataSample1.xml new file mode 100644 index 0000000..c59c87b --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/_files/OwnerEntryDataSample1.xml @@ -0,0 +1,10 @@ + + + https://www.google.com/a/feeds/group/2.0/example.com/us-sales/owner/joe%40example.com + 1970-01-01T00:00:00.000Z + + + + diff --git a/zend/tests/Zend/Gdata/Gapps/_files/OwnerFeedDataSample1.xml b/zend/tests/Zend/Gdata/Gapps/_files/OwnerFeedDataSample1.xml new file mode 100644 index 0000000..bf1c775 --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/_files/OwnerFeedDataSample1.xml @@ -0,0 +1,30 @@ + + + https://www.google.com/a/feeds/group/2.0/example.com/us-sales/owner + 1970-01-01T00:00:00.000Z + + + + 1 + + https://www.google.com/a/feeds/group/2.0/example.com/us-sales/owner/joe%40example.com + 1970-01-01T00:00:00.000Z + + + + + + https://www.google.com/a/feeds/group/2.0/example.com/us-sales/owner/suejones%40example.com + 1970-01-01T00:00:00.000Z + + + + + diff --git a/zend/tests/Zend/Gdata/Gapps/_files/PropertyElementSample1.xml b/zend/tests/Zend/Gdata/Gapps/_files/PropertyElementSample1.xml new file mode 100644 index 0000000..7402071 --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/_files/PropertyElementSample1.xml @@ -0,0 +1,2 @@ + + diff --git a/zend/tests/Zend/Gdata/Gapps/_files/QuotaElementSample1.xml b/zend/tests/Zend/Gdata/Gapps/_files/QuotaElementSample1.xml new file mode 100644 index 0000000..f516dbd --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/_files/QuotaElementSample1.xml @@ -0,0 +1,2 @@ + + diff --git a/zend/tests/Zend/Gdata/Gapps/_files/UserEntryDataSample1.xml b/zend/tests/Zend/Gdata/Gapps/_files/UserEntryDataSample1.xml new file mode 100644 index 0000000..0754443 --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/_files/UserEntryDataSample1.xml @@ -0,0 +1,20 @@ + + + https://apps-apis.google.com/a/feeds/example.com/user/2.0/SusanJones + 1970-01-01T00:00:00.000Z + + SusanJones + + + + + + + + diff --git a/zend/tests/Zend/Gdata/Gapps/_files/UserFeedDataSample1.xml b/zend/tests/Zend/Gdata/Gapps/_files/UserFeedDataSample1.xml new file mode 100644 index 0000000..ff4b78e --- /dev/null +++ b/zend/tests/Zend/Gdata/Gapps/_files/UserFeedDataSample1.xml @@ -0,0 +1,66 @@ + + + + http://apps-apis.google.com/a/feeds/example.com/user/2.0 + + 1970-01-01T00:00:00.000Z + + Users + diff --git a/zend/tests/Zend/Gdata/GappsOnlineTest.php b/zend/tests/Zend/Gdata/GappsOnlineTest.php new file mode 100644 index 0000000..4eecbac --- /dev/null +++ b/zend/tests/Zend/Gdata/GappsOnlineTest.php @@ -0,0 +1,834 @@ +id = uniqid('ZF-'); + $username = constant('TESTS_ZEND_GDATA_GAPPS_EMAIL'); + $pass = constant('TESTS_ZEND_GDATA_GAPPS_PASSWORD'); + $this->domain = constant('TESTS_ZEND_GDATA_GAPPS_DOMAIN'); + $client = Zend_Gdata_ClientLogin::getHttpClient($username, $pass, Zend_Gdata_Gapps::AUTH_SERVICE_NAME); + $this->gdata = new Zend_Gdata_Gapps($client, $this->domain); + + // Container to hold users and lists created during tests. All entries in + // here will have delete() called during tear down. + // + // Failed deletions are okay, so add everying creatd in here, even if + // you plan to delete the user yourself! + $this->autoDeletePool = array(); + } + + public function tearDown() + { + // Delete all entries in $this->autoDeletePool. + foreach ($this->autoDeletePool as $x) { + try { + $x->delete(); + } catch (Exception $e) { + // Failed deletes are okay. Try and delete the rest anyway. + } + } + } + + // Schedule an entry for deletion at test tear-down. + protected function autoDelete($entry) { + $this->autoDeletePool[] = $entry; + } + + // Test Create/Read/Update/Destroy operations on a UserEntry + public function testUserCRUDOperations() { + // Create a new user + $user = $this->gdata->createUser($this->id, self::GIVEN_NAME, self::FAMILY_NAME, + sha1(self::PASSWORD), self::PASSWORD_HASH); + $this->autoDelete($user); + + // Verify that returned values are correct + $this->assertEquals($this->id, $user->login->username); + $this->assertEquals(self::GIVEN_NAME, $user->name->givenName); + $this->assertEquals(self::FAMILY_NAME, $user->name->familyName); + + // Since we can't retrieve the password or hash function via the + // API, let's see if a ClientLogin auth request succeeds + try { + Zend_Gdata_ClientLogin::getHTTPClient($this->id . '@' . + $this->domain, self::PASSWORD, 'xapi'); + } catch (Zend_Gdata_App_AuthException $e) { + $this->fail("Unable to authenticate new user via ClientLogin."); + } + + // Check to make sure there are no extension elements/attributes + // in the retrieved user + $this->assertTrue(count($user->extensionElements) == 0); + $this->assertTrue(count($user->extensionAttributes) == 0); + + // Try searching for the same user and make sure that they're returned + $user2 = $this->gdata->retrieveUser($this->id); + $this->assertEquals($user->saveXML(), $user2->saveXML()); + + // Delete user (uses builtin delete method, convenience delete + // method tested further down) + $user->delete(); + + // Ensure that user was deleted + $deletedUser = $this->gdata->retrieveUser($this->id); + $this->assertNull($deletedUser); + } + + // Test to make sure that users with unicode characters can be created + // okay. + public function testUsersSupportUnicode() { + // Create a user + $user = $this->gdata->createUser($this->id, 'テスト', 'ユーザー', + sha1(self::PASSWORD), self::PASSWORD_HASH); + $this->autoDelete($user); + + // Make sure the user is the same as returned by the server + $this->assertEquals('テスト', $user->name->givenName); + $this->assertEquals('ユーザー', $user->name->familyName); + } + + // Test to make sure that a page of users can be retrieved. + public function testRetrievePageOfUsers() { + $feed = $this->gdata->retrievePageOfUsers(); + $this->assertTrue(count($feed->entries) > 0); + } + + // Test to make sure that a page of users can be retrieved with a + // startUsername parameter. + public function testRetrievePageOfUsersWithStartingUsername() { + $feed = $this->gdata->retrievePageOfUsers(); + $this->assertTrue(count($feed->entries) > 0); + $username = $feed->entries[0]->login->username; + $feed = $this->gdata->retrievePageOfUsers($username); + $this->assertTrue(count($feed->entries) > 0); + } + + // Test to see if all users can be retrieved + // NOTE: This test may timeout if the domain used for testing contains + // many pages of users. + public function testRetrieveAllUsers() { + // Create 35 users to make sure that there's more than one page. + for ($i = 0; $i < 25; $i++) { + $user = $this->gdata->createUser(uniqid('ZF-'), self::GIVEN_NAME, + self::FAMILY_NAME, sha1(self::PASSWORD), self::PASSWORD_HASH); + $this->autoDelete($user); + } + + $feed = $this->gdata->retrieveAllUsers(); + $this->assertTrue(count($feed->entry) > 0); + } + + // Test to see if a user can be manually updated by calling updateUser(). + public function testManualUserEntryUpdate() { + $user = $this->gdata->createUser($this->id, self::GIVEN_NAME, self::FAMILY_NAME, + sha1(self::PASSWORD), self::PASSWORD_HASH); + $this->autoDelete($user); + $user->name->givenName = "Renamed"; + $user2 = $this->gdata->updateUser($this->id, $user); + $this->assertEquals("Renamed", $user2->name->givenName); + } + + // Test to see if a user can be suspended, then un-suspended + public function testCanSuspendAndRestoreUser() { + $user = $this->gdata->createUser($this->id, self::GIVEN_NAME, self::FAMILY_NAME, + sha1(self::PASSWORD), self::PASSWORD_HASH); + $this->autoDelete($user); + + $returned = $this->gdata->suspendUser($this->id); + $user = $this->gdata->retrieveUser($this->id); + $this->assertEquals(true, $user->login->suspended); + $this->assertEquals($this->id, $returned->login->username); + + $returned = $this->gdata->restoreUser($this->id); + $user = $this->gdata->retrieveUser($this->id); + $this->assertEquals(false, $user->login->suspended); + $this->assertEquals($this->id, $returned->login->username); + } + + // Test the convenience delete method for users + public function testCanDeleteUser() { + $user = $this->gdata->createUser($this->id, self::GIVEN_NAME, self::FAMILY_NAME, + sha1(self::PASSWORD), self::PASSWORD_HASH); + $this->autoDelete($user); + + // Assert that the user exists, just in case... + $rUser = $this->gdata->retrieveUser($this->id); + $this->assertNotNull($rUser); + + // Delete user + $this->gdata->deleteUser($this->id); + + // Ensure that user was deleted + $rUser = $this->gdata->retrieveUser($this->id); + $this->assertNull($rUser); + } + + public function testNicknameCRUDOperations() { + $user = $this->gdata->createUser($this->id, self::GIVEN_NAME, self::FAMILY_NAME, + sha1(self::PASSWORD), self::PASSWORD_HASH); + $this->autoDelete($user); + + // Create nickname + // Apps will convert the nickname to lowercase on the server, so + // we just make sure the generated nickname is lowercase here to start + // to avoid confusion later on. + $generatedNickname = strtolower(uniqid('zf-nick-')); + $nickname = $this->gdata->createNickname($this->id, $generatedNickname); + $this->assertEquals($generatedNickname, $nickname->nickname->name); + $this->assertEquals($this->id, $nickname->login->username); + + // Retrieve nickname + $nickname = $this->gdata->retrieveNickname($generatedNickname); + $this->assertEquals($generatedNickname, $nickname->nickname->name); + $this->assertEquals($this->id, $nickname->login->username); + + // Delete nickname (uses builtin delete method, convenience delete + // method tested further down) + $nickname->delete(); + + // Ensure that nickname was deleted + $nickname = $this->gdata->retrieveNickname($generatedNickname); + $this->assertNull($nickname); + } + + public function testRetrieveNicknames() { + $user = $this->gdata->createUser($this->id, self::GIVEN_NAME, + self::FAMILY_NAME, sha1(self::PASSWORD), self::PASSWORD_HASH); + $this->autoDelete($user); + + // Create 5 nicknames + for ($i = 0; $i < 5; $i++) { + $generatedNickname[$i] = strtolower(uniqid('zf-nick-')); + $this->gdata->createNickname($this->id, $generatedNickname[$i]); + } + + // Retrieve all nicknames for the test user and see if they match + $nicknameFeed = $this->gdata->retrieveNicknames($this->id); + $this->assertEquals(count($generatedNickname), count($nicknameFeed->entry)); + foreach ($nicknameFeed as $nicknameEntry) { + $searchResult = array_search($nicknameEntry->nickname->name, + $generatedNickname); + $this->assertNotSame(false, $searchResult); + unset($generatedNickname[$searchResult]); + } + $this->assertEquals(0, count($generatedNickname)); + } + + public function testRetrievePageOfNicknames() { + $user = $this->gdata->createUser($this->id, self::GIVEN_NAME, + self::FAMILY_NAME, sha1(self::PASSWORD), self::PASSWORD_HASH); + $this->autoDelete($user); + + // Create 5 nicknames + for ($i = 0; $i < 5; $i++) { + $generatedNickname[$i] = strtolower(uniqid('zf-nick-')); + $this->gdata->createNickname($this->id, $generatedNickname[$i]); + } + + // Test to make sure that we receive at least 5 nicknames back + // from the server + $results = $this->gdata->retrievePageOfNicknames(); + $this->assertTrue(count($results->entry) >= 5); + } + + public function testRetrieveAllNicknames() { + // Create 3 users, each with 10 nicknames + for ($i = 0; $i < 3; $i++) { + $user = $this->gdata->createUser(uniqid('ZF-'), self::GIVEN_NAME, + self::FAMILY_NAME, sha1(self::PASSWORD), self::PASSWORD_HASH); + $this->autoDelete($user); + for ($j = 0; $j < 10; $j++) { + $generatedNickname = strtolower(uniqid('zf-nick-')); + $this->gdata->createNickname($user->login->username, $generatedNickname); + } + } + + // Test to make sure that we receive at least 5 nicknames back + // from the server + $results = $this->gdata->retrieveAllNicknames(); + $this->assertTrue(count($results->entry) >= 30); + } + + // Test the convenience delete method for nicknames + public function testCanDeleteNickname() { + $user = $this->gdata->createUser($this->id, self::GIVEN_NAME, self::FAMILY_NAME, + sha1(self::PASSWORD), self::PASSWORD_HASH); + $this->autoDelete($user); + $generatedNickname = strtolower(uniqid('zf-nick-')); + $this->gdata->createNickname($this->id, $generatedNickname); + + // Assert that the nickname exists, just in case... + $rNick = $this->gdata->retrieveNickname($generatedNickname); + $this->assertNotNull($rNick); + + // Delete nickname + $this->gdata->deleteNickname($generatedNickname); + + // Ensure that nickname was deleted + $rNick = $this->gdata->retrieveNickname($generatedNickname); + $this->assertNull($rNick); + } + + public function testGroupCRUDOperations() { + // Create group + $generatedGroupName = strtolower(uniqid('zf-group-')); + $group = $this->gdata->createGroup($generatedGroupName, 'zf-group-', + 'testGroupCRUDOperations()'); + $this->autoDelete($group); + + $groupId = null; + $properties = $group->getProperty(); + foreach ($properties as $property) { + if($property->name == 'groupId') { + $groupId = $property->value; + } + } + + $this->assertEquals($generatedGroupName, $groupId); + + // Retrieve group + $query = $this->gdata->newGroupQuery(); + $groupFeed = $this->gdata->getGroupFeed($query); + $entryCount = count($groupFeed->entry); + $this->assertTrue($entryCount > 0); + + // Delete group (uses builtin delete method, convenience delete + // method tested further down) + $group->delete(); + + // Ensure that group was deleted + $groupFeed = $this->gdata->getGroupFeed($query); + $this->assertEquals($entryCount - 1, count($groupFeed->entry)); + + } + + public function testCanAssignMultipleGroupsToOneUser() { + // Create a user + $user = $this->gdata->createUser($this->id, self::GIVEN_NAME, self::FAMILY_NAME, + sha1(self::PASSWORD), self::PASSWORD_HASH); + $this->autoDelete($user); + + // Create two groups + $groupCount = 2; + + for ($i = 0; $i < $groupCount; $i++) { + $generatedGroupName = strtolower(uniqid('zf-group-')); + $group = $this->gdata->createGroup($generatedGroupName, 'Test Group', + 'testCanAssignMultipleGroupsToOneUser() ' . $i); + $this->autoDelete($group); + $this->gdata->addMemberToGroup($this->id, $generatedGroupName); + } + + // Make sure that the user is subscribed to both groups + $subscriptions = $this->gdata->retrieveGroups($this->id); + $this->assertEquals($groupCount, count($subscriptions->entry)); + + } + + public function testCanRetrievePageOfGroups() { + // Create a group + $generatedGroupName = strtolower(uniqid('zf-group-')); + $group = $this->gdata->createGroup($generatedGroupName, 'Test Group', + 'testCanRetrievePageOfGroups()'); + $this->autoDelete($group); + + // Try retrieving the group feed + $feed = $this->gdata->retrievePageOfGroups(); + $this->assertTrue(count($feed->entry) > 0); + + } + + public function testCanRetrieveAllGroups() { + // Create a couple of users to make sure we don't hit the limit + // on the max number of groups. + for ($i = 0; $i < 3; $i++) { + $user = $this->gdata->createUser(uniqid('ZF-'), self::GIVEN_NAME, self::FAMILY_NAME, + sha1(self::PASSWORD), self::PASSWORD_HASH); + $this->autoDelete($user); + } + + // Create a whole bunch of groups to make sure we trigger + // paging. + for ($i = 0; $i < 30; $i++) { + $generatedGroupName = strtolower(uniqid('zf-group-')); + $group = $this->gdata->createGroup($generatedGroupName, 'Test Group ' . $i, + 'testCanRetrieveAllGroups()'); + $this->autoDelete($group); + } + + // Try retrieving the group feed + $feed = $this->gdata->retrieveAllGroups(); + $this->assertTrue(count($feed->entry) >= 30); + + } + + // Test the convenience delete method for groups + public function testCanDeleteGroup() { + // Create a group + $generatedGroupName = strtolower(uniqid('zf-group-')); + $group = $this->gdata->createGroup($generatedGroupName, 'Test Group', + 'testCanDeleteGroup()'); + $this->autoDelete($group); + + // Assert that the group exists, just in case... + $query = $this->gdata->newGroupQuery(); + $query->setGroupId($generatedGroupName); + $entry = $this->gdata->getGroupEntry($query); + $this->assertNotNull($entry); + + // Delete group + $this->gdata->deleteGroup($generatedGroupName); + + // Ensure that group was deleted + try { + $query = $this->gdata->newGroupQuery(); + $query->setGroupId($generatedGroupName); + $entry = $this->gdata->getGroupEntry($query); + // This souldn't execute + $this->fail('Retrieving a non-existant group entry didn\'t' . + 'raise exception.'); + } catch (Zend_Gdata_Gapps_ServiceException $e) { + if ($e->hasError(Zend_Gdata_Gapps_Error::ENTITY_DOES_NOT_EXIST)) { + // Dummy assertion just to say we tested something here. + $this->assertTrue(true); + } else { + // Exception thrown for an unexpected reason + throw $e; + } + } + + } + + public function testCanRetrievePageOfMembers() { + // Create a new group + $generatedGroupName = strtolower(uniqid('zf-group-')); + $group = $this->gdata->createGroup($generatedGroupName, 'Test Group', + 'testCanRetrievePageOfMembers()'); + $this->autoDelete($group); + + // Create two users and assign them to the group + $userCount = 2; + for ($i = 0; $i < $userCount; $i++) { + $generatedUsername = uniqid('ZF-'); + $user = $this->gdata->createUser($generatedUsername, + self::GIVEN_NAME, self::FAMILY_NAME, sha1(self::PASSWORD), + self::PASSWORD_HASH); + $this->autoDelete($user); + $this->gdata->addMemberToGroup($generatedUsername, + $generatedGroupName); + } + + // Retrieve members + $memberFeed = $this->gdata->retrievePageOfMembers($generatedGroupName); + $this->assertTrue(count($memberFeed->entry) == $userCount); + + } + + public function testCanRetrievAllMembers() { + // Create a new group + $generatedGroupName = strtolower(uniqid('zf-list-')); + $group = $this->gdata->createGroup($generatedGroupName, 'Test Group', + 'testCanRetrievAllMembers()'); + $this->autoDelete($group); + + // Create enough users to trigger paging and assign them to the group + $userCount = 30; + for ($i = 0; $i < $userCount; $i++) { + $generatedUsername = uniqid('ZF-'); + $user = $this->gdata->createUser($generatedUsername, + self::GIVEN_NAME, self::FAMILY_NAME, sha1(self::PASSWORD), + self::PASSWORD_HASH); + $this->autoDelete($user); + $this->gdata->addMemberToGroup($generatedUsername, $generatedGroupName); + } + + // Retrieve members + $memberFeed = $this->gdata->retrieveAllMembers($generatedGroupName); + $this->assertTrue(count($memberFeed->entry) == $userCount); + + } + + // Test the convenience removeMemberFromGroup method for group members + public function testCanRemoveMemberFromGroup() { + // Create a group + $generatedGroupName = strtolower(uniqid('zf-list-')); + $group = $this->gdata->createGroup($generatedGroupName, 'Test Group', + 'testCanDeleteGroupMember()'); + $this->autoDelete($group); + + // Create a user for the group + $user = $this->gdata->createUser($this->id, self::GIVEN_NAME, + self::FAMILY_NAME, sha1(self::PASSWORD), self::PASSWORD_HASH); + $this->autoDelete($user); + $this->gdata->addMemberToGroup($this->id, $generatedGroupName); + + // Assert that the member exists, just in case... + $members = $this->gdata->retrieveAllMembers($generatedGroupName); + $this->assertTrue(count($members->entry) == 1); + + // Remove the member from the group + $this->gdata->removeMemberFromGroup($user->login->username, + $generatedGroupName); + + // Ensure that user was deleted + $members = $this->gdata->retrieveAllMembers($generatedGroupName); + $this->assertTrue(count($members->entry) == 0); + + } + + public function testCanRetrieveGroupOwners() { + // Create a new group + $generatedGroupName = strtolower(uniqid('zf-list-')); + $group = $this->gdata->createGroup($generatedGroupName, 'Test Group', + 'testCanRetrievAllOwners()'); + $this->autoDelete($group); + + $userCount = 3; + for ($i = 0; $i < $userCount; $i++) { + $generatedUsername = uniqid('ZF-'); + $user = $this->gdata->createUser($generatedUsername, + self::GIVEN_NAME, self::FAMILY_NAME, sha1(self::PASSWORD), + self::PASSWORD_HASH); + $this->autoDelete($user); + $this->gdata->addOwnerToGroup($generatedUsername, + $generatedGroupName); + } + + // Retrieve owners + $ownerFeed = $this->gdata->retrieveGroupOwners($generatedGroupName); + $this->assertTrue(count($ownerFeed->entry) == $userCount); + + } + + // Test the convenience removeOwnerFromGroup method for group owners + public function testCanRemoveOwnerFromGroup() { + // Create a group + $generatedGroupName = strtolower(uniqid('zf-list-')); + $group = $this->gdata->createGroup($generatedGroupName, 'Test Group', + 'testCanDeleteGroupOwner()'); + $this->autoDelete($group); + + // Create a user for the group + $user = $this->gdata->createUser($this->id, self::GIVEN_NAME, + self::FAMILY_NAME, sha1(self::PASSWORD), self::PASSWORD_HASH); + $this->autoDelete($user); + $this->gdata->addOwnerToGroup($this->id, $generatedGroupName); + + // Assert that the owner exists, just in case... + $owners = $this->gdata->retrieveGroupOwners($generatedGroupName); + $this->assertTrue(count($owners->entry) == 1); + + // Remove the owner from the group + $this->gdata->removeOwnerFromGroup($user->login->username, + $generatedGroupName); + + // Ensure that user was deleted + $owners = $this->gdata->retrieveGroupOwners($generatedGroupName); + $this->assertTrue(count($owners->entry) == 0); + } + + // Test the convenience isMember method + public function testIsMember() { + // Create a group + $generatedGroupName = strtolower(uniqid('zf-list-')); + $group = $this->gdata->createGroup($generatedGroupName, 'Test Group', + 'testIsMember()'); + $this->autoDelete($group); + + // Create a user for the group + $user = $this->gdata->createUser($this->id, self::GIVEN_NAME, + self::FAMILY_NAME, sha1(self::PASSWORD), self::PASSWORD_HASH); + $this->autoDelete($user); + $this->gdata->addMemberToGroup($this->id, $generatedGroupName); + + $isMember = $this->gdata->isMember($this->id, $generatedGroupName); + + $this->assertTrue($isMember); + + $isMember = $this->gdata->isMember('foo_' . $this->id, $generatedGroupName); + + $this->assertFalse($isMember); + + } + + // Test the convenience isOwner method + public function testIsOwner() { + // Create a group + $generatedGroupName = strtolower(uniqid('zf-list-')); + $group = $this->gdata->createGroup($generatedGroupName, 'Test Group', + 'testIsMember()'); + $this->autoDelete($group); + + // Create a user for the group + $user = $this->gdata->createUser($this->id, self::GIVEN_NAME, + self::FAMILY_NAME, sha1(self::PASSWORD), self::PASSWORD_HASH); + $this->autoDelete($user); + $this->gdata->addOwnerToGroup($this->id, $generatedGroupName); + + $isOwner = $this->gdata->isOwner($this->id, $generatedGroupName); + + $this->assertTrue($isOwner); + + $isOwner = $this->gdata->isOwner('foo_' . $this->id, $generatedGroupName); + + $this->assertFalse($isOwner); + + } + + // Test the convenience updateGroup method + public function testCanUpdateGroup() { + // Create a group + $generatedGroupName = strtolower(uniqid('zf-list-')); + $group = $this->gdata->createGroup($generatedGroupName, 'Test Group', + 'testCanUpdateGroup()'); + $this->autoDelete($group); + + //set new value and save it + + $group = $this->gdata->updateGroup($generatedGroupName, null, 'new description here'); + + //verify new value + $description = null; + + $properties = $group->getProperty(); + foreach ($properties as $property) { + if($property->name == 'description') { + $description = $property->value; + } + } + + $this->assertEquals('new description here', $description); + + } + + public function testEmailListCRUDOperations() { + // Create email list + $generatedListName = strtolower(uniqid('zf-list-')); + $list = $this->gdata->createEmailList($generatedListName); + $this->autoDelete($list); + $this->assertEquals($generatedListName, $list->emailList->name); + + // Retrieve email list + $query = $this->gdata->newEmailListQuery(); + $listFeed = $this->gdata->getEmailListFeed($query); + $entryCount = count($listFeed->entry); + $this->assertTrue($entryCount > 0); + + // Delete email list (uses builtin delete method, convenience delete + // method tested further down) + $list->delete(); + + // Ensure that nickname was deleted + $listFeed = $this->gdata->getEmailListFeed($query); + $this->assertEquals($entryCount - 1, count($listFeed->entry)); + } + + public function testCanAssignMultipleEmailListsToOneUser() { + // Create a user + $user = $this->gdata->createUser($this->id, self::GIVEN_NAME, self::FAMILY_NAME, + sha1(self::PASSWORD), self::PASSWORD_HASH); + $this->autoDelete($user); + + // Create two email lists + $listCount = 2; + + for ($i = 0; $i < $listCount; $i++) { + $generatedListName = strtolower(uniqid('zf-list-')); + $list = $this->gdata->createEmailList($generatedListName); + $this->autoDelete($list); + $this->gdata->addRecipientToEmailList($this->id, $generatedListName); + } + + // Make sure that the user is subscribed to both lists + $subscriptions = $this->gdata->retrieveEmailLists($this->id); + $this->assertEquals($listCount, count($subscriptions->entry)); + } + + public function testCanRetrievePageOfEmailLists() { + // Create an email list + $generatedListName = strtolower(uniqid('zf-list-')); + $list = $this->gdata->createEmailList($generatedListName); + $this->autoDelete($list); + + // Try retrieving the email list feed + $feed = $this->gdata->retrievePageOfEmailLists(); + $this->assertTrue(count($feed->entry) > 0); + } + + public function testCanRetrieveAllEmailLists() { + // Create a couple of users to make sure we don't hit the limit + // on the max number of email lists. + for ($i = 0; $i < 3; $i++) { + $user = $this->gdata->createUser(uniqid('ZF-'), self::GIVEN_NAME, self::FAMILY_NAME, + sha1(self::PASSWORD), self::PASSWORD_HASH); + $this->autoDelete($user); + } + + // Create a whole bunch of email lists to make sure we trigger + // paging. + for ($i = 0; $i < 30; $i++) { + $generatedListName = strtolower(uniqid('zf-list-')); + $list = $this->gdata->createEmailList($generatedListName); + $this->autoDelete($list); + } + + // Try retrieving the email list feed + $feed = $this->gdata->retrieveAllEmailLists(); + $this->assertTrue(count($feed->entry) >= 30); + } + + // Test the convenience delete method for email lists + public function testCanDeleteEmailList() { + // Create an email list + $generatedListName = strtolower(uniqid('zf-list-')); + $list = $this->gdata->createEmailList($generatedListName); + $this->autoDelete($list); + + // Assert that the email list exists, just in case... + $query = $this->gdata->newEmailListQuery(); + $query->setEmailListName($generatedListName); + $entry = $this->gdata->getEmailListEntry($query); + $this->assertNotNull($entry); + + // Delete nickname + $this->gdata->deleteEmailList($generatedListName); + + // Ensure that nickname was deleted + try { + $query = $this->gdata->newEmailListQuery(); + $query->setEmailListName($generatedListName); + $entry = $this->gdata->getEmailListEntry($query); + // This souldn't execute + $this->fail('Retrieving a non-existant email list entry didn\'t' . + 'raise exception.'); + } catch (Zend_Gdata_Gapps_ServiceException $e) { + if ($e->hasError(Zend_Gdata_Gapps_Error::ENTITY_DOES_NOT_EXIST)) { + // Dummy assertion just to say we tested something here. + $this->assertTrue(true); + } else { + // Exception thrown for an unexpected reason + throw $e; + } + } + } + + public function testCanRetrievePageOfRecipients() { + // Create a new email list + $generatedListName = strtolower(uniqid('zf-list-')); + $list = $this->gdata->createEmailList($generatedListName); + $this->autoDelete($list); + + // Create two users and assign them to the email list + $userCount = 2; + for ($i = 0; $i < $userCount; $i++) { + $generatedUsername = uniqid('ZF-'); + $user = $this->gdata->createUser($generatedUsername, + self::GIVEN_NAME, self::FAMILY_NAME, sha1(self::PASSWORD), + self::PASSWORD_HASH); + $this->autoDelete($user); + $this->gdata->addRecipientToEmailList($generatedUsername, + $generatedListName); + } + + // Retrieve recipients + $recipientFeed = + $this->gdata->retrievePageOfRecipients($generatedListName); + $this->assertTrue(count($recipientFeed->entry) == $userCount); + } + + public function testCanRetrievAllRecipients() { + // Create a new email list + $generatedListName = strtolower(uniqid('zf-list-')); + $list = $this->gdata->createEmailList($generatedListName); + $this->autoDelete($list); + + // Create enough users to trigger paging and assign them to the email + // list + $userCount = 30; + for ($i = 0; $i < $userCount; $i++) { + $generatedUsername = uniqid('ZF-'); + $user = $this->gdata->createUser($generatedUsername, + self::GIVEN_NAME, self::FAMILY_NAME, sha1(self::PASSWORD), + self::PASSWORD_HASH); + $this->autoDelete($user); + $this->gdata->addRecipientToEmailList($generatedUsername, + $generatedListName); + } + + // Retrieve recipients + $recipientFeed = + $this->gdata->retrieveAllRecipients($generatedListName); + $this->assertTrue(count($recipientFeed->entry) == $userCount); + } + + // Test the convenience delete method for email list recipients + public function testCanDeleteEmailListRecipient() { + // Create an email list + $generatedListName = strtolower(uniqid('zf-list-')); + $list = $this->gdata->createEmailList($generatedListName); + $this->autoDelete($list); + + // Create a user for the email list + $user = $this->gdata->createUser($this->id, self::GIVEN_NAME, + self::FAMILY_NAME, sha1(self::PASSWORD), self::PASSWORD_HASH); + $this->autoDelete($user); + $this->gdata->addRecipientToEmailList($this->id, $generatedListName); + + // Assert that the recipient exists, just in case... + $recipients = + $this->gdata->retrieveAllRecipients($generatedListName); + $this->assertTrue(count($recipients->entry) == 1); + + // Remove the user from the list + $this->gdata->removeRecipientFromEmailList($user->login->username, + $generatedListName); + + // Ensure that user was deleted + $recipients = + $this->gdata->retrieveAllRecipients($generatedListName); + $this->assertTrue(count($recipients->entry) == 0); + } + +} diff --git a/zend/tests/Zend/Gdata/GappsTest.php b/zend/tests/Zend/Gdata/GappsTest.php new file mode 100644 index 0000000..c1ec04d --- /dev/null +++ b/zend/tests/Zend/Gdata/GappsTest.php @@ -0,0 +1,79 @@ +gdata = new Zend_Gdata_Gapps(null, self::TEST_DOMAIN); + } + + public function testMagicFactoryProvidesQueriesWithDomains() { + $userQ = $this->gdata->newUserQuery(); + $this->assertTrue($userQ instanceof Zend_Gdata_Gapps_UserQuery); + $this->assertEquals(self::TEST_DOMAIN, $userQ->getDomain()); + $this->assertEquals(null, $userQ->getUsername()); + + $userQ = $this->gdata->newUserQuery('foo'); + $this->assertTrue($userQ instanceof Zend_Gdata_Gapps_UserQuery); + $this->assertEquals(self::TEST_DOMAIN, $userQ->getDomain()); + $this->assertEquals('foo', $userQ->getUsername()); + } + + public function testMagicFactoryLeavesNonQueriesAlone() { + $login = $this->gdata->newLogin('blah'); + $this->assertTrue($login instanceof Zend_Gdata_Gapps_Extension_Login); + $this->assertEquals('blah', $login->username); + } + + public function testEmptyResponseExceptionRaisesException() { + require_once('Zend/Gdata/App/HttpException.php'); + $e = new Zend_Gdata_App_HttpException(); + $e->setResponse(null); + $success = false; + try { + $this->gdata->throwServiceExceptionIfDetected($e); + } catch (Zend_Gdata_App_IOException $f) { + $success = true; + } + $this->assertTrue($success, 'Zend_Gdata_App_IOException not thrown'); + } + +} diff --git a/zend/tests/Zend/Gdata/GdataOnlineTest.php b/zend/tests/Zend/Gdata/GdataOnlineTest.php new file mode 100644 index 0000000..16abbec --- /dev/null +++ b/zend/tests/Zend/Gdata/GdataOnlineTest.php @@ -0,0 +1,341 @@ +blog = constant('TESTS_ZEND_GDATA_BLOG_ID'); + $service = 'blogger'; + $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service); + $this->gdata = new Zend_Gdata($client); + $this->gdata->setMajorProtocolVersion(2); + } + + public function testPostAndDeleteByEntry() + { + $postUrl = 'http://www.blogger.com/feeds/' . $this->blog . + '/posts/default'; + $entry = $this->gdata->newEntry(); + $entry->title = $this->gdata->newTitle('PHP test blog post'); + $entry->content = $this->gdata->newContent('Blog post content...'); + $insertedEntry = $this->gdata->insertEntry($entry, $postUrl); + $this->assertEquals('PHP test blog post', $insertedEntry->title->text); + $this->assertEquals('Blog post content...', + $insertedEntry->content->text); + $this->assertTrue( + strpos($insertedEntry->getEditLink()->href, 'http') === 0); + $this->gdata->delete($insertedEntry); + } + + public function testPostAndDeleteByUrl() + { + $postUrl = 'http://www.blogger.com/feeds/' . $this->blog . + '/posts/default'; + $entry = $this->gdata->newEntry(); + $entry->title = $this->gdata->newTitle('PHP test blog post'); + $entry->content = $this->gdata->newContent('Blog post content...'); + $insertedEntry = $this->gdata->insertEntry($entry, $postUrl); + $this->assertTrue( + strpos($insertedEntry->getEditLink()->href, 'http') === 0); + $this->gdata->delete($insertedEntry->getEditLink()->href); + } + + public function testPostRetrieveEntryAndDelete() + { + $postUrl = 'http://www.blogger.com/feeds/' . $this->blog . + '/posts/default'; + $entry = $this->gdata->newEntry(); + $entry->title = $this->gdata->newTitle(' PHP test blog post '); + $this->assertTrue(isset($entry->title)); + $entry->content = $this->gdata->newContent('Blog post content...'); + + /* testing getText and __toString */ + $this->assertEquals("PHP test blog post", + $entry->title->getText()); + $this->assertEquals(" PHP test blog post ", + $entry->title->getText(false)); + $this->assertEquals($entry->title->getText(), + $entry->title->__toString()); + + $insertedEntry = $this->gdata->insertEntry($entry, $postUrl); + $retrievedEntryQuery = $this->gdata->newQuery( + $insertedEntry->getSelfLink()->href); + $retrievedEntry = $this->gdata->getEntry($retrievedEntryQuery); + $this->assertTrue( + strpos($retrievedEntry->getEditLink()->href, 'http') === 0); + $this->gdata->delete($retrievedEntry); + } + + public function testPostUpdateAndDeleteEntry() + { + $postUrl = 'http://www.blogger.com/feeds/' . $this->blog . + '/posts/default'; + $entry = $this->gdata->newEntry(); + $entry->title = $this->gdata->newTitle('PHP test blog post'); + $entry->content = $this->gdata->newContent('Blog post content...'); + $insertedEntry = $this->gdata->insertEntry($entry, $postUrl); + $this->assertTrue( + strpos($insertedEntry->getEditLink()->href, 'http') === 0); + $insertedEntry->title->text = 'PHP test blog post modified'; + $updatedEntry = $this->gdata->updateEntry($insertedEntry); + $this->assertEquals('PHP test blog post modified', + $updatedEntry->title->text); + $updatedEntry->title->text = 'PHP test blog post modified twice'; + // entry->saveXML() and entry->getXML() should be the same + $this->assertEquals($updatedEntry->saveXML(), + $updatedEntry->getXML()); + $newlyUpdatedEntry = $this->gdata->updateEntry($updatedEntry); + $this->assertEquals('PHP test blog post modified twice', + $updatedEntry->title->text); + $updatedEntry->delete(); + } + + public function testFeedImplementation() + { + $blogsUrl = 'http://www.blogger.com/feeds/default/blogs'; + $blogsQuery = $this->gdata->newQuery($blogsUrl); + $retrievedFeed = $this->gdata->getFeed($blogsQuery); + // rewind the retrieved feed first + $retrievedFeed->rewind(); + + // Make sure the iterator and array impls match + $entry1 = $retrievedFeed->current(); + $entry2 = $retrievedFeed[0]; + $this->assertEquals($entry1, $entry2); + + /* + TODO: Fix these tests + // Test ArrayAccess interface + $firstBlogTitle = $retrievedFeed[0]->title->text; + $entries = $retrievedFeed->entry; + $entries[0]->title->text = $firstBlogTitle . "**"; + $retrievedFeed[0] = $entries[0]; + $this->assertEquals($retrievedFeed->entry[0]->title->text, + $retrievedFeed[0]->title->text); + $this->assertEquals($firstBlogTitle . "**", + $retrievedFeed[0]->title->text); + */ + } + + public function testBadFeedRetrieval() + { + $feed = $this->gdata->newFeed(); + try { + $returnedFeed = $this->gdata->getFeed($feed); + } catch (Zend_Gdata_App_InvalidArgumentException $e) { + // we're expecting to cause an exception here + } + } + + public function testBadEntryRetrieval() + { + $entry = $this->gdata->newEntry(); + try { + $returnedEntry = $this->gdata->getEntry($entry); + } catch (Zend_Gdata_App_InvalidArgumentException $e) { + // we're expecting to cause an exception here + } + } + + public function testMediaUpload() + { + // the standard sevice for Gdata testing is Blogger, due to the strong + // match to the standard Gdata/APP protocol. However, Blogger doesn't + // currently support media uploads, so we're using Picasa Web Albums + // for this test instead + $user = constant('TESTS_ZEND_GDATA_CLIENTLOGIN_EMAIL'); + $pass = constant('TESTS_ZEND_GDATA_CLIENTLOGIN_PASSWORD'); + $this->blog = constant('TESTS_ZEND_GDATA_BLOG_ID'); + $service = 'lh2'; + $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service); + $gd = new Zend_Gdata($client); + + // setup the photo content + $fs = $gd->newMediaFileSource('Zend/Gdata/_files/testImage.jpg'); + $fs->setContentType('image/jpeg'); + + + // create a new picasa album + $albumEntry = $gd->newEntry(); + $albumEntry->setTitle($gd->newTitle('My New Test Album')); + $albumEntry->setCategory(array($gd->newCategory( + 'http://schemas.google.com/photos/2007#album', + 'http://schemas.google.com/g/2005#kind' + ))); + $createdAlbumEntry = $gd->insertEntry($albumEntry, + 'http://picasaweb.google.com/data/feed/api/user/default'); + $this->assertEquals('My New Test Album', + $createdAlbumEntry->title->text); + $albumUrl = $createdAlbumEntry->getLink('http://schemas.google.com/g/2005#feed')->href; + + // post the photo to the new album, without any metadata + // other than the slug + // add a slug header to the media file source + $fs->setSlug('Going to the park'); + $createdPhotoBinaryOnly = $gd->insertEntry($fs, $albumUrl); + $this->assertEquals('Going to the park', + $createdPhotoBinaryOnly->title->text); + + // post the photo to the new album along with the entry + // remove slug header from the media file source + $fs->setSlug(null); + + // setup an entry with metadata + $mediaEntry = $gd->newMediaEntry(); + $mediaEntry->setMediaSource($fs); + + $mediaEntry->setTitle($gd->newTitle('My New Test Photo')); + $mediaEntry->setSummary($gd->newSummary('My New Test Photo Summary')); + $mediaEntry->setCategory(array($gd->newCategory( + 'http://schemas.google.com/photos/2007#photo ', + 'http://schemas.google.com/g/2005#kind' + ))); + $createdPhotoMultipart = $gd->insertEntry($mediaEntry, $albumUrl); + $this->assertEquals('My New Test Photo', + $createdPhotoMultipart->title->text); + + // cleanup and remove the album + // first we wait 5 seconds + sleep(5); + try { + $albumEntry->delete(); + } catch (Zend_Gdata_App_Exception $e) { + $this->fail('Tried to delete the test album, got exception: ' . + $e->getMessage()); + } + } + + function testIsAuthenticated() + { + $this->assertTrue($this->gdata->isAuthenticated()); + } + + function testRetrieveNextAndPreviousFeedsFromService() + { + $user = constant('TESTS_ZEND_GDATA_CLIENTLOGIN_EMAIL'); + $pass = constant('TESTS_ZEND_GDATA_CLIENTLOGIN_PASSWORD'); + $this->blog = constant('TESTS_ZEND_GDATA_BLOG_ID'); + $service = 'youtube'; + $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service); + $gd = new Zend_Gdata($client); + + $feed = $gd->getFeed( + 'http://gdata.youtube.com/feeds/api/standardfeeds/recently_featured', + 'Zend_Gdata_App_Feed'); + + $this->assertNotNull($feed); + $this->assertTrue($feed instanceof Zend_Gdata_App_Feed); + $this->assertEquals($feed->count(), 25); + + $nextFeed = $gd->getNextFeed($feed); + + $this->assertNotNull($nextFeed); + $this->assertTrue($nextFeed instanceof Zend_Gdata_App_Feed); + $this->assertEquals($nextFeed->count(), 25); + + $previousFeed = $gd->getPreviousFeed($nextFeed); + + $this->assertNotNull($previousFeed); + $this->assertTrue($previousFeed instanceof Zend_Gdata_App_Feed); + $this->assertEquals($previousFeed->count(), 25); + + } + + function testRetrieveNextFeedAndPreviousFeedsFromFeed() + { + $user = constant('TESTS_ZEND_GDATA_CLIENTLOGIN_EMAIL'); + $pass = constant('TESTS_ZEND_GDATA_CLIENTLOGIN_PASSWORD'); + $this->blog = constant('TESTS_ZEND_GDATA_BLOG_ID'); + $service = 'youtube'; + $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service); + $gd = new Zend_Gdata($client); + + $feed = $gd->getFeed( + 'http://gdata.youtube.com/feeds/api/standardfeeds/recently_featured', + 'Zend_Gdata_App_Feed'); + + $nextFeed = $feed->getNextFeed(); + + $this->assertNotNull($nextFeed); + $this->assertTrue($nextFeed instanceof Zend_Gdata_App_Feed); + $this->assertEquals($nextFeed->count(), 25); + + $previousFeed = $nextFeed->getPreviousFeed(); + + $this->assertNotNull($previousFeed); + $this->assertTrue($previousFeed instanceof Zend_Gdata_App_Feed); + $this->assertEquals($previousFeed->count(), 25); + + } + + public function testDisableXMLToObjectMappingReturnsStringForFeed() + { + $gdata = new Zend_Gdata(); + $gdata->useObjectMapping(false); + $xmlString = $gdata->getFeed( + 'http://gdata.youtube.com/feeds/api/standardfeeds/top_rated'); + $this->assertEquals('string', gettype($xmlString)); + } + + public function testDisableXMLToObjectMappingReturnsStringForEntry() + { + $gdata = new Zend_Gdata(); + $gdata->useObjectMapping(false); + $xmlString = $gdata->getFeed( + 'http://gdata.youtube.com/feeds/api/videos/O4SWAfisH-8'); + $this->assertEquals('string', gettype($xmlString)); + } + + public function testDisableAndReEnableXMLToObjectMappingReturnsObject() + { + $gdata = new Zend_Gdata(); + $gdata->useObjectMapping(false); + $xmlString = $gdata->getEntry( + 'http://gdata.youtube.com/feeds/api/videos/O4SWAfisH-8'); + $this->assertEquals('string', gettype($xmlString)); + $gdata->useObjectMapping(true); + $entry = $gdata->getEntry( + 'http://gdata.youtube.com/feeds/api/videos/O4SWAfisH-8'); + $this->assertTrue($entry instanceof Zend_Gdata_Entry); + } + +} diff --git a/zend/tests/Zend/Gdata/GdataTest.php b/zend/tests/Zend/Gdata/GdataTest.php new file mode 100644 index 0000000..1ffe1c8 --- /dev/null +++ b/zend/tests/Zend/Gdata/GdataTest.php @@ -0,0 +1,102 @@ +getHttpClient(); + $this->assertTrue($client instanceof Zend_Http_Client, + 'Expecting object of type Zend_Http_Client, got ' + . (gettype($client) == 'object' ? get_class($client) : gettype($client)) + ); + } + + public function testSpecificHttpClient() + { + $client = new Zend_Http_Client(); + $gdata = new Zend_Gdata($client); + $client2 = $gdata->getHttpClient(); + $this->assertTrue($client2 instanceof Zend_Http_Client, + 'Expecting object of type Zend_Http_Client, got ' + . (gettype($client) == 'object' ? get_class($client) : gettype($client)) + ); + $this->assertSame($client, $client2); + } + + public function testExceptionNotHttpClient() + { + $obj = new ArrayObject(); + try { + $gdata = new Zend_Gdata($obj); + $this->fail('Expecting to catch Zend_Gdata_App_HttpException'); + } catch (Exception $e) { + $this->assertThat($e, $this->isInstanceOf('Zend_Gdata_App_HttpException'), + 'Expecting Zend_Gdata_App_HttpException, got '.get_class($e)); + $this->assertEquals('Argument is not an instance of Zend_Http_Client.', $e->getMessage()); + } + } + + public function testGetFeedExceptionInvalidLocationType() + { + $gdata = new Zend_Gdata(); + try { + // give it neither a string nor a Zend_Gdata_Query object, + // and see if it throws an exception. + $feed = $gdata->getFeed(new stdClass()); + $this->fail('Expecting to catch Zend_Gdata_App_InvalidArgumentException'); + } catch (Zend_Exception $e) { + $this->assertType('Zend_Gdata_App_InvalidArgumentException', $e, + 'Expecting Zend_Gdata_App_InvalidArgumentException, got '.get_class($e)); + $this->assertEquals('You must specify the location as either a string URI or a child of Zend_Gdata_Query', $e->getMessage()); + } + } + + public function testGetEntryExceptionInvalidLocationType() + { + $gdata = new Zend_Gdata(); + try { + // give it neither a string nor a Zend_Gdata_Query object, + // and see if it throws an exception. + $feed = $gdata->getEntry(new stdClass()); + $this->fail('Expecting to catch Zend_Gdata_App_InvalidArgumentException'); + } catch (Zend_Exception $e) { + $this->assertType('Zend_Gdata_App_InvalidArgumentException', $e, + 'Expecting Zend_Gdata_App_InvalidArgumentException, got '.get_class($e)); + $this->assertEquals('You must specify the location as either a string URI or a child of Zend_Gdata_Query', $e->getMessage()); + } + } + +} diff --git a/zend/tests/Zend/Gdata/MediaMimeStreamTest.php b/zend/tests/Zend/Gdata/MediaMimeStreamTest.php new file mode 100644 index 0000000..f0b2660 --- /dev/null +++ b/zend/tests/Zend/Gdata/MediaMimeStreamTest.php @@ -0,0 +1,186 @@ +locationOfFakeBinary = + 'Zend/Gdata/_files/MediaMimeStreamSample1.txt'; + $this->smallXMLString = 'foo'; + $this->testMediaType = 'video/mpeg'; + $this->mediaMimeStream = new Zend_Gdata_MediaMimeStream( + $this->smallXMLString, $this->locationOfFakeBinary, + $this->testMediaType); + $this->exceptedLenOfMimeMessage = 283; + } + + public function testExceptionOnUnreadableFile() + { + $exceptionThrown = false; + try { + $mediaMimeStream = new Zend_Gdata_MediaMimeStream( + $this->smallXMLString, '/non/existant/path/to/nowhere'); + } catch (Zend_Gdata_App_IOException $e) { + $exceptionThrown = true; + } + $this->assertTrue($exceptionThrown, 'Was expecting an exception on ' . + 'attempting to read an unreadable or non-existant file'); + } + + public function testGetTotalSize() + { + $this->assertEquals($this->exceptedLenOfMimeMessage, + $this->mediaMimeStream->getTotalSize()); + } + + public function testHasData() + { + $this->assertTrue($this->mediaMimeStream->hasData()); + } + + public function testGetContentType() + { + $pattern = + '/multipart\/related;\sboundary=\"=_[a-z0-9]{32,}.*\"/'; + $this->assertEquals(1, preg_match($pattern, + $this->mediaMimeStream->getContentType())); + } + + /** + * Ensure that nothing breaks if we read past the end of the messsage in a + * single read. + * + * Note: The test message has the following part sizes in length: + * 211, 22, 39 for a total size of 272. This test performs a single read + * for 400 bytes. + */ + public function testReadAll() + { + $this->assertEquals($this->exceptedLenOfMimeMessage, + $this->mediaMimeStream->getTotalSize()); + $outputArray = array(); + while ($this->mediaMimeStream->hasData()) { + $outputArray = explode("\r\n", $this->mediaMimeStream->read(400)); + } + $mimeBoundaryPattern = '/--=_[a-z0-9]{32,}/'; + $mimeClosingBoundaryPattern = '/--=_[a-z0-9]{32,}--/'; + $this->assertEquals('', $outputArray[0]); + $this->assertEquals(1, + preg_match($mimeBoundaryPattern, $outputArray[1])); + $this->assertEquals('Content-Type: application/atom+xml', + $outputArray[2]); + $this->assertEquals('', $outputArray[3]); + $this->assertEquals($this->smallXMLString, $outputArray[4]); + $this->assertEquals('', $outputArray[5]); + $this->assertEquals(1, + preg_match($mimeBoundaryPattern, $outputArray[6])); + $this->assertEquals('Content-Type: video/mpeg', $outputArray[7]); + $this->assertEquals('Content-Transfer-Encoding: binary', + $outputArray[8]); + $this->assertEquals('', $outputArray[9]); + $this->assertEquals(file_get_contents($this->locationOfFakeBinary), + $outputArray[10]); + $this->assertEquals(1, + preg_match($mimeClosingBoundaryPattern, $outputArray[11])); + } + + /** + * Ensure that a variety of different stream sizes work. + * + * Note: The test message has the following part sizes in length: + * 211, 22, 39 for a total size of 287. + */ + public function testReadVariousBufferSizes() + { + $bufferSizesToTest = array(2, 20, 33, 44, 88, 100, 201); + foreach($bufferSizesToTest as $sizeToTest) { + $mediaMimeStream = new Zend_Gdata_MediaMimeStream( + $this->smallXMLString, $this->locationOfFakeBinary, + $this->testMediaType); + $this->assertEquals($sizeToTest, + strlen($mediaMimeStream->read($sizeToTest))); + } + } + + /** + * Ensure that nothing breaks if we read a message 1 byte at time. + */ + public function testReadWithoutCrossingSections() + { + $outputString = ''; + while ($this->mediaMimeStream->hasData()) { + $outputString .= $this->mediaMimeStream->read(1); + } + $this->assertEquals($this->exceptedLenOfMimeMessage, + strlen($outputString)); + } + + /** + * Ensure that nothing breaks if we read past at least two sections of + * the message. + * + * Note: The test message has the following part sizes in length: + * 211, 22, 39 for a total size of 272. This test reads 250 bytes at a time + * to make sure that we cross sections 1 and 2 and then read part of + * section 3. + */ + public function testReadCrossing2Sections() + { + $outputString = ''; + while ($this->mediaMimeStream->hasData()) { + $outputString .= $this->mediaMimeStream->read(250); + } + $this->assertEquals($this->exceptedLenOfMimeMessage, + strlen($outputString)); + } + + /** + * Ensure that nothing breaks if we read past at least one section of + * the message. + * + * Note: The test message has the following part sizes in length: + * 211, 22, 39 for a total size of 272. This test reads 230 bytes at a time + * to make sure that we cross section 1 and then read sections 2 and 3. + */ + public function testReadCrossing1Section() + { + $outputString = ''; + while ($this->mediaMimeStream->hasData()) { + $outputString .= $this->mediaMimeStream->read(230); + } + $this->assertEquals($this->exceptedLenOfMimeMessage, + strlen($outputString)); + } + +} diff --git a/zend/tests/Zend/Gdata/OpenSearchItemsPerPageTest.php b/zend/tests/Zend/Gdata/OpenSearchItemsPerPageTest.php new file mode 100644 index 0000000..bbacade --- /dev/null +++ b/zend/tests/Zend/Gdata/OpenSearchItemsPerPageTest.php @@ -0,0 +1,126 @@ +openSearchItemsPerPageText = file_get_contents( + 'Zend/Gdata/_files/OpenSearchItemsPerPageElementSample1.xml', + true); + $this->openSearchItemsPerPage = new Zend_Gdata_Extension_OpenSearchItemsPerPage(); + } + + public function testEmptyOpenSearchItemsPerPageShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->openSearchItemsPerPage->extensionElements)); + $this->assertTrue(count($this->openSearchItemsPerPage->extensionElements) == 0); + } + + public function testEmptyOpenSearchItemsPerPageShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->openSearchItemsPerPage->extensionAttributes)); + $this->assertTrue(count($this->openSearchItemsPerPage->extensionAttributes) == 0); + } + + public function testSampleOpenSearchItemsPerPageShouldHaveNoExtensionElements() { + $this->openSearchItemsPerPage->transferFromXML($this->openSearchItemsPerPageText); + $this->assertTrue(is_array($this->openSearchItemsPerPage->extensionElements)); + $this->assertTrue(count($this->openSearchItemsPerPage->extensionElements) == 0); + } + + public function testSampleOpenSearchItemsPerPageShouldHaveNoExtensionAttributes() { + $this->openSearchItemsPerPage->transferFromXML($this->openSearchItemsPerPageText); + $this->assertTrue(is_array($this->openSearchItemsPerPage->extensionAttributes)); + $this->assertTrue(count($this->openSearchItemsPerPage->extensionAttributes) == 0); + } + + public function testNormalOpenSearchItemsPerPageShouldHaveNoExtensionElements() { + $this->openSearchItemsPerPage->text = "200"; + + $this->assertEquals("200", $this->openSearchItemsPerPage->text); + + $this->assertEquals(0, count($this->openSearchItemsPerPage->extensionElements)); + $newOpenSearchItemsPerPage = new Zend_Gdata_Extension_OpenSearchItemsPerPage(); + $newOpenSearchItemsPerPage->transferFromXML($this->openSearchItemsPerPage->saveXML()); + $this->assertEquals(0, count($newOpenSearchItemsPerPage->extensionElements)); + $newOpenSearchItemsPerPage->extensionElements = array( + new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); + $this->assertEquals(1, count($newOpenSearchItemsPerPage->extensionElements)); + $this->assertEquals("200", $newOpenSearchItemsPerPage->text); + + /* try constructing using magic factory */ + $gdata = new Zend_Gdata(); + $newOpenSearchItemsPerPage2 = $gdata->newOpenSearchItemsPerPage(); + $newOpenSearchItemsPerPage2->transferFromXML($newOpenSearchItemsPerPage->saveXML()); + $this->assertEquals(1, count($newOpenSearchItemsPerPage2->extensionElements)); + $this->assertEquals("200", $newOpenSearchItemsPerPage2->text); + } + + public function testEmptyOpenSearchItemsPerPageToAndFromStringShouldMatch() { + $openSearchItemsPerPageXml = $this->openSearchItemsPerPage->saveXML(); + $newOpenSearchItemsPerPage = new Zend_Gdata_Extension_OpenSearchItemsPerPage(); + $newOpenSearchItemsPerPage->transferFromXML($openSearchItemsPerPageXml); + $newOpenSearchItemsPerPageXml = $newOpenSearchItemsPerPage->saveXML(); + $this->assertTrue($openSearchItemsPerPageXml == $newOpenSearchItemsPerPageXml); + } + + public function testOpenSearchItemsPerPageWithValueToAndFromStringShouldMatch() { + $this->openSearchItemsPerPage->text = "200"; + $openSearchItemsPerPageXml = $this->openSearchItemsPerPage->saveXML(); + $newOpenSearchItemsPerPage = new Zend_Gdata_Extension_OpenSearchItemsPerPage(); + $newOpenSearchItemsPerPage->transferFromXML($openSearchItemsPerPageXml); + $newOpenSearchItemsPerPageXml = $newOpenSearchItemsPerPage->saveXML(); + $this->assertTrue($openSearchItemsPerPageXml == $newOpenSearchItemsPerPageXml); + $this->assertEquals("200", $this->openSearchItemsPerPage->text); + } + + public function testExtensionAttributes() { + $extensionAttributes = $this->openSearchItemsPerPage->extensionAttributes; + $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); + $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); + $this->openSearchItemsPerPage->extensionAttributes = $extensionAttributes; + $this->assertEquals('bar', $this->openSearchItemsPerPage->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $this->openSearchItemsPerPage->extensionAttributes['foo2']['value']); + $openSearchItemsPerPageXml = $this->openSearchItemsPerPage->saveXML(); + $newOpenSearchItemsPerPage = new Zend_Gdata_Extension_OpenSearchItemsPerPage(); + $newOpenSearchItemsPerPage->transferFromXML($openSearchItemsPerPageXml); + $this->assertEquals('bar', $newOpenSearchItemsPerPage->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $newOpenSearchItemsPerPage->extensionAttributes['foo2']['value']); + } + + public function testConvertFullOpenSearchItemsPerPageToAndFromString() { + $this->openSearchItemsPerPage->transferFromXML($this->openSearchItemsPerPageText); + $this->assertEquals("25", $this->openSearchItemsPerPage->text); + } + +} diff --git a/zend/tests/Zend/Gdata/OpenSearchStartIndexTest.php b/zend/tests/Zend/Gdata/OpenSearchStartIndexTest.php new file mode 100644 index 0000000..4363d82 --- /dev/null +++ b/zend/tests/Zend/Gdata/OpenSearchStartIndexTest.php @@ -0,0 +1,126 @@ +openSearchStartIndexText = file_get_contents( + 'Zend/Gdata/_files/OpenSearchStartIndexElementSample1.xml', + true); + $this->openSearchStartIndex = new Zend_Gdata_Extension_OpenSearchStartIndex(); + } + + public function testEmptyOpenSearchStartIndexShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->openSearchStartIndex->extensionElements)); + $this->assertTrue(count($this->openSearchStartIndex->extensionElements) == 0); + } + + public function testEmptyOpenSearchStartIndexShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->openSearchStartIndex->extensionAttributes)); + $this->assertTrue(count($this->openSearchStartIndex->extensionAttributes) == 0); + } + + public function testSampleOpenSearchStartIndexShouldHaveNoExtensionElements() { + $this->openSearchStartIndex->transferFromXML($this->openSearchStartIndexText); + $this->assertTrue(is_array($this->openSearchStartIndex->extensionElements)); + $this->assertTrue(count($this->openSearchStartIndex->extensionElements) == 0); + } + + public function testSampleOpenSearchStartIndexShouldHaveNoExtensionAttributes() { + $this->openSearchStartIndex->transferFromXML($this->openSearchStartIndexText); + $this->assertTrue(is_array($this->openSearchStartIndex->extensionAttributes)); + $this->assertTrue(count($this->openSearchStartIndex->extensionAttributes) == 0); + } + + public function testNormalOpenSearchStartIndexShouldHaveNoExtensionElements() { + $this->openSearchStartIndex->text = "20"; + + $this->assertEquals("20", $this->openSearchStartIndex->text); + + $this->assertEquals(0, count($this->openSearchStartIndex->extensionElements)); + $newOpenSearchStartIndex = new Zend_Gdata_Extension_OpenSearchStartIndex(); + $newOpenSearchStartIndex->transferFromXML($this->openSearchStartIndex->saveXML()); + $this->assertEquals(0, count($newOpenSearchStartIndex->extensionElements)); + $newOpenSearchStartIndex->extensionElements = array( + new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); + $this->assertEquals(1, count($newOpenSearchStartIndex->extensionElements)); + $this->assertEquals("20", $newOpenSearchStartIndex->text); + + /* try constructing using magic factory */ + $gdata = new Zend_Gdata(); + $newOpenSearchStartIndex2 = $gdata->newOpenSearchStartIndex(); + $newOpenSearchStartIndex2->transferFromXML($newOpenSearchStartIndex->saveXML()); + $this->assertEquals(1, count($newOpenSearchStartIndex2->extensionElements)); + $this->assertEquals("20", $newOpenSearchStartIndex2->text); + } + + public function testEmptyOpenSearchStartIndexToAndFromStringShouldMatch() { + $openSearchStartIndexXml = $this->openSearchStartIndex->saveXML(); + $newOpenSearchStartIndex = new Zend_Gdata_Extension_OpenSearchStartIndex(); + $newOpenSearchStartIndex->transferFromXML($openSearchStartIndexXml); + $newOpenSearchStartIndexXml = $newOpenSearchStartIndex->saveXML(); + $this->assertTrue($openSearchStartIndexXml == $newOpenSearchStartIndexXml); + } + + public function testOpenSearchStartIndexWithValueToAndFromStringShouldMatch() { + $this->openSearchStartIndex->text = "20"; + $openSearchStartIndexXml = $this->openSearchStartIndex->saveXML(); + $newOpenSearchStartIndex = new Zend_Gdata_Extension_OpenSearchStartIndex(); + $newOpenSearchStartIndex->transferFromXML($openSearchStartIndexXml); + $newOpenSearchStartIndexXml = $newOpenSearchStartIndex->saveXML(); + $this->assertTrue($openSearchStartIndexXml == $newOpenSearchStartIndexXml); + $this->assertEquals("20", $this->openSearchStartIndex->text); + } + + public function testExtensionAttributes() { + $extensionAttributes = $this->openSearchStartIndex->extensionAttributes; + $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); + $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); + $this->openSearchStartIndex->extensionAttributes = $extensionAttributes; + $this->assertEquals('bar', $this->openSearchStartIndex->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $this->openSearchStartIndex->extensionAttributes['foo2']['value']); + $openSearchStartIndexXml = $this->openSearchStartIndex->saveXML(); + $newOpenSearchStartIndex = new Zend_Gdata_Extension_OpenSearchStartIndex(); + $newOpenSearchStartIndex->transferFromXML($openSearchStartIndexXml); + $this->assertEquals('bar', $newOpenSearchStartIndex->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $newOpenSearchStartIndex->extensionAttributes['foo2']['value']); + } + + public function testConvertFullOpenSearchStartIndexToAndFromString() { + $this->openSearchStartIndex->transferFromXML($this->openSearchStartIndexText); + $this->assertEquals("5", $this->openSearchStartIndex->text); + } + +} diff --git a/zend/tests/Zend/Gdata/OpenSearchTotalResultsTest.php b/zend/tests/Zend/Gdata/OpenSearchTotalResultsTest.php new file mode 100644 index 0000000..6b4ff16 --- /dev/null +++ b/zend/tests/Zend/Gdata/OpenSearchTotalResultsTest.php @@ -0,0 +1,126 @@ +openSearchTotalResultsText = file_get_contents( + 'Zend/Gdata/_files/OpenSearchTotalResultsElementSample1.xml', + true); + $this->openSearchTotalResults = new Zend_Gdata_Extension_OpenSearchTotalResults(); + } + + public function testEmptyOpenSearchTotalResultsShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->openSearchTotalResults->extensionElements)); + $this->assertTrue(count($this->openSearchTotalResults->extensionElements) == 0); + } + + public function testEmptyOpenSearchTotalResultsShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->openSearchTotalResults->extensionAttributes)); + $this->assertTrue(count($this->openSearchTotalResults->extensionAttributes) == 0); + } + + public function testSampleOpenSearchTotalResultsShouldHaveNoExtensionElements() { + $this->openSearchTotalResults->transferFromXML($this->openSearchTotalResultsText); + $this->assertTrue(is_array($this->openSearchTotalResults->extensionElements)); + $this->assertTrue(count($this->openSearchTotalResults->extensionElements) == 0); + } + + public function testSampleOpenSearchTotalResultsShouldHaveNoExtensionAttributes() { + $this->openSearchTotalResults->transferFromXML($this->openSearchTotalResultsText); + $this->assertTrue(is_array($this->openSearchTotalResults->extensionAttributes)); + $this->assertTrue(count($this->openSearchTotalResults->extensionAttributes) == 0); + } + + public function testNormalOpenSearchTotalResultsShouldHaveNoExtensionElements() { + $this->openSearchTotalResults->text = "42"; + + $this->assertEquals("42", $this->openSearchTotalResults->text); + + $this->assertEquals(0, count($this->openSearchTotalResults->extensionElements)); + $newOpenSearchTotalResults = new Zend_Gdata_Extension_OpenSearchTotalResults(); + $newOpenSearchTotalResults->transferFromXML($this->openSearchTotalResults->saveXML()); + $this->assertEquals(0, count($newOpenSearchTotalResults->extensionElements)); + $newOpenSearchTotalResults->extensionElements = array( + new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); + $this->assertEquals(1, count($newOpenSearchTotalResults->extensionElements)); + $this->assertEquals("42", $newOpenSearchTotalResults->text); + + /* try constructing using magic factory */ + $gdata = new Zend_Gdata(); + $newOpenSearchTotalResults2 = $gdata->newOpenSearchTotalResults(); + $newOpenSearchTotalResults2->transferFromXML($newOpenSearchTotalResults->saveXML()); + $this->assertEquals(1, count($newOpenSearchTotalResults2->extensionElements)); + $this->assertEquals("42", $newOpenSearchTotalResults2->text); + } + + public function testEmptyOpenSearchTotalResultsToAndFromStringShouldMatch() { + $openSearchTotalResultsXml = $this->openSearchTotalResults->saveXML(); + $newOpenSearchTotalResults = new Zend_Gdata_Extension_OpenSearchTotalResults(); + $newOpenSearchTotalResults->transferFromXML($openSearchTotalResultsXml); + $newOpenSearchTotalResultsXml = $newOpenSearchTotalResults->saveXML(); + $this->assertTrue($openSearchTotalResultsXml == $newOpenSearchTotalResultsXml); + } + + public function testOpenSearchTotalResultsWithValueToAndFromStringShouldMatch() { + $this->openSearchTotalResults->text = "42"; + $openSearchTotalResultsXml = $this->openSearchTotalResults->saveXML(); + $newOpenSearchTotalResults = new Zend_Gdata_Extension_OpenSearchTotalResults(); + $newOpenSearchTotalResults->transferFromXML($openSearchTotalResultsXml); + $newOpenSearchTotalResultsXml = $newOpenSearchTotalResults->saveXML(); + $this->assertTrue($openSearchTotalResultsXml == $newOpenSearchTotalResultsXml); + $this->assertEquals("42", $this->openSearchTotalResults->text); + } + + public function testExtensionAttributes() { + $extensionAttributes = $this->openSearchTotalResults->extensionAttributes; + $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); + $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); + $this->openSearchTotalResults->extensionAttributes = $extensionAttributes; + $this->assertEquals('bar', $this->openSearchTotalResults->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $this->openSearchTotalResults->extensionAttributes['foo2']['value']); + $openSearchTotalResultsXml = $this->openSearchTotalResults->saveXML(); + $newOpenSearchTotalResults = new Zend_Gdata_Extension_OpenSearchTotalResults(); + $newOpenSearchTotalResults->transferFromXML($openSearchTotalResultsXml); + $this->assertEquals('bar', $newOpenSearchTotalResults->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $newOpenSearchTotalResults->extensionAttributes['foo2']['value']); + } + + public function testConvertFullOpenSearchTotalResultsToAndFromString() { + $this->openSearchTotalResults->transferFromXML($this->openSearchTotalResultsText); + $this->assertEquals("12", $this->openSearchTotalResults->text); + } + +} diff --git a/zend/tests/Zend/Gdata/OriginalEventTest.php b/zend/tests/Zend/Gdata/OriginalEventTest.php new file mode 100644 index 0000000..6147d88 --- /dev/null +++ b/zend/tests/Zend/Gdata/OriginalEventTest.php @@ -0,0 +1,134 @@ +originalEventText = file_get_contents( + 'Zend/Gdata/_files/OriginalEventElementSample1.xml', + true); + $this->originalEvent = new Zend_Gdata_Extension_OriginalEvent(); + } + + public function testEmptyOriginalEventShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->originalEvent->extensionElements)); + $this->assertTrue(count($this->originalEvent->extensionElements) == 0); + } + + public function testEmptyOriginalEventShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->originalEvent->extensionAttributes)); + $this->assertTrue(count($this->originalEvent->extensionAttributes) == 0); + } + + public function testSampleOriginalEventShouldHaveNoExtensionElements() { + $this->originalEvent->transferFromXML($this->originalEventText); + $this->assertTrue(is_array($this->originalEvent->extensionElements)); + $this->assertTrue(count($this->originalEvent->extensionElements) == 0); + } + + public function testSampleOriginalEventShouldHaveNoExtensionAttributes() { + $this->originalEvent->transferFromXML($this->originalEventText); + $this->assertTrue(is_array($this->originalEvent->extensionAttributes)); + $this->assertTrue(count($this->originalEvent->extensionAttributes) == 0); + } + + public function testNormalOriginalEventShouldHaveNoExtensionElements() { + $this->originalEvent->href = "http://www.google.com/calendar/feeds/nobody@gmail.com/private/composite"; + $this->originalEvent->id = "abcdef123456789"; + + $this->assertEquals("http://www.google.com/calendar/feeds/nobody@gmail.com/private/composite", $this->originalEvent->href); + $this->assertEquals("abcdef123456789", $this->originalEvent->id); + + $this->assertEquals(0, count($this->originalEvent->extensionElements)); + $newOriginalEvent = new Zend_Gdata_Extension_OriginalEvent(); + $newOriginalEvent->transferFromXML($this->originalEvent->saveXML()); + $this->assertEquals(0, count($newOriginalEvent->extensionElements)); + $newOriginalEvent->extensionElements = array( + new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); + $this->assertEquals(1, count($newOriginalEvent->extensionElements)); + $this->assertEquals("http://www.google.com/calendar/feeds/nobody@gmail.com/private/composite", $newOriginalEvent->href); + $this->assertEquals("abcdef123456789", $newOriginalEvent->id); + + /* try constructing using magic factory */ + $gdata = new Zend_Gdata(); + $newOriginalEvent2 = $gdata->newOriginalEvent(); + $newOriginalEvent2->transferFromXML($newOriginalEvent->saveXML()); + $this->assertEquals(1, count($newOriginalEvent2->extensionElements)); + $this->assertEquals("http://www.google.com/calendar/feeds/nobody@gmail.com/private/composite", $newOriginalEvent2->href); + $this->assertEquals("abcdef123456789", $newOriginalEvent2->id); + } + + public function testEmptyOriginalEventToAndFromStringShouldMatch() { + $originalEventXml = $this->originalEvent->saveXML(); + $newOriginalEvent = new Zend_Gdata_Extension_OriginalEvent(); + $newOriginalEvent->transferFromXML($originalEventXml); + $newOriginalEventXml = $newOriginalEvent->saveXML(); + $this->assertTrue($originalEventXml == $newOriginalEventXml); + } + + public function testOriginalEventWithValueToAndFromStringShouldMatch() { + $this->originalEvent->href = "http://www.google.com/calendar/feeds/nobody@gmail.com/private/composite"; + $this->originalEvent->id = "abcdef123456789"; + $originalEventXml = $this->originalEvent->saveXML(); + $newOriginalEvent = new Zend_Gdata_Extension_OriginalEvent(); + $newOriginalEvent->transferFromXML($originalEventXml); + $newOriginalEventXml = $newOriginalEvent->saveXML(); + $this->assertTrue($originalEventXml == $newOriginalEventXml); + $this->assertEquals("http://www.google.com/calendar/feeds/nobody@gmail.com/private/composite", $this->originalEvent->href); + $this->assertEquals("abcdef123456789", $this->originalEvent->id); + } + + public function testExtensionAttributes() { + $extensionAttributes = $this->originalEvent->extensionAttributes; + $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); + $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); + $this->originalEvent->extensionAttributes = $extensionAttributes; + $this->assertEquals('bar', $this->originalEvent->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $this->originalEvent->extensionAttributes['foo2']['value']); + $originalEventXml = $this->originalEvent->saveXML(); + $newOriginalEvent = new Zend_Gdata_Extension_OriginalEvent(); + $newOriginalEvent->transferFromXML($originalEventXml); + $this->assertEquals('bar', $newOriginalEvent->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $newOriginalEvent->extensionAttributes['foo2']['value']); + } + + public function testConvertFullOriginalEventToAndFromString() { + $this->originalEvent->transferFromXML($this->originalEventText); + $this->assertEquals("http://www.google.com/calendar/feeds/userID/private/full/123456789", $this->originalEvent->href); + $this->assertEquals("i8fl1nrv2bl57c1qgr3f0onmgg", $this->originalEvent->id); + $this->assertTrue($this->originalEvent->when instanceof Zend_Gdata_Extension_When); + $this->assertEquals("2006-03-17T22:00:00.000Z", $this->originalEvent->when->startTime); + } + +} 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 diff --git a/zend/tests/Zend/Gdata/PhotosOnlineTest.php b/zend/tests/Zend/Gdata/PhotosOnlineTest.php new file mode 100755 index 0000000..3cadc23 --- /dev/null +++ b/zend/tests/Zend/Gdata/PhotosOnlineTest.php @@ -0,0 +1,288 @@ +photos = new Zend_Gdata_Photos($client); + } + + /** + * 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 verifyProperty($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()); + } + + public function createAlbum() + { + $client = $this->photos; + + $album = new Zend_Gdata_Photos_AlbumEntry(); + $album->setTitle($client->newTitle("testAlbum")); + $album->setCategory(array($client->newCategory( + 'http://schemas.google.com/photos/2007#album', + 'http://schemas.google.com/g/2005#kind'))); + + $newAlbum = $client->insertAlbumEntry($album); + $this->assertEquals($album->getTitle(), $newAlbum->getTitle()); + $this->assertEquals($newAlbum->getTitle(), $client->getAlbumEntry($newAlbum->getLink('self')->href)->getTitle()); + + $albumFeedUri = $newAlbum->getLink('http://schemas.google.com/g/2005#feed')->href; + $albumFeed = $client->getAlbumFeed($albumFeedUri); + $this->verifyProperty($albumFeed, "title", "text", "testAlbum"); + + return $newAlbum; + } + + public function createPhoto($album) + { + $client = $this->photos; + + $fd = $client->newMediaFileSource('Zend/Gdata/_files/testImage.jpg'); + $fd->setContentType('image/jpeg'); + + $photo = new Zend_Gdata_Photos_PhotoEntry(); + $photo->setMediaSource($fd); + $photo->setTitle($client->newTitle("test photo")); + $photo->setCategory(array($client->newCategory( + 'http://schemas.google.com/photos/2007#photo', + 'http://schemas.google.com/g/2005#kind'))); + + $newPhoto = $client->insertPhotoEntry($photo, $album); + $this->assertEquals($photo->getTitle(), $newPhoto->getTitle()); + $this->assertEquals($newPhoto->getTitle(), $client->getPhotoEntry($newPhoto->getLink('self')->href)->getTitle()); + + $photoFeedUri = $newPhoto->getLink('http://schemas.google.com/g/2005#feed')->href; + $photoFeed = $client->getPhotoFeed($photoFeedUri); + $this->verifyProperty($photoFeed, "title", "text", "test photo"); + + return $newPhoto; + } + + public function updatePhotoMetaData() + { + $client = $this->photos; + $album = $this->createAlbum(); + $insertedEntry = $this->createPhoto($album); + + $insertedEntry->title->text = "New Photo"; + $insertedEntry->summary->text = "Photo caption"; + $keywords = new Zend_Gdata_Media_Extension_MediaKeywords(); + $keywords->setText("foo, bar, baz"); + $insertedEntry->mediaGroup->keywords = $keywords; + + $updatedEntry = $insertedEntry->save(); + return array($updatedEntry, $album); + } + + public function createComment($photo) + { + $client = $this->photos; + + $comment = new Zend_Gdata_Photos_CommentEntry(); + $comment->setTitle($client->newTitle("test comment")); + $comment->setContent($client->newContent("test comment")); + $comment->setCategory(array($client->newCategory( + 'http://schemas.google.com/photos/2007#comment', + 'http://schemas.google.com/g/2005#kind'))); + + $newComment = $client->insertCommentEntry($comment, $photo); + $this->assertEquals($comment->getContent(), $newComment->getContent()); + $this->assertEquals($newComment->getContent(), $client->getCommentEntry($newComment->getLink('self')->href)->getContent()); + + return $newComment; + } + + public function createTag($photo) + { + $client = $this->photos; + + $tag = new Zend_Gdata_Photos_TagEntry(); + $tag->setTitle($client->newTitle("test tag")); + $tag->setContent($client->newContent("test tag")); + $tag->setCategory(array($client->newCategory( + 'http://schemas.google.com/photos/2007#tag', + 'http://schemas.google.com/g/2005#kind'))); + + $newTag = $client->insertTagEntry($tag, $photo); + $this->assertEquals($tag->getTitle(), $newTag->getTitle()); + $this->assertEquals($newTag->getTitle(), $client->getTagEntry($newTag->getLink('self')->href)->getTitle()); + + return $newTag; + } + + public function testCreateAlbumAndUploadPhoto() + { + $client = $this->photos; + $album = $this->createAlbum(); + $photo = $this->createPhoto($album); + + // Clean up the mess + $client->deletePhotoEntry($photo, true); + $client->deleteAlbumEntry($album, true); + } + + public function testUpdatePhotoMetadata() + { + $client = $this->photos; + $dataArray = $this->updatePhotoMetaData(); + $updatedPhoto = $dataArray[0]; + $album = $dataArray[1]; + + $this->assertTrue($updatedPhoto instanceof Zend_Gdata_Photos_PhotoEntry); + + // Clean up the mess + $client->deletePhotoEntry($updatedPhoto, true); + $client->deleteAlbumEntry($album, true); + } + + public function testUserFeedAndEntry() + { + $client = $this->photos; + + $userEntryUri = "http://picasaweb.google.com/data/entry/api/user/" . + constant('TESTS_ZEND_GDATA_PHOTOS_USERNAME'); + + $userEntry = $client->getUserEntry($userEntryUri); + $this->verifyProperty($userEntry, "id", "text", + "http://picasaweb.google.com/data/entry/api/user/" . + constant('TESTS_ZEND_GDATA_PHOTOS_USERNAME')); + + + $userFeed = $client->getUserFeed(constant('TESTS_ZEND_GDATA_PHOTOS_USERNAME')); + $this->verifyProperty($userFeed, "id", "text", + "http://picasaweb.google.com/data/feed/api/user/" . + constant('TESTS_ZEND_GDATA_PHOTOS_USERNAME')); + } + + public function testCreatePhotoCommentAndTag() + { + $client = $this->photos; + $album = $this->createAlbum(); + $photo = $this->createPhoto($album); + $comment = $this->createComment($photo); + $tag = $this->createTag($photo); + + // Clean up the mess + $client->deleteTagEntry($tag, true); + $client->deleteCommentEntry($comment, true); + $client->deletePhotoEntry($photo, true); + $client->deleteAlbumEntry($album, true); + } + + public function testInvalidEntryFetchingAndInserting() + { + $client = $this->photos; + + try { + $userEntry = $client->getUserEntry(null); + } catch (Exception $e) { + $this->assertTrue($e instanceof Zend_Gdata_App_InvalidArgumentException); + } + try { + $userEntry = $client->getAlbumEntry(null); + } catch (Exception $e) { + $this->assertTrue($e instanceof Zend_Gdata_App_InvalidArgumentException); + } + try { + $photoEntry = $client->getPhotoEntry(null); + } catch (Exception $e) { + $this->assertTrue($e instanceof Zend_Gdata_App_InvalidArgumentException); + } + try { + $tagEntry = $client->getTagEntry(null); + } catch (Exception $e) { + $this->assertTrue($e instanceof Zend_Gdata_App_InvalidArgumentException); + } + try { + $commentEntry = $client->getCommentEntry(null); + } catch (Exception $e) { + $this->assertTrue($e instanceof Zend_Gdata_App_InvalidArgumentException); + } + try { + $photo = new Zend_Gdata_Photos_PhotoEntry(); + $result = $client->insertPhotoEntry($photo, null); + } catch (Exception $e) { + $this->assertTrue($e instanceof Zend_Gdata_App_InvalidArgumentException); + } + try { + $comment = new Zend_Gdata_Photos_CommentEntry(); + $result = $client->insertCommentEntry($comment, null); + } catch (Exception $e) { + $this->assertTrue($e instanceof Zend_Gdata_App_InvalidArgumentException); + } + try { + $tag = new Zend_Gdata_Photos_TagEntry(); + $result = $client->insertTagEntry($tag, null); + } catch (Exception $e) { + $this->assertTrue($e instanceof Zend_Gdata_App_InvalidArgumentException); + } + } + + public function testInvalidFeedFetching() + { + $client = $this->photos; + + try { + $albumFeed = $client->getAlbumFeed(null); + } catch (Exception $e) { + $this->assertTrue($e instanceof Zend_Gdata_App_InvalidArgumentException); + } + } + +} diff --git a/zend/tests/Zend/Gdata/QueryTest.php b/zend/tests/Zend/Gdata/QueryTest.php new file mode 100644 index 0000000..5c0bf3f --- /dev/null +++ b/zend/tests/Zend/Gdata/QueryTest.php @@ -0,0 +1,122 @@ +setAlt('rss'); + $this->assertEquals('rss', $query->alt); + $this->assertContains('alt=rss', $query->getQueryUrl()); + } + + public function testSetAndGetUpdatedMax() + { + $query = new Zend_Gdata_Query(); + $query->setUpdatedMax('2007-01-01'); + $this->assertEquals('2007-01-01', $query->getUpdatedMax()); + $this->assertContains('updated-max=2007-01-01', $query->getQueryUrl()); + } + + public function testSetAndGetUpdatedMin() + { + $query = new Zend_Gdata_Query(); + $query->setUpdatedMin('2007-01-01'); + $this->assertEquals('2007-01-01', $query->getUpdatedMin()); + $this->assertContains('updated-min=2007-01-01', $query->getQueryUrl()); + } + + public function testSetAndGetPublishedMax() + { + $query = new Zend_Gdata_Query(); + $query->setPublishedMax('2007-01-01'); + $this->assertEquals('2007-01-01', $query->getPublishedMax()); + $this->assertContains('published-max=2007-01-01', + $query->getQueryUrl()); + } + + public function testSetAndGetPublishedMin() + { + $query = new Zend_Gdata_Query(); + $query->setPublishedMin('2007-01-01'); + $this->assertEquals('2007-01-01', $query->getPublishedMin()); + $this->assertContains('published-min=2007-01-01', + $query->getQueryUrl()); + } + + public function testSetAndGetAuthor() + { + $query = new Zend_Gdata_Query(); + $query->setAuthor('My Name'); + $this->assertEquals('My Name', $query->getAuthor()); + $this->assertContains('author=My+Name', $query->getQueryUrl()); + } + + public function testSetAndGetMaxResults() + { + $query = new Zend_Gdata_Query(); + $query->setMaxResults('300'); + $this->assertEquals('300', $query->getMaxResults()); + $this->assertContains('max-results=300', $query->getQueryUrl()); + } + + public function testSetAndGetGenericParam() + { + $query = new Zend_Gdata_Query(); + $query->setParam('fw', 'zend'); + $this->assertEquals('zend', $query->getParam('fw')); + $this->assertContains('fw=zend', $query->getQueryUrl()); + } + + public function testSetAndGetFullTextQuery() + { + $query = new Zend_Gdata_Query(); + $query->setQuery('geek events'); + $this->assertEquals('geek events', $query->getQuery()); + $this->assertContains('q=geek+events', $query->getQueryUrl()); + } + + public function testSetAndGetStartIndex() + { + $query = new Zend_Gdata_Query(); + $query->setStartIndex(12); + $this->assertEquals(12, $query->getStartIndex()); + $this->assertContains('start-index=12', $query->getQueryUrl()); + } + +} diff --git a/zend/tests/Zend/Gdata/RecurrenceExceptionTest.php b/zend/tests/Zend/Gdata/RecurrenceExceptionTest.php new file mode 100644 index 0000000..86ac4aa --- /dev/null +++ b/zend/tests/Zend/Gdata/RecurrenceExceptionTest.php @@ -0,0 +1,129 @@ +recurrenceExceptionText = file_get_contents( + 'Zend/Gdata/_files/RecurrenceExceptionElementSample1.xml', + true); + $this->recurrenceException = new Zend_Gdata_Extension_RecurrenceException(); + } + + public function testEmptyRecurrenceExceptionShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->recurrenceException->extensionElements)); + $this->assertTrue(count($this->recurrenceException->extensionElements) == 0); + } + + public function testEmptyRecurrenceExceptionShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->recurrenceException->extensionAttributes)); + $this->assertTrue(count($this->recurrenceException->extensionAttributes) == 0); + } + + public function testSampleRecurrenceExceptionShouldHaveNoExtensionElements() { + $this->recurrenceException->transferFromXML($this->recurrenceExceptionText); + $this->assertTrue(is_array($this->recurrenceException->extensionElements)); + $this->assertTrue(count($this->recurrenceException->extensionElements) == 0); + } + + public function testSampleRecurrenceExceptionShouldHaveNoExtensionAttributes() { + $this->recurrenceException->transferFromXML($this->recurrenceExceptionText); + $this->assertTrue(is_array($this->recurrenceException->extensionAttributes)); + $this->assertTrue(count($this->recurrenceException->extensionAttributes) == 0); + } + + public function testNormalRecurrenceExceptionShouldHaveNoExtensionElements() { + $this->recurrenceException->specialized = "false"; + + $this->assertEquals("false", $this->recurrenceException->specialized); + + $this->assertEquals(0, count($this->recurrenceException->extensionElements)); + $newRecurrenceException = new Zend_Gdata_Extension_RecurrenceException(); + $newRecurrenceException->transferFromXML($this->recurrenceException->saveXML()); + $this->assertEquals(0, count($newRecurrenceException->extensionElements)); + $newRecurrenceException->extensionElements = array( + new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); + $this->assertEquals(1, count($newRecurrenceException->extensionElements)); + $this->assertEquals("false", $newRecurrenceException->specialized); + + /* try constructing using magic factory */ + $gdata = new Zend_Gdata(); + $newRecurrenceException2 = $gdata->newRecurrenceException(); + $newRecurrenceException2->transferFromXML($newRecurrenceException->saveXML()); + $this->assertEquals(1, count($newRecurrenceException2->extensionElements)); + $this->assertEquals("false", $newRecurrenceException2->specialized); + } + + public function testEmptyRecurrenceExceptionToAndFromStringShouldMatch() { + $recurrenceExceptionXml = $this->recurrenceException->saveXML(); + $newRecurrenceException = new Zend_Gdata_Extension_RecurrenceException(); + $newRecurrenceException->transferFromXML($recurrenceExceptionXml); + $newRecurrenceExceptionXml = $newRecurrenceException->saveXML(); + $this->assertTrue($recurrenceExceptionXml == $newRecurrenceExceptionXml); + } + + public function testRecurrenceExceptionWithValueToAndFromStringShouldMatch() { + $this->recurrenceException->specialized = "false"; + $recurrenceExceptionXml = $this->recurrenceException->saveXML(); + $newRecurrenceException = new Zend_Gdata_Extension_RecurrenceException(); + $newRecurrenceException->transferFromXML($recurrenceExceptionXml); + $newRecurrenceExceptionXml = $newRecurrenceException->saveXML(); + $this->assertTrue($recurrenceExceptionXml == $newRecurrenceExceptionXml); + $this->assertEquals("false", $this->recurrenceException->specialized); + } + + public function testExtensionAttributes() { + $extensionAttributes = $this->recurrenceException->extensionAttributes; + $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); + $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); + $this->recurrenceException->extensionAttributes = $extensionAttributes; + $this->assertEquals('bar', $this->recurrenceException->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $this->recurrenceException->extensionAttributes['foo2']['value']); + $recurrenceExceptionXml = $this->recurrenceException->saveXML(); + $newRecurrenceException = new Zend_Gdata_Extension_RecurrenceException(); + $newRecurrenceException->transferFromXML($recurrenceExceptionXml); + $this->assertEquals('bar', $newRecurrenceException->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $newRecurrenceException->extensionAttributes['foo2']['value']); + } + + public function testConvertFullRecurrenceExceptionToAndFromString() { + $this->recurrenceException->transferFromXML($this->recurrenceExceptionText); + $this->assertEquals("true", $this->recurrenceException->specialized); + $this->assertTrue($this->recurrenceException->entryLink instanceof Zend_Gdata_Extension_EntryLink); + $this->assertEquals("http://www.google.com/calendar/feeds/default/private/full/hj4geu9lpkh3ebk6rvm4k8mhik", $this->recurrenceException->entryLink->href); + $this->assertTrue($this->recurrenceException->originalEvent instanceof Zend_Gdata_Extension_OriginalEvent); + $this->assertEquals("hj4geu9lpkh3ebk6rvm4k8mhik", $this->recurrenceException->originalEvent->id); + } + +} diff --git a/zend/tests/Zend/Gdata/RecurrenceTest.php b/zend/tests/Zend/Gdata/RecurrenceTest.php new file mode 100644 index 0000000..6c3ac47 --- /dev/null +++ b/zend/tests/Zend/Gdata/RecurrenceTest.php @@ -0,0 +1,125 @@ +recurrenceText = file_get_contents( + 'Zend/Gdata/_files/RecurrenceElementSample1.xml', + true); + $this->recurrence = new Zend_Gdata_Extension_Recurrence(); + } + + public function testEmptyRecurrenceShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->recurrence->extensionElements)); + $this->assertTrue(count($this->recurrence->extensionElements) == 0); + } + + public function testEmptyRecurrenceShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->recurrence->extensionAttributes)); + $this->assertTrue(count($this->recurrence->extensionAttributes) == 0); + } + + public function testSampleRecurrenceShouldHaveNoExtensionElements() { + $this->recurrence->transferFromXML($this->recurrenceText); + $this->assertTrue(is_array($this->recurrence->extensionElements)); + $this->assertTrue(count($this->recurrence->extensionElements) == 0); + } + + public function testSampleRecurrenceShouldHaveNoExtensionAttributes() { + $this->recurrence->transferFromXML($this->recurrenceText); + $this->assertTrue(is_array($this->recurrence->extensionAttributes)); + $this->assertTrue(count($this->recurrence->extensionAttributes) == 0); + } + + public function testNormalRecurrenceShouldHaveNoExtensionElements() { + $this->recurrence->text = "Foo"; + + $this->assertEquals("Foo", $this->recurrence->text); + + $this->assertEquals(0, count($this->recurrence->extensionElements)); + $newRecurrence = new Zend_Gdata_Extension_Recurrence(); + $newRecurrence->transferFromXML($this->recurrence->saveXML()); + $this->assertEquals(0, count($newRecurrence->extensionElements)); + $newRecurrence->extensionElements = array( + new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); + $this->assertEquals(1, count($newRecurrence->extensionElements)); + $this->assertEquals("Foo", $newRecurrence->text); + + /* try constructing using magic factory */ + $gdata = new Zend_Gdata(); + $newRecurrence2 = $gdata->newRecurrence(); + $newRecurrence2->transferFromXML($newRecurrence->saveXML()); + $this->assertEquals(1, count($newRecurrence2->extensionElements)); + $this->assertEquals("Foo", $newRecurrence2->text); + } + + public function testEmptyRecurrenceToAndFromStringShouldMatch() { + $recurrenceXml = $this->recurrence->saveXML(); + $newRecurrence = new Zend_Gdata_Extension_Recurrence(); + $newRecurrence->transferFromXML($recurrenceXml); + $newRecurrenceXml = $newRecurrence->saveXML(); + $this->assertTrue($recurrenceXml == $newRecurrenceXml); + } + + public function testRecurrenceWithValueToAndFromStringShouldMatch() { + $this->recurrence->text = "Foo"; + $recurrenceXml = $this->recurrence->saveXML(); + $newRecurrence = new Zend_Gdata_Extension_Recurrence(); + $newRecurrence->transferFromXML($recurrenceXml); + $newRecurrenceXml = $newRecurrence->saveXML(); + $this->assertTrue($recurrenceXml == $newRecurrenceXml); + $this->assertEquals("Foo", $this->recurrence->text); + } + + public function testExtensionAttributes() { + $extensionAttributes = $this->recurrence->extensionAttributes; + $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); + $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); + $this->recurrence->extensionAttributes = $extensionAttributes; + $this->assertEquals('bar', $this->recurrence->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $this->recurrence->extensionAttributes['foo2']['value']); + $recurrenceXml = $this->recurrence->saveXML(); + $newRecurrence = new Zend_Gdata_Extension_Recurrence(); + $newRecurrence->transferFromXML($recurrenceXml); + $this->assertEquals('bar', $newRecurrence->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $newRecurrence->extensionAttributes['foo2']['value']); + } + + public function testConvertFullRecurrenceToAndFromString() { + $this->recurrence->transferFromXML($this->recurrenceText); + $this->assertEquals("DTSTART;VALUE=DATE:20070501\nDTEND;VALUE=DATE:20070502\nRRULE:FREQ=WEEKLY;BYDAY=Tu;UNTIL=20070904", $this->recurrence->text); + } + +} diff --git a/zend/tests/Zend/Gdata/ReminderTest.php b/zend/tests/Zend/Gdata/ReminderTest.php new file mode 100644 index 0000000..8268353 --- /dev/null +++ b/zend/tests/Zend/Gdata/ReminderTest.php @@ -0,0 +1,153 @@ +reminderText = file_get_contents( + 'Zend/Gdata/_files/ReminderElementSample1.xml', + true); + $this->reminder = new Zend_Gdata_Extension_Reminder(); + } + + public function testEmptyReminderShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->reminder->extensionElements)); + $this->assertTrue(count($this->reminder->extensionElements) == 0); + } + + public function testEmptyReminderShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->reminder->extensionAttributes)); + $this->assertTrue(count($this->reminder->extensionAttributes) == 0); + } + + public function testSampleReminderShouldHaveNoExtensionElements() { + $this->reminder->transferFromXML($this->reminderText); + $this->assertTrue(is_array($this->reminder->extensionElements)); + $this->assertTrue(count($this->reminder->extensionElements) == 0); + } + + public function testSampleReminderShouldHaveNoExtensionAttributes() { + $this->reminder->transferFromXML($this->reminderText); + $this->assertTrue(is_array($this->reminder->extensionAttributes)); + $this->assertTrue(count($this->reminder->extensionAttributes) == 0); + } + + public function testNormalReminderShouldHaveNoExtensionElements() { + $this->reminder->days = "12"; + $this->reminder->minutes = "64"; + $this->reminder->absoluteTime = "2007-06-19T12:42:19-06:00"; + $this->reminder->method = "email"; + $this->reminder->hours = "80"; + + $this->assertEquals("12", $this->reminder->days); + $this->assertEquals("64", $this->reminder->minutes); + $this->assertEquals("2007-06-19T12:42:19-06:00", $this->reminder->absoluteTime); + $this->assertEquals("email", $this->reminder->method); + $this->assertEquals("80", $this->reminder->hours); + + $this->assertEquals(0, count($this->reminder->extensionElements)); + $newReminder = new Zend_Gdata_Extension_Reminder(); + $newReminder->transferFromXML($this->reminder->saveXML()); + $this->assertEquals(0, count($newReminder->extensionElements)); + $newReminder->extensionElements = array( + new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); + $this->assertEquals(1, count($newReminder->extensionElements)); + $this->assertEquals("12", $newReminder->days); + $this->assertEquals("64", $newReminder->minutes); + $this->assertEquals("2007-06-19T12:42:19-06:00", $newReminder->absoluteTime); + $this->assertEquals("email", $newReminder->method); + $this->assertEquals("80", $newReminder->hours); + + /* try constructing using magic factory */ + $gdata = new Zend_Gdata(); + $newReminder2 = $gdata->newReminder(); + $newReminder2->transferFromXML($newReminder->saveXML()); + $this->assertEquals(1, count($newReminder2->extensionElements)); + $this->assertEquals("12", $newReminder2->days); + $this->assertEquals("64", $newReminder2->minutes); + $this->assertEquals("2007-06-19T12:42:19-06:00", $newReminder2->absoluteTime); + $this->assertEquals("email", $newReminder2->method); + $this->assertEquals("80", $newReminder2->hours); + } + + public function testEmptyReminderToAndFromStringShouldMatch() { + $reminderXml = $this->reminder->saveXML(); + $newReminder = new Zend_Gdata_Extension_Reminder(); + $newReminder->transferFromXML($reminderXml); + $newReminderXml = $newReminder->saveXML(); + $this->assertTrue($reminderXml == $newReminderXml); + } + + public function testReminderWithValueToAndFromStringShouldMatch() { + $this->reminder->days = "12"; + $this->reminder->minutes = "64"; + $this->reminder->absoluteTime = "2007-06-19T12:42:19-06:00"; + $this->reminder->method = "email"; + $this->reminder->hours = "80"; + $reminderXml = $this->reminder->saveXML(); + $newReminder = new Zend_Gdata_Extension_Reminder(); + $newReminder->transferFromXML($reminderXml); + $newReminderXml = $newReminder->saveXML(); + $this->assertTrue($reminderXml == $newReminderXml); + $this->assertEquals("12", $this->reminder->days); + $this->assertEquals("64", $this->reminder->minutes); + $this->assertEquals("2007-06-19T12:42:19-06:00", $this->reminder->absoluteTime); + $this->assertEquals("email", $this->reminder->method); + $this->assertEquals("80", $this->reminder->hours); + } + + public function testExtensionAttributes() { + $extensionAttributes = $this->reminder->extensionAttributes; + $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); + $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); + $this->reminder->extensionAttributes = $extensionAttributes; + $this->assertEquals('bar', $this->reminder->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $this->reminder->extensionAttributes['foo2']['value']); + $reminderXml = $this->reminder->saveXML(); + $newReminder = new Zend_Gdata_Extension_Reminder(); + $newReminder->transferFromXML($reminderXml); + $this->assertEquals('bar', $newReminder->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $newReminder->extensionAttributes['foo2']['value']); + } + + public function testConvertFullReminderToAndFromString() { + $this->reminder->transferFromXML($this->reminderText); + $this->assertEquals("42", $this->reminder->days); + $this->assertEquals("50", $this->reminder->minutes); + $this->assertEquals("2005-06-06T16:55:00-08:00", $this->reminder->absoluteTime); + $this->assertEquals("sms", $this->reminder->method); + $this->assertEquals("20", $this->reminder->hours); + } + +} diff --git a/zend/tests/Zend/Gdata/SkipTests.php b/zend/tests/Zend/Gdata/SkipTests.php new file mode 100644 index 0000000..2829893 --- /dev/null +++ b/zend/tests/Zend/Gdata/SkipTests.php @@ -0,0 +1,55 @@ +markTestSkipped("Zend_Gdata online tests are not enabled in TestConfiguration.php"); + } + + public function testOnline() + { + // this is here only so we have at least one test + } +} + +class Zend_Gdata_SkipClientLoginTest extends PHPUnit_Framework_TestCase +{ + public function setUp() + { + $this->markTestSkipped("Zend_Gdata authenticated tests are not enabled in TestConfiguration.php"); + } + + public function testClientLogin() + { + // this is here only so we have at least one test + } +} diff --git a/zend/tests/Zend/Gdata/Spreadsheets/CellEntryTest.php b/zend/tests/Zend/Gdata/Spreadsheets/CellEntryTest.php new file mode 100644 index 0000000..84b2ca3 --- /dev/null +++ b/zend/tests/Zend/Gdata/Spreadsheets/CellEntryTest.php @@ -0,0 +1,64 @@ +cellEntry = new Zend_Gdata_Spreadsheets_CellEntry(); + } + + public function testToAndFromString() + { + $this->cellEntry->setCell(new Zend_Gdata_Spreadsheets_Extension_Cell('my cell', '1', '2', 'input value', 'numeric value')); + $this->assertTrue($this->cellEntry->getCell()->getText() == 'my cell'); + $this->assertTrue($this->cellEntry->getCell()->getRow() == '1'); + $this->assertTrue($this->cellEntry->getCell()->getColumn() == '2'); + $this->assertTrue($this->cellEntry->getCell()->getInputValue() == 'input value'); + $this->assertTrue($this->cellEntry->getCell()->getNumericValue() == 'numeric value'); + + $newCellEntry = new Zend_Gdata_Spreadsheets_CellEntry(); + $doc = new DOMDocument(); + $doc->loadXML($this->cellEntry->saveXML()); + $newCellEntry->transferFromDom($doc->documentElement); + + $this->assertTrue($this->cellEntry->getCell()->getText() == $newCellEntry->getCell()->getText()); + $this->assertTrue($this->cellEntry->getCell()->getRow() == $newCellEntry->getCell()->getRow()); + $this->assertTrue($this->cellEntry->getCell()->getColumn() == $newCellEntry->getCell()->getColumn()); + $this->assertTrue($this->cellEntry->getCell()->getInputValue() == $newCellEntry->getCell()->getInputValue()); + $this->assertTrue($this->cellEntry->getCell()->getNumericValue() == $newCellEntry->getCell()->getNumericValue()); + } + +} diff --git a/zend/tests/Zend/Gdata/Spreadsheets/CellFeedTest.php b/zend/tests/Zend/Gdata/Spreadsheets/CellFeedTest.php new file mode 100644 index 0000000..b6c804d --- /dev/null +++ b/zend/tests/Zend/Gdata/Spreadsheets/CellFeedTest.php @@ -0,0 +1,91 @@ +cellFeed = new Zend_Gdata_Spreadsheets_CellFeed( + file_get_contents('Zend/Gdata/Spreadsheets/_files/TestDataCellFeedSample1.xml', true), + true); + } + + public function testToAndFromString() + { + $this->assertTrue(count($this->cellFeed->entries) == 2); + $this->assertTrue($this->cellFeed->entries->count() == 2); + + foreach($this->cellFeed->entries as $entry) + { + $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_CellEntry); + } + $this->assertTrue($this->cellFeed->getRowCount() instanceof Zend_Gdata_Spreadsheets_Extension_RowCount); + $this->assertTrue($this->cellFeed->getRowCount()->getText() == '100'); + $this->assertTrue($this->cellFeed->getColumnCount() instanceof Zend_Gdata_Spreadsheets_Extension_ColCount); + $this->assertTrue($this->cellFeed->getColumnCount()->getText() == '20'); + + $newCellFeed = new Zend_Gdata_Spreadsheets_CellFeed(); + $doc = new DOMDocument(); + $doc->loadXML($this->cellFeed->saveXML()); + $newCellFeed->transferFromDom($doc->documentElement); + + $this->assertTrue(count($newCellFeed->entries) == 2); + $this->assertTrue($newCellFeed->entries->count() == 2); + + foreach($newCellFeed->entries as $entry) + { + $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_CellEntry); + } + $this->assertTrue($newCellFeed->getRowCount() instanceof Zend_Gdata_Spreadsheets_Extension_RowCount); + $this->assertTrue($newCellFeed->getRowCount()->getText() == '100'); + $this->assertTrue($newCellFeed->getColumnCount() instanceof Zend_Gdata_Spreadsheets_Extension_ColCount); + $this->assertTrue($newCellFeed->getColumnCount()->getText() == '20'); + } + + public function testGetSetCounts() + { + $newRowCount = new Zend_Gdata_Spreadsheets_Extension_RowCount(); + $newRowCount->setText("20"); + $newColCount = new Zend_Gdata_Spreadsheets_Extension_ColCount(); + $newColCount->setText("50"); + + $this->cellFeed->setRowCount($newRowCount); + $this->cellFeed->setColumnCount($newColCount); + + $this->assertTrue($this->cellFeed->getRowCount()->getText() == "20"); + $this->assertTrue($this->cellFeed->getColumnCount()->getText() == "50"); + } + +} diff --git a/zend/tests/Zend/Gdata/Spreadsheets/CellQueryTest.php b/zend/tests/Zend/Gdata/Spreadsheets/CellQueryTest.php new file mode 100644 index 0000000..997c926 --- /dev/null +++ b/zend/tests/Zend/Gdata/Spreadsheets/CellQueryTest.php @@ -0,0 +1,138 @@ +docQuery = new Zend_Gdata_Spreadsheets_CellQuery(); + } + + public function testMinRow() + { + $this->assertTrue($this->docQuery->getMinRow() == null); + $this->docQuery->setMinRow('1'); + $this->assertTrue($this->docQuery->getMinRow() == '1'); + $this->assertTrue($this->docQuery->getQueryString() == '?min-row=1'); + $this->docQuery->setMinRow(null); + $this->assertTrue($this->docQuery->getMinRow() == null); + } + + public function testMaxRow() + { + $this->assertTrue($this->docQuery->getMaxRow() == null); + $this->docQuery->setMaxRow('2'); + $this->assertTrue($this->docQuery->getMaxRow() == '2'); + $this->assertTrue($this->docQuery->getQueryString() == '?max-row=2'); + $this->docQuery->setMaxRow(null); + $this->assertTrue($this->docQuery->getMaxRow() == null); + } + + public function testMinCol() + { + $this->assertTrue($this->docQuery->getMinCol() == null); + $this->docQuery->setMinCol('3'); + $this->assertTrue($this->docQuery->getMinCol() == '3'); + $this->assertTrue($this->docQuery->getQueryString() == '?min-col=3'); + $this->docQuery->setMinCol(null); + $this->assertTrue($this->docQuery->getMinCol() == null); + } + + public function testMaxCol() + { + $this->assertTrue($this->docQuery->getMaxCol() == null); + $this->docQuery->setMaxCol('4'); + $this->assertTrue($this->docQuery->getMaxCol() == '4'); + $this->assertTrue($this->docQuery->getQueryString() == '?max-col=4'); + $this->docQuery->setMaxCol(null); + $this->assertTrue($this->docQuery->getMaxCol() == null); + } + + public function testRange() + { + $this->assertTrue($this->docQuery->getRange() == null); + $this->docQuery->setRange('A1:B4'); + $this->assertTrue($this->docQuery->getRange() == 'A1:B4'); + $this->assertTrue($this->docQuery->getQueryString() == '?range=A1%3AB4'); + $this->docQuery->setRange(null); + $this->assertTrue($this->docQuery->getRange() == null); + } + + public function testReturnEmpty() + { + $this->assertTrue($this->docQuery->getReturnEmpty() == null); + $this->docQuery->setReturnEmpty('false'); + $this->assertTrue($this->docQuery->getReturnEmpty() == 'false'); + $this->assertTrue($this->docQuery->getQueryString() == '?return-empty=false'); + $this->docQuery->setReturnEmpty(null); + $this->assertTrue($this->docQuery->getReturnEmpty() == null); + } + + public function testWorksheetId() + { + $this->assertTrue($this->docQuery->getWorksheetId() == 'default'); + $this->docQuery->setWorksheetId('123'); + $this->assertTrue($this->docQuery->getWorksheetId() == '123'); + } + + public function testSpreadsheetKey() + { + $this->assertTrue($this->docQuery->getSpreadsheetKey() == null); + $this->docQuery->setSpreadsheetKey('abc'); + $this->assertTrue($this->docQuery->getSpreadsheetKey() == 'abc'); + } + + public function testCellId() + { + $this->assertTrue($this->docQuery->getCellId() == null); + $this->docQuery->setCellId('xyz'); + $this->assertTrue($this->docQuery->getCellId() == 'xyz'); + } + + public function testProjection() + { + $this->assertTrue($this->docQuery->getProjection() == 'full'); + $this->docQuery->setProjection('abc'); + $this->assertTrue($this->docQuery->getProjection() == 'abc'); + } + + public function testVisibility() + { + $this->assertTrue($this->docQuery->getVisibility() == 'private'); + $this->docQuery->setVisibility('xyz'); + $this->assertTrue($this->docQuery->getVisibility() == 'xyz'); + } + +} diff --git a/zend/tests/Zend/Gdata/Spreadsheets/CellTest.php b/zend/tests/Zend/Gdata/Spreadsheets/CellTest.php new file mode 100644 index 0000000..f743d15 --- /dev/null +++ b/zend/tests/Zend/Gdata/Spreadsheets/CellTest.php @@ -0,0 +1,67 @@ +cell = new Zend_Gdata_Spreadsheets_Extension_Cell(); + } + + public function testToAndFromString() + { + $this->cell->setText('test cell'); + $this->assertTrue($this->cell->getText() == 'test cell'); + $this->cell->setRow('1'); + $this->assertTrue($this->cell->getRow() == '1'); + $this->cell->setColumn('2'); + $this->assertTrue($this->cell->getColumn() == '2'); + $this->cell->setInputValue('test input value'); + $this->assertTrue($this->cell->getInputValue() == 'test input value'); + $this->cell->setNumericValue('test numeric value'); + $this->assertTrue($this->cell->getNumericValue() == 'test numeric value'); + + $newCell = new Zend_Gdata_Spreadsheets_Extension_Cell(); + $doc = new DOMDocument(); + $doc->loadXML($this->cell->saveXML()); + $newCell->transferFromDom($doc->documentElement); + $this->assertTrue($this->cell->getText() == $newCell->getText()); + $this->assertTrue($this->cell->getRow() == $newCell->getRow()); + $this->assertTrue($this->cell->getColumn() == $newCell->getColumn()); + $this->assertTrue($this->cell->getInputValue() == $newCell->getInputValue()); + $this->assertTrue($this->cell->getNumericValue() == $newCell->getNumericValue()); + } + +} diff --git a/zend/tests/Zend/Gdata/Spreadsheets/ColCountTest.php b/zend/tests/Zend/Gdata/Spreadsheets/ColCountTest.php new file mode 100644 index 0000000..e54d10f --- /dev/null +++ b/zend/tests/Zend/Gdata/Spreadsheets/ColCountTest.php @@ -0,0 +1,54 @@ +colCount = new Zend_Gdata_Spreadsheets_Extension_ColCount(); + } + + public function testToAndFromString() + { + $this->colCount->setText('20'); + $this->assertTrue($this->colCount->getText() == '20'); + $newColCount = new Zend_Gdata_Spreadsheets_Extension_ColCount(); + $doc = new DOMDocument(); + $doc->loadXML($this->colCount->saveXML()); + $newColCount->transferFromDom($doc->documentElement); + $this->assertTrue($this->colCount->getText() == $newColCount->getText()); + } + +} diff --git a/zend/tests/Zend/Gdata/Spreadsheets/CustomTest.php b/zend/tests/Zend/Gdata/Spreadsheets/CustomTest.php new file mode 100644 index 0000000..73f06b6 --- /dev/null +++ b/zend/tests/Zend/Gdata/Spreadsheets/CustomTest.php @@ -0,0 +1,57 @@ +custom = new Zend_Gdata_Spreadsheets_Extension_Custom(); + } + + public function testToAndFromString() + { + $this->custom->setText('value'); + $this->assertTrue($this->custom->getText() == 'value'); + $this->custom->setColumnName('column_name'); + $this->assertTrue($this->custom->getColumnName() == 'column_name'); + $newCustom = new Zend_Gdata_Spreadsheets_Extension_Custom(); + $doc = new DOMDocument(); + $doc->loadXML($this->custom->saveXML()); + $newCustom->transferFromDom($doc->documentElement); + $this->assertTrue($this->custom->getText() == $newCustom->getText()); + $this->assertTrue($this->custom->getColumnName() == $newCustom->getColumnName()); + } + +} diff --git a/zend/tests/Zend/Gdata/Spreadsheets/DocumentQueryTest.php b/zend/tests/Zend/Gdata/Spreadsheets/DocumentQueryTest.php new file mode 100644 index 0000000..39016b7 --- /dev/null +++ b/zend/tests/Zend/Gdata/Spreadsheets/DocumentQueryTest.php @@ -0,0 +1,91 @@ +docQuery = new Zend_Gdata_Spreadsheets_DocumentQuery(); + } + + public function testTitle() + { + $this->assertTrue($this->docQuery->getTitle() == null); + $this->docQuery->setTitle('test title'); + $this->assertTrue($this->docQuery->getTitle() == 'test title'); + $this->assertTrue($this->docQuery->getQueryString() == '?title=test+title'); + $this->docQuery->setTitle(null); + $this->assertTrue($this->docQuery->getTitle() == null); + } + + public function testTitleExact() + { + $this->assertTrue($this->docQuery->getTitleExact() == null); + $this->docQuery->setTitleExact('test title'); + $this->assertTrue($this->docQuery->getTitleExact() == 'test title'); + $this->assertTrue($this->docQuery->getQueryString() == '?title-exact=test+title'); + $this->docQuery->setTitleExact(null); + $this->assertTrue($this->docQuery->getTitleExact() == null); + } + + public function testWorksheetId() + { + $this->assertTrue($this->docQuery->getWorksheetId() == null); + $this->docQuery->setWorksheetId('123'); + $this->assertTrue($this->docQuery->getWorksheetId() == '123'); + } + + public function testSpreadsheetKey() + { + $this->assertTrue($this->docQuery->getSpreadsheetKey() == null); + $this->docQuery->setSpreadsheetKey('abc'); + $this->assertTrue($this->docQuery->getSpreadsheetKey() == 'abc'); + } + + public function testProjection() + { + $this->assertTrue($this->docQuery->getProjection() == 'full'); + $this->docQuery->setProjection('abc'); + $this->assertTrue($this->docQuery->getProjection() == 'abc'); + } + + public function testVisibility() + { + $this->assertTrue($this->docQuery->getVisibility() == 'private'); + $this->docQuery->setVisibility('xyz'); + $this->assertTrue($this->docQuery->getVisibility() == 'xyz'); + } + +} diff --git a/zend/tests/Zend/Gdata/Spreadsheets/ListEntryTest.php b/zend/tests/Zend/Gdata/Spreadsheets/ListEntryTest.php new file mode 100644 index 0000000..1c3458e --- /dev/null +++ b/zend/tests/Zend/Gdata/Spreadsheets/ListEntryTest.php @@ -0,0 +1,225 @@ +listEntry = new Zend_Gdata_Spreadsheets_ListEntry(); + $this->rowData = array(); + $this->rowData[] = new Zend_Gdata_Spreadsheets_Extension_Custom( + 'column_1', 'value 1'); + $this->rowData[] = new Zend_Gdata_Spreadsheets_Extension_Custom( + 'column_2', 'value 2'); + } + + public function testToAndFromString() + { + $this->listEntry->setCustom($this->rowData); + $rowDataOut = $this->listEntry->getCustom(); + + $this->assertEquals(count($this->rowData), count($rowDataOut)); + for ($i = 0; $i < count($this->rowData); $i++) { + $this->assertEquals($this->rowData[$i]->getText(), + $rowDataOut[$i]->getText()); + $this->assertEquals($this->rowData[$i]->getColumnName(), + $rowDataOut[$i]->getColumnName()); + } + + $newListEntry = new Zend_Gdata_Spreadsheets_ListEntry(); + $doc = new DOMDocument(); + $doc->loadXML($this->listEntry->saveXML()); + $newListEntry->transferFromDom($doc->documentElement); + $rowDataFromXML = $newListEntry->getCustom(); + + $this->assertEquals(count($this->rowData), count($rowDataFromXML)); + for ($i = 0; $i < count($this->rowData); $i++) { + $this->assertEquals($this->rowData[$i]->getText(), + $rowDataFromXML[$i]->getText()); + $this->assertEquals($this->rowData[$i]->getColumnName(), + $rowDataFromXML[$i]->getColumnName()); + } + } + + public function testCustomElementOrderingPreserved() + { + $this->listEntry->setCustom($this->rowData); + + $this->assertEquals(count($this->rowData), + count($this->listEntry->getCustom())); + $this->assertEquals(count($this->listEntry->getCustom()), + count($this->listEntry->getCustomByName())); + for ($i = 0; $i < count($this->rowData); $i++) { + $this->assertEquals($this->rowData[$i], + $this->listEntry->custom[$i]); + } + } + + public function testCustomElementsCanBeRetrievedByName() + { + $this->listEntry->setCustom($this->rowData); + + $this->assertEquals(count($this->rowData), + count($this->listEntry->getCustom())); + $this->assertEquals(count($this->listEntry->getCustom()), + count($this->listEntry->getCustomByName())); + for ($i = 0; $i < count($this->rowData); $i++) { + $this->assertEquals($this->rowData[$i], + $this->listEntry->getCustomByName( + $this->rowData[$i]->getColumnName())); + } + } + + public function testCustomElementsCanBeRetrievedByNameUsingArrayNotation() + { + $this->listEntry->setCustom($this->rowData); + + $this->assertEquals(count($this->rowData), + count($this->listEntry->getCustom())); + $this->assertEquals(count($this->listEntry->getCustom()), + count($this->listEntry->getCustomByName())); + for ($i = 0; $i < count($this->rowData); $i++) { + $this->assertEquals($this->rowData[$i], + $this->listEntry->getCustomByName( + $this->rowData[$i]->getColumnName())); + } + } + + public function testCanAddIndividualCustomElements() + { + for ($i = 0; $i < count($this->rowData); $i++) { + $this->listEntry->addCustom($this->rowData[$i]); + } + + $this->assertEquals(count($this->rowData), + count($this->listEntry->getCustom())); + $this->assertEquals(count($this->listEntry->getCustom()), + count($this->listEntry->getCustomByName())); + for ($i = 0; $i < count($this->rowData); $i++) { + $this->assertEquals($this->rowData[$i], + $this->listEntry->custom[$i]); + } + } + + public function testRetrievingNonexistantCustomElementReturnsNull() + { + $this->assertNull($this->listEntry->getCustomByName('nonexistant')); + } + + public function testCanReplaceAllCustomElements() + { + $this->listEntry->setCustom($this->rowData); + $this->assertEquals(count($this->rowData), + count($this->listEntry->getCustom())); + $this->assertEquals(count($this->listEntry->getCustom()), + count($this->listEntry->getCustomByName())); + $this->listEntry->setCustom(array()); + $this->assertEquals(0, count($this->listEntry->getCustom())); + } + + public function testCanDeleteCustomElementById() + { + $this->listEntry->setCustom($this->rowData); + $this->assertEquals(count($this->rowData), + count($this->listEntry->getCustom())); + $this->assertEquals(count($this->listEntry->getCustom()), + count($this->listEntry->getCustomByName())); + $this->assertEquals($this->rowData[0], $this->listEntry->custom[0]); + + $this->listEntry->removeCustom(0); + $this->assertEquals(count($this->rowData) - 1, + count($this->listEntry->getCustom())); + $this->assertEquals(count($this->listEntry->getCustom()), + count($this->listEntry->getCustomByName())); + $this->assertEquals($this->rowData[1], $this->listEntry->custom[0]); + } + + public function testCanDeleteCustomElementByName() + { + $this->listEntry->setCustom($this->rowData); + $this->assertEquals(count($this->rowData), + count($this->listEntry->getCustom())); + $this->assertEquals(count($this->listEntry->getCustom()), + count($this->listEntry->getCustomByName())); + $this->assertEquals($this->rowData[0], + $this->listEntry->getCustomByName( + $this->rowData[0]->getColumnName())); + + $this->listEntry->removeCustomByName('column_1'); + $this->assertEquals(count($this->rowData) - 1, + count($this->listEntry->getCustom())); + $this->assertEquals(count($this->listEntry->getCustom()), + count($this->listEntry->getCustomByName())); + $this->assertNull($this->listEntry->getCustomByName( + $this->rowData[0]->getColumnName())); + } + + public function testDeletingNonexistantElementByIdThrowsException() + { + $this->listEntry->setCustom($this->rowData); + $this->assertEquals(count($this->rowData), + count($this->listEntry->getCustom())); + $this->assertEquals(count($this->listEntry->getCustom()), + count($this->listEntry->getCustomByName())); + + $exceptionCaught = false; + try { + $this->listEntry->removeCustom(9999); + } catch (Zend_Gdata_App_InvalidArgumentException $e) { + $exceptionCaught = true; + $this->assertEquals('Element does not exist.', $e->getMessage()); + } + $this->assertTrue($exceptionCaught); + } + + public function testDeletingNonexistantElementByNameThrowsException() + { + $this->listEntry->setCustom($this->rowData); + $this->assertEquals(count($this->rowData), + count($this->listEntry->getCustom())); + $this->assertEquals(count($this->listEntry->getCustom()), + count($this->listEntry->getCustomByName())); + + $exceptionCaught = false; + try { + $this->listEntry->removeCustomByName('nonexistant'); + } catch (Zend_Gdata_App_InvalidArgumentException $e) { + $exceptionCaught = true; + $this->assertEquals('Element does not exist.', $e->getMessage()); + } + $this->assertTrue($exceptionCaught); + } + +} diff --git a/zend/tests/Zend/Gdata/Spreadsheets/ListFeedTest.php b/zend/tests/Zend/Gdata/Spreadsheets/ListFeedTest.php new file mode 100644 index 0000000..8be5dd2 --- /dev/null +++ b/zend/tests/Zend/Gdata/Spreadsheets/ListFeedTest.php @@ -0,0 +1,68 @@ +listFeed = new Zend_Gdata_Spreadsheets_ListFeed( + file_get_contents(dirname(__FILE__) . '/_files/TestDataListFeedSample1.xml'), + true); + } + + public function testToAndFromString() + { + $this->assertTrue(count($this->listFeed->entries) == 2); + $this->assertTrue($this->listFeed->entries->count() == 2); + foreach($this->listFeed->entries as $entry) + { + $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_ListEntry); + } + + $newListFeed = new Zend_Gdata_Spreadsheets_ListFeed(); + $doc = new DOMDocument(); + $doc->loadXML($this->listFeed->saveXML()); + $newListFeed->transferFromDom($doc->documentElement); + + $this->assertTrue(count($newListFeed->entries) == 2); + $this->assertTrue($newListFeed->entries->count() == 2); + foreach($newListFeed->entries as $entry) + { + $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_ListEntry); + } + + } + +} diff --git a/zend/tests/Zend/Gdata/Spreadsheets/ListQueryTest.php b/zend/tests/Zend/Gdata/Spreadsheets/ListQueryTest.php new file mode 100644 index 0000000..81fb405 --- /dev/null +++ b/zend/tests/Zend/Gdata/Spreadsheets/ListQueryTest.php @@ -0,0 +1,109 @@ +docQuery = new Zend_Gdata_Spreadsheets_ListQuery(); + } + + public function testWorksheetId() + { + $this->assertTrue($this->docQuery->getWorksheetId() == 'default'); + $this->docQuery->setWorksheetId('123'); + $this->assertTrue($this->docQuery->getWorksheetId() == '123'); + } + + public function testSpreadsheetKey() + { + $this->assertTrue($this->docQuery->getSpreadsheetKey() == null); + $this->docQuery->setSpreadsheetKey('abc'); + $this->assertTrue($this->docQuery->getSpreadsheetKey() == 'abc'); + } + + public function testRowId() + { + $this->assertTrue($this->docQuery->getRowId() == null); + $this->docQuery->setRowId('xyz'); + $this->assertTrue($this->docQuery->getRowId() == 'xyz'); + } + + public function testProjection() + { + $this->assertTrue($this->docQuery->getProjection() == 'full'); + $this->docQuery->setProjection('abc'); + $this->assertTrue($this->docQuery->getProjection() == 'abc'); + } + + public function testVisibility() + { + $this->assertTrue($this->docQuery->getVisibility() == 'private'); + $this->docQuery->setVisibility('xyz'); + $this->assertTrue($this->docQuery->getVisibility() == 'xyz'); + } + + public function testSpreadsheetQuery() + { + $this->assertTrue($this->docQuery->getSpreadsheetQuery() == null); + $this->docQuery->setSpreadsheetQuery('first=john&last=smith'); + $this->assertTrue($this->docQuery->getSpreadsheetQuery() == 'first=john&last=smith'); + $this->assertTrue($this->docQuery->getQueryString() == '?sq=first%3Djohn%26last%3Dsmith'); + $this->docQuery->setSpreadsheetQuery(null); + $this->assertTrue($this->docQuery->getSpreadsheetQuery() == null); + } + + + public function testOrderBy() + { + $this->assertTrue($this->docQuery->getOrderBy() == null); + $this->docQuery->setOrderBy('column:first'); + $this->assertTrue($this->docQuery->getOrderBy() == 'column:first'); + $this->assertTrue($this->docQuery->getQueryString() == '?orderby=column%3Afirst'); + $this->docQuery->setOrderBy(null); + $this->assertTrue($this->docQuery->getOrderBy() == null); + } + + public function testReverse() + { + $this->assertTrue($this->docQuery->getReverse() == null); + $this->docQuery->setReverse('true'); + $this->assertTrue($this->docQuery->getReverse() == 'true'); + $this->assertTrue($this->docQuery->getQueryString() == '?reverse=true'); + $this->docQuery->setReverse(null); + $this->assertTrue($this->docQuery->getReverse() == null); + } + +} diff --git a/zend/tests/Zend/Gdata/Spreadsheets/RowCountTest.php b/zend/tests/Zend/Gdata/Spreadsheets/RowCountTest.php new file mode 100644 index 0000000..822eb10 --- /dev/null +++ b/zend/tests/Zend/Gdata/Spreadsheets/RowCountTest.php @@ -0,0 +1,54 @@ +rowCount = new Zend_Gdata_Spreadsheets_Extension_RowCount(); + } + + public function testToAndFromString() + { + $this->rowCount->setText('20'); + $this->assertTrue($this->rowCount->getText() == '20'); + $newRowCount = new Zend_Gdata_Spreadsheets_Extension_RowCount(); + $doc = new DOMDocument(); + $doc->loadXML($this->rowCount->saveXML()); + $newRowCount->transferFromDom($doc->documentElement); + $this->assertTrue($this->rowCount->getText() == $newRowCount->getText()); + } + +} diff --git a/zend/tests/Zend/Gdata/Spreadsheets/SpreadsheetFeedTest.php b/zend/tests/Zend/Gdata/Spreadsheets/SpreadsheetFeedTest.php new file mode 100644 index 0000000..d715326 --- /dev/null +++ b/zend/tests/Zend/Gdata/Spreadsheets/SpreadsheetFeedTest.php @@ -0,0 +1,65 @@ +sprFeed = new Zend_Gdata_Spreadsheets_SpreadsheetFeed( + file_get_contents(dirname(__FILE__) . '/_files/TestDataSpreadsheetFeedSample1.xml'), + true); + } + + public function testToAndFromString() + { + $this->assertTrue(count($this->sprFeed->entries) == 1); + foreach($this->sprFeed->entries as $entry) + { + $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_SpreadsheetEntry); + } + + $newSprFeed = new Zend_Gdata_Spreadsheets_SpreadsheetFeed(); + $doc = new DOMDocument(); + $doc->loadXML($this->sprFeed->saveXML()); + $newSprFeed->transferFromDom($doc->documentElement); + + $this->assertTrue(count($newSprFeed->entries) == 1); + foreach($newSprFeed->entries as $entry) + { + $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_SpreadsheetEntry); + } + } + +} diff --git a/zend/tests/Zend/Gdata/Spreadsheets/WorksheetEntryTest.php b/zend/tests/Zend/Gdata/Spreadsheets/WorksheetEntryTest.php new file mode 100644 index 0000000..69d5aab --- /dev/null +++ b/zend/tests/Zend/Gdata/Spreadsheets/WorksheetEntryTest.php @@ -0,0 +1,57 @@ +wksEntry = new Zend_Gdata_Spreadsheets_WorksheetEntry(); + } + + public function testToAndFromString() + { + $this->wksEntry->setRowCount(new Zend_Gdata_Spreadsheets_Extension_RowCount('20')); + $this->assertTrue($this->wksEntry->getRowCount()->getText() == '20'); + $this->wksEntry->setColumnCount(new Zend_Gdata_Spreadsheets_Extension_ColCount('40')); + $this->assertTrue($this->wksEntry->getColumnCount()->getText() == '40'); + $newWksEntry = new Zend_Gdata_Spreadsheets_WorksheetEntry(); + $doc = new DOMDocument(); + $doc->loadXML($this->wksEntry->saveXML()); + $newWksEntry->transferFromDom($doc->documentElement); + $this->assertTrue($this->wksEntry->getRowCount()->getText() == $newWksEntry->getRowCount()->getText()); + $this->assertTrue($this->wksEntry->getColumnCount()->getText() == $newWksEntry->getColumnCount()->getText()); + } + +} diff --git a/zend/tests/Zend/Gdata/Spreadsheets/WorksheetFeedTest.php b/zend/tests/Zend/Gdata/Spreadsheets/WorksheetFeedTest.php new file mode 100644 index 0000000..8a26f6a --- /dev/null +++ b/zend/tests/Zend/Gdata/Spreadsheets/WorksheetFeedTest.php @@ -0,0 +1,65 @@ +wksFeed = new Zend_Gdata_Spreadsheets_WorksheetFeed( + file_get_contents(dirname(__FILE__) . '/_files/TestDataWorksheetFeedSample1.xml'), + true); + } + + public function testToAndFromString() + { + $this->assertTrue(count($this->wksFeed->entries) == 1); + foreach($this->wksFeed->entries as $entry) + { + $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_WorksheetEntry); + } + + $newWksFeed = new Zend_Gdata_Spreadsheets_WorksheetFeed(); + $doc = new DOMDocument(); + $doc->loadXML($this->wksFeed->saveXML()); + $newWksFeed->transferFromDom($doc->documentElement); + + $this->assertTrue(count($newWksFeed->entries) == 1); + foreach($newWksFeed->entries as $entry) + { + $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_WorksheetEntry); + } + } + +} diff --git a/zend/tests/Zend/Gdata/Spreadsheets/_files/TestDataCellFeedSample1.xml b/zend/tests/Zend/Gdata/Spreadsheets/_files/TestDataCellFeedSample1.xml new file mode 100644 index 0000000..e40a0c3 --- /dev/null +++ b/zend/tests/Zend/Gdata/Spreadsheets/_files/TestDataCellFeedSample1.xml @@ -0,0 +1,49 @@ + + http://spreadsheets.google.com/feeds/cells/key/od6/private/full + 2006-11-17T18:27:32.543Z + Sheet1 + + + + + + Fitzwilliam Darcy + fitz@gmail.com + + 1 + 1 + 100 + 20 + + http://spreadsheets.google.com/feeds/cells/key/od6/private/full/R1C1 + 2006-11-17T18:27:32.543Z + + A1 + Name + + + Name + + + http://spreadsheets.google.com/feeds/cells/key/od6/private/full/R1C2 + 2006-11-17T18:27:32.543Z + + B1 + Hours + + + Hours + + \ No newline at end of file diff --git a/zend/tests/Zend/Gdata/Spreadsheets/_files/TestDataListFeedSample1.xml b/zend/tests/Zend/Gdata/Spreadsheets/_files/TestDataListFeedSample1.xml new file mode 100644 index 0000000..1f8212b --- /dev/null +++ b/zend/tests/Zend/Gdata/Spreadsheets/_files/TestDataListFeedSample1.xml @@ -0,0 +1,56 @@ + + http://spreadsheets.google.com/feeds/list/key/od6/private/full + 2006-11-17T18:23:45.173Z + Sheet1 + + + + + + Fitzwilliam Darcy + fitz@gmail.com + + 2 + 1 + 2 + + http://spreadsheets.google.com/feeds/list/key/od6/private/full/cokwr + 2006-11-17T18:23:45.173Z + + Bingley + Hours: 10, Items: 2, IPM: 0.0033 + + + Bingley + 10 + 2 + 0.0033 + + + http://spreadsheets.google.com/feeds/list/key/od6/private/full/cyevm + 2006-11-17T18:23:45.173Z + + Charlotte + Hours: 60, Items: 18000, IPM: 5 + + + Charlotte + 60 + 18000 + 5 + + \ No newline at end of file diff --git a/zend/tests/Zend/Gdata/Spreadsheets/_files/TestDataSpreadsheetFeedSample1.xml b/zend/tests/Zend/Gdata/Spreadsheets/_files/TestDataSpreadsheetFeedSample1.xml new file mode 100644 index 0000000..b069efc --- /dev/null +++ b/zend/tests/Zend/Gdata/Spreadsheets/_files/TestDataSpreadsheetFeedSample1.xml @@ -0,0 +1,38 @@ + + http://spreadsheets.google.com/feeds/spreadsheets/private/full + 2006-11-17T18:23:45.173Z + Available Spreadsheets + + + + + Fitzwilliam Darcy + fitz@gmail.com + + 1 + 1 + 1 + + http://spreadsheets.google.com/feeds/spreadsheets/private/full/key + 2006-11-17T18:24:18.231Z + Groceries R Us + Groceries R Us + + + + + Fitzwilliam Darcy + fitz@gmail.com + + + \ No newline at end of file diff --git a/zend/tests/Zend/Gdata/Spreadsheets/_files/TestDataWorksheetFeedSample1.xml b/zend/tests/Zend/Gdata/Spreadsheets/_files/TestDataWorksheetFeedSample1.xml new file mode 100644 index 0000000..d86afca --- /dev/null +++ b/zend/tests/Zend/Gdata/Spreadsheets/_files/TestDataWorksheetFeedSample1.xml @@ -0,0 +1,37 @@ + + http://spreadsheets.google.com/feeds/worksheets/key/private/full + 2006-11-17T18:23:45.173Z + Groceries R Us + + + + + Fitzwilliam Darcy + fitz@gmail.com + + 1 + 1 + 1 + + http://spreadsheets.google.com/feeds/worksheets/key/private/full/od6 + 2006-11-17T18:23:45.173Z + Sheet1 + Sheet1 + + + + 100 + 20 + + \ No newline at end of file diff --git a/zend/tests/Zend/Gdata/SpreadsheetsOnlineTest.php b/zend/tests/Zend/Gdata/SpreadsheetsOnlineTest.php new file mode 100644 index 0000000..57a6c52 --- /dev/null +++ b/zend/tests/Zend/Gdata/SpreadsheetsOnlineTest.php @@ -0,0 +1,295 @@ +sprKey = constant('TESTS_ZEND_GDATA_SPREADSHEETS_SPREADSHEETKEY'); + $this->wksId = constant('TESTS_ZEND_GDATA_SPREADSHEETS_WORKSHEETID'); + $service = Zend_Gdata_Spreadsheets::AUTH_SERVICE_NAME; + $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service); + $this->gdata = new Zend_Gdata_Spreadsheets($client); + } + + public function testGetSpreadsheetsAndWorksheetsAndData() + { + $spreadsheetCount = 0; + + $spreadsheets = $this->gdata->getSpreadsheets(); + $testedContents = false; + foreach($spreadsheets as $spreadsheet) { + $spreadsheetCount++; + $worksheetCount = 0; + $this->assertTrue($spreadsheet instanceof Zend_Gdata_Spreadsheets_SpreadsheetEntry, 'not instance of SpreadsheetEntry'); + foreach($spreadsheet->getWorksheets() as $worksheet) { + $this->assertTrue($worksheet instanceof Zend_Gdata_Spreadsheets_WorksheetEntry, 'not instance of WorksheetEntry'); + $worksheetCount++; + if ($spreadsheet->getTitle()->getText() == 'PHP Unit Test Sheet') { + $testedContents = true; + $contentAsCells = $worksheet->getContentsAsCells(); + $this->assertEquals('a1', $contentAsCells['A1']['value']); + $this->assertEquals('new', $contentAsCells['A2']['value']); + $this->assertEquals('row', $contentAsCells['B2']['value']); + $contentAsRows = $worksheet->getContentsAsRows(); + $this->assertEquals('new', $contentAsRows[0]['a1']); + $this->assertEquals('data', $contentAsRows[0]['c1']); + $this->assertEquals('here', $contentAsRows[0]['d1']); + } + } + $this->assertTrue($worksheetCount >= 1, 'didn\'t get >= 1 worksheet'); + } + $this->assertTrue($spreadsheetCount > 1, 'didn\'t get >1 spreadsheet'); + $this->assertTrue($testedContents, 'didn\'t test the contents of the worksheet'); + } + + public function testGetSpreadsheetFeed() + { + $feed = $this->gdata->getSpreadsheetFeed(); + $this->assertTrue($feed instanceof Zend_Gdata_Spreadsheets_SpreadsheetFeed); + foreach ($feed->entries as $entry) { + $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_SpreadsheetEntry); + $this->assertTrue($entry->getHttpClient() == $feed->getHttpClient()); + } + + $query = new Zend_Gdata_Spreadsheets_DocumentQuery(); + $feed = $this->gdata->getSpreadsheetFeed($query); + $this->assertTrue($feed instanceof Zend_Gdata_Spreadsheets_SpreadsheetFeed); + foreach ($feed->entries as $entry) { + $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_SpreadsheetEntry); + $this->assertTrue($entry->getHttpClient() == $feed->getHttpClient()); + } + + $uri = $query->getQueryUrl(); + $feed = $this->gdata->getSpreadsheetFeed($uri); + $this->assertTrue($feed instanceof Zend_Gdata_Spreadsheets_SpreadsheetFeed); + foreach ($feed->entries as $entry) { + $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_SpreadsheetEntry); + $this->assertTrue($entry->getHttpClient() == $feed->getHttpClient()); + } + } + + public function testGetWorksheetFeed() + { + $query = new Zend_Gdata_Spreadsheets_DocumentQuery(); + $query->setSpreadsheetKey($this->sprKey); + $feed = $this->gdata->getWorksheetFeed($query); + $this->assertTrue($feed instanceof Zend_Gdata_Spreadsheets_WorksheetFeed); + foreach ($feed->entries as $entry) { + $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_WorksheetEntry); + $this->assertTrue($entry->getHttpClient() == $feed->getHttpClient()); + } + + $uri = $query->getQueryUrl(); + $feed = $this->gdata->getWorksheetFeed($uri); + $this->assertTrue($feed instanceof Zend_Gdata_Spreadsheets_WorksheetFeed); + foreach ($feed->entries as $entry) { + $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_WorksheetEntry); + $this->assertTrue($entry->getHttpClient() == $feed->getHttpClient()); + } + } + + public function testGetCellFeed() + { + $query = new Zend_Gdata_Spreadsheets_CellQuery(); + $query->setSpreadsheetKey($this->sprKey); + $query->setWorksheetId($this->wksId); + $feed = $this->gdata->getCellFeed($query); + $this->assertTrue($feed instanceof Zend_Gdata_Spreadsheets_CellFeed); + foreach ($feed->entries as $entry) { + $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_CellEntry); + $this->assertTrue($entry->getHttpClient() == $feed->getHttpClient()); + } + + $feed = $this->gdata->getCellFeed($query->getQueryUrl()); + $this->assertTrue($feed instanceof Zend_Gdata_Spreadsheets_CellFeed); + foreach ($feed->entries as $entry) { + $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_CellEntry); + $this->assertTrue($entry->getHttpClient() == $feed->getHttpClient()); + } + } + + public function testGetListFeed() + { + $query = new Zend_Gdata_Spreadsheets_ListQuery(); + $query->setSpreadsheetKey($this->sprKey); + $query->setWorksheetId($this->wksId); + $feed = $this->gdata->getListFeed($query); + $this->assertTrue($feed instanceof Zend_Gdata_Spreadsheets_ListFeed); + foreach ($feed->entries as $entry) { + $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_ListEntry); + $this->assertTrue($entry->getHttpClient() == $feed->getHttpClient()); + } + + $feed = $this->gdata->getListFeed($query->getQueryUrl()); + $this->assertTrue($feed instanceof Zend_Gdata_Spreadsheets_ListFeed); + foreach ($feed->entries as $entry) { + $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_ListEntry); + $this->assertTrue($entry->getHttpClient() == $feed->getHttpClient()); + } + } + + public function testGetSpreadsheetEntry() + { + $query = new Zend_Gdata_Spreadsheets_DocumentQuery(); + $query->setSpreadsheetKey($this->sprKey); + $entry = $this->gdata->getSpreadsheetEntry($query); + $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_SpreadsheetEntry); + + $entry = $this->gdata->getSpreadsheetEntry($query->getQueryUrl()); + $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_SpreadsheetEntry); + } + + public function testGetWorksheetEntry() + { + $query = new Zend_Gdata_Spreadsheets_DocumentQuery(); + $query->setSpreadsheetKey($this->sprKey); + $query->setWorksheetId($this->wksId); + $entry = $this->gdata->getWorksheetEntry($query); + $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_WorksheetEntry); + + $entry = $this->gdata->getWorksheetEntry($query->getQueryUrl()); + $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_WorksheetEntry); + } + + public function testGetCellEntry() + { + $query = new Zend_Gdata_Spreadsheets_CellQuery(); + $query->setSpreadsheetKey($this->sprKey); + $query->setCellId('R1C1'); + $entry = $this->gdata->getCellEntry($query); + $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_CellEntry); + + $entry = $this->gdata->getCellEntry($query->getQueryUrl()); + $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_CellEntry); + } + + public function testGetListEntry() + { + $query = new Zend_Gdata_Spreadsheets_ListQuery(); + $query->setSpreadsheetKey($this->sprKey); + $query->setStartIndex('1'); + $query->setMaxResults('1'); + $entry = $this->gdata->getListEntry($query); + $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_ListEntry); + + $entry = $this->gdata->getListEntry($query->getQueryUrl()); + $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_ListEntry); + } + + public function testUpdateCell() + { + $this->gdata->updateCell(5, 1, 'updated data', $this->sprKey, $this->wksId); + + $query = new Zend_Gdata_Spreadsheets_CellQuery(); + $query->setSpreadsheetKey($this->sprKey); + $query->setCellId('R5C1'); + $entry = $this->gdata->getCellEntry($query); + $this->assertTrue($entry instanceof Zend_Gdata_Spreadsheets_CellEntry); + $this->assertTrue($entry->cell->getText() == 'updated data'); + + $this->gdata->updateCell(5, 1, '', $this->sprKey, $this->wksId); + } + + public function testInsertUpdateDeleteRow() + { + $rowData = array(); + $rowData['a1'] = 'new'; + $rowData['b1'] = 'row'; + $rowData['c1'] = 'data'; + $rowData['d1'] = 'here'; + $entry = $this->gdata->insertRow($rowData, $this->sprKey); + $rowData['a1'] = 'newer'; + $entry = $this->gdata->updateRow($entry, $rowData); + $this->gdata->deleteRow($entry); + } + + public function testInsertUpdateDeleteRow2() + { + $rowData = array(); + $rowData['a1'] = 'new'; + $rowData['b1'] = 'row'; + $rowData['c1'] = 'data'; + $rowData['d1'] = 'here'; + $entry = $this->gdata->insertRow($rowData, $this->sprKey); + $rowData['a1'] = 'newer'; + $entry = $this->gdata->updateRow($entry, $rowData); + $ssTest = new Zend_Gdata_Spreadsheets($entry->getHttpClient()); + $ssTest->delete($entry->getEditLink()->href); + } + + public function testInsertUpdateDeleteRow3() + { + $rowData = array(); + $rowData['a1'] = 'new'; + $rowData['b1'] = 'row'; + $rowData['c1'] = 'data'; + $rowData['d1'] = 'here'; + $entry = $this->gdata->insertRow($rowData, $this->sprKey); + $rowData['a1'] = 'newer'; + $entry = $this->gdata->updateRow($entry, $rowData); + $ssTest = new Zend_Gdata_Spreadsheets($entry->getHttpClient()); + $ssTest->delete($entry); + } + + public function testCustomElementsCollected() { + $rowData = array(); + $rowData['a1'] = 'new'; + $rowData['b1'] = 'row'; + $rowData['c1'] = 'data'; + $rowData['d1'] = 'here'; + $entry = $this->gdata->insertRow($rowData, $this->sprKey); + + $this->assertEquals(4, count($entry->custom)); + $this->assertEquals(4, count($entry->customByName)); + + $this->assertEquals('new', $entry->custom[0]->getText()); + $this->assertEquals('row', $entry->custom[1]->getText()); + $this->assertEquals('data', $entry->custom[2]->getText()); + $this->assertEquals('here', $entry->custom[3]->getText()); + + $this->assertEquals('new', $entry->customByName['a1']->getText()); + $this->assertEquals('row', $entry->customByName['b1']->getText()); + $this->assertEquals('data', $entry->customByName['c1']->getText()); + $this->assertEquals('here', $entry->customByName['d1']->getText()); + + $ssTest = new Zend_Gdata_Spreadsheets($entry->getHttpClient()); + $ssTest->delete($entry); + } + +} diff --git a/zend/tests/Zend/Gdata/SpreadsheetsTest.php b/zend/tests/Zend/Gdata/SpreadsheetsTest.php new file mode 100644 index 0000000..6af7c99 --- /dev/null +++ b/zend/tests/Zend/Gdata/SpreadsheetsTest.php @@ -0,0 +1,48 @@ +gdata = new Zend_Gdata_Spreadsheets(new Zend_Http_Client()); + } + + public function testSpreadsheets() + { + $this->assertTrue(true); + } + +} diff --git a/zend/tests/Zend/Gdata/TestUtility/MockHttpClient.php b/zend/tests/Zend/Gdata/TestUtility/MockHttpClient.php new file mode 100644 index 0000000..453da0f --- /dev/null +++ b/zend/tests/Zend/Gdata/TestUtility/MockHttpClient.php @@ -0,0 +1,81 @@ +_requests = array(); + } + + public function popRequest() + { + if (count($this->_requests)) + return array_pop($this->_requests); + else + return NULL; + } + + public function write($method, + $uri, + $http_ver = '1.1', + $headers = array(), + $body = '') + { + $request = new Test_Zend_Gdata_MockHttpClient_Request(); + $request->method = $method; + $request->uri = $uri; + $request->http_ver = $http_ver; + $request->headers = $headers; + $request->body = $body; + array_push($this->_requests, $request); + return parent::write($method, $uri, $http_ver, $headers, $body); + } +} diff --git a/zend/tests/Zend/Gdata/TransparencyTest.php b/zend/tests/Zend/Gdata/TransparencyTest.php new file mode 100644 index 0000000..5b8d44f --- /dev/null +++ b/zend/tests/Zend/Gdata/TransparencyTest.php @@ -0,0 +1,125 @@ +transparencyText = file_get_contents( + 'Zend/Gdata/_files/TransparencyElementSample1.xml', + true); + $this->transparency = new Zend_Gdata_Extension_Transparency(); + } + + public function testEmptyTransparencyShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->transparency->extensionElements)); + $this->assertTrue(count($this->transparency->extensionElements) == 0); + } + + public function testEmptyTransparencyShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->transparency->extensionAttributes)); + $this->assertTrue(count($this->transparency->extensionAttributes) == 0); + } + + public function testSampleTransparencyShouldHaveNoExtensionElements() { + $this->transparency->transferFromXML($this->transparencyText); + $this->assertTrue(is_array($this->transparency->extensionElements)); + $this->assertTrue(count($this->transparency->extensionElements) == 0); + } + + public function testSampleTransparencyShouldHaveNoExtensionAttributes() { + $this->transparency->transferFromXML($this->transparencyText); + $this->assertTrue(is_array($this->transparency->extensionAttributes)); + $this->assertTrue(count($this->transparency->extensionAttributes) == 0); + } + + public function testNormalTransparencyShouldHaveNoExtensionElements() { + $this->transparency->value = "http://schemas.google.com/g/2005#event.opaque"; + + $this->assertEquals("http://schemas.google.com/g/2005#event.opaque", $this->transparency->value); + + $this->assertEquals(0, count($this->transparency->extensionElements)); + $newTransparency = new Zend_Gdata_Extension_Transparency(); + $newTransparency->transferFromXML($this->transparency->saveXML()); + $this->assertEquals(0, count($newTransparency->extensionElements)); + $newTransparency->extensionElements = array( + new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); + $this->assertEquals(1, count($newTransparency->extensionElements)); + $this->assertEquals("http://schemas.google.com/g/2005#event.opaque", $newTransparency->value); + + /* try constructing using magic factory */ + $gdata = new Zend_Gdata(); + $newTransparency2 = $gdata->newTransparency(); + $newTransparency2->transferFromXML($newTransparency->saveXML()); + $this->assertEquals(1, count($newTransparency2->extensionElements)); + $this->assertEquals("http://schemas.google.com/g/2005#event.opaque", $newTransparency2->value); + } + + public function testEmptyTransparencyToAndFromStringShouldMatch() { + $transparencyXml = $this->transparency->saveXML(); + $newTransparency = new Zend_Gdata_Extension_Transparency(); + $newTransparency->transferFromXML($transparencyXml); + $newTransparencyXml = $newTransparency->saveXML(); + $this->assertTrue($transparencyXml == $newTransparencyXml); + } + + public function testTransparencyWithValueToAndFromStringShouldMatch() { + $this->transparency->value = "http://schemas.google.com/g/2005#event.opaque"; + $transparencyXml = $this->transparency->saveXML(); + $newTransparency = new Zend_Gdata_Extension_Transparency(); + $newTransparency->transferFromXML($transparencyXml); + $newTransparencyXml = $newTransparency->saveXML(); + $this->assertTrue($transparencyXml == $newTransparencyXml); + $this->assertEquals("http://schemas.google.com/g/2005#event.opaque", $this->transparency->value); + } + + public function testExtensionAttributes() { + $extensionAttributes = $this->transparency->extensionAttributes; + $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); + $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); + $this->transparency->extensionAttributes = $extensionAttributes; + $this->assertEquals('bar', $this->transparency->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $this->transparency->extensionAttributes['foo2']['value']); + $transparencyXml = $this->transparency->saveXML(); + $newTransparency = new Zend_Gdata_Extension_Transparency(); + $newTransparency->transferFromXML($transparencyXml); + $this->assertEquals('bar', $newTransparency->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $newTransparency->extensionAttributes['foo2']['value']); + } + + public function testConvertFullTransparencyToAndFromString() { + $this->transparency->transferFromXML($this->transparencyText); + $this->assertEquals("http://schemas.google.com/g/2005#event.transparent", $this->transparency->value); + } + +} diff --git a/zend/tests/Zend/Gdata/VisibilityTest.php b/zend/tests/Zend/Gdata/VisibilityTest.php new file mode 100644 index 0000000..d9df1cc --- /dev/null +++ b/zend/tests/Zend/Gdata/VisibilityTest.php @@ -0,0 +1,125 @@ +visibilityText = file_get_contents( + 'Zend/Gdata/_files/VisibilityElementSample1.xml', + true); + $this->visibility = new Zend_Gdata_Extension_Visibility(); + } + + public function testEmptyVisibilityShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->visibility->extensionElements)); + $this->assertTrue(count($this->visibility->extensionElements) == 0); + } + + public function testEmptyVisibilityShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->visibility->extensionAttributes)); + $this->assertTrue(count($this->visibility->extensionAttributes) == 0); + } + + public function testSampleVisibilityShouldHaveNoExtensionElements() { + $this->visibility->transferFromXML($this->visibilityText); + $this->assertTrue(is_array($this->visibility->extensionElements)); + $this->assertTrue(count($this->visibility->extensionElements) == 0); + } + + public function testSampleVisibilityShouldHaveNoExtensionAttributes() { + $this->visibility->transferFromXML($this->visibilityText); + $this->assertTrue(is_array($this->visibility->extensionAttributes)); + $this->assertTrue(count($this->visibility->extensionAttributes) == 0); + } + + public function testNormalVisibilityShouldHaveNoExtensionElements() { + $this->visibility->value = "http://schemas.google.com/g/2005#event.private"; + + $this->assertEquals("http://schemas.google.com/g/2005#event.private", $this->visibility->value); + + $this->assertEquals(0, count($this->visibility->extensionElements)); + $newVisibility = new Zend_Gdata_Extension_Visibility(); + $newVisibility->transferFromXML($this->visibility->saveXML()); + $this->assertEquals(0, count($newVisibility->extensionElements)); + $newVisibility->extensionElements = array( + new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); + $this->assertEquals(1, count($newVisibility->extensionElements)); + $this->assertEquals("http://schemas.google.com/g/2005#event.private", $newVisibility->value); + + /* try constructing using magic factory */ + $gdata = new Zend_Gdata(); + $newVisibility2 = $gdata->newVisibility(); + $newVisibility2->transferFromXML($newVisibility->saveXML()); + $this->assertEquals(1, count($newVisibility2->extensionElements)); + $this->assertEquals("http://schemas.google.com/g/2005#event.private", $newVisibility2->value); + } + + public function testEmptyVisibilityToAndFromStringShouldMatch() { + $visibilityXml = $this->visibility->saveXML(); + $newVisibility = new Zend_Gdata_Extension_Visibility(); + $newVisibility->transferFromXML($visibilityXml); + $newVisibilityXml = $newVisibility->saveXML(); + $this->assertTrue($visibilityXml == $newVisibilityXml); + } + + public function testVisibilityWithValueToAndFromStringShouldMatch() { + $this->visibility->value = "http://schemas.google.com/g/2005#event.private"; + $visibilityXml = $this->visibility->saveXML(); + $newVisibility = new Zend_Gdata_Extension_Visibility(); + $newVisibility->transferFromXML($visibilityXml); + $newVisibilityXml = $newVisibility->saveXML(); + $this->assertTrue($visibilityXml == $newVisibilityXml); + $this->assertEquals("http://schemas.google.com/g/2005#event.private", $this->visibility->value); + } + + public function testExtensionAttributes() { + $extensionAttributes = $this->visibility->extensionAttributes; + $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); + $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); + $this->visibility->extensionAttributes = $extensionAttributes; + $this->assertEquals('bar', $this->visibility->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $this->visibility->extensionAttributes['foo2']['value']); + $visibilityXml = $this->visibility->saveXML(); + $newVisibility = new Zend_Gdata_Extension_Visibility(); + $newVisibility->transferFromXML($visibilityXml); + $this->assertEquals('bar', $newVisibility->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $newVisibility->extensionAttributes['foo2']['value']); + } + + public function testConvertFullVisibilityToAndFromString() { + $this->visibility->transferFromXML($this->visibilityText); + $this->assertEquals("http://schemas.google.com/g/2005#event.confidential", $this->visibility->value); + } + +} diff --git a/zend/tests/Zend/Gdata/WhenTest.php b/zend/tests/Zend/Gdata/WhenTest.php new file mode 100644 index 0000000..3e5f574 --- /dev/null +++ b/zend/tests/Zend/Gdata/WhenTest.php @@ -0,0 +1,144 @@ +whenText = file_get_contents( + 'Zend/Gdata/_files/WhenElementSample1.xml', + true); + $this->when = new Zend_Gdata_Extension_When(); + } + + public function testEmptyWhenShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->when->extensionElements)); + $this->assertTrue(count($this->when->extensionElements) == 0); + } + + public function testEmptyWhenShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->when->extensionAttributes)); + $this->assertTrue(count($this->when->extensionAttributes) == 0); + } + + public function testSampleWhenShouldHaveNoExtensionElements() { + $this->when->transferFromXML($this->whenText); + $this->assertTrue(is_array($this->when->extensionElements)); + $this->assertTrue(count($this->when->extensionElements) == 0); + } + + public function testSampleWhenShouldHaveNoExtensionAttributes() { + $this->when->transferFromXML($this->whenText); + $this->assertTrue(is_array($this->when->extensionAttributes)); + $this->assertTrue(count($this->when->extensionAttributes) == 0); + } + + public function testNormalWhenShouldHaveNoExtensionElements() { + $this->when->valueString = "Later"; + $this->when->endTime = "2007-06-21T21:31:56-07:00"; + $this->when->startTime = "2007-06-19T05:42:19-06:00"; + + $this->assertEquals("Later", $this->when->valueString); + $this->assertEquals("2007-06-21T21:31:56-07:00", $this->when->endTime); + $this->assertEquals("2007-06-19T05:42:19-06:00", $this->when->startTime); + + $this->assertEquals(0, count($this->when->extensionElements)); + $newWhen = new Zend_Gdata_Extension_When(); + $newWhen->transferFromXML($this->when->saveXML()); + $this->assertEquals(0, count($newWhen->extensionElements)); + $newWhen->extensionElements = array( + new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); + $this->assertEquals(1, count($newWhen->extensionElements)); + $this->assertEquals("Later", $newWhen->valueString); + $this->assertEquals("2007-06-21T21:31:56-07:00", $newWhen->endTime); + $this->assertEquals("2007-06-19T05:42:19-06:00", $newWhen->startTime); + + /* try constructing using magic factory */ + $gdata = new Zend_Gdata(); + $newWhen2 = $gdata->newWhen(); + $newWhen2->transferFromXML($newWhen->saveXML()); + $this->assertEquals(1, count($newWhen2->extensionElements)); + $this->assertEquals("Later", $newWhen2->valueString); + $this->assertEquals("2007-06-21T21:31:56-07:00", $newWhen2->endTime); + $this->assertEquals("2007-06-19T05:42:19-06:00", $newWhen2->startTime); + } + + public function testEmptyWhenToAndFromStringShouldMatch() { + $whenXml = $this->when->saveXML(); + $newWhen = new Zend_Gdata_Extension_When(); + $newWhen->transferFromXML($whenXml); + $newWhenXml = $newWhen->saveXML(); + $this->assertTrue($whenXml == $newWhenXml); + } + + public function testWhenWithValueToAndFromStringShouldMatch() { + $this->when->valueString = "Later"; + $this->when->endTime = "2007-06-21T21:31:56-07:00"; + $this->when->startTime = "2007-06-19T05:42:19-06:00"; + $whenXml = $this->when->saveXML(); + $newWhen = new Zend_Gdata_Extension_When(); + $newWhen->transferFromXML($whenXml); + $newWhenXml = $newWhen->saveXML(); + $this->assertTrue($whenXml == $newWhenXml); + $this->assertEquals("Later", $this->when->valueString); + $this->assertEquals("2007-06-21T21:31:56-07:00", $this->when->endTime); + $this->assertEquals("2007-06-19T05:42:19-06:00", $this->when->startTime); + } + + public function testExtensionAttributes() { + $extensionAttributes = $this->when->extensionAttributes; + $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); + $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); + $this->when->extensionAttributes = $extensionAttributes; + $this->assertEquals('bar', $this->when->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $this->when->extensionAttributes['foo2']['value']); + $whenXml = $this->when->saveXML(); + $newWhen = new Zend_Gdata_Extension_When(); + $newWhen->transferFromXML($whenXml); + $this->assertEquals('bar', $newWhen->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $newWhen->extensionAttributes['foo2']['value']); + } + + public function testConvertFullWhenToAndFromString() { + $this->when->transferFromXML($this->whenText); + $this->assertEquals("Tomorrow @ 5 PM", $this->when->valueString); + $this->assertEquals("2005-06-06T18:00:00-08:00", $this->when->endTime); + $this->assertEquals("2005-06-06T17:00:00-08:00", $this->when->startTime); + } + + public function testToStringCanReturnValueString() { + $this->when->transferFromXML($this->whenText); + $this->assertEquals('Tomorrow @ 5 PM', $this->when->__toString()); + } + +} diff --git a/zend/tests/Zend/Gdata/WhereTest.php b/zend/tests/Zend/Gdata/WhereTest.php new file mode 100644 index 0000000..1996f57 --- /dev/null +++ b/zend/tests/Zend/Gdata/WhereTest.php @@ -0,0 +1,141 @@ +whereText = file_get_contents( + 'Zend/Gdata/_files/WhereElementSample1.xml', + true); + $this->where = new Zend_Gdata_Extension_Where(); + } + + public function testEmptyWhereShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->where->extensionElements)); + $this->assertTrue(count($this->where->extensionElements) == 0); + } + + public function testEmptyWhereShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->where->extensionAttributes)); + $this->assertTrue(count($this->where->extensionAttributes) == 0); + } + + public function testSampleWhereShouldHaveNoExtensionElements() { + $this->where->transferFromXML($this->whereText); + $this->assertTrue(is_array($this->where->extensionElements)); + $this->assertTrue(count($this->where->extensionElements) == 0); + } + + public function testSampleWhereShouldHaveNoExtensionAttributes() { + $this->where->transferFromXML($this->whereText); + $this->assertTrue(is_array($this->where->extensionAttributes)); + $this->assertTrue(count($this->where->extensionAttributes) == 0); + } + + public function testNormalWhereShouldHaveNoExtensionElements() { + $this->where->valueString = "Test Value String"; + $this->where->rel = "http://schemas.google.com/g/2005#event.alternate"; + $this->where->label = "Test Label"; + + $this->assertEquals("Test Value String", $this->where->valueString); + $this->assertEquals("http://schemas.google.com/g/2005#event.alternate", $this->where->rel); + $this->assertEquals("Test Label", $this->where->label); + + $this->assertEquals(0, count($this->where->extensionElements)); + $newWhere = new Zend_Gdata_Extension_Where(); + $newWhere->transferFromXML($this->where->saveXML()); + $this->assertEquals(0, count($newWhere->extensionElements)); + $newWhere->extensionElements = array( + new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); + $this->assertEquals(1, count($newWhere->extensionElements)); + $this->assertEquals("Test Value String", $newWhere->valueString); + $this->assertEquals("http://schemas.google.com/g/2005#event.alternate", $newWhere->rel); + $this->assertEquals("Test Label", $newWhere->label); + + /* try constructing using magic factory */ + $gdata = new Zend_Gdata(); + $newWhere2 = $gdata->newWhere(); + $newWhere2->transferFromXML($newWhere->saveXML()); + $this->assertEquals(1, count($newWhere2->extensionElements)); + $this->assertEquals("Test Value String", $newWhere2->valueString); + $this->assertEquals("http://schemas.google.com/g/2005#event.alternate", $newWhere2->rel); + $this->assertEquals("Test Label", $newWhere2->label); + } + + public function testEmptyWhereToAndFromStringShouldMatch() { + $whereXml = $this->where->saveXML(); + $newWhere = new Zend_Gdata_Extension_Where(); + $newWhere->transferFromXML($whereXml); + $newWhereXml = $newWhere->saveXML(); + $this->assertTrue($whereXml == $newWhereXml); + } + + public function testWhereWithValueToAndFromStringShouldMatch() { + $this->where->valueString = "Test Value String"; + $this->where->rel = "http://schemas.google.com/g/2005#event.alternate"; + $this->where->label = "Test Label"; + $whereXml = $this->where->saveXML(); + $newWhere = new Zend_Gdata_Extension_Where(); + $newWhere->transferFromXML($whereXml); + $newWhereXml = $newWhere->saveXML(); + $this->assertTrue($whereXml == $newWhereXml); + $this->assertEquals("Test Value String", $this->where->valueString); + $this->assertEquals("http://schemas.google.com/g/2005#event.alternate", $this->where->rel); + $this->assertEquals("Test Label", $this->where->label); + } + + public function testExtensionAttributes() { + $extensionAttributes = $this->where->extensionAttributes; + $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); + $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); + $this->where->extensionAttributes = $extensionAttributes; + $this->assertEquals('bar', $this->where->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $this->where->extensionAttributes['foo2']['value']); + $whereXml = $this->where->saveXML(); + $newWhere = new Zend_Gdata_Extension_Where(); + $newWhere->transferFromXML($whereXml); + $this->assertEquals('bar', $newWhere->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $newWhere->extensionAttributes['foo2']['value']); + } + + public function testConvertFullWhereToAndFromString() { + $this->where->transferFromXML($this->whereText); + $this->assertEquals("Joe's Pub", $this->where->valueString); + $this->assertEquals("http://schemas.google.com/g/2005#event", $this->where->rel); + $this->assertEquals("1234 Anywhere Ln., New York, NY", $this->where->label); + $this->assertTrue($this->where->entryLink instanceof Zend_Gdata_Extension_EntryLink); + $this->assertEquals("http://local.example.com/10018/JoesPub", $this->where->entryLink->href); + } + +} diff --git a/zend/tests/Zend/Gdata/WhoTest.php b/zend/tests/Zend/Gdata/WhoTest.php new file mode 100644 index 0000000..8d1df5f --- /dev/null +++ b/zend/tests/Zend/Gdata/WhoTest.php @@ -0,0 +1,145 @@ +whoText = file_get_contents( + 'Zend/Gdata/_files/WhoElementSample1.xml', + true); + $this->who = new Zend_Gdata_Extension_Who(); + } + + public function testEmptyWhoShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->who->extensionElements)); + $this->assertTrue(count($this->who->extensionElements) == 0); + } + + public function testEmptyWhoShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->who->extensionAttributes)); + $this->assertTrue(count($this->who->extensionAttributes) == 0); + } + + public function testSampleWhoShouldHaveNoExtensionElements() { + $this->who->transferFromXML($this->whoText); + $this->assertTrue(is_array($this->who->extensionElements)); + $this->assertTrue(count($this->who->extensionElements) == 0); + } + + public function testSampleWhoShouldHaveNoExtensionAttributes() { + $this->who->transferFromXML($this->whoText); + $this->assertTrue(is_array($this->who->extensionAttributes)); + $this->assertTrue(count($this->who->extensionAttributes) == 0); + } + + public function testNormalWhoShouldHaveNoExtensionElements() { + $this->who->valueString = "Test Value String"; + $this->who->rel = "http://schemas.google.com/g/2005#event.speaker"; + $this->who->email = "testemail@somewhere.domain.invalid"; + + $this->assertEquals("Test Value String", $this->who->valueString); + $this->assertEquals("http://schemas.google.com/g/2005#event.speaker", $this->who->rel); + $this->assertEquals("testemail@somewhere.domain.invalid", $this->who->email); + + $this->assertEquals(0, count($this->who->extensionElements)); + $newWho = new Zend_Gdata_Extension_Who(); + $newWho->transferFromXML($this->who->saveXML()); + $this->assertEquals(0, count($newWho->extensionElements)); + $newWho->extensionElements = array( + new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar')); + $this->assertEquals(1, count($newWho->extensionElements)); + $this->assertEquals("Test Value String", $newWho->valueString); + $this->assertEquals("http://schemas.google.com/g/2005#event.speaker", $newWho->rel); + $this->assertEquals("testemail@somewhere.domain.invalid", $newWho->email); + + /* try constructing using magic factory */ + $gdata = new Zend_Gdata(); + $newWho2 = $gdata->newWho(); + $newWho2->transferFromXML($newWho->saveXML()); + $this->assertEquals(1, count($newWho2->extensionElements)); + $this->assertEquals("Test Value String", $newWho2->valueString); + $this->assertEquals("http://schemas.google.com/g/2005#event.speaker", $newWho2->rel); + $this->assertEquals("testemail@somewhere.domain.invalid", $newWho2->email); + } + + public function testEmptyWhoToAndFromStringShouldMatch() { + $whoXml = $this->who->saveXML(); + $newWho = new Zend_Gdata_Extension_Who(); + $newWho->transferFromXML($whoXml); + $newWhoXml = $newWho->saveXML(); + $this->assertTrue($whoXml == $newWhoXml); + } + + public function testWhoWithValueToAndFromStringShouldMatch() { + $this->who->valueString = "Test Value String"; + $this->who->rel = "http://schemas.google.com/g/2005#event.speaker"; + $this->who->email = "testemail@somewhere.domain.invalid"; + $whoXml = $this->who->saveXML(); + $newWho = new Zend_Gdata_Extension_Who(); + $newWho->transferFromXML($whoXml); + $newWhoXml = $newWho->saveXML(); + $this->assertTrue($whoXml == $newWhoXml); + $this->assertEquals("Test Value String", $this->who->valueString); + $this->assertEquals("http://schemas.google.com/g/2005#event.speaker", $this->who->rel); + $this->assertEquals("testemail@somewhere.domain.invalid", $this->who->email); + } + + public function testExtensionAttributes() { + $extensionAttributes = $this->who->extensionAttributes; + $extensionAttributes['foo1'] = array('name'=>'foo1', 'value'=>'bar'); + $extensionAttributes['foo2'] = array('name'=>'foo2', 'value'=>'rab'); + $this->who->extensionAttributes = $extensionAttributes; + $this->assertEquals('bar', $this->who->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $this->who->extensionAttributes['foo2']['value']); + $whoXml = $this->who->saveXML(); + $newWho = new Zend_Gdata_Extension_Who(); + $newWho->transferFromXML($whoXml); + $this->assertEquals('bar', $newWho->extensionAttributes['foo1']['value']); + $this->assertEquals('rab', $newWho->extensionAttributes['foo2']['value']); + } + + public function testConvertFullWhoToAndFromString() { + $this->who->transferFromXML($this->whoText); + $this->assertEquals("Jo", $this->who->valueString); + $this->assertEquals("http://schemas.google.com/g/2005#event.attendee", $this->who->rel); + $this->assertEquals("jo@nowhere.invalid", $this->who->email); + $this->assertTrue($this->who->attendeeStatus instanceof Zend_Gdata_Extension_AttendeeStatus); + $this->assertEquals("http://schemas.google.com/g/2005#event.tentative", $this->who->attendeeStatus->value); + $this->assertTrue($this->who->attendeeType instanceof Zend_Gdata_Extension_AttendeeType); + $this->assertEquals("http://schemas.google.com/g/2005#event.required", $this->who->attendeeType->value); + $this->assertTrue($this->who->entryLink instanceof Zend_Gdata_Extension_EntryLink); + $this->assertEquals("http://gmail.com/jo/contacts/Jo", $this->who->entryLink->href); + } + +} diff --git a/zend/tests/Zend/Gdata/YouTube/ActivityEntryTest.php b/zend/tests/Zend/Gdata/YouTube/ActivityEntryTest.php new file mode 100644 index 0000000..5f925d7 --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/ActivityEntryTest.php @@ -0,0 +1,153 @@ +entryText = file_get_contents( + 'Zend/Gdata/YouTube/_files/ActivityEntryDataSample1.xml', + true); + $this->entry = new Zend_Gdata_YouTube_ActivityEntry(); + $this->entry->setMajorProtocolVersion(2); + } + + private function verifyAllSamplePropertiesAreCorrect ($activityEntry) { + $this->assertEquals( + 'tag:youtube.com,2008:event:Z2RweXRob24xMTIzNDMwMDAyMzI5NTQ2N' . + 'zg2MA%3D%3D', + $activityEntry->id->text); + $this->assertEquals('2009-01-16T09:13:49.000-08:00', + $activityEntry->updated->text); + $this->assertEquals( + 'http://gdata.youtube.com/schemas/2007/userevents.cat', + $activityEntry->category[0]->scheme); + $this->assertEquals('video_favorited', + $activityEntry->category[0]->term); + $this->assertEquals('http://schemas.google.com/g/2005#kind', + $activityEntry->category[1]->scheme); + $this->assertEquals('http://gdata.youtube.com/schemas/2007#userEvent', + $activityEntry->category[1]->term); + $this->assertEquals('tayzonzay has favorited a video', + $activityEntry->title->text);; + + $this->assertEquals('self', $activityEntry->getLink('self')->rel); + $this->assertEquals('application/atom+xml', + $activityEntry->getLink('self')->type); + $this->assertEquals( + 'http://gdata.youtube.com/feeds/api/events/VGF5Wm9uZGF5MzEyaIl2' . + 'MTMxOTcxMDk3NzQ5MzM%3D?v=2', + $activityEntry->getLink('self')->href); + + $this->assertEquals('alternate', + $activityEntry->getLink('alternate')->rel); + $this->assertEquals('text/html', + $activityEntry->getLink('alternate')->type); + $this->assertEquals('http://www.youtube.com', + $activityEntry->getLink('alternate')->href); + + $this->assertEquals('http://gdata.youtube.com/schemas/2007#video', + $activityEntry->getLink( + 'http://gdata.youtube.com/schemas/2007#video')->rel); + $this->assertEquals('application/atom+xml', $activityEntry->getLink( + 'http://gdata.youtube.com/schemas/2007#video')->type); + $this->assertEquals( + 'http://gdata.youtube.com/feeds/api/videos/z3U0kuLH974?v=2', + $activityEntry->getLink( + 'http://gdata.youtube.com/schemas/2007#video')->href); + + $this->assertEquals('tayzonzay', $activityEntry->author[0]->name->text); + $this->assertEquals( + 'http://gdata.youtube.com/feeds/api/users/tayzonzay', + $activityEntry->author[0]->uri->text); + } + + public function testEmptyEntryShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->entry->extensionElements)); + $this->assertTrue(count($this->entry->extensionElements) == 0); + } + + public function testEmptyEntryShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->entry->extensionAttributes)); + $this->assertTrue(count($this->entry->extensionAttributes) == 0); + } + + public function testSampleEntryShouldHaveNoExtensionElements() { + $this->entry->transferFromXML($this->entryText); + $this->assertTrue(is_array($this->entry->extensionElements)); + $this->assertTrue(count($this->entry->extensionElements) == 0); + } + + public function testSampleEntryShouldHaveNoExtensionAttributes() { + $this->entry->transferFromXML($this->entryText); + $this->assertTrue(is_array($this->entry->extensionAttributes)); + $this->assertTrue(count($this->entry->extensionAttributes) == 0); + } + + public function testEmptyActivityEntryToAndFromStringShouldMatch() { + $entryXml = $this->entry->saveXML(); + $newActivityEntry = new Zend_Gdata_YouTube_ActivityEntry(); + $newActivityEntry->transferFromXML($entryXml); + $newActivityEntryXml = $newActivityEntry->saveXML(); + $this->assertTrue($entryXml == $newActivityEntryXml); + } + + public function testSamplePropertiesAreCorrect () { + $this->entry->transferFromXML($this->entryText); + $this->verifyAllSamplePropertiesAreCorrect($this->entry); + } + + public function testHelperMethods() { + $this->entry->transferFromXML($this->entryText); + $this->assertEquals('z3U0kuLH974', + $this->entry->getVideoId()->getText()); + $this->assertEquals('foo', + $this->entry->getUsername()->getText()); + $this->assertEquals('2', + $this->entry->getRatingValue()); + $this->assertEquals('video_favorited', + $this->entry->getActivityType()); + } + + public function testConvertActivityEntryToAndFromString() { + $this->entry->transferFromXML($this->entryText); + $entryXml = $this->entry->saveXML(); + $newActivityEntry = new Zend_Gdata_YouTube_ActivityEntry(); + $newActivityEntry->transferFromXML($entryXml); + $this->verifyAllSamplePropertiesAreCorrect($newActivityEntry); + $newActivityEntryXml = $newActivityEntry->saveXML(); + $this->assertEquals($entryXml, $newActivityEntryXml); + } + +} diff --git a/zend/tests/Zend/Gdata/YouTube/ActivityFeedTest.php b/zend/tests/Zend/Gdata/YouTube/ActivityFeedTest.php new file mode 100644 index 0000000..ae70798 --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/ActivityFeedTest.php @@ -0,0 +1,149 @@ +feedText = file_get_contents( + 'Zend/Gdata/YouTube/_files/ActivityFeedDataSample1.xml', + true); + $this->feed = new Zend_Gdata_YouTube_ActivityFeed(); + $this->feed->setMajorProtocolVersion(2); + } + + private function verifyAllSamplePropertiesAreCorrect ($activityFeed) { + $this->assertEquals('2009-01-28T09:13:49.000-08:00', + $activityFeed->updated->text); + $this->assertEquals( + 'http://schemas.google.com/g/2005#kind', + $activityFeed->category[0]->scheme); + $this->assertEquals('http://gdata.youtube.com/schemas/2007#userEvent', + $activityFeed->category[0]->term); + $this->assertEquals('Activity of tayzonzay', + $activityFeed->title->text);; + + $this->assertEquals('self', $activityFeed->getLink('self')->rel); + $this->assertEquals('application/atom+xml', + $activityFeed->getLink('self')->type); + $this->assertEquals( + 'http://gdata.youtube.com/feeds/api/events?author=gdpython' . + '&start-index=1&max-results=25&v=2', + $activityFeed->getLink('self')->href); + $this->assertEquals('http://schemas.google.com/g/2005#feed', + $activityFeed->getLink( + 'http://schemas.google.com/g/2005#feed')->rel); + $this->assertEquals('application/atom+xml', + $activityFeed->getLink( + 'http://schemas.google.com/g/2005#feed')->type); + $this->assertEquals('http://gdata.youtube.com/feeds/api/events?v=2', + $activityFeed->getLink( + 'http://schemas.google.com/g/2005#feed')->href); + $this->assertEquals('http://schemas.google.com/g/2005#batch', + $activityFeed->getLink( + 'http://schemas.google.com/g/2005#batch')->rel); + $this->assertEquals('application/atom+xml', + $activityFeed->getLink( + 'http://schemas.google.com/g/2005#batch')->type); + $this->assertEquals( + 'application/atom+xml', + $activityFeed->getLink( + 'http://schemas.google.com/g/2005#batch')->type); + $this->assertEquals('service', + $activityFeed->getLink('service')->rel); + $this->assertEquals('application/atomsvc+xml', + $activityFeed->getLink('service')->type); + $this->assertEquals( + 'http://gdata.youtube.com/feeds/api/events?alt=atom-service&v=2', + $activityFeed->getLink('service')->href); + + $this->assertEquals('YouTube', $activityFeed->author[0]->name->text); + $this->assertEquals('http://www.youtube.com/', + $activityFeed->author[0]->uri->text); + $this->assertEquals(12, $activityFeed->totalResults->text); + $this->assertEquals(1, $activityFeed->startIndex->text); + $this->assertEquals(25, $activityFeed->itemsPerPage->text); + } + + public function testEmptyEntryShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->feed->extensionElements)); + $this->assertEquals(0, count($this->feed->extensionElements)); + } + + public function testEmptyEntryShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->feed->extensionAttributes)); + $this->assertEquals(0, count($this->feed->extensionAttributes)); + } + + public function testSampleEntryShouldHaveNoExtensionElements() { + $this->feed->transferFromXML($this->feedText); + $this->assertTrue(is_array($this->feed->extensionElements)); + $this->assertEquals(0, count($this->feed->extensionElements)); + } + + public function testSampleEntryShouldHaveNoExtensionAttributes() { + $this->feed->transferFromXML($this->feedText); + $this->assertTrue(is_array($this->feed->extensionAttributes)); + $this->assertEquals(0, count($this->feed->extensionAttributes)); + } + + public function testEmptyActivityFeedToAndFromStringShouldMatch() { + $entryXml = $this->feed->saveXML(); + $newActivityFeed = new Zend_Gdata_YouTube_ActivityFeed(); + $newActivityFeed->transferFromXML($entryXml); + $newActivityFeedXml = $newActivityFeed->saveXML(); + $this->assertTrue($entryXml == $newActivityFeedXml); + } + + public function testSamplePropertiesAreCorrect () { + $this->feed->transferFromXML($this->feedText); + $this->verifyAllSamplePropertiesAreCorrect($this->feed); + } + + public function testConvertActivityFeedToAndFromString() { + $this->feed->transferFromXML($this->feedText); + $entryXml = $this->feed->saveXML(); + $newActivityFeed = new Zend_Gdata_YouTube_ActivityFeed(); + $newActivityFeed->transferFromXML($entryXml); + $this->verifyAllSamplePropertiesAreCorrect($newActivityFeed); + $newActivityFeedXml = $newActivityFeed->saveXML(); + $this->assertEquals($entryXml, $newActivityFeedXml); + } + + public function testEntryCanBeRetrieved() { + $this->feed->transferFromXML($this->feedText); + $this->assertTrue(count($this->feed->entries) > 0); + } + +} diff --git a/zend/tests/Zend/Gdata/YouTube/CommentEntryTest.php b/zend/tests/Zend/Gdata/YouTube/CommentEntryTest.php new file mode 100644 index 0000000..7ffad58 --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/CommentEntryTest.php @@ -0,0 +1,107 @@ +entryText = file_get_contents( + 'Zend/Gdata/YouTube/_files/CommentEntryDataSample1.xml', + true); + $this->entry = new Zend_Gdata_YouTube_CommentEntry(); + } + + private function verifyAllSamplePropertiesAreCorrect ($commentEntry) { + $this->assertEquals('http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments/CE0314DEBFFC9052', + $commentEntry->id->text); + $this->assertEquals('2007-09-02T18:00:04.000-07:00', $commentEntry->updated->text); + $this->assertEquals('http://schemas.google.com/g/2005#kind', $commentEntry->category[0]->scheme); + $this->assertEquals('http://gdata.youtube.com/schemas/2007#comment', $commentEntry->category[0]->term); + $this->assertEquals('text', $commentEntry->title->type); + $this->assertEquals('how to turn ...', $commentEntry->title->text);; + $this->assertEquals('text', $commentEntry->content->type); + $this->assertEquals('how to turn rejection and heartbreak into something positive is the big mystery of life but you\'re managed to turn it to your advantage with a beautiful song. Who was she?', $commentEntry->content->text);; + $this->assertEquals('self', $commentEntry->getLink('self')->rel); + $this->assertEquals('application/atom+xml', $commentEntry->getLink('self')->type); + $this->assertEquals('http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments/CE0314DEBFFC9052', $commentEntry->getLink('self')->href); + $this->assertEquals('reneemathome', $commentEntry->author[0]->name->text); + $this->assertEquals('http://gdata.youtube.com/feeds/users/reneemathome', $commentEntry->author[0]->uri->text); + } + + public function testEmptyEntryShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->entry->extensionElements)); + $this->assertTrue(count($this->entry->extensionElements) == 0); + } + + public function testEmptyEntryShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->entry->extensionAttributes)); + $this->assertTrue(count($this->entry->extensionAttributes) == 0); + } + + public function testSampleEntryShouldHaveNoExtensionElements() { + $this->entry->transferFromXML($this->entryText); + $this->assertTrue(is_array($this->entry->extensionElements)); + $this->assertTrue(count($this->entry->extensionElements) == 0); + } + + public function testSampleEntryShouldHaveNoExtensionAttributes() { + $this->entry->transferFromXML($this->entryText); + $this->assertTrue(is_array($this->entry->extensionAttributes)); + $this->assertTrue(count($this->entry->extensionAttributes) == 0); + } + + public function testEmptyCommentEntryToAndFromStringShouldMatch() { + $entryXml = $this->entry->saveXML(); + $newCommentEntry = new Zend_Gdata_YouTube_CommentEntry(); + $newCommentEntry->transferFromXML($entryXml); + $newCommentEntryXml = $newCommentEntry->saveXML(); + $this->assertTrue($entryXml == $newCommentEntryXml); + } + + public function testSamplePropertiesAreCorrect () { + $this->entry->transferFromXML($this->entryText); + $this->verifyAllSamplePropertiesAreCorrect($this->entry); + } + + public function testConvertCommentEntryToAndFromString() { + $this->entry->transferFromXML($this->entryText); + $entryXml = $this->entry->saveXML(); + $newCommentEntry = new Zend_Gdata_YouTube_CommentEntry(); + $newCommentEntry->transferFromXML($entryXml); + $this->verifyAllSamplePropertiesAreCorrect($newCommentEntry); + $newCommentEntryXml = $newCommentEntry->saveXML(); + $this->assertEquals($entryXml, $newCommentEntryXml); + } + +} diff --git a/zend/tests/Zend/Gdata/YouTube/CommentFeedTest.php b/zend/tests/Zend/Gdata/YouTube/CommentFeedTest.php new file mode 100644 index 0000000..2da13f4 --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/CommentFeedTest.php @@ -0,0 +1,109 @@ +feedText = file_get_contents( + 'Zend/Gdata/YouTube/_files/CommentFeedDataSample1.xml', + true); + $this->feed = new Zend_Gdata_YouTube_CommentFeed(); + } + + private function verifyAllSamplePropertiesAreCorrect ($commentFeed) { + $this->assertEquals('http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments', + $commentFeed->id->text); + $this->assertEquals('2007-09-21T02:32:55.032Z', $commentFeed->updated->text); + $this->assertEquals('http://schemas.google.com/g/2005#kind', $commentFeed->category[0]->scheme); + $this->assertEquals('http://gdata.youtube.com/schemas/2007#comment', $commentFeed->category[0]->term); + $this->assertEquals('http://www.youtube.com/img/pic_youtubelogo_123x63.gif', $commentFeed->logo->text); + $this->assertEquals('text', $commentFeed->title->type); + $this->assertEquals('Comments on \'"That Girl" - Original Song - Acoustic Version\'', $commentFeed->title->text);; + $this->assertEquals('self', $commentFeed->getLink('self')->rel); + $this->assertEquals('application/atom+xml', $commentFeed->getLink('self')->type); + $this->assertEquals('http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments?start-index=1&max-results=4', $commentFeed->getLink('self')->href); + $this->assertEquals('YouTube', $commentFeed->author[0]->name->text); + $this->assertEquals('http://www.youtube.com/', $commentFeed->author[0]->uri->text); + $this->assertEquals(100, $commentFeed->totalResults->text); + $this->assertEquals(1, $commentFeed->startIndex->text); + $this->assertEquals(4, $commentFeed->itemsPerPage->text); + } + + public function testEmptyEntryShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->feed->extensionElements)); + $this->assertTrue(count($this->feed->extensionElements) == 0); + } + + public function testEmptyEntryShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->feed->extensionAttributes)); + $this->assertTrue(count($this->feed->extensionAttributes) == 0); + } + + public function testSampleEntryShouldHaveNoExtensionElements() { + $this->feed->transferFromXML($this->feedText); + $this->assertTrue(is_array($this->feed->extensionElements)); + $this->assertTrue(count($this->feed->extensionElements) == 0); + } + + public function testSampleEntryShouldHaveNoExtensionAttributes() { + $this->feed->transferFromXML($this->feedText); + $this->assertTrue(is_array($this->feed->extensionAttributes)); + $this->assertTrue(count($this->feed->extensionAttributes) == 0); + } + + public function testEmptyCommentFeedToAndFromStringShouldMatch() { + $entryXml = $this->feed->saveXML(); + $newCommentFeed = new Zend_Gdata_YouTube_CommentFeed(); + $newCommentFeed->transferFromXML($entryXml); + $newCommentFeedXml = $newCommentFeed->saveXML(); + $this->assertTrue($entryXml == $newCommentFeedXml); + } + + public function testSamplePropertiesAreCorrect () { + $this->feed->transferFromXML($this->feedText); + $this->verifyAllSamplePropertiesAreCorrect($this->feed); + } + + public function testConvertCommentFeedToAndFromString() { + $this->feed->transferFromXML($this->feedText); + $entryXml = $this->feed->saveXML(); + $newCommentFeed = new Zend_Gdata_YouTube_CommentFeed(); + $newCommentFeed->transferFromXML($entryXml); + $this->verifyAllSamplePropertiesAreCorrect($newCommentFeed); + $newCommentFeedXml = $newCommentFeed->saveXML(); + $this->assertEquals($entryXml, $newCommentFeedXml); + } + +} diff --git a/zend/tests/Zend/Gdata/YouTube/ContactEntryTest.php b/zend/tests/Zend/Gdata/YouTube/ContactEntryTest.php new file mode 100644 index 0000000..23b461a --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/ContactEntryTest.php @@ -0,0 +1,109 @@ +entryText = file_get_contents( + 'Zend/Gdata/YouTube/_files/ContactEntryDataSample1.xml', + true); + $this->entry = new Zend_Gdata_YouTube_ContactEntry(); + } + + private function verifyAllSamplePropertiesAreCorrect ($contactEntry) { + $this->assertEquals('http://gdata.youtube.com/feeds/users/davidchoimusic/contacts/testuser', + $contactEntry->id->text); + $this->assertEquals('2007-09-21T02:44:41.134Z', $contactEntry->updated->text); + $this->assertEquals('http://schemas.google.com/g/2005#kind', $contactEntry->category[0]->scheme); + $this->assertEquals('http://gdata.youtube.com/schemas/2007#friend', $contactEntry->category[0]->term); + $this->assertEquals('http://gdata.youtube.com/schemas/2007/contact.cat', $contactEntry->category[1]->scheme); + $this->assertEquals('Friends', $contactEntry->category[1]->term); + $this->assertEquals('text', $contactEntry->title->type); + $this->assertEquals('testuser', $contactEntry->title->text);; + $this->assertEquals('self', $contactEntry->getLink('self')->rel); + $this->assertEquals('application/atom+xml', $contactEntry->getLink('self')->type); + $this->assertEquals('http://gdata.youtube.com/feeds/users/davidchoimusic/contacts/testuser', $contactEntry->getLink('self')->href); + $this->assertEquals('davidchoimusic', $contactEntry->author[0]->name->text); + $this->assertEquals('http://gdata.youtube.com/feeds/users/davidchoimusic', $contactEntry->author[0]->uri->text); + $this->assertEquals('testuser', $contactEntry->username->text); + $this->assertEquals('accepted', $contactEntry->status->text); + } + + public function testEmptyEntryShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->entry->extensionElements)); + $this->assertTrue(count($this->entry->extensionElements) == 0); + } + + public function testEmptyEntryShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->entry->extensionAttributes)); + $this->assertTrue(count($this->entry->extensionAttributes) == 0); + } + + public function testSampleEntryShouldHaveNoExtensionElements() { + $this->entry->transferFromXML($this->entryText); + $this->assertTrue(is_array($this->entry->extensionElements)); + $this->assertTrue(count($this->entry->extensionElements) == 0); + } + + public function testSampleEntryShouldHaveNoExtensionAttributes() { + $this->entry->transferFromXML($this->entryText); + $this->assertTrue(is_array($this->entry->extensionAttributes)); + $this->assertTrue(count($this->entry->extensionAttributes) == 0); + } + + public function testEmptyContactEntryToAndFromStringShouldMatch() { + $entryXml = $this->entry->saveXML(); + $newContactEntry = new Zend_Gdata_YouTube_ContactEntry(); + $newContactEntry->transferFromXML($entryXml); + $newContactEntryXml = $newContactEntry->saveXML(); + $this->assertTrue($entryXml == $newContactEntryXml); + } + + public function testSamplePropertiesAreCorrect () { + $this->entry->transferFromXML($this->entryText); + $this->verifyAllSamplePropertiesAreCorrect($this->entry); + } + + public function testConvertContactEntryToAndFromString() { + $this->entry->transferFromXML($this->entryText); + $entryXml = $this->entry->saveXML(); + $newContactEntry = new Zend_Gdata_YouTube_ContactEntry(); + $newContactEntry->transferFromXML($entryXml); + $this->verifyAllSamplePropertiesAreCorrect($newContactEntry); + $newContactEntryXml = $newContactEntry->saveXML(); + $this->assertEquals($entryXml, $newContactEntryXml); + } + +} diff --git a/zend/tests/Zend/Gdata/YouTube/ContactFeedTest.php b/zend/tests/Zend/Gdata/YouTube/ContactFeedTest.php new file mode 100644 index 0000000..e561daf --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/ContactFeedTest.php @@ -0,0 +1,109 @@ +feedText = file_get_contents( + 'Zend/Gdata/YouTube/_files/ContactFeedDataSample1.xml', + true); + $this->feed = new Zend_Gdata_YouTube_ContactFeed(); + } + + private function verifyAllSamplePropertiesAreCorrect ($contactFeed) { + $this->assertEquals('http://gdata.youtube.com/feeds/users/davidchoimusic/contacts', + $contactFeed->id->text); + $this->assertEquals('2007-09-21T02:44:41.135Z', $contactFeed->updated->text); + $this->assertEquals('http://schemas.google.com/g/2005#kind', $contactFeed->category[0]->scheme); + $this->assertEquals('http://gdata.youtube.com/schemas/2007#friend', $contactFeed->category[0]->term); + $this->assertEquals('http://www.youtube.com/img/pic_youtubelogo_123x63.gif', $contactFeed->logo->text); + $this->assertEquals('text', $contactFeed->title->type); + $this->assertEquals('davidchoimusic\'s Contacts', $contactFeed->title->text);; + $this->assertEquals('self', $contactFeed->getLink('self')->rel); + $this->assertEquals('application/atom+xml', $contactFeed->getLink('self')->type); + $this->assertEquals('http://gdata.youtube.com/feeds/users/davidchoimusic/contacts?start-index=1&max-results=5', $contactFeed->getLink('self')->href); + $this->assertEquals('davidchoimusic', $contactFeed->author[0]->name->text); + $this->assertEquals('http://gdata.youtube.com/feeds/users/davidchoimusic', $contactFeed->author[0]->uri->text); + $this->assertEquals(1558, $contactFeed->totalResults->text); + $this->assertEquals(1, $contactFeed->startIndex->text); + $this->assertEquals(5, $contactFeed->itemsPerPage->text); + } + + public function testEmptyEntryShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->feed->extensionElements)); + $this->assertTrue(count($this->feed->extensionElements) == 0); + } + + public function testEmptyEntryShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->feed->extensionAttributes)); + $this->assertTrue(count($this->feed->extensionAttributes) == 0); + } + + public function testSampleEntryShouldHaveNoExtensionElements() { + $this->feed->transferFromXML($this->feedText); + $this->assertTrue(is_array($this->feed->extensionElements)); + $this->assertTrue(count($this->feed->extensionElements) == 0); + } + + public function testSampleEntryShouldHaveNoExtensionAttributes() { + $this->feed->transferFromXML($this->feedText); + $this->assertTrue(is_array($this->feed->extensionAttributes)); + $this->assertTrue(count($this->feed->extensionAttributes) == 0); + } + + public function testEmptyContactFeedToAndFromStringShouldMatch() { + $entryXml = $this->feed->saveXML(); + $newContactFeed = new Zend_Gdata_YouTube_ContactFeed(); + $newContactFeed->transferFromXML($entryXml); + $newContactFeedXml = $newContactFeed->saveXML(); + $this->assertTrue($entryXml == $newContactFeedXml); + } + + public function testSamplePropertiesAreCorrect () { + $this->feed->transferFromXML($this->feedText); + $this->verifyAllSamplePropertiesAreCorrect($this->feed); + } + + public function testConvertContactFeedToAndFromString() { + $this->feed->transferFromXML($this->feedText); + $entryXml = $this->feed->saveXML(); + $newContactFeed = new Zend_Gdata_YouTube_ContactFeed(); + $newContactFeed->transferFromXML($entryXml); + $this->verifyAllSamplePropertiesAreCorrect($newContactFeed); + $newContactFeedXml = $newContactFeed->saveXML(); + $this->assertEquals($entryXml, $newContactFeedXml); + } + +} diff --git a/zend/tests/Zend/Gdata/YouTube/InboxEntryTest.php b/zend/tests/Zend/Gdata/YouTube/InboxEntryTest.php new file mode 100644 index 0000000..c4b2e5e --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/InboxEntryTest.php @@ -0,0 +1,217 @@ +entryText = file_get_contents( + 'Zend/Gdata/YouTube/_files/InboxEntryDataSample1.xml', + true); + $this->v2entryText = file_get_contents( + 'Zend/Gdata/YouTube/_files/' . + 'InboxEntryDataSampleV2.xml', + true); + + $this->entry = new Zend_Gdata_YouTube_InboxEntry(); + } + + private function verifyAllSamplePropertiesAreCorrect ($InboxEntry) { + $this->assertEquals( + 'http://gdata.youtube.com/feeds/api/users/andyland74/' . + 'inbox/ffb9a5f32cd5f55', + $InboxEntry->id->text); + $this->assertEquals('http://schemas.google.com/g/2005#kind', + $InboxEntry->category[0]->scheme); + $this->assertEquals( + 'http://gdata.youtube.com/schemas/2007#videoMessage', + $InboxEntry->category[0]->term); + $this->assertEquals('andyland74sFriend sent you a video!', + $InboxEntry->title->text);; + $this->assertEquals('self', + $InboxEntry->getLink('self')->rel); + $this->assertEquals('application/atom+xml', + $InboxEntry->getLink('self')->type); + $this->assertEquals( + 'http://gdata.youtube.com/feeds/api/users/andyland74/' . + 'inbox/ffb9a5f32cd5f55', + $InboxEntry->getLink('self')->href); + $this->assertEquals('andyland74sFriend', + $InboxEntry->author[0]->name->text); + $this->assertEquals( + 'http://gdata.youtube.com/feeds/api/users/andyland74sFriend', + $InboxEntry->author[0]->uri->text); + $this->assertEquals( + 'Check out this video!', + $InboxEntry->getDescription()->text); + } + + public function verifyAllSamplePropertiesAreCorrectV2( + $InboxEntry) { + $this->assertEquals( + 'tag:youtube,2008:user:andyland74:inbox:D_uaXzLRX1U', + $InboxEntry->id->text); + $this->assertEquals('2008-06-10T13:55:32.000-07:00', + $InboxEntry->published->text); + $this->assertEquals('2008-06-10T13:55:32.000-07:00', + $InboxEntry->updated->text); + $this->assertEquals( + 'http://schemas.google.com/g/2005#kind', + $InboxEntry->category[0]->scheme); + $this->assertEquals( + 'http://gdata.youtube.com/schemas/2007#videoMessage', + $InboxEntry->category[0]->term); + $this->assertEquals( + 'http://gdata.youtube.com/schemas/2007/keywords.cat', + $InboxEntry->category[1]->scheme); + $this->assertEquals( + 'surfing', + $InboxEntry->category[1]->term); + $this->assertEquals( + 'http://gdata.youtube.com/schemas/2007/categories.cat', + $InboxEntry->category[2]->scheme); + $this->assertEquals( + 'People', + $InboxEntry->category[2]->term); + $this->assertEquals('self', + $InboxEntry->getLink('self')->rel); + $this->assertEquals('application/atom+xml', + $InboxEntry->getLink('self')->type); + $this->assertEquals( + 'http://gdata.youtube.com/feeds/api/users/andyland74/' . + 'inbox/ffb9a5f32cd5f55?v=2', + $InboxEntry->getLink('self')->href); + $this->assertEquals('related', + $InboxEntry->getLink('related')->rel); + $this->assertEquals('application/atom+xml', + $InboxEntry->getLink('related')->type); + $this->assertEquals( + 'http://gdata.youtube.com/feeds/api/videos/jXE6G9CYcJs?v=2', + $InboxEntry->getLink('related')->href); + $this->assertEquals('alternate', + $InboxEntry->getLink('alternate')->rel); + $this->assertEquals('text/html', + $InboxEntry->getLink('alternate')->type); + $this->assertEquals( + 'http://www.youtube.com/watch?v=jXE6G9CYcJs', + $InboxEntry->getLink('alternate')->href); + $this->assertEquals('andyland74sFriend', + $InboxEntry->author[0]->name->text); + $this->assertEquals( + 'http://gdata.youtube.com/feeds/api/users/andyland74sFriend', + $InboxEntry->author[0]->uri->text); + $this->assertEquals(877, $InboxEntry->getRating()->numRaters); + $this->assertEquals( + 'http://gdata.youtube.com/feeds/api/videos/jXE6G9CYcJs/comments', + $InboxEntry->getComments()->getFeedLink()->getHref()); + $this->assertEquals(286355, + $InboxEntry->getStatistics()->getViewCount()); + } + + public function testEmptyEntryShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->entry->extensionElements)); + $this->assertEquals(0, count($this->entry->extensionElements)); + } + + public function testEmptyEntryShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->entry->extensionAttributes)); + $this->assertEquals(0, count($this->entry->extensionAttributes)); + } + + public function testSampleEntryShouldHaveNoExtensionElements() { + $this->entry->transferFromXML($this->entryText); + $this->assertTrue(is_array($this->entry->extensionElements)); + $this->assertEquals(0, count($this->entry->extensionElements)); + } + + public function testSampleEntryShouldHaveNoExtensionAttributes() { + $this->entry->transferFromXML($this->entryText); + $this->assertTrue(is_array($this->entry->extensionAttributes)); + $this->assertEquals(0, count($this->entry->extensionAttributes)); + } + + public function testSampleEntryShouldHaveNoExtensionElementsV2() { + $this->entry->setMajorProtocolVersion(2); + $this->entry->transferFromXML($this->v2entryText); + $this->assertTrue(is_array($this->entry->extensionElements)); + $this->assertEquals(0, count($this->entry->extensionElements)); + } + + public function testSampleEntryShouldHaveNoExtensionAttributesV2() { + $this->entry->setMajorProtocolVersion(2); + $this->entry->transferFromXML($this->v2entryText); + $this->assertTrue(is_array($this->entry->extensionAttributes)); + $this->assertEquals(0, count($this->entry->extensionAttributes)); + } + + public function testEmptyInboxEntryToAndFromStringShouldMatch() { + $entryXml = $this->entry->saveXML(); + $newInboxEntry = new Zend_Gdata_YouTube_InboxEntry(); + $newInboxEntry->transferFromXML($entryXml); + $newInboxEntryXml = $newInboxEntry->saveXML(); + $this->assertTrue($entryXml == $newInboxEntryXml); + } + + public function testEmptyInboxEntryToAndFromStringShouldMatchV2() { + $this->entry->transferFromXML($this->v2entryText); + $entryXml = $this->entry->saveXML(); + $newInboxEntry = new Zend_Gdata_YouTube_InboxEntry(); + $newInboxEntry->transferFromXML($entryXml); + $newInboxEntry->setMajorProtocolVersion(2); + $newInboxEntryXml = $newInboxEntry->saveXML(); + $this->assertTrue($entryXml == $newInboxEntryXml); + } + + public function testSamplePropertiesAreCorrect () { + $this->entry->transferFromXML($this->entryText); + $this->verifyAllSamplePropertiesAreCorrect($this->entry); + } + + public function testSamplePropertiesAreCorrectV2 () { + $this->entry->setMajorProtocolVersion(2); + $this->entry->transferFromXML($this->v2entryText); + $this->verifyAllSamplePropertiesAreCorrectV2($this->entry); + } + + public function testConvertInboxEntryToAndFromString() { + $this->entry->transferFromXML($this->entryText); + $entryXml = $this->entry->saveXML(); + $newInboxEntry = new Zend_Gdata_YouTube_InboxEntry(); + $newInboxEntry->transferFromXML($entryXml); + $this->verifyAllSamplePropertiesAreCorrect($newInboxEntry); + $newInboxEntryXml = $newInboxEntry->saveXML(); + $this->assertEquals($entryXml, $newInboxEntryXml); + } + +} diff --git a/zend/tests/Zend/Gdata/YouTube/InboxFeedTest.php b/zend/tests/Zend/Gdata/YouTube/InboxFeedTest.php new file mode 100644 index 0000000..a7a63cd --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/InboxFeedTest.php @@ -0,0 +1,182 @@ +feedText = file_get_contents( + 'Zend/Gdata/YouTube/_files/InboxFeedDataSample1.xml', + true); + $this->V2feedText = file_get_contents( + 'Zend/Gdata/YouTube/_files/InboxFeedDataSampleV2.xml', + true); + $this->feed = new Zend_Gdata_YouTube_InboxFeed(); + } + + private function verifyAllSamplePropertiesAreCorrect ($inboxFeed) { + $this->assertEquals('http://gdata.youtube.com/feeds/api/users/' . + 'default/inbox', + $inboxFeed->id->text); + $this->assertEquals('2008-06-10T20:55:40.271Z', + $inboxFeed->updated->text); + $this->assertEquals('http://schemas.google.com/g/2005#kind', + $inboxFeed->category[0]->scheme); + $this->assertEquals( + 'http://gdata.youtube.com/schemas/2007#videoMessage', + $inboxFeed->category[0]->term); + $this->assertEquals( + 'http://www.youtube.com/img/pic_youtubelogo_123x63.gif', + $inboxFeed->logo->text); + $this->assertEquals('text', $inboxFeed->title->type); + $this->assertEquals('Inbox of andyland74', + $inboxFeed->title->text);; + $this->assertEquals('self', $inboxFeed->getLink('self')->rel); + $this->assertEquals('application/atom+xml', + $inboxFeed->getLink('self')->type); + $this->assertEquals( + 'http://gdata.youtube.com/feeds/api/users/andyland74/inbox?...', + $inboxFeed->getLink('self')->href); + $this->assertEquals('andyland74', $inboxFeed->author[0]->name->text); + $this->assertEquals( + 'http://gdata.youtube.com/feeds/api/users/andyland74', + $inboxFeed->author[0]->uri->text); + $this->assertEquals(1, $inboxFeed->totalResults->text); + } + + private function verifyAllSamplePropertiesAreCorrectV2 ($inboxFeed) { + $this->assertEquals('tag:youtube,2008:user:andyland74:inbox', + $inboxFeed->id->text); + $this->assertEquals('2008-07-21T17:54:30.236Z', + $inboxFeed->updated->text); + $this->assertEquals('http://schemas.google.com/g/2005#kind', + $inboxFeed->category[0]->scheme); + $this->assertEquals( + 'http://gdata.youtube.com/schemas/2007#videoMessage', + $inboxFeed->category[0]->term); + $this->assertEquals( + 'http://www.youtube.com/img/pic_youtubelogo_123x63.gif', + $inboxFeed->logo->text); + $this->assertEquals('Inbox of andyland74', + $inboxFeed->title->text);; + $this->assertEquals('andyland74', + $inboxFeed->author[0]->name->text); + $this->assertEquals( + 'http://gdata.youtube.com/feeds/api/users/andyland74', + $inboxFeed->author[0]->uri->text); + $this->assertEquals('self', $inboxFeed->getLink('self')->rel); + $this->assertEquals('application/atom+xml', + $inboxFeed->getLink('self')->type); + $this->assertEquals( + 'http://gdata.youtube.com/feeds/api/users/andyland74/inbox?...', + $inboxFeed->getLink('self')->href); + $this->assertEquals('alternate', $inboxFeed->getLink('alternate')->rel); + $this->assertEquals('text/html', + $inboxFeed->getLink('alternate')->type); + $this->assertEquals( + 'http://www.youtube.com/my_messages?folder=inbox&filter=videos', + $inboxFeed->getLink('alternate')->href); + $this->assertEquals('service', $inboxFeed->getLink('service')->rel); + $this->assertEquals('application/atomsvc+xml', + $inboxFeed->getLink('service')->type); + $this->assertEquals( + 'http://gdata.youtube.com/feeds/api/users/andyland74/inbox?' . + 'alt=...', + $inboxFeed->getLink('service')->href); + + } + + public function testEmptyEntryShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->feed->extensionElements)); + $this->assertEquals(0, count($this->feed->extensionElements)); + } + + public function testEmptyEntryShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->feed->extensionAttributes)); + $this->assertEquals(0, count($this->feed->extensionAttributes)); + } + + public function testSampleEntryShouldHaveNoExtensionElements() { + $this->feed->transferFromXML($this->feedText); + $this->assertTrue(is_array($this->feed->extensionElements)); + $this->assertEquals(0, count($this->feed->extensionElements)); + } + + public function testSampleEntryShouldHaveNoExtensionAttributes() { + $this->feed->transferFromXML($this->feedText); + $this->assertTrue(is_array($this->feed->extensionAttributes)); + $this->assertEquals(0, count($this->feed->extensionAttributes)); + } + + public function testEmptyInboxFeedToAndFromStringShouldMatch() { + $feedXml = $this->feed->saveXML(); + $newInboxFeed = new Zend_Gdata_YouTube_InboxFeed(); + $newInboxFeed->transferFromXML($feedXml); + $newInboxFeedXml = $newInboxFeed->saveXML(); + $this->assertTrue($feedXml == $newInboxFeedXml); + } + + public function testSamplePropertiesAreCorrect () { + $this->feed->transferFromXML($this->feedText); + $this->verifyAllSamplePropertiesAreCorrect($this->feed); + } + + public function testSamplePropertiesAreCorrectV2 () { + $this->feed->transferFromXML($this->V2feedText); + $this->verifyAllSamplePropertiesAreCorrectV2($this->feed); + } + + public function testConvertInboxFeedToAndFromString() { + $this->feed->transferFromXML($this->feedText); + $feedXml = $this->feed->saveXML(); + $newInboxFeed = new Zend_Gdata_YouTube_InboxFeed(); + $newInboxFeed->transferFromXML($feedXml); + $this->verifyAllSamplePropertiesAreCorrect($newInboxFeed); + $newInboxFeedXml = $newInboxFeed->saveXML(); + $this->assertEquals($feedXml, $newInboxFeedXml); + } + + public function testConvertInboxFeedToAndFromStringV2() { + $this->feed->setMajorProtocolVersion(2); + $this->feed->transferFromXML($this->V2feedText); + $feedXml = $this->feed->saveXML(); + $newInboxFeed = new Zend_Gdata_YouTube_InboxFeed(); + $newInboxFeed->transferFromXML($feedXml); + $newInboxFeed->setMajorProtocolVersion(2); + $this->verifyAllSamplePropertiesAreCorrectV2($newInboxFeed); + $newInboxFeedXml = $newInboxFeed->saveXML(); + $this->assertEquals($feedXml, $newInboxFeedXml); + } + +} diff --git a/zend/tests/Zend/Gdata/YouTube/PlaylistListEntryTest.php b/zend/tests/Zend/Gdata/YouTube/PlaylistListEntryTest.php new file mode 100644 index 0000000..34e1069 --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/PlaylistListEntryTest.php @@ -0,0 +1,239 @@ +entryText = file_get_contents( + 'Zend/Gdata/YouTube/_files/PlaylistListEntryDataSample1.xml', + true); + $this->v2entryText = file_get_contents( + 'Zend/Gdata/YouTube/_files/PlaylistListEntryDataSampleV2.xml', + true); + $this->entry = new Zend_Gdata_YouTube_PlaylistListEntry(); + } + + private function verifyAllSamplePropertiesAreCorrect ($playlistListEntry) { + $this->assertEquals('http://gdata.youtube.com/feeds/users/testuser/playlists/46A2F8C9B36B6FE7', + $playlistListEntry->id->text); + $this->assertEquals('2007-09-20T13:42:19.000-07:00', $playlistListEntry->updated->text); + $this->assertEquals('http://gdata.youtube.com/schemas/2007/tags.cat', $playlistListEntry->category[0]->scheme); + $this->assertEquals('music', $playlistListEntry->category[0]->term); + $this->assertEquals('http://schemas.google.com/g/2005#kind', $playlistListEntry->category[1]->scheme); + $this->assertEquals('http://gdata.youtube.com/schemas/2007#playlistLink', $playlistListEntry->category[1]->term); + $this->assertEquals('text', $playlistListEntry->title->type); + $this->assertEquals('YouTube Musicians', $playlistListEntry->title->text);; + $this->assertEquals('text', $playlistListEntry->content->type); + $this->assertEquals('Music from talented people on YouTube.', $playlistListEntry->content->text);; + $this->assertEquals('self', $playlistListEntry->getLink('self')->rel); + $this->assertEquals('application/atom+xml', $playlistListEntry->getLink('self')->type); + $this->assertEquals('http://gdata.youtube.com/feeds/users/testuser/playlists/46A2F8C9B36B6FE7', $playlistListEntry->getLink('self')->href); + $this->assertEquals('testuser', $playlistListEntry->author[0]->name->text); + $this->assertEquals('http://gdata.youtube.com/feeds/users/testuser', $playlistListEntry->author[0]->uri->text); + $this->assertEquals('Music from talented people on YouTube.', $playlistListEntry->description->text); + $this->assertEquals('http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7', $playlistListEntry->getPlaylistVideoFeedUrl()); + $this->assertEquals('http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7', $playlistListEntry->feedLink[0]->href); + $this->assertEquals('http://gdata.youtube.com/schemas/2007#playlist', $playlistListEntry->feedLink[0]->rel); + } + + private function verifyAllSamplePropertiesAreCorrectV2 ($playlistListEntry) { + $this->assertEquals('tag:youtube.com,2008:user:googledevelopers:playlist:8E2186857EE27746', + $playlistListEntry->id->text); + $this->assertEquals('2008-12-10T09:56:03.000Z', $playlistListEntry->updated->text); + $this->assertEquals('2007-08-23T21:48:43.000Z', $playlistListEntry->published->text); + $this->assertEquals('http://schemas.google.com/g/2005#kind', $playlistListEntry->category[0]->scheme); + $this->assertEquals('http://gdata.youtube.com/schemas/2007#playlistLink', $playlistListEntry->category[0]->term); + $this->assertEquals('http://schemas.google.com/g/2005#kind', $playlistListEntry->category[0]->scheme); + $this->assertEquals('Non-google Interviews', $playlistListEntry->title->text); + $this->assertEquals('This playlist contains interviews with people outside of Google.', $playlistListEntry->summary->text); + + $this->assertEquals('self', $playlistListEntry->getLink('self')->rel); + $this->assertEquals('http://gdata.youtube.com/feeds/api/users/googledevelopers/playlists/8E2186857EE27746?v=2', $playlistListEntry->getLink('self')->href); + $this->assertEquals('application/atom+xml', $playlistListEntry->getLink('self')->type); + $this->assertEquals('alternate', $playlistListEntry->getLink('alternate')->rel); + $this->assertEquals('http://www.youtube.com/view_play_list?p=8E2186857EE27746', $playlistListEntry->getLink('alternate')->href); + $this->assertEquals('text/html', $playlistListEntry->getLink('alternate')->type); + $this->assertEquals('related', $playlistListEntry->getLink('related')->rel); + $this->assertEquals('http://gdata.youtube.com/feeds/api/users/googledevelopers?v=2', $playlistListEntry->getLink('related')->href); + $this->assertEquals('application/atom+xml', $playlistListEntry->getLink('related')->type); + $this->assertEquals('googledevelopers', $playlistListEntry->author[0]->name->text); + $this->assertEquals('http://gdata.youtube.com/feeds/api/users/googledevelopers', $playlistListEntry->author[0]->uri->text); + + $this->assertEquals('8E2186857EE27746', $playlistListEntry->getPlaylistId()->text); + $this->assertEquals('1', $playlistListEntry->getCountHint()->text); + + $this->assertEquals('application/atom+xml;type=feed', $playlistListEntry->getContent()->getType()); + $this->assertEquals('http://gdata.youtube.com/feeds/api/playlists/8E2186857EE27746?v=2', $playlistListEntry->getContent()->getSrc()); + } + + public function testEmptyEntryShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->entry->extensionElements)); + $this->assertEquals(0, count($this->entry->extensionElements)); + } + + public function testEmptyEntryShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->entry->extensionAttributes)); + $this->assertEquals(0, count($this->entry->extensionAttributes)); + } + + public function testSampleEntryShouldHaveNoExtensionElements() { + $this->entry->transferFromXML($this->entryText); + $this->assertTrue(is_array($this->entry->extensionElements)); + $this->assertEquals(0, count($this->entry->extensionElements)); + } + + public function testSampleEntryShouldHaveNoExtensionAttributes() { + $this->entry->transferFromXML($this->entryText); + $this->assertTrue(is_array($this->entry->extensionAttributes)); + $this->assertEquals(0, count($this->entry->extensionAttributes)); + } + + public function testEmptyPlaylistListEntryToAndFromStringShouldMatch() { + $entryXml = $this->entry->saveXML(); + $newPlaylistListEntry = new Zend_Gdata_YouTube_PlaylistListEntry(); + $newPlaylistListEntry->transferFromXML($entryXml); + $newPlaylistListEntryXml = $newPlaylistListEntry->saveXML(); + $this->assertTrue($entryXml == $newPlaylistListEntryXml); + } + + public function testSampleEntryShouldHaveNoExtensionElementsV2() { + $this->entry->transferFromXML($this->entryText); + $this->entry->setMajorProtocolVersion(2); + $this->assertTrue(is_array($this->entry->extensionElements)); + $this->assertEquals(0, count($this->entry->extensionElements)); + } + + public function testSampleEntryShouldHaveNoExtensionAttributesV2() { + $this->entry->transferFromXML($this->entryText); + $this->entry->setMajorProtocolVersion(2); + $this->assertTrue(is_array($this->entry->extensionAttributes)); + $this->assertEquals(0, count($this->entry->extensionAttributes)); + } + + public function testGetFeedLinkReturnsAllStoredEntriesWhenUsedWithNoParameters() { + // Prepare test data + $entry1 = new Zend_Gdata_Extension_FeedLink(); + $entry1->rel = "first"; + $entry1->href= "foo"; + $entry2 = new Zend_Gdata_Extension_FeedLink(); + $entry2->rel = "second"; + $entry2->href= "bar"; + $data = array($entry1, $entry2); + + // Load test data and run test + $this->entry->feedLink = $data; + $this->assertEquals(2, count($this->entry->feedLink)); + } + + public function testGetFeedLinkCanReturnEntriesByRelValue() { + // Prepare test data + $entry1 = new Zend_Gdata_Extension_FeedLink(); + $entry1->rel = "first"; + $entry1->href= "foo"; + $entry2 = new Zend_Gdata_Extension_FeedLink(); + $entry2->rel = "second"; + $entry2->href= "bar"; + $data = array($entry1, $entry2); + + // Load test data and run test + $this->entry->feedLink = $data; + $this->assertEquals($entry1, $this->entry->getFeedLink('first')); + $this->assertEquals($entry2, $this->entry->getFeedLink('second')); + } + + public function testSamplePropertiesAreCorrect () { + $this->entry->transferFromXML($this->entryText); + $this->verifyAllSamplePropertiesAreCorrect($this->entry); + } + + public function testSamplePropertiesAreCorrectV2 () { + $this->entry->transferFromXML($this->v2entryText); + $this->entry->setMajorProtocolVersion(2); + $this->verifyAllSamplePropertiesAreCorrectV2($this->entry); + } + + public function testConvertPlaylistListEntryToAndFromStringV2() { + $this->entry->transferFromXML($this->v2entryText); + $entryXml = $this->entry->saveXML(); + $newPlaylistListEntry = new Zend_Gdata_YouTube_PlaylistListEntry(); + $newPlaylistListEntry->transferFromXML($entryXml); + $newPlaylistListEntry->setMajorProtocolVersion(2); + $this->verifyAllSamplePropertiesAreCorrectV2($newPlaylistListEntry); + $newPlaylistListEntryXml = $newPlaylistListEntry->saveXML(); + $this->assertEquals($entryXml, $newPlaylistListEntryXml); + } + + public function testConvertPlaylistListEntryToAndFromString() { + $this->entry->transferFromXML($this->entryText); + $entryXml = $this->entry->saveXML(); + $newPlaylistListEntry = new Zend_Gdata_YouTube_PlaylistListEntry(); + $newPlaylistListEntry->transferFromXML($entryXml); + $this->verifyAllSamplePropertiesAreCorrect($newPlaylistListEntry); + $newPlaylistListEntryXml = $newPlaylistListEntry->saveXML(); + $this->assertEquals($entryXml, $newPlaylistListEntryXml); + } + + public function testGettingCountHintOnV1EntryShouldThrowException() { + $exceptionCaught = false; + $this->entry->transferFromXML($this->entryText); + try { + $this->entry->getCountHint(); + } catch (Zend_Gdata_App_VersionException $e) { + $exceptionCaught = true; + } + $this->assertTrue($exceptionCaught, 'Calling getCountHint on a v1 ' . + 'playlistListEntry should throw an exception'); + } + + public function testGettingPlaylistIdOnV1EntryShouldThrowException() { + $exceptionCaught = false; + $this->entry->transferFromXML($this->entryText); + try { + $this->entry->getPlaylistId(); + } catch (Zend_Gdata_App_VersionException $e) { + $exceptionCaught = true; + } + $this->assertTrue($exceptionCaught, 'Calling getPlaylistId on a v1 ' . + 'playlistListEntry should throw an exception'); + } + + public function testGetPlaylistVideoFeedUrlWorksInV2() { + $this->entry->transferFromXML($this->v2entryText); + $this->entry->setMajorProtocolVersion(2); + $this->assertEquals( + 'http://gdata.youtube.com/feeds/api/playlists/8E2186857EE27746?v=2', + $this->entry->getPlaylistVideoFeedUrl()); + } +} diff --git a/zend/tests/Zend/Gdata/YouTube/PlaylistListFeedTest.php b/zend/tests/Zend/Gdata/YouTube/PlaylistListFeedTest.php new file mode 100644 index 0000000..477f19b --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/PlaylistListFeedTest.php @@ -0,0 +1,171 @@ +feedText = file_get_contents( + 'Zend/Gdata/YouTube/_files/PlaylistListFeedDataSample1.xml', + true); + $this->V2feedText = file_get_contents( + 'Zend/Gdata/YouTube/_files/PlaylistListFeedDataSampleV2.xml', + true); + + $this->feed = new Zend_Gdata_YouTube_PlaylistListFeed(); + } + + private function verifyAllSamplePropertiesAreCorrect ($playlistListFeed) { + $this->assertEquals('http://gdata.youtube.com/feeds/users/testuser/playlists', + $playlistListFeed->id->text); + $this->assertEquals('2007-09-20T20:59:47.530Z', $playlistListFeed->updated->text); + $this->assertEquals('http://schemas.google.com/g/2005#kind', $playlistListFeed->category[0]->scheme); + $this->assertEquals('http://gdata.youtube.com/schemas/2007#playlistLink', $playlistListFeed->category[0]->term); + $this->assertEquals('http://www.youtube.com/img/pic_youtubelogo_123x63.gif', $playlistListFeed->logo->text); + $this->assertEquals('text', $playlistListFeed->title->type); + $this->assertEquals('testuser\'s Playlists', $playlistListFeed->title->text);; + $this->assertEquals('self', $playlistListFeed->getLink('self')->rel); + $this->assertEquals('application/atom+xml', $playlistListFeed->getLink('self')->type); + $this->assertEquals('http://gdata.youtube.com/feeds/users/testuser/playlists?start-index=1&max-results=25', $playlistListFeed->getLink('self')->href); + $this->assertEquals('testuser', $playlistListFeed->author[0]->name->text); + $this->assertEquals('http://gdata.youtube.com/feeds/users/testuser', $playlistListFeed->author[0]->uri->text); + $this->assertEquals(2, $playlistListFeed->totalResults->text); + } + + private function verifyAllSamplePropertiesAreCorrectV2 ($playlistListFeed) { + $this->assertEquals('tag:youtube.com,2008:user:GoogleDevelopers:playlists', + $playlistListFeed->id->text); + $this->assertEquals('2008-12-10T09:56:03.000Z', + $playlistListFeed->updated->text); + $this->assertEquals('http://schemas.google.com/g/2005#kind', + $playlistListFeed->category[0]->scheme); + $this->assertEquals( + 'http://gdata.youtube.com/schemas/2007#playlistLink', + $playlistListFeed->category[0]->term); + $this->assertEquals( + 'http://www.youtube.com/img/pic_youtubelogo_123x63.gif', + $playlistListFeed->logo->text); + $this->assertEquals('Playlists of GoogleDevelopers', + $playlistListFeed->title->text);; + $this->assertEquals('self', $playlistListFeed->getLink('self')->rel); + $this->assertEquals('application/atom+xml', + $playlistListFeed->getLink('self')->type); + $this->assertEquals( + 'http://gdata.youtube.com/feeds/api/users/GoogleDevelopers/' . + 'playlists?start-index=1&max-results=25&v=2', + $playlistListFeed->getLink('self')->href); + $this->assertEquals('GoogleDevelopers', + $playlistListFeed->author[0]->name->text); + $this->assertEquals('http://gdata.youtube.com/feeds/api/users/' . + 'googledevelopers', $playlistListFeed->author[0]->uri->text); + $this->assertEquals(70, $playlistListFeed->totalResults->text); + } + + public function testEmptyEntryShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->feed->extensionElements)); + $this->assertEquals(0, count($this->feed->extensionElements)); + } + + public function testEmptyEntryShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->feed->extensionAttributes)); + $this->assertEquals(0, count($this->feed->extensionAttributes)); + } + + public function testSampleEntryShouldHaveNoExtensionElements() { + $this->feed->transferFromXML($this->feedText); + $this->assertTrue(is_array($this->feed->extensionElements)); + $this->assertEquals(0, count($this->feed->extensionElements)); + } + + public function testSampleEntryShouldHaveNoExtensionAttributes() { + $this->feed->transferFromXML($this->feedText); + $this->assertTrue(is_array($this->feed->extensionAttributes)); + $this->assertEquals(0, count($this->feed->extensionAttributes)); + } + + public function testSampleEntryShouldHaveNoExtensionElementsV2() { + $this->feed->setMajorProtocolVersion(2); + $this->feed->transferFromXML($this->V2feedText); + $this->assertTrue(is_array($this->feed->extensionElements)); + $this->assertEquals(0, count($this->feed->extensionElements)); + } + + public function testSampleEntryShouldHaveNoExtensionAttributesV2() { + $this->feed->setMajorProtocolVersion(2); + $this->feed->transferFromXML($this->V2feedText); + $this->assertTrue(is_array($this->feed->extensionAttributes)); + $this->assertEquals(0, count($this->feed->extensionAttributes)); + } + + public function testEmptyPlaylistListFeedToAndFromStringShouldMatch() { + $feedXml = $this->feed->saveXML(); + $newPlaylistListFeed = new Zend_Gdata_YouTube_PlaylistListFeed(); + $newPlaylistListFeed->transferFromXML($feedXml); + $newPlaylistListFeedXml = $newPlaylistListFeed->saveXML(); + $this->assertTrue($feedXml == $newPlaylistListFeedXml); + } + + public function testEmptyPlaylistListFeedToAndFromStringShouldMatchV2() { + $this->feed->setMajorProtocolVersion(2); + $this->feed->transferFromXML($this->V2feedText); + $feedXml = $this->feed->saveXML(); + $newPlaylistListFeed = new Zend_Gdata_YouTube_PlaylistListFeed(); + $newPlaylistListFeed->transferFromXML($feedXml); + $newPlaylistListFeed->setMajorProtocolVersion(2); + $newPlaylistListFeedXml = $newPlaylistListFeed->saveXML(); + $this->assertTrue($feedXml == $newPlaylistListFeedXml); + } + + public function testSamplePropertiesAreCorrect () { + $this->feed->transferFromXML($this->feedText); + $this->verifyAllSamplePropertiesAreCorrect($this->feed); + } + + public function testSamplePropertiesAreCorrectV2 () { + $this->feed->setMajorProtocolVersion(2); + $this->feed->transferFromXML($this->V2feedText); + $this->verifyAllSamplePropertiesAreCorrectV2($this->feed); + } + + public function testConvertPlaylistListFeedToAndFromString() { + $this->feed->transferFromXML($this->feedText); + $entryXml = $this->feed->saveXML(); + $newPlaylistListFeed = new Zend_Gdata_YouTube_PlaylistListFeed(); + $newPlaylistListFeed->transferFromXML($entryXml); + $this->verifyAllSamplePropertiesAreCorrect($newPlaylistListFeed); + $newPlaylistListFeedXml = $newPlaylistListFeed->saveXML(); + $this->assertEquals($entryXml, $newPlaylistListFeedXml); + } + +} diff --git a/zend/tests/Zend/Gdata/YouTube/PlaylistVideoEntryTest.php b/zend/tests/Zend/Gdata/YouTube/PlaylistVideoEntryTest.php new file mode 100644 index 0000000..c6ffd65 --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/PlaylistVideoEntryTest.php @@ -0,0 +1,356 @@ +entryText = file_get_contents( + 'Zend/Gdata/YouTube/_files/PlaylistVideoEntryDataSample1.xml', + true); + $this->V2entryText = file_get_contents( + 'Zend/Gdata/YouTube/_files/PlaylistVideoEntryDataSampleV2.xml', + true); + $this->entry = new Zend_Gdata_YouTube_PlaylistVideoEntry(); + } + + private function verifyAllSamplePropertiesAreCorrect ($playlistVideoEntry) { + $this->assertEquals('http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/efb9b9a8dd4c2b21', + $playlistVideoEntry->id->text); + $this->assertEquals('2007-09-20T22:56:57.061Z', $playlistVideoEntry->updated->text); + $this->assertEquals('http://schemas.google.com/g/2005#kind', $playlistVideoEntry->category[0]->scheme); + $this->assertEquals('http://gdata.youtube.com/schemas/2007#playlist', $playlistVideoEntry->category[0]->term); + $this->assertEquals('text', $playlistVideoEntry->title->type); + $this->assertEquals('"Crazy (Gnarles Barkley)" - Acoustic Cover', $playlistVideoEntry->title->text);; + $this->assertEquals('html', $playlistVideoEntry->content->type); + $this->assertEquals('self', $playlistVideoEntry->getLink('self')->rel); + $this->assertEquals('application/atom+xml', $playlistVideoEntry->getLink('self')->type); + $this->assertEquals('http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/efb9b9a8dd4c2b21', $playlistVideoEntry->getLink('self')->href); + $this->assertEquals('davidchoimusic', $playlistVideoEntry->author[0]->name->text); + $this->assertEquals('http://gdata.youtube.com/feeds/users/davidchoimusic', $playlistVideoEntry->author[0]->uri->text); + $mediaGroup = $playlistVideoEntry->mediaGroup; + + $this->assertEquals('plain', $mediaGroup->title->type); + $this->assertEquals('"Crazy (Gnarles Barkley)" - Acoustic Cover', $mediaGroup->title->text); + $this->assertEquals('plain', $mediaGroup->description->type); + $this->assertEquals('Gnarles Barkley acoustic cover http://www.myspace.com/davidchoimusic', $mediaGroup->description->text); + $this->assertEquals('music, singing, gnarls, barkley, acoustic, cover', $mediaGroup->keywords->text); + $this->assertEquals(255, $mediaGroup->duration->seconds); + $this->assertEquals('Music', $mediaGroup->category[0]->label); + $this->assertEquals('http://gdata.youtube.com/schemas/2007/categories.cat', $mediaGroup->category[0]->scheme); + $this->assertEquals('video', $mediaGroup->content[0]->medium); + $this->assertEquals('http://www.youtube.com/v/UMFI1hdm96E', $mediaGroup->content[0]->url); + $this->assertEquals('application/x-shockwave-flash', $mediaGroup->content[0]->type); + $this->assertEquals('true', $mediaGroup->content[0]->isDefault); + $this->assertEquals('full', $mediaGroup->content[0]->expression); + $this->assertEquals(255, $mediaGroup->content[0]->duration); + $this->assertEquals(5, $mediaGroup->content[0]->format); + + $this->assertEquals('http://img.youtube.com/vi/UMFI1hdm96E/2.jpg', $mediaGroup->thumbnail[0]->url); + $this->assertEquals(97, $mediaGroup->thumbnail[0]->height); + $this->assertEquals(130, $mediaGroup->thumbnail[0]->width); + $this->assertEquals('00:02:07.500', $mediaGroup->thumbnail[0]->time); + $this->assertEquals('http://img.youtube.com/vi/UMFI1hdm96E/1.jpg', $mediaGroup->thumbnail[1]->url); + $this->assertEquals(97, $mediaGroup->thumbnail[1]->height); + $this->assertEquals(130, $mediaGroup->thumbnail[1]->width); + $this->assertEquals('00:01:03.750', $mediaGroup->thumbnail[1]->time); + $this->assertEquals('http://img.youtube.com/vi/UMFI1hdm96E/3.jpg', $mediaGroup->thumbnail[2]->url); + $this->assertEquals(97, $mediaGroup->thumbnail[2]->height); + $this->assertEquals(130, $mediaGroup->thumbnail[2]->width); + $this->assertEquals('00:03:11.250', $mediaGroup->thumbnail[2]->time); + $this->assertEquals('http://img.youtube.com/vi/UMFI1hdm96E/0.jpg', $mediaGroup->thumbnail[3]->url); + $this->assertEquals(240, $mediaGroup->thumbnail[3]->height); + $this->assertEquals(320, $mediaGroup->thumbnail[3]->width); + $this->assertEquals('00:02:07.500', $mediaGroup->thumbnail[3]->time); + + $this->assertEquals(113321, $playlistVideoEntry->statistics->viewCount); + $this->assertEquals(1, $playlistVideoEntry->rating->min); + $this->assertEquals(5, $playlistVideoEntry->rating->max); + $this->assertEquals(1005, $playlistVideoEntry->rating->numRaters); + $this->assertEquals(4.77, $playlistVideoEntry->rating->average); + $this->assertEquals(1, $playlistVideoEntry->position->text); + $this->assertEquals('http://gdata.youtube.com/feeds/videos/UMFI1hdm96E/comments', $playlistVideoEntry->comments->feedLink->href); + } + + private function verifyAllSamplePropertiesAreCorrectV2 ($playlistVideoEntry) { + $this->assertEquals( + 'tag:youtube.com,2008:playlist:4E6265CEF8BAA793:579617126485907C', + $playlistVideoEntry->id->text); + $this->assertEquals('2008-12-16T18:32:03.434Z', + $playlistVideoEntry->updated->text); + $this->assertEquals( + 'http://gdata.youtube.com/schemas/2007/keywords.cat', + $playlistVideoEntry->category[0]->scheme); + $this->assertEquals('dynamite', $playlistVideoEntry->category[0]->term); + $this->assertEquals( + 'http://gdata.youtube.com/schemas/2007/categories.cat', + $playlistVideoEntry->category[1]->scheme); + $this->assertEquals('News', $playlistVideoEntry->category[1]->term); + $this->assertEquals('News & Politics', + $playlistVideoEntry->category[1]->getLabel()); + $this->assertEquals( + 'http://schemas.google.com/g/2005#kind', + $playlistVideoEntry->category[2]->scheme); + $this->assertEquals('http://gdata.youtube.com/schemas/2007#playlist', + $playlistVideoEntry->category[2]->term); + $this->assertEquals('Paris Police Find Dynamite in Department Store', + $playlistVideoEntry->title->text);; + + $this->assertEquals('alternate', + $playlistVideoEntry->getLink('alternate')->rel); + $this->assertEquals('text/html', + $playlistVideoEntry->getLink('alternate')->type); + $this->assertEquals( + 'http://www.youtube.com/watch?v=Lur391T5ApY', + $playlistVideoEntry->getLink('alternate')->href); + + $this->assertEquals( + 'http://gdata.youtube.com/schemas/2007#video.responses', + $playlistVideoEntry->getLink( + 'http://gdata.youtube.com/schemas/2007#video.responses')->rel); + $this->assertEquals('application/atom+xml', + $playlistVideoEntry->getLink( + 'http://gdata.youtube.com/schemas/2007#video.responses')->type); + $this->assertEquals( + 'http://gdata.youtube.com/feeds/api/videos/Lur391T5ApY/' . + 'responses?v=2', + $playlistVideoEntry->getLink( + 'http://gdata.youtube.com/schemas/2007#video.responses')->href); + + $this->assertEquals( + 'http://gdata.youtube.com/schemas/2007#mobile', + $playlistVideoEntry->getLink( + 'http://gdata.youtube.com/schemas/2007#mobile')->rel); + $this->assertEquals('text/html', + $playlistVideoEntry->getLink( + 'http://gdata.youtube.com/schemas/2007#mobile')->type); + $this->assertEquals( + 'http://m.youtube.com/details?v=Lur391T5ApY', + $playlistVideoEntry->getLink( + 'http://gdata.youtube.com/schemas/2007#mobile')->href); + + $this->assertEquals('related', + $playlistVideoEntry->getLink('related')->rel); + $this->assertEquals('application/atom+xml', + $playlistVideoEntry->getLink('related')->type); + $this->assertEquals( + 'http://gdata.youtube.com/feeds/api/videos/Lur391T5ApY?v=2', + $playlistVideoEntry->getLink('related')->href); + + $this->assertEquals('self', + $playlistVideoEntry->getLink('self')->rel); + $this->assertEquals('application/atom+xml', + $playlistVideoEntry->getLink('self')->type); + $this->assertEquals( + 'http://gdata.youtube.com/feeds/api/playlists/4E6265CEF8BAA793/' . + '579617126485907C?v=2', + $playlistVideoEntry->getLink('self')->href); + + $this->assertEquals('zfgdata', + $playlistVideoEntry->author[0]->name->text); + $this->assertEquals( + 'http://gdata.youtube.com/feeds/api/users/zfgdata', + $playlistVideoEntry->author[0]->uri->text); + + $mediaGroup = $playlistVideoEntry->mediaGroup; + + $this->assertEquals('plain', $mediaGroup->title->type); + $this->assertEquals('Paris Police Find', + $mediaGroup->title->text); + $this->assertEquals('plain', $mediaGroup->description->type); + $this->assertEquals('French police found.', + $mediaGroup->description->text); + $this->assertEquals( + 'department, dynamite, explosives, find', + $mediaGroup->keywords->text); + $this->assertEquals(67, $mediaGroup->duration->seconds); + $this->assertEquals('News & Politics', + $mediaGroup->category[0]->label); + $this->assertEquals( + 'http://gdata.youtube.com/schemas/2007/categories.cat', + $mediaGroup->category[0]->scheme); + $this->assertEquals('video', $mediaGroup->content[0]->medium); + $this->assertEquals( + 'http://www.youtube.com/v/Lur391T5ApY&f=gdata_playlists', + $mediaGroup->content[0]->url); + $this->assertEquals('application/x-shockwave-flash', + $mediaGroup->content[0]->type); + $this->assertEquals('video', + $mediaGroup->content[0]->medium); + $this->assertEquals('true', $mediaGroup->content[0]->isDefault); + $this->assertEquals('full', $mediaGroup->content[0]->expression); + $this->assertEquals(67, $mediaGroup->content[0]->duration); + $this->assertEquals(5, $mediaGroup->content[0]->format); + + $this->assertEquals('http://i.ytimg.com/vi/Lur391T5ApY/2.jpg', + $mediaGroup->thumbnail[0]->url); + $this->assertEquals(97, $mediaGroup->thumbnail[0]->height); + $this->assertEquals(130, $mediaGroup->thumbnail[0]->width); + $this->assertEquals('00:00:33.500', $mediaGroup->thumbnail[0]->time); + $this->assertEquals('http://i.ytimg.com/vi/Lur391T5ApY/1.jpg', + $mediaGroup->thumbnail[1]->url); + $this->assertEquals(97, $mediaGroup->thumbnail[1]->height); + $this->assertEquals(130, $mediaGroup->thumbnail[1]->width); + $this->assertEquals('00:00:16.750', $mediaGroup->thumbnail[1]->time); + $this->assertEquals('http://i.ytimg.com/vi/Lur391T5ApY/3.jpg', + $mediaGroup->thumbnail[2]->url); + $this->assertEquals(97, $mediaGroup->thumbnail[2]->height); + $this->assertEquals(130, $mediaGroup->thumbnail[2]->width); + $this->assertEquals('00:00:50.250', $mediaGroup->thumbnail[2]->time); + $this->assertEquals('http://i.ytimg.com/vi/Lur391T5ApY/hqdefault.jpg', + $mediaGroup->thumbnail[3]->url); + $this->assertEquals(360, $mediaGroup->thumbnail[3]->height); + $this->assertEquals(480, $mediaGroup->thumbnail[3]->width); + $this->assertEquals('2008-12-16T17:01:42.000Z', + $mediaGroup->getUploaded()->text); + $this->assertEquals('AssociatedPress', + $mediaGroup->getMediaCredit()->text); + $this->assertEquals('uploader', + $mediaGroup->getMediaCredit()->role); + $this->assertEquals('urn:youtube', + $mediaGroup->getMediaCredit()->scheme); + $this->assertEquals('partner', + $mediaGroup->getMediaCredit()->getYTtype()); + $players = $mediaGroup->getPlayer(); + $this->assertEquals('http://www.youtube.com/watch?v=Lur391T5ApY', + $players[0]->url); + + $this->assertEquals(271, $playlistVideoEntry->statistics->viewCount); + $this->assertEquals(1, $playlistVideoEntry->rating->min); + $this->assertEquals(5, $playlistVideoEntry->rating->max); + $this->assertEquals(5, $playlistVideoEntry->rating->numRaters); + $this->assertEquals(4.20, $playlistVideoEntry->rating->average); + $this->assertEquals(1, $playlistVideoEntry->position->text); + $this->assertEquals( + 'http://gdata.youtube.com/feeds/api/videos/Lur391T5ApY/comments?v=2', + $playlistVideoEntry->comments->feedLink->href); + $this->assertEquals(4, + $playlistVideoEntry->comments->feedLink->countHint); + $this->assertEquals('New York, NY', + $playlistVideoEntry->getLocation()->text); + $this->assertEquals('2008-12-16', + $playlistVideoEntry->getRecorded()->text); + $this->assertEquals('Lur391T5ApY', + $playlistVideoEntry->getVideoId()); + + } + + public function testEmptyEntryShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->entry->extensionElements)); + $this->assertTrue(count($this->entry->extensionElements) == 0); + } + + public function testEmptyEntryShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->entry->extensionAttributes)); + $this->assertTrue(count($this->entry->extensionAttributes) == 0); + } + + public function testSampleEntryShouldHaveNoExtensionElements() { + $this->entry->transferFromXML($this->entryText); + $this->assertTrue(is_array($this->entry->extensionElements)); + $this->assertTrue(count($this->entry->extensionElements) == 0); + } + + public function testSampleEntryShouldHaveNoExtensionAttributes() { + $this->entry->transferFromXML($this->entryText); + $this->assertTrue(is_array($this->entry->extensionAttributes)); + $this->assertTrue(count($this->entry->extensionAttributes) == 0); + } + + public function testSampleEntryShouldHaveNoExtensionElementsV2() { + $this->entry->setMajorProtocolVersion(2); + $this->entry->transferFromXML($this->V2entryText); + $this->assertTrue(is_array($this->entry->extensionElements)); + $this->assertTrue(count($this->entry->extensionElements) == 0); + } + + public function testSampleEntryShouldHaveNoExtensionAttributesV2() { + $this->entry->setMajorProtocolVersion(2); + $this->entry->transferFromXML($this->V2entryText); + $this->assertTrue(is_array($this->entry->extensionAttributes)); + $this->assertTrue(count($this->entry->extensionAttributes) == 0); + } + + public function testEmptyPlaylistVideoEntryToAndFromStringShouldMatch() { + $entryXml = $this->entry->saveXML(); + $newPlaylistVideoEntry = new Zend_Gdata_YouTube_PlaylistVideoEntry(); + $newPlaylistVideoEntry->transferFromXML($entryXml); + $newPlaylistVideoEntryXml = $newPlaylistVideoEntry->saveXML(); + $this->assertTrue($entryXml == $newPlaylistVideoEntryXml); + } + + public function testEmptyPlaylistVideoEntryToAndFromStringShouldMatchV2() { + $this->entry->setMajorProtocolVersion(2); + $entryXml = $this->entry->saveXML(); + $newPlaylistVideoEntry = new Zend_Gdata_YouTube_PlaylistVideoEntry(); + $newPlaylistVideoEntry->setMajorProtocolVersion(2); + $newPlaylistVideoEntry->transferFromXML($entryXml); + $newPlaylistVideoEntryXml = $newPlaylistVideoEntry->saveXML(); + $this->assertTrue($entryXml == $newPlaylistVideoEntryXml); + } + + public function testSamplePropertiesAreCorrect () { + $this->entry->transferFromXML($this->entryText); + $this->verifyAllSamplePropertiesAreCorrect($this->entry); + } + + public function testSamplePropertiesAreCorrectV2 () { + $this->entry->setMajorProtocolVersion(2); + $this->entry->transferFromXML($this->V2entryText); + $this->verifyAllSamplePropertiesAreCorrectV2($this->entry); + } + + public function testConvertPlaylistVideoEntryToAndFromString() { + $this->entry->transferFromXML($this->entryText); + $entryXml = $this->entry->saveXML(); + $newPlaylistVideoEntry = new Zend_Gdata_YouTube_PlaylistVideoEntry(); + $newPlaylistVideoEntry->transferFromXML($entryXml); + $this->verifyAllSamplePropertiesAreCorrect($newPlaylistVideoEntry); + $newPlaylistVideoEntryXml = $newPlaylistVideoEntry->saveXML(); + $this->assertEquals($entryXml, $newPlaylistVideoEntryXml); + } + + public function testConvertPlaylistVideoEntryToAndFromStringV2() { + $this->entry->setMajorProtocolVersion(2); + $this->entry->transferFromXML($this->V2entryText); + $entryXml = $this->entry->saveXML(); + $newPlaylistVideoEntry = new Zend_Gdata_YouTube_PlaylistVideoEntry(); + $newPlaylistVideoEntry->setMajorProtocolVersion(2); + $newPlaylistVideoEntry->transferFromXML($entryXml); + $this->verifyAllSamplePropertiesAreCorrectV2($newPlaylistVideoEntry); + $newPlaylistVideoEntryXml = $newPlaylistVideoEntry->saveXML(); + $this->assertEquals($entryXml, $newPlaylistVideoEntryXml); + } + +} diff --git a/zend/tests/Zend/Gdata/YouTube/PlaylistVideoFeedTest.php b/zend/tests/Zend/Gdata/YouTube/PlaylistVideoFeedTest.php new file mode 100644 index 0000000..d145656 --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/PlaylistVideoFeedTest.php @@ -0,0 +1,112 @@ +feedText = file_get_contents( + 'Zend/Gdata/YouTube/_files/PlaylistVideoFeedDataSample1.xml', + true); + $this->feed = new Zend_Gdata_YouTube_PlaylistVideoFeed(); + } + + private function verifyAllSamplePropertiesAreCorrect ($playlistVideoFeed) { + $this->assertEquals('http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7', + $playlistVideoFeed->id->text); + $this->assertEquals('2007-09-20T13:42:19.000-07:00', $playlistVideoFeed->updated->text); + $this->assertEquals('http://schemas.google.com/g/2005#kind', $playlistVideoFeed->category[0]->scheme); + $this->assertEquals('http://gdata.youtube.com/schemas/2007#playlist', $playlistVideoFeed->category[0]->term); + $this->assertEquals('http://gdata.youtube.com/schemas/2007/tags.cat', $playlistVideoFeed->category[1]->scheme); + $this->assertEquals('music', $playlistVideoFeed->category[1]->term); + $this->assertEquals('http://www.youtube.com/img/pic_youtubelogo_123x63.gif', $playlistVideoFeed->logo->text); + $this->assertEquals('text', $playlistVideoFeed->title->type); + $this->assertEquals('YouTube Musicians', $playlistVideoFeed->title->text);; + $this->assertEquals('self', $playlistVideoFeed->getLink('self')->rel); + $this->assertEquals('application/atom+xml', $playlistVideoFeed->getLink('self')->type); + $this->assertEquals('http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7?start-index=1&max-results=25', $playlistVideoFeed->getLink('self')->href); + $this->assertEquals('testuser', $playlistVideoFeed->author[0]->name->text); + $this->assertEquals('http://gdata.youtube.com/feeds/users/testuser', $playlistVideoFeed->author[0]->uri->text); + $this->assertEquals(13, $playlistVideoFeed->totalResults->text); + $this->assertEquals(13, count($playlistVideoFeed->entry)); + $entries = $playlistVideoFeed->entry; + $this->assertEquals(1, $entries[0]->getPosition()->getText()); + } + + public function testEmptyEntryShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->feed->extensionElements)); + $this->assertTrue(count($this->feed->extensionElements) == 0); + } + + public function testEmptyEntryShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->feed->extensionAttributes)); + $this->assertTrue(count($this->feed->extensionAttributes) == 0); + } + + public function testSampleEntryShouldHaveNoExtensionElements() { + $this->feed->transferFromXML($this->feedText); + $this->assertTrue(is_array($this->feed->extensionElements)); + $this->assertTrue(count($this->feed->extensionElements) == 0); + } + + public function testSampleEntryShouldHaveNoExtensionAttributes() { + $this->feed->transferFromXML($this->feedText); + $this->assertTrue(is_array($this->feed->extensionAttributes)); + $this->assertTrue(count($this->feed->extensionAttributes) == 0); + } + + public function testEmptyPlaylistVideoFeedToAndFromStringShouldMatch() { + $entryXml = $this->feed->saveXML(); + $newPlaylistVideoFeed = new Zend_Gdata_YouTube_PlaylistVideoFeed(); + $newPlaylistVideoFeed->transferFromXML($entryXml); + $newPlaylistVideoFeedXml = $newPlaylistVideoFeed->saveXML(); + $this->assertTrue($entryXml == $newPlaylistVideoFeedXml); + } + + public function testSamplePropertiesAreCorrect () { + $this->feed->transferFromXML($this->feedText); + $this->verifyAllSamplePropertiesAreCorrect($this->feed); + } + + public function testConvertPlaylistVideoFeedToAndFromString() { + $this->feed->transferFromXML($this->feedText); + $feedXml = $this->feed->saveXML(); + $newPlaylistVideoFeed = new Zend_Gdata_YouTube_PlaylistVideoFeed(); + $newPlaylistVideoFeed->transferFromXML($feedXml); + $this->verifyAllSamplePropertiesAreCorrect($newPlaylistVideoFeed); + $newPlaylistVideoFeedXml = $newPlaylistVideoFeed->saveXML(); + $this->assertEquals($feedXml, $newPlaylistVideoFeedXml); + } + +} diff --git a/zend/tests/Zend/Gdata/YouTube/SubscriptionEntryTest.php b/zend/tests/Zend/Gdata/YouTube/SubscriptionEntryTest.php new file mode 100644 index 0000000..a6e065b --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/SubscriptionEntryTest.php @@ -0,0 +1,332 @@ +entryText = file_get_contents( + 'Zend/Gdata/YouTube/_files/SubscriptionEntryDataSample1.xml', + true); + $this->v2entryText_channel = file_get_contents( + 'Zend/Gdata/YouTube/_files/' . + 'SubscriptionEntryDataSample_channelV2.xml', + true); + $this->v2entryText_playlist = file_get_contents( + 'Zend/Gdata/YouTube/_files/' . + 'SubscriptionEntryDataSample_playlistV2.xml', + true); + $this->v2entryText_favorites = file_get_contents( + 'Zend/Gdata/YouTube/_files/' . + 'SubscriptionEntryDataSample_favoritesV2.xml', + true); + $this->v2entryText_query = file_get_contents( + 'Zend/Gdata/YouTube/_files/' . + 'SubscriptionEntryDataSample_queryV2.xml', + true); + + $this->entry = new Zend_Gdata_YouTube_SubscriptionEntry(); + } + + private function verifyAllSamplePropertiesAreCorrect ($subscriptionListEntry) { + $this->assertEquals( + 'http://gdata.youtube.com/feeds/users/testuser/' . + 'subscriptions/35bbde297dba88db', + $subscriptionListEntry->id->text); + $this->assertEquals('2007-03-02T11:58:22.000-08:00', + $subscriptionListEntry->updated->text); + $this->assertEquals( + 'http://gdata.youtube.com/schemas/2007/subscriptiontypes.cat', + $subscriptionListEntry->category[1]->scheme); + $this->assertEquals('publisher', + $subscriptionListEntry->category[1]->term); + $this->assertEquals('http://schemas.google.com/g/2005#kind', + $subscriptionListEntry->category[0]->scheme); + $this->assertEquals( + 'http://gdata.youtube.com/schemas/2007#subscription', + $subscriptionListEntry->category[0]->term); + $this->assertEquals('text', $subscriptionListEntry->title->type); + $this->assertEquals('Videos published by : BBC', + $subscriptionListEntry->title->text);; + $this->assertEquals('self', + $subscriptionListEntry->getLink('self')->rel); + $this->assertEquals('application/atom+xml', + $subscriptionListEntry->getLink('self')->type); + $this->assertEquals( + 'http://gdata.youtube.com/feeds/users/testuser/' . + 'subscriptions/35bbde297dba88db', + $subscriptionListEntry->getLink('self')->href); + $this->assertEquals('testuser', + $subscriptionListEntry->author[0]->name->text); + $this->assertEquals('http://gdata.youtube.com/feeds/users/testuser', + $subscriptionListEntry->author[0]->uri->text); + $this->assertEquals('http://gdata.youtube.com/feeds/users/BBC/uploads', + $subscriptionListEntry->feedLink[0]->href); + $this->assertEquals('697', + $subscriptionListEntry->feedLink[0]->countHint); + $this->assertEquals( + 'http://gdata.youtube.com/schemas/2007#user.uploads', + $subscriptionListEntry->feedLink[0]->rel); + } + + public function verifyAllSamplePropertiesAreCorrectV2( + $subscriptionListEntry) { + $this->assertEquals( + 'tag:youtube.com,2008:user:googledevelopers:subscription:' . + 'Z1Lm-S9gkRQ', + $subscriptionListEntry->id->text); + $this->assertEquals('2007-11-16T15:15:17.000-08:00', + $subscriptionListEntry->published->text); + $this->assertEquals('2007-11-16T15:15:17.000-08:00', + $subscriptionListEntry->updated->text); + $this->assertEquals( + 'http://gdata.youtube.com/schemas/2007/subscriptiontypes.cat', + $subscriptionListEntry->category[0]->scheme); + $this->assertEquals('channel', + $subscriptionListEntry->category[0]->term); + $this->assertEquals('http://schemas.google.com/g/2005#kind', + $subscriptionListEntry->category[1]->scheme); + $this->assertEquals( + 'http://gdata.youtube.com/schemas/2007#subscription', + $subscriptionListEntry->category[1]->term); + + $this->assertEquals('self', + $subscriptionListEntry->getLink('self')->rel); + $this->assertEquals('application/atom+xml', + $subscriptionListEntry->getLink('self')->type); + $this->assertEquals( + 'http://gdata.youtube.com/feeds/api/users/googledevelopers/' . + 'subscriptions/Z1Lm-S9gkRQ?v=2', + $subscriptionListEntry->getLink('self')->href); + $this->assertEquals('related', + $subscriptionListEntry->getLink('related')->rel); + $this->assertEquals('application/atom+xml', + $subscriptionListEntry->getLink('related')->type); + $this->assertEquals( + 'http://gdata.youtube.com/feeds/api/users/googledevelopers?v=2', + $subscriptionListEntry->getLink('related')->href); + $this->assertEquals('alternate', + $subscriptionListEntry->getLink('alternate')->rel); + $this->assertEquals('text/html', + $subscriptionListEntry->getLink('alternate')->type); + $this->assertEquals( + 'http://www.youtube.com/profile_videos?user=androiddevelopers', + $subscriptionListEntry->getLink('alternate')->href); + $this->assertEquals('GoogleDevelopers', + $subscriptionListEntry->author[0]->name->text); + $this->assertEquals( + 'http://gdata.youtube.com/feeds/api/users/googledevelopers', + $subscriptionListEntry->author[0]->uri->text); + $this->assertEquals('androiddevelopers', + $subscriptionListEntry->getUsername()->text); + $this->assertEquals('50', + $subscriptionListEntry->getCountHint()->text); + $thumbnail = $subscriptionListEntry->getMediaThumbnail(); + $this->assertTrue( + $thumbnail instanceof Zend_Gdata_Media_Extension_MediaThumbnail); + $this->assertTrue($thumbnail->getUrl() != null); + $this->assertEquals( + 'http://gdata.youtube.com/feeds/api/users/' . + 'androiddevelopers/uploads?v=2', + $subscriptionListEntry->getContent()->getSrc()); + } + + public function testEmptyEntryShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->entry->extensionElements)); + $this->assertTrue(count($this->entry->extensionElements) == 0); + } + + public function testEmptyEntryShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->entry->extensionAttributes)); + $this->assertTrue(count($this->entry->extensionAttributes) == 0); + } + + public function testSampleEntryShouldHaveNoExtensionElements() { + $this->entry->transferFromXML($this->entryText); + $this->assertTrue(is_array($this->entry->extensionElements)); + $this->assertTrue(count($this->entry->extensionElements) == 0); + } + + public function testSampleEntryShouldHaveNoExtensionAttributes() { + $this->entry->transferFromXML($this->entryText); + $this->assertTrue(is_array($this->entry->extensionAttributes)); + $this->assertTrue(count($this->entry->extensionAttributes) == 0); + } + + public function testSampleEntryShouldHaveNoExtensionElementsV2() { + $this->entry->transferFromXML($this->v2entryText_channel); + $this->assertTrue(is_array($this->entry->extensionElements)); + $this->assertTrue(count($this->entry->extensionElements) == 0); + } + + public function testSampleEntryShouldHaveNoExtensionAttributesV2() { + $this->entry->transferFromXML($this->v2entryText_channel); + $this->assertTrue(is_array($this->entry->extensionAttributes)); + $this->assertTrue(count($this->entry->extensionAttributes) == 0); + } + + public function testEmptySubscriptionEntryToAndFromStringShouldMatch() { + $entryXml = $this->entry->saveXML(); + $newSubscriptionEntry = new Zend_Gdata_YouTube_SubscriptionEntry(); + $newSubscriptionEntry->transferFromXML($entryXml); + $newSubscriptionEntryXml = $newSubscriptionEntry->saveXML(); + $this->assertTrue($entryXml == $newSubscriptionEntryXml); + } + + public function testEmptySubscriptionEntryToAndFromStringShouldMatchV2() { + $this->entry->transferFromXML($this->v2entryText_channel); + $entryXml = $this->entry->saveXML(); + $newSubscriptionEntry = new Zend_Gdata_YouTube_SubscriptionEntry(); + $newSubscriptionEntry->transferFromXML($entryXml); + $newSubscriptionEntry->setMajorProtocolVersion(2); + $newSubscriptionEntryXml = $newSubscriptionEntry->saveXML(); + $this->assertTrue($entryXml == $newSubscriptionEntryXml); + } + + public function testGetFeedLinkReturnsAllStoredEntriesWhenUsedWithNoParameters() { + // Prepare test data + $entry1 = new Zend_Gdata_Extension_FeedLink(); + $entry1->rel = "first"; + $entry1->href= "foo"; + $entry2 = new Zend_Gdata_Extension_FeedLink(); + $entry2->rel = "second"; + $entry2->href= "bar"; + $data = array($entry1, $entry2); + + // Load test data and run test + $this->entry->feedLink = $data; + $this->assertEquals(2, count($this->entry->feedLink)); + } + + public function testGetFeedLinkCanReturnEntriesByRelValue() { + // Prepare test data + $entry1 = new Zend_Gdata_Extension_FeedLink(); + $entry1->rel = "first"; + $entry1->href= "foo"; + $entry2 = new Zend_Gdata_Extension_FeedLink(); + $entry2->rel = "second"; + $entry2->href= "bar"; + $data = array($entry1, $entry2); + + // Load test data and run test + $this->entry->feedLink = $data; + $this->assertEquals($entry1, $this->entry->getFeedLink('first')); + $this->assertEquals($entry2, $this->entry->getFeedLink('second')); + } + + public function testSamplePropertiesAreCorrect () { + $this->entry->transferFromXML($this->entryText); + $this->verifyAllSamplePropertiesAreCorrect($this->entry); + } + + public function testSamplePropertiesAreCorrectV2 () { + $this->entry->transferFromXML($this->v2entryText_channel); + $this->entry->setMajorProtocolVersion(2); + $this->verifyAllSamplePropertiesAreCorrectV2($this->entry); + } + + public function testConvertSubscriptionEntryToAndFromString() { + $this->entry->transferFromXML($this->entryText); + $entryXml = $this->entry->saveXML(); + $newSubscriptionEntry = new Zend_Gdata_YouTube_SubscriptionEntry(); + $newSubscriptionEntry->transferFromXML($entryXml); + $this->verifyAllSamplePropertiesAreCorrect($newSubscriptionEntry); + $newSubscriptionEntryXml = $newSubscriptionEntry->saveXML(); + $this->assertEquals($entryXml, $newSubscriptionEntryXml); + } + + public function testExceptionThrownInChannelSubscription() { + $this->entry->transferFromXML($this->entryText); + $exceptionCaught = false; + try { + $this->entry->getCountHint(); + } catch (Zend_Gdata_App_VersionException $e) { + $exceptionCaught = true; + } + $this->assertTrue($exceptionCaught, 'Expected a VersionException on ' . + 'calling getCountHint() on a v1 subscription entry.'); + } + + public function testChannelSubscriptionFunctionalityV2() { + $this->entry->transferFromXML($this->v2entryText_channel); + $this->assertEquals('androiddevelopers', + $this->entry->getUsername()->text); + $categories = $this->entry->getCategory(); + foreach($categories as $category) { + if ($category->getScheme() == + 'http://gdata.youtube.com/schemas/2007/subscriptiontypes.cat') { + $this->assertEquals('channel', $category->getTerm()); + } + } + } + + public function testPlaylistSubscriptionFunctionalityV2() { + $this->entry->transferFromXML($this->v2entryText_playlist); + $this->entry->setMajorProtocolVersion(2); + $this->assertEquals('From Google Engineers', + $this->entry->getPlaylistTitle()->text); + $this->assertEquals('4AE5C0D23C2EB82D', + $this->entry->getPlaylistId()->text); + $categories = $this->entry->getCategory(); + foreach($categories as $category) { + if ($category->getScheme() == + 'http://gdata.youtube.com/schemas/2007/subscriptiontypes.cat') { + $this->assertEquals('playlist', $category->getTerm()); + } + } + } + + public function testFavoritesSubscriptionFunctionalityV2() { + $this->entry->transferFromXML($this->v2entryText_favorites); + $categories = $this->entry->getCategory(); + foreach($categories as $category) { + if ($category->getScheme() == + 'http://gdata.youtube.com/schemas/2007/subscriptiontypes.cat') { + $this->assertEquals('favorites', $category->getTerm()); + } + } + } + + public function testQuerySubscriptionFunctionalityV2() { + $this->entry->transferFromXML($this->v2entryText_query); + $categories = $this->entry->getCategory(); + foreach($categories as $category) { + if ($category->getScheme() == + 'http://gdata.youtube.com/schemas/2007/subscriptiontypes.cat') { + $this->assertEquals('query', $category->getTerm()); + } + } + } + +} diff --git a/zend/tests/Zend/Gdata/YouTube/SubscriptionFeedTest.php b/zend/tests/Zend/Gdata/YouTube/SubscriptionFeedTest.php new file mode 100644 index 0000000..c357721 --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/SubscriptionFeedTest.php @@ -0,0 +1,178 @@ +feedText = file_get_contents( + 'Zend/Gdata/YouTube/_files/SubscriptionFeedDataSample1.xml', + true); + $this->V2feedText = file_get_contents( + 'Zend/Gdata/YouTube/_files/SubscriptionFeedDataSampleV2.xml', + true); + $this->feed = new Zend_Gdata_YouTube_SubscriptionFeed(); + } + + private function verifyAllSamplePropertiesAreCorrect ($subscriptionFeed) { + $this->assertEquals('http://gdata.youtube.com/feeds/users/testuser/subscriptions', + $subscriptionFeed->id->text); + $this->assertEquals('2007-09-20T22:12:45.193Z', $subscriptionFeed->updated->text); + $this->assertEquals('http://schemas.google.com/g/2005#kind', $subscriptionFeed->category[0]->scheme); + $this->assertEquals('http://gdata.youtube.com/schemas/2007#subscription', $subscriptionFeed->category[0]->term); + $this->assertEquals('http://www.youtube.com/img/pic_youtubelogo_123x63.gif', $subscriptionFeed->logo->text); + $this->assertEquals('text', $subscriptionFeed->title->type); + $this->assertEquals('testuser\'s Subscriptions', $subscriptionFeed->title->text);; + $this->assertEquals('self', $subscriptionFeed->getLink('self')->rel); + $this->assertEquals('application/atom+xml', $subscriptionFeed->getLink('self')->type); + $this->assertEquals('http://gdata.youtube.com/feeds/users/testuser/subscriptions?start-index=1&max-results=25', $subscriptionFeed->getLink('self')->href); + $this->assertEquals('testuser', $subscriptionFeed->author[0]->name->text); + $this->assertEquals('http://gdata.youtube.com/feeds/users/testuser', $subscriptionFeed->author[0]->uri->text); + $this->assertEquals(3, $subscriptionFeed->totalResults->text); + } + + private function verifyAllSamplePropertiesAreCorrectV2 ($subscriptionFeed) { + $this->assertEquals('tag:youtube.com,2008:user:zfgdata:subscriptions', + $subscriptionFeed->id->text); + $this->assertEquals('2007-09-20T21:01:13.000-07:00', + $subscriptionFeed->updated->text); + $this->assertEquals('http://schemas.google.com/g/2005#kind', + $subscriptionFeed->category[0]->scheme); + $this->assertEquals( + 'http://gdata.youtube.com/schemas/2007#subscription', + $subscriptionFeed->category[0]->term); + $this->assertEquals( + 'http://www.youtube.com/img/pic_youtubelogo_123x63.gif', + $subscriptionFeed->logo->text); + $this->assertEquals('Subscriptions of zfgdata', + $subscriptionFeed->title->text);; + $this->assertEquals('zfgdata', + $subscriptionFeed->author[0]->name->text); + $this->assertEquals('http://gdata.youtube.com/feeds/api/users/zfgdata', + $subscriptionFeed->author[0]->uri->text); + // fail because of opensearch issue TODO jhartman -> fix once trevor commits his fix + //$this->assertEquals(3, $subscriptionFeed->totalResults->text); + + $this->assertEquals('self', $subscriptionFeed->getLink('self')->rel); + $this->assertEquals('application/atom+xml', + $subscriptionFeed->getLink('self')->type); + $this->assertEquals( + 'http://gdata.youtube.com/feeds/api/users/zfgdata/subscriptions' . + '?start-index=1&max-results=25&v=2', + $subscriptionFeed->getLink('self')->href); + $this->assertEquals('related', $subscriptionFeed->getLink('related')->rel); + $this->assertEquals('application/atom+xml', + $subscriptionFeed->getLink('related')->type); + $this->assertEquals( + 'http://gdata.youtube.com/feeds/api/users/zfgdata?v=2', + $subscriptionFeed->getLink('related')->href); + $this->assertEquals('alternate', $subscriptionFeed->getLink('alternate')->rel); + $this->assertEquals('text/html', + $subscriptionFeed->getLink('alternate')->type); + $this->assertEquals( + 'http://www.youtube.com/profile_subscriptions?user=zfgdata', + $subscriptionFeed->getLink('alternate')->href); + $this->assertEquals('service', $subscriptionFeed->getLink('service')->rel); + $this->assertEquals('application/atomsvc+xml', + $subscriptionFeed->getLink('service')->type); + $this->assertEquals( + 'http://gdata.youtube.com/feeds/api/users/zfgdata/subscriptions?' . + 'alt=atom-service&v=2', + $subscriptionFeed->getLink('service')->href); + + } + + public function testEmptyEntryShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->feed->extensionElements)); + $this->assertEquals(0, count($this->feed->extensionElements)); + } + + public function testEmptyEntryShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->feed->extensionAttributes)); + $this->assertEquals(0, count($this->feed->extensionAttributes)); + } + + public function testSampleEntryShouldHaveNoExtensionElements() { + $this->feed->transferFromXML($this->feedText); + $this->assertTrue(is_array($this->feed->extensionElements)); + $this->assertEquals(0, count($this->feed->extensionElements)); + } + + public function testSampleEntryShouldHaveNoExtensionAttributes() { + $this->feed->transferFromXML($this->feedText); + $this->assertTrue(is_array($this->feed->extensionAttributes)); + $this->assertEquals(0, count($this->feed->extensionAttributes)); + } + + public function testEmptySubscriptionFeedToAndFromStringShouldMatch() { + $feedXml = $this->feed->saveXML(); + $newSubscriptionFeed = new Zend_Gdata_YouTube_SubscriptionFeed(); + $newSubscriptionFeed->transferFromXML($feedXml); + $newSubscriptionFeedXml = $newSubscriptionFeed->saveXML(); + $this->assertTrue($feedXml == $newSubscriptionFeedXml); + } + + public function testSamplePropertiesAreCorrect () { + $this->feed->transferFromXML($this->feedText); + $this->verifyAllSamplePropertiesAreCorrect($this->feed); + } + + public function testSamplePropertiesAreCorrectV2 () { + $this->feed->transferFromXML($this->V2feedText); + $this->verifyAllSamplePropertiesAreCorrectV2($this->feed); + } + + public function testConvertSubscriptionFeedToAndFromString() { + $this->feed->transferFromXML($this->feedText); + $feedXml = $this->feed->saveXML(); + $newSubscriptionFeed = new Zend_Gdata_YouTube_SubscriptionFeed(); + $newSubscriptionFeed->transferFromXML($feedXml); + $this->verifyAllSamplePropertiesAreCorrect($newSubscriptionFeed); + $newSubscriptionFeedXml = $newSubscriptionFeed->saveXML(); + $this->assertEquals($feedXml, $newSubscriptionFeedXml); + } + + public function testConvertSubscriptionFeedToAndFromStringV2() { + $this->feed->transferFromXML($this->V2feedText); + $this->feed->setMajorProtocolVersion(2); + $feedXml = $this->feed->saveXML(); + $newSubscriptionFeed = new Zend_Gdata_YouTube_SubscriptionFeed(); + $newSubscriptionFeed->transferFromXML($feedXml); + $newSubscriptionFeed->setMajorProtocolVersion(2); + $this->verifyAllSamplePropertiesAreCorrectV2($newSubscriptionFeed); + $newSubscriptionFeedXml = $newSubscriptionFeed->saveXML(); + $this->assertEquals($feedXml, $newSubscriptionFeedXml); + } + +} diff --git a/zend/tests/Zend/Gdata/YouTube/UserProfileEntryTest.php b/zend/tests/Zend/Gdata/YouTube/UserProfileEntryTest.php new file mode 100644 index 0000000..645b125 --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/UserProfileEntryTest.php @@ -0,0 +1,253 @@ +entryText = file_get_contents( + 'Zend/Gdata/YouTube/_files/UserProfileEntryDataSample1.xml', + true); + $this->V2entryText = file_get_contents( + 'Zend/Gdata/YouTube/_files/UserProfileEntryDataSampleV2.xml', + true); + $this->entry = new Zend_Gdata_YouTube_UserProfileEntry(); + } + + private function verifyAllSamplePropertiesAreCorrect ($userProfileEntry) { + $this->assertEquals('http://gdata.youtube.com/feeds/users/darcy', + $userProfileEntry->id->text); + $this->assertEquals('2007-08-13T12:37:03.000-07:00', $userProfileEntry->updated->text); + $this->assertEquals('http://schemas.google.com/g/2005#kind', $userProfileEntry->category[0]->scheme); + $this->assertEquals('http://gdata.youtube.com/schemas/2007#userProfile', $userProfileEntry->category[0]->term); + $this->assertEquals('text', $userProfileEntry->title->type); + $this->assertEquals('Darcy', $userProfileEntry->title->text);; + $this->assertEquals('self', $userProfileEntry->getLink('self')->rel); + $this->assertEquals('application/atom+xml', $userProfileEntry->getLink('self')->type); + $this->assertEquals('http://gdata.youtube.com/feeds/users/darcy', $userProfileEntry->getLink('self')->href); + $this->assertEquals('Fitzwilliam Darcy', $userProfileEntry->author[0]->name->text); + $this->assertEquals(32, $userProfileEntry->age->text); + $this->assertEquals('darcy', $userProfileEntry->username->text); + $this->assertEquals('A person of great interest', $userProfileEntry->description->text); + $this->assertEquals('Pride and Prejudice', $userProfileEntry->books->text); + $this->assertEquals('Self employed', $userProfileEntry->company->text); + $this->assertEquals('Reading, arguing with Liz', $userProfileEntry->hobbies->text); + $this->assertEquals('Steventon', $userProfileEntry->hometown->text); + $this->assertEquals('Longbourn in Hertfordshire, Pemberley in Derbyshire', $userProfileEntry->location->text); + $this->assertEquals('Pride and Prejudice, 2005', $userProfileEntry->movies->text); + $this->assertEquals('Air Con Varizzioni, The Pleasure of the Town', $userProfileEntry->music->text); + $this->assertEquals('Gentleman', $userProfileEntry->occupation->text); + $this->assertEquals('Home schooling', $userProfileEntry->school->text); + $this->assertEquals('m', $userProfileEntry->gender->text); + $this->assertEquals('taken', $userProfileEntry->relationship->text); + $this->assertEquals('http://gdata.youtube.com/feeds/users/darcy', $userProfileEntry->author[0]->uri->text); + $this->assertEquals('http://gdata.youtube.com/feeds/users/darcy/favorites', $userProfileEntry->feedLink[0]->href); + $this->assertEquals('http://gdata.youtube.com/schemas/2007#user.favorites', $userProfileEntry->feedLink[0]->rel); + $this->assertEquals('http://gdata.youtube.com/feeds/users/darcy/contacts', $userProfileEntry->feedLink[1]->href); + $this->assertEquals('http://gdata.youtube.com/schemas/2007#user.contacts', $userProfileEntry->feedLink[1]->rel); + $this->assertEquals('http://gdata.youtube.com/feeds/users/darcy/inbox', $userProfileEntry->feedLink[2]->href); + $this->assertEquals('http://gdata.youtube.com/schemas/2007#user.inbox', $userProfileEntry->feedLink[2]->rel); + $this->assertEquals('http://gdata.youtube.com/feeds/users/darcy/playlists', $userProfileEntry->feedLink[3]->href); + $this->assertEquals('http://gdata.youtube.com/schemas/2007#user.playlists', $userProfileEntry->feedLink[3]->rel); + $this->assertEquals('http://gdata.youtube.com/feeds/users/darcy/subscriptions', $userProfileEntry->feedLink[4]->href); + $this->assertEquals('http://gdata.youtube.com/schemas/2007#user.subscriptions', $userProfileEntry->feedLink[4]->rel); + $this->assertEquals('http://gdata.youtube.com/feeds/users/darcy/uploads', $userProfileEntry->feedLink[5]->href); + $this->assertEquals('http://gdata.youtube.com/schemas/2007#user.uploads', $userProfileEntry->feedLink[5]->rel); + } + + private function verifyAllSamplePropertiesAreCorrectV2 ($userProfileEntry) { + $this->assertEquals('tag:youtube.com,2008:user:zfgdata', + $userProfileEntry->id->text); + $this->assertEquals('2008-12-15T13:30:56.000-08:00', + $userProfileEntry->updated->text); + $this->assertEquals( + 'http://gdata.youtube.com/schemas/2007/channeltypes.cat', + $userProfileEntry->category[0]->scheme); + $this->assertEquals( + 'Standard', + $userProfileEntry->category[0]->term); + $this->assertEquals('zfgdata Channel', + $userProfileEntry->title->text);; + $this->assertEquals('self', $userProfileEntry->getLink('self')->rel); + $this->assertEquals("I'm a lonely test account, with little to do " . + "but sit\naround and wait for people to use me. I get bored in " . + "between\nreleases and often sleep to pass the time. Please use " . + "me more\noften, as I love to show off my talent in breaking " . + "your\ncode.", $userProfileEntry->getAboutMe()->text); + $this->assertEquals('88', + $userProfileEntry->getStatistics()->getViewCount()); + $thumbnail = $userProfileEntry->getThumbnail(); + $this->assertTrue( + $thumbnail instanceof Zend_Gdata_Media_Extension_MediaThumbnail); + $this->assertTrue($thumbnail->getUrl() != null); + $this->assertEquals('TestAccount', + $userProfileEntry->getLastName()->text); + $this->assertEquals('Lonely', + $userProfileEntry->getFirstName()->text); + } + + public function testEmptyEntryShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->entry->extensionElements)); + $this->assertEquals(0, count($this->entry->extensionElements)); + } + + public function testEmptyEntryShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->entry->extensionAttributes)); + $this->assertEquals(0, count($this->entry->extensionAttributes)); + } + + public function testSampleEntryShouldHaveNoExtensionElements() { + $this->entry->transferFromXML($this->entryText); + $this->assertTrue(is_array($this->entry->extensionElements)); + $this->assertEquals(0, count($this->entry->extensionElements)); + } + + public function testSampleEntryShouldHaveNoExtensionAttributes() { + $this->entry->transferFromXML($this->entryText); + $this->assertTrue(is_array($this->entry->extensionAttributes)); + $this->assertEquals(0, count($this->entry->extensionAttributes)); + } + + public function testSampleEntryShouldHaveNoExtensionElementsV2() { + $this->entry->transferFromXML($this->V2entryText); + $this->assertTrue(is_array($this->entry->extensionElements)); + $this->assertEquals(0, count($this->entry->extensionElements)); + } + + public function testSampleEntryShouldHaveNoExtensionAttributesV2() { + $this->entry->transferFromXML($this->V2entryText); + $this->assertTrue(is_array($this->entry->extensionAttributes)); + $this->assertEquals(0, count($this->entry->extensionAttributes)); + } + + public function testEmptyUserProfileEntryToAndFromStringShouldMatch() { + $entryXml = $this->entry->saveXML(); + $newUserProfileEntry = new Zend_Gdata_YouTube_UserProfileEntry(); + $newUserProfileEntry->transferFromXML($entryXml); + $newUserProfileEntryXml = $newUserProfileEntry->saveXML(); + $this->assertTrue($entryXml == $newUserProfileEntryXml); + } + + public function testEmptyUserProfileEntryToAndFromStringShouldMatchV2() { + $this->entry->setMajorProtocolVersion(2); + $entryXml = $this->entry->saveXML(); + $newUserProfileEntry = new Zend_Gdata_YouTube_UserProfileEntry(); + $newUserProfileEntry->setMajorProtocolVersion(2); + $newUserProfileEntry->transferFromXML($entryXml); + $newUserProfileEntryXml = $newUserProfileEntry->saveXML(); + $this->assertTrue($entryXml == $newUserProfileEntryXml); + } + + public function testGetFeedLinkReturnsAllStoredEntriesWhenUsedWithNoParameters() { + // Prepare test data + $entry1 = new Zend_Gdata_Extension_FeedLink(); + $entry1->rel = "first"; + $entry1->href= "foo"; + $entry2 = new Zend_Gdata_Extension_FeedLink(); + $entry2->rel = "second"; + $entry2->href= "bar"; + $data = array($entry1, $entry2); + + // Load test data and run test + $this->entry->feedLink = $data; + $this->assertEquals(2, count($this->entry->feedLink)); + } + + public function testGetFeedLinkCanReturnEntriesByRelValue() { + // Prepare test data + $entry1 = new Zend_Gdata_Extension_FeedLink(); + $entry1->rel = "first"; + $entry1->href= "foo"; + $entry2 = new Zend_Gdata_Extension_FeedLink(); + $entry2->rel = "second"; + $entry2->href= "bar"; + $data = array($entry1, $entry2); + + // Load test data and run test + $this->entry->feedLink = $data; + $this->assertEquals($entry1, $this->entry->getFeedLink('first')); + $this->assertEquals($entry2, $this->entry->getFeedLink('second')); + } + + public function testSamplePropertiesAreCorrect () { + $this->entry->transferFromXML($this->entryText); + $this->verifyAllSamplePropertiesAreCorrect($this->entry); + } + + public function testSamplePropertiesAreCorrectV2 () { + $this->entry->transferFromXML($this->V2entryText); + $this->entry->setMajorProtocolVersion(2); + $this->verifyAllSamplePropertiesAreCorrectV2($this->entry); + } + + public function testConvertUserProfileEntryToAndFromString() { + $this->entry->transferFromXML($this->entryText); + $entryXml = $this->entry->saveXML(); + $newUserProfileEntry = new Zend_Gdata_YouTube_UserProfileEntry(); + $newUserProfileEntry->transferFromXML($entryXml); + $this->verifyAllSamplePropertiesAreCorrect($newUserProfileEntry); + $newUserProfileEntryXml = $newUserProfileEntry->saveXML(); + $this->assertEquals($entryXml, $newUserProfileEntryXml); + } + + public function testConvertUserProfileEntryToAndFromStringV2() { + $this->entry->transferFromXML($this->V2entryText); + $entryXml = $this->entry->saveXML(); + $newUserProfileEntry = new Zend_Gdata_YouTube_UserProfileEntry(); + $newUserProfileEntry->setMajorProtocolVersion(2); + $newUserProfileEntry->transferFromXML($entryXml); + $this->verifyAllSamplePropertiesAreCorrectV2($newUserProfileEntry); + $newUserProfileEntryXml = $newUserProfileEntry->saveXML(); + $this->assertEquals($entryXml, $newUserProfileEntryXml); + } + + public function testYTStatisticsInUserProfileEntryV2() { + $this->entry->transferFromXML($this->V2entryText); + $this->entry->setMajorProtocolVersion(2); + $statistics = $this->entry->getStatistics(); + $this->assertEquals(14, $statistics->getVideoWatchCount()); + $this->assertEquals(88, $statistics->getViewCount()); + $this->assertEquals(12, $statistics->getSubscriberCount()); + $this->assertEquals('2008-12-15T14:56:57.000-08:00', + $statistics->getLastWebAccess()); + + // test __toString() + $this->assertEquals('View Count=88 VideoWatchCount=14 ' . + 'SubscriberCount=12 LastWebAccess=2008-12-15T14:56:57.000-08:00 ' . + 'FavoriteCount=', + sprintf("%s", $statistics)); + + } + +} diff --git a/zend/tests/Zend/Gdata/YouTube/VideoEntryTest.php b/zend/tests/Zend/Gdata/YouTube/VideoEntryTest.php new file mode 100644 index 0000000..132bc29 --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/VideoEntryTest.php @@ -0,0 +1,767 @@ +entryText = file_get_contents( + 'Zend/Gdata/YouTube/_files/VideoEntryDataSample1.xml', + true); + $this->privateEntryText = file_get_contents( + 'Zend/Gdata/YouTube/_files/VideoEntryDataSamplePrivate.xml', + true); + $this->v2EntryText = file_get_contents( + 'Zend/Gdata/YouTube/_files/VideoEntryDataSampleV2.xml', + true); + $this->entry = new Zend_Gdata_YouTube_VideoEntry(); + } + + private function createRandomString() { + $randomString = ''; + for ($x = 0; $x < 10; $x++) { + $randomCharacter = chr(rand(97,122)); + $randomString .= $randomCharacter; + } + return $randomString; + } + + private function verifyAllSamplePropertiesAreCorrect ($videoEntry) { + $this->assertEquals('http://gdata.youtube.com/feeds/videos/UMFI1hdm96E', + $videoEntry->id->text); + $this->assertEquals('UMFI1hdm96E', $videoEntry->getVideoId()); + $this->assertEquals('2007-01-07T01:50:15.000Z', $videoEntry->updated->text); + $this->assertEquals('http://schemas.google.com/g/2005#kind', $videoEntry->category[0]->scheme); + $this->assertEquals('http://gdata.youtube.com/schemas/2007#video', $videoEntry->category[0]->term); + $this->assertEquals('http://gdata.youtube.com/schemas/2007/keywords.cat', $videoEntry->category[1]->scheme); + $this->assertEquals('barkley', $videoEntry->category[1]->term); + $this->assertEquals('http://gdata.youtube.com/schemas/2007/keywords.cat', $videoEntry->category[2]->scheme); + $this->assertEquals('singing', $videoEntry->category[2]->term); + $this->assertEquals('http://gdata.youtube.com/schemas/2007/keywords.cat', $videoEntry->category[3]->scheme); + $this->assertEquals('acoustic', $videoEntry->category[3]->term); + $this->assertEquals('http://gdata.youtube.com/schemas/2007/keywords.cat', $videoEntry->category[4]->scheme); + $this->assertEquals('cover', $videoEntry->category[4]->term); + $this->assertEquals('http://gdata.youtube.com/schemas/2007/categories.cat', $videoEntry->category[5]->scheme); + $this->assertEquals('Music', $videoEntry->category[5]->term); + $this->assertEquals('Music', $videoEntry->category[5]->label); + $this->assertEquals('http://gdata.youtube.com/schemas/2007/keywords.cat', $videoEntry->category[6]->scheme); + $this->assertEquals('gnarls', $videoEntry->category[6]->term); + $this->assertEquals('http://gdata.youtube.com/schemas/2007/keywords.cat', $videoEntry->category[7]->scheme); + $this->assertEquals('music', $videoEntry->category[7]->term); + + $this->assertEquals('text', $videoEntry->title->type); + $this->assertEquals('"Crazy (Gnarles Barkley)" - Acoustic Cover', $videoEntry->title->text);; + $this->assertEquals('html', $videoEntry->content->type); + $this->assertEquals('self', $videoEntry->getLink('self')->rel); + $this->assertEquals('application/atom+xml', $videoEntry->getLink('self')->type); + $this->assertEquals('http://gdata.youtube.com/feeds/videos/UMFI1hdm96E', $videoEntry->getLink('self')->href); + $this->assertEquals('text/html', $videoEntry->getLink('alternate')->type); + $this->assertEquals('http://www.youtube.com/watch?v=UMFI1hdm96E', $videoEntry->getLink('alternate')->href); + $this->assertEquals('application/atom+xml', $videoEntry->getLink('http://gdata.youtube.com/schemas/2007#video.responses')->type); + $this->assertEquals('http://gdata.youtube.com/feeds/videos/UMFI1hdm96E/responses', $videoEntry->getLink('http://gdata.youtube.com/schemas/2007#video.responses')->href); + $this->assertEquals('application/atom+xml', $videoEntry->getLink('http://gdata.youtube.com/schemas/2007#video.related')->type); + $this->assertEquals('http://gdata.youtube.com/feeds/videos/UMFI1hdm96E/related', $videoEntry->getLink('http://gdata.youtube.com/schemas/2007#video.related')->href); + $this->assertEquals('davidchoimusic', $videoEntry->author[0]->name->text); + $this->assertEquals('http://gdata.youtube.com/feeds/users/davidchoimusic', $videoEntry->author[0]->uri->text); + $mediaGroup = $videoEntry->mediaGroup; + + $this->assertEquals('plain', $mediaGroup->title->type); + $this->assertEquals('"Crazy (Gnarles Barkley)" - Acoustic Cover', $mediaGroup->title->text); + $this->assertEquals('plain', $mediaGroup->description->type); + $this->assertEquals('Gnarles Barkley acoustic cover http://www.myspace.com/davidchoimusic', $mediaGroup->description->text); + $this->assertEquals('music, singing, gnarls, barkley, acoustic, cover', $mediaGroup->keywords->text); + $this->assertEquals(255, $mediaGroup->duration->seconds); + $this->assertEquals('Music', $mediaGroup->category[0]->label); + $this->assertEquals('http://gdata.youtube.com/schemas/2007/categories.cat', $mediaGroup->category[0]->scheme); + $this->assertEquals('http://gdata.youtube.com/schemas/2007/developertags.cat', $mediaGroup->category[1]->scheme); + $this->assertEquals('DeveloperTag1', $mediaGroup->category[1]->text); + $this->assertEquals('video', $mediaGroup->content[0]->medium); + $this->assertEquals('http://www.youtube.com/v/UMFI1hdm96E', $mediaGroup->content[0]->url); + $this->assertEquals('application/x-shockwave-flash', $mediaGroup->content[0]->type); + $this->assertEquals('true', $mediaGroup->content[0]->isDefault); + $this->assertEquals('full', $mediaGroup->content[0]->expression); + $this->assertEquals(255, $mediaGroup->content[0]->duration); + $this->assertEquals(5, $mediaGroup->content[0]->format); + $this->assertEquals('http://www.youtube.com/watch?v=UMFI1hdm96E', $mediaGroup->player[0]->url); + + $this->assertEquals('http://img.youtube.com/vi/UMFI1hdm96E/2.jpg', $mediaGroup->thumbnail[0]->url); + $this->assertEquals(97, $mediaGroup->thumbnail[0]->height); + $this->assertEquals(130, $mediaGroup->thumbnail[0]->width); + $this->assertEquals('00:02:07.500', $mediaGroup->thumbnail[0]->time); + $this->assertEquals('http://img.youtube.com/vi/UMFI1hdm96E/1.jpg', $mediaGroup->thumbnail[1]->url); + $this->assertEquals(97, $mediaGroup->thumbnail[1]->height); + $this->assertEquals(130, $mediaGroup->thumbnail[1]->width); + $this->assertEquals('00:01:03.750', $mediaGroup->thumbnail[1]->time); + $this->assertEquals('http://img.youtube.com/vi/UMFI1hdm96E/3.jpg', $mediaGroup->thumbnail[2]->url); + $this->assertEquals(97, $mediaGroup->thumbnail[2]->height); + $this->assertEquals(130, $mediaGroup->thumbnail[2]->width); + $this->assertEquals('00:03:11.250', $mediaGroup->thumbnail[2]->time); + $this->assertEquals('http://img.youtube.com/vi/UMFI1hdm96E/0.jpg', $mediaGroup->thumbnail[3]->url); + $this->assertEquals(240, $mediaGroup->thumbnail[3]->height); + $this->assertEquals(320, $mediaGroup->thumbnail[3]->width); + $this->assertEquals('00:02:07.500', $mediaGroup->thumbnail[3]->time); + $this->assertNull($mediaGroup->private); + + $this->assertEquals(113321, $videoEntry->statistics->viewCount); + $this->assertEquals(1, $videoEntry->rating->min); + $this->assertEquals(5, $videoEntry->rating->max); + $this->assertEquals(1005, $videoEntry->rating->numRaters); + $this->assertEquals(4.77, $videoEntry->rating->average); + $this->assertEquals('http://gdata.youtube.com/feeds/videos/UMFI1hdm96E/comments', $videoEntry->comments->feedLink->href); + + $this->assertEquals('37.398529052734375 -122.0635986328125', $videoEntry->where->point->pos->text); + $this->assertEquals('2008-09-25', $videoEntry->getVideoRecorded()); + } + + private function verifyAllPrivateSamplePropertiesAreCorrect ($videoEntry) { + $this->assertEquals('http://gdata.youtube.com/feeds/videos/UMFI1hdm96E', + $videoEntry->id->text); + $this->assertEquals('UMFI1hdm96E', $videoEntry->getVideoId()); + $this->assertEquals('2007-01-07T01:50:15.000Z', $videoEntry->updated->text); + $this->assertEquals('http://schemas.google.com/g/2005#kind', $videoEntry->category[0]->scheme); + $this->assertEquals('http://gdata.youtube.com/schemas/2007#video', $videoEntry->category[0]->term); + $this->assertEquals('http://gdata.youtube.com/schemas/2007/keywords.cat', $videoEntry->category[1]->scheme); + $this->assertEquals('barkley', $videoEntry->category[1]->term); + $this->assertEquals('http://gdata.youtube.com/schemas/2007/keywords.cat', $videoEntry->category[2]->scheme); + $this->assertEquals('singing', $videoEntry->category[2]->term); + $this->assertEquals('http://gdata.youtube.com/schemas/2007/keywords.cat', $videoEntry->category[3]->scheme); + $this->assertEquals('acoustic', $videoEntry->category[3]->term); + $this->assertEquals('http://gdata.youtube.com/schemas/2007/keywords.cat', $videoEntry->category[4]->scheme); + $this->assertEquals('cover', $videoEntry->category[4]->term); + $this->assertEquals('http://gdata.youtube.com/schemas/2007/categories.cat', $videoEntry->category[5]->scheme); + $this->assertEquals('Music', $videoEntry->category[5]->term); + $this->assertEquals('Music', $videoEntry->category[5]->label); + $this->assertEquals('http://gdata.youtube.com/schemas/2007/keywords.cat', $videoEntry->category[6]->scheme); + $this->assertEquals('gnarls', $videoEntry->category[6]->term); + $this->assertEquals('http://gdata.youtube.com/schemas/2007/keywords.cat', $videoEntry->category[7]->scheme); + $this->assertEquals('music', $videoEntry->category[7]->term); + + $this->assertEquals('text', $videoEntry->title->type); + $this->assertEquals('"Crazy (Gnarles Barkley)" - Acoustic Cover', $videoEntry->title->text);; + $this->assertEquals('html', $videoEntry->content->type); + $this->assertEquals('self', $videoEntry->getLink('self')->rel); + $this->assertEquals('application/atom+xml', $videoEntry->getLink('self')->type); + $this->assertEquals('http://gdata.youtube.com/feeds/videos/UMFI1hdm96E', $videoEntry->getLink('self')->href); + $this->assertEquals('text/html', $videoEntry->getLink('alternate')->type); + $this->assertEquals('http://www.youtube.com/watch?v=UMFI1hdm96E', $videoEntry->getLink('alternate')->href); + $this->assertEquals('application/atom+xml', $videoEntry->getLink('http://gdata.youtube.com/schemas/2007#video.responses')->type); + $this->assertEquals('http://gdata.youtube.com/feeds/videos/UMFI1hdm96E/responses', $videoEntry->getLink('http://gdata.youtube.com/schemas/2007#video.responses')->href); + $this->assertEquals('application/atom+xml', $videoEntry->getLink('http://gdata.youtube.com/schemas/2007#video.related')->type); + $this->assertEquals('http://gdata.youtube.com/feeds/videos/UMFI1hdm96E/related', $videoEntry->getLink('http://gdata.youtube.com/schemas/2007#video.related')->href); + $this->assertEquals('davidchoimusic', $videoEntry->author[0]->name->text); + $this->assertEquals('http://gdata.youtube.com/feeds/users/davidchoimusic', $videoEntry->author[0]->uri->text); + $mediaGroup = $videoEntry->mediaGroup; + + $this->assertEquals('plain', $mediaGroup->title->type); + $this->assertEquals('"Crazy (Gnarles Barkley)" - Acoustic Cover', $mediaGroup->title->text); + $this->assertEquals('plain', $mediaGroup->description->type); + $this->assertEquals('Gnarles Barkley acoustic cover http://www.myspace.com/davidchoimusic', $mediaGroup->description->text); + $this->assertEquals('music, singing, gnarls, barkley, acoustic, cover', $mediaGroup->keywords->text); + $this->assertEquals(255, $mediaGroup->duration->seconds); + + $this->assertEquals('Music', $mediaGroup->category[0]->label); + $this->assertEquals('http://gdata.youtube.com/schemas/2007/categories.cat', $mediaGroup->category[0]->scheme); + $this->assertEquals('http://gdata.youtube.com/schemas/2007/developertags.cat', $mediaGroup->category[1]->scheme); + $this->assertEquals('DeveloperTag1', $mediaGroup->category[1]->text); + $this->assertEquals('video', $mediaGroup->content[0]->medium); + $this->assertEquals('http://www.youtube.com/v/UMFI1hdm96E', $mediaGroup->content[0]->url); + $this->assertEquals('application/x-shockwave-flash', $mediaGroup->content[0]->type); + $this->assertEquals('true', $mediaGroup->content[0]->isDefault); + $this->assertEquals('full', $mediaGroup->content[0]->expression); + $this->assertEquals(255, $mediaGroup->content[0]->duration); + $this->assertEquals(5, $mediaGroup->content[0]->format); + $this->assertEquals('http://www.youtube.com/watch?v=UMFI1hdm96E', $mediaGroup->player[0]->url); + + $this->assertEquals('http://img.youtube.com/vi/UMFI1hdm96E/2.jpg', $mediaGroup->thumbnail[0]->url); + $this->assertEquals(97, $mediaGroup->thumbnail[0]->height); + $this->assertEquals(130, $mediaGroup->thumbnail[0]->width); + $this->assertEquals('00:02:07.500', $mediaGroup->thumbnail[0]->time); + $this->assertEquals('http://img.youtube.com/vi/UMFI1hdm96E/1.jpg', $mediaGroup->thumbnail[1]->url); + $this->assertEquals(97, $mediaGroup->thumbnail[1]->height); + $this->assertEquals(130, $mediaGroup->thumbnail[1]->width); + $this->assertEquals('00:01:03.750', $mediaGroup->thumbnail[1]->time); + $this->assertEquals('http://img.youtube.com/vi/UMFI1hdm96E/3.jpg', $mediaGroup->thumbnail[2]->url); + $this->assertEquals(97, $mediaGroup->thumbnail[2]->height); + $this->assertEquals(130, $mediaGroup->thumbnail[2]->width); + $this->assertEquals('00:03:11.250', $mediaGroup->thumbnail[2]->time); + $this->assertEquals('http://img.youtube.com/vi/UMFI1hdm96E/0.jpg', $mediaGroup->thumbnail[3]->url); + $this->assertEquals(240, $mediaGroup->thumbnail[3]->height); + $this->assertEquals(320, $mediaGroup->thumbnail[3]->width); + $this->assertEquals('00:02:07.500', $mediaGroup->thumbnail[3]->time); + $this->assertTrue($mediaGroup->private instanceof Zend_Gdata_YouTube_Extension_Private); + + $this->assertEquals(113321, $videoEntry->statistics->viewCount); + $this->assertEquals(1, $videoEntry->rating->min); + $this->assertEquals(5, $videoEntry->rating->max); + $this->assertEquals(1005, $videoEntry->rating->numRaters); + $this->assertEquals(4.77, $videoEntry->rating->average); + $this->assertEquals('http://gdata.youtube.com/feeds/videos/UMFI1hdm96E/comments', $videoEntry->comments->feedLink->href); + + $this->assertEquals('37.398529052734375 -122.0635986328125', $videoEntry->where->point->pos->text); + $this->assertEquals('2008-09-25', $videoEntry->getVideoRecorded()); + } + + public function verifyAllV2SamplePropertiesAreCorrect($videoEntry) { + $this->assertEquals('tag:youtube.com,2008:video:UMFI1hdm96E', + $videoEntry->id->text); + $this->assertEquals('UMFI1hdm96E', $videoEntry->getVideoId()); + $this->assertEquals('2008-12-08T04:04:33.000Z', $videoEntry->updated->text); + + $this->assertEquals('http://gdata.youtube.com/schemas/2007/keywords.cat', $videoEntry->category[0]->scheme); + $this->assertEquals('cover', $videoEntry->category[0]->term); + $this->assertEquals('http://gdata.youtube.com/schemas/2007/keywords.cat', $videoEntry->category[1]->scheme); + $this->assertEquals('acoustic', $videoEntry->category[1]->term); + $this->assertEquals('http://gdata.youtube.com/schemas/2007/keywords.cat', $videoEntry->category[2]->scheme); + $this->assertEquals('gnarls', $videoEntry->category[2]->term); + $this->assertEquals('http://schemas.google.com/g/2005#kind', $videoEntry->category[3]->scheme); + $this->assertEquals('http://gdata.youtube.com/schemas/2007#video', $videoEntry->category[3]->term); + $this->assertEquals('http://gdata.youtube.com/schemas/2007/keywords.cat', $videoEntry->category[4]->scheme); + $this->assertEquals('barkley', $videoEntry->category[4]->term); + $this->assertEquals('http://gdata.youtube.com/schemas/2007/keywords.cat', $videoEntry->category[5]->scheme); + $this->assertEquals('music', $videoEntry->category[5]->term); + $this->assertEquals('http://gdata.youtube.com/schemas/2007/keywords.cat', $videoEntry->category[6]->scheme); + $this->assertEquals('singing', $videoEntry->category[6]->term); + $this->assertEquals('http://gdata.youtube.com/schemas/2007/categories.cat', $videoEntry->category[7]->scheme); + $this->assertEquals('Music', $videoEntry->category[7]->term); + + $this->assertEquals('text', $videoEntry->title->type); + $this->assertEquals('"Crazy (Gnarles Barkley)" - Acoustic Cover', $videoEntry->title->text);; + $this->assertEquals('application/x-shockwave-flash', $videoEntry->content->type); + $this->assertEquals('self', $videoEntry->getLink('self')->rel); + $this->assertEquals('application/atom+xml', $videoEntry->getLink('self')->type); + $this->assertEquals('http://gdata.youtube.com/feeds/api/videos/UMFI1hdm96E?v=2', $videoEntry->getLink('self')->href); + $this->assertEquals('text/html', $videoEntry->getLink('alternate')->type); + $this->assertEquals('http://www.youtube.com/watch?v=UMFI1hdm96E', $videoEntry->getLink('alternate')->href); + $this->assertEquals('application/atom+xml', $videoEntry->getLink('http://gdata.youtube.com/schemas/2007#video.responses')->type); + $this->assertEquals('http://gdata.youtube.com/feeds/api/videos/UMFI1hdm96E/responses?v=2', $videoEntry->getLink('http://gdata.youtube.com/schemas/2007#video.responses')->href); + $this->assertEquals('application/atom+xml', $videoEntry->getLink('http://gdata.youtube.com/schemas/2007#video.related')->type); + $this->assertEquals('http://gdata.youtube.com/feeds/api/videos/UMFI1hdm96E/related?v=2', $videoEntry->getLink('http://gdata.youtube.com/schemas/2007#video.related')->href); + $this->assertEquals('davidchoimusic', $videoEntry->author[0]->name->text); + $this->assertEquals('http://gdata.youtube.com/feeds/api/users/davidchoimusic', $videoEntry->author[0]->uri->text); + + $mediaGroup = $videoEntry->mediaGroup; + + $this->assertEquals('UMFI1hdm96E', $mediaGroup->getVideoId()->text); + $this->assertEquals('plain', $mediaGroup->title->type); + $this->assertEquals('"Crazy (Gnarles Barkley)" - Acoustic Cover', $mediaGroup->title->text); + $this->assertEquals('plain', $mediaGroup->description->type); + $this->assertEquals('Gnarles Barkley acoustic cover http://www.myspace.com/davidchoimusic', $mediaGroup->description->text); + $this->assertEquals('acoustic, barkley, cover, gnarls, music, singing', $mediaGroup->keywords->text); + $this->assertEquals(255, $mediaGroup->duration->seconds); + + $this->assertEquals('http://gdata.youtube.com/schemas/2007/developertags.cat', $mediaGroup->category[0]->scheme); + $this->assertEquals('DeveloperTag1', $mediaGroup->category[0]->text); + $this->assertEquals('http://gdata.youtube.com/schemas/2007/categories.cat', $mediaGroup->category[1]->scheme); + $this->assertEquals('Music', $mediaGroup->category[1]->text); + $this->assertEquals('video', $mediaGroup->content[0]->medium); + $this->assertEquals('http://www.youtube.com/v/UMFI1hdm96E&f=gdata_videos', $mediaGroup->content[0]->url); + $this->assertEquals('application/x-shockwave-flash', $mediaGroup->content[0]->type); + $this->assertEquals('true', $mediaGroup->content[0]->isDefault); + $this->assertEquals('full', $mediaGroup->content[0]->expression); + $this->assertEquals(255, $mediaGroup->content[0]->duration); + $this->assertEquals(5, $mediaGroup->content[0]->format); + $this->assertEquals('http://www.youtube.com/watch?v=UMFI1hdm96E', $mediaGroup->player[0]->url); + + $this->assertEquals('HK,TW', $mediaGroup->getMediaRating()->getCountry()); + $this->assertEquals(1, $mediaGroup->getMediaRating()->text); + $this->assertEquals('http://gdata.youtube.com/schemas/2007#mediarating', + $mediaGroup->getMediaRating()->getScheme()); + + $this->assertEquals('http://i.ytimg.com/vi/UMFI1hdm96E/2.jpg', $mediaGroup->thumbnail[0]->url); + $this->assertEquals(97, $mediaGroup->thumbnail[0]->height); + $this->assertEquals(130, $mediaGroup->thumbnail[0]->width); + $this->assertEquals('00:02:07.500', $mediaGroup->thumbnail[0]->time); + $this->assertEquals('http://i.ytimg.com/vi/UMFI1hdm96E/1.jpg', $mediaGroup->thumbnail[1]->url); + $this->assertEquals(97, $mediaGroup->thumbnail[1]->height); + $this->assertEquals(130, $mediaGroup->thumbnail[1]->width); + $this->assertEquals('00:01:03.750', $mediaGroup->thumbnail[1]->time); + $this->assertEquals('http://i.ytimg.com/vi/UMFI1hdm96E/3.jpg', $mediaGroup->thumbnail[2]->url); + $this->assertEquals(97, $mediaGroup->thumbnail[2]->height); + $this->assertEquals(130, $mediaGroup->thumbnail[2]->width); + $this->assertEquals('00:03:11.250', $mediaGroup->thumbnail[2]->time); + $this->assertEquals('http://i.ytimg.com/vi/UMFI1hdm96E/0.jpg', $mediaGroup->thumbnail[3]->url); + $this->assertEquals(240, $mediaGroup->thumbnail[3]->height); + $this->assertEquals(320, $mediaGroup->thumbnail[3]->width); + $this->assertEquals('00:02:07.500', $mediaGroup->thumbnail[3]->time); + + $this->assertEquals(267971, $videoEntry->statistics->viewCount); + $this->assertEquals(1, $videoEntry->rating->min); + $this->assertEquals(5, $videoEntry->rating->max); + $this->assertEquals(2062, $videoEntry->rating->numRaters); + $this->assertEquals(4.74, $videoEntry->rating->average); + $this->assertEquals('http://gdata.youtube.com/feeds/api/videos/UMFI1hdm96E/comments?v=2', $videoEntry->comments->feedLink->href); + + $this->assertEquals('37.398529052734375 -122.0635986328125', $videoEntry->where->point->pos->text); + $this->assertEquals('2008-09-25', $videoEntry->getVideoRecorded()); + + + + } + + public function testGetVideoId() { + $videoEntry = new Zend_Gdata_YouTube_VideoEntry(); + + // assert valid ID + $videoEntry->id = new Zend_Gdata_App_Extension_Id('http://gdata.youtube.com/feeds/videos/ABCDEFG12AB'); + $this->assertEquals('ABCDEFG12AB', $videoEntry->getVideoId()); + } + + public function testGetVideoIdV2() { + $v2VideoEntry = new Zend_Gdata_YouTube_VideoEntry(); + $v2VideoEntry->setMajorProtocolVersion(2); + + $v2MediaGroup = new Zend_Gdata_YouTube_Extension_MediaGroup(); + $v2MediaGroup->setVideoId( + new Zend_Gdata_YouTube_Extension_VideoId('UMFI1hdm96E')); + + $v2VideoEntry->setMediaGroup($v2MediaGroup); + + $this->assertEquals('UMFI1hdm96E', $v2VideoEntry->getVideoId()); + } + + public function testGetVideoIdException() { + + $exceptionCaught = false; + $videoEntry = new Zend_Gdata_YouTube_VideoEntry(); + + // use invalid ID + $videoEntry->id = new Zend_Gdata_App_Extension_Id('adfadfasf'); + + try { + $videoEntry->getVideoId(); + + } catch (Zend_Gdata_App_Exception $e) { + $exceptionCaught = true; + } + + $this->assertTrue($exceptionCaught, 'Expected exception not caught: ' . + 'Zend_Gdata_AppException'); + } + + public function testGetVersionExceptionOnGetRacy() { + $videoEntry = new Zend_Gdata_YouTube_VideoEntry(); + $videoEntry->setMajorProtocolVersion(2); + + $exceptionCaught = false; + + try { + $videoEntry->getRacy(); + } catch (Zend_Gdata_App_VersionException $e) { + $exceptionCaught = true; + } + + $this->assertTrue($exceptionCaught, 'Expected exception not caught: ' . + 'Zend_Gdata_App_VersionException'); + } + + public function testGetVersionExceptionOnSetRacy() { + $videoEntry = new Zend_Gdata_YouTube_VideoEntry(); + $videoEntry->setMajorProtocolVersion(2); + + $exceptionCaught = false; + + try { + $videoEntry->getRacy(); + } catch (Zend_Gdata_App_VersionException $e) { + $exceptionCaught = true; + } + + $this->assertTrue($exceptionCaught, 'Expected exception not caught: ' . + 'Zend_Gdata_App_VersionException'); + } + + public function testEmptyEntryShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->entry->extensionElements)); + $this->assertTrue(count($this->entry->extensionElements) == 0); + } + + public function testEmptyEntryShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->entry->extensionAttributes)); + $this->assertTrue(count($this->entry->extensionAttributes) == 0); + } + + public function testSampleEntryShouldHaveNoExtensionElements() { + $this->entry->transferFromXML($this->entryText); + $this->assertTrue(is_array($this->entry->extensionElements)); + $this->assertTrue(count($this->entry->extensionElements) == 0); + } + + public function testSampleEntryShouldHaveNoExtensionAttributes() { + $this->entry->transferFromXML($this->entryText); + $this->assertTrue(is_array($this->entry->extensionAttributes)); + $this->assertTrue(count($this->entry->extensionAttributes) == 0); + } + + public function testSampleEntryShouldHaveNoExtensionElementsV2() { + $this->entry->transferFromXML($this->v2EntryText); + $this->assertTrue(is_array($this->entry->extensionElements)); + $this->assertTrue(count($this->entry->extensionElements) == 0); + } + + public function testSampleEntryShouldHaveNoExtensionAttributesV2() { + $this->entry->transferFromXML($this->v2EntryText); + $this->assertTrue(is_array($this->entry->extensionAttributes)); + $this->assertTrue(count($this->entry->extensionAttributes) == 0); + } + + public function testEmptyVideoEntryToAndFromStringShouldMatch() { + $entryXml = $this->entry->saveXML(); + $newVideoEntry = new Zend_Gdata_YouTube_VideoEntry(); + $newVideoEntry->transferFromXML($entryXml); + $newVideoEntryXml = $newVideoEntry->saveXML(); + $this->assertTrue($entryXml == $newVideoEntryXml); + } + + public function testSamplePropertiesAreCorrect () { + $this->entry->transferFromXML($this->entryText); + $this->verifyAllSamplePropertiesAreCorrect($this->entry); + } + + public function testPrivateSamplePropertiesAreCorrect () { + $this->entry->transferFromXML($this->privateEntryText); + $this->verifyAllPrivateSamplePropertiesAreCorrect($this->entry); + } + + public function testV2SamplePropertiesAreCorrect() { + $this->entry->transferFromXML($this->v2EntryText); + $this->entry->setMajorProtocolVersion(2); + $this->verifyAllV2SamplePropertiesAreCorrect($this->entry); + } + + public function testGetVideoTitle() { + $this->entry->transferFromXML($this->entryText); + $videoEntry = $this->entry; + $this->assertEquals('"Crazy (Gnarles Barkley)" - Acoustic Cover', $videoEntry->getVideoTitle()); + + $newEntry = new Zend_Gdata_YouTube_VideoEntry(); + $this->assertEquals(null, $newEntry->getVideoTitle()); + } + + public function testSetVideoTitle() { + $this->entry->transferFromXML($this->entryText); + $videoEntry = $this->entry; + $newTitle = 'My New Title'; + $videoEntry->setVideoTitle($newTitle); + $this->assertEquals($videoEntry->getVideoTitle(), $newTitle); + } + + public function testGetVideoDescription() { + $this->entry->transferFromXML($this->entryText); + $videoEntry = $this->entry; + $this->assertEquals('Gnarles Barkley acoustic cover http://www.myspace.com/davidchoimusic', $videoEntry->getVideoDescription()); + + $newEntry = new Zend_Gdata_YouTube_VideoEntry(); + $this->assertEquals(null, $newEntry->getVideoDescription()); + } + + public function testSetVideoDescription() { + $this->entry->transferFromXML($this->entryText); + $videoEntry = $this->entry; + $newDescription = 'My New Description'; + $videoEntry->setVideoDescription($newDescription); + $this->assertEquals($videoEntry->getVideoDescription(), $newDescription); + } + + public function testGetVideoWatchPageUrl() { + $this->entry->transferFromXML($this->entryText); + $videoEntry = $this->entry; + $this->assertEquals('http://www.youtube.com/watch?v=UMFI1hdm96E', $videoEntry->getVideoWatchPageUrl()); + + $newEntry = new Zend_Gdata_YouTube_VideoEntry(); + $this->assertEquals(null, $newEntry->getVideoWatchPageUrl()); + } + + public function testGetVideoThumbnails() { + $this->entry->transferFromXML($this->entryText); + $videoEntry = $this->entry; + + $mediaThumbnails1 = $videoEntry->getMediaGroup()->getThumbnail(); + $mediaThumbnails2 = $videoEntry->getVideoThumbnails(); + + $this->assertEquals(count($mediaThumbnails1), count($mediaThumbnails2)); + + $foundThumbnail = false; + foreach ($mediaThumbnails2 as $thumbnail) { + if ($thumbnail['url'] == 'http://img.youtube.com/vi/UMFI1hdm96E/1.jpg') { + $foundThumbnail = true; + $this->assertEquals(97, $thumbnail['height']); + $this->assertEquals(130, $thumbnail['width']); + $this->assertEquals('00:01:03.750', $thumbnail['time']); + } + } + $this->assertTrue($foundThumbnail); + + $newEntry = new Zend_Gdata_YouTube_VideoEntry(); + $this->assertEquals(array(), $newEntry->getVideoThumbnails()); + } + + public function testGetVideoTags() { + $this->entry->transferFromXML($this->entryText); + $videoEntry = $this->entry; + + $keywords = $videoEntry->getMediaGroup()->getKeywords(); + + $keywordsString = (string) $keywords; + + if (strlen(trim($keywordsString)) > 0) { + $keywordArray = preg_split('/(, *)|,/', $keywordsString); + } + + $tagArray = $videoEntry->getVideoTags(); + $this->assertEquals(count($keywordArray), count($tagArray)); + foreach ($keywordArray as $keyword) { + $this->assertTrue(in_array($keyword, $tagArray)); + } + foreach ($tagArray as $tag) { + $this->assertTrue(in_array($tag, $keywordArray)); + } + + $newEntry = new Zend_Gdata_YouTube_VideoEntry(); + $this->assertEquals(array(), $newEntry->getVideoTags()); + } + + public function testSetVideoTags() { + $this->entry->transferFromXML($this->entryText); + $videoEntry = $this->entry; + + $newKeywordsString = $this->createRandomString() + . ', ' . $this->createRandomString(); + $videoEntry->setVideoTags($newKeywordsString); + + if (strlen(trim($newKeywordsString)) > 0) { + $keywordArray = preg_split('/(, *)|,/', $newKeywordsString); + } + + $tagArray = $videoEntry->getVideoTags(); + $this->assertEquals(count($keywordArray), count($tagArray)); + + foreach ($keywordArray as $keyword) { + $this->assertTrue(in_array($keyword, $tagArray)); + } + + foreach ($tagArray as $tag) { + $this->assertTrue(in_array($tag, $keywordArray)); + } + + $newEntry = new Zend_Gdata_YouTube_VideoEntry(); + $this->assertEquals(array(), $newEntry->getVideoTags()); + } + + public function testGetVideoDeveloperTags() { + $this->entry->transferFromXML($this->entryText); + $videoEntry = $this->entry; + + $categories = $videoEntry->getMediaGroup()->getCategory(); + $developerTagsArrayFromMediaGroup = null; + foreach($categories as $category) { + if ($category->getScheme() == 'http://gdata.youtube.com/schemas/2007/developertags.cat') { + $developerTagsArrayFromMediaGroup[] = $category->getText(); + } + } + + $developerTagsArray = $videoEntry->getVideoDeveloperTags(); + + $this->assertEquals(count($developerTagsArrayFromMediaGroup), count($developerTagsArray)); + foreach ($developerTagsArrayFromMediaGroup as $devTagMG) { + $this->assertTrue(in_array($devTagMG, $developerTagsArrayFromMediaGroup)); + } + foreach ($developerTagsArray as $devTag) { + $this->assertTrue(in_array($devTag, $developerTagsArray)); + } + } + + public function testSetVideoDeveloperTags() { + $this->entry->transferFromXML($this->entryText); + $videoEntry = $this->entry; + $existingDevTags = $videoEntry->getVideoDeveloperTags(); + + $newDeveloperTags = array( + $this->createRandomString(), + $this->createRandomString()); + + $videoEntry->setVideoDeveloperTags($newDeveloperTags); + $newAndOldDeveloperTags = array_merge($newDeveloperTags, $existingDevTags); + $developerTagsArray = $videoEntry->getVideoDeveloperTags(); + $this->assertEquals(count($newAndOldDeveloperTags), count($developerTagsArray)); + + foreach($developerTagsArray as $developerTagOnEntry) { + $this->assertTrue(in_array($developerTagOnEntry, $newAndOldDeveloperTags)); + } + } + + public function testGetFlashPlayerUrl() { + $this->entry->transferFromXML($this->entryText); + $videoEntry = $this->entry; + $this->assertEquals('http://www.youtube.com/v/UMFI1hdm96E', $videoEntry->getFlashPlayerUrl()); + + $newEntry = new Zend_Gdata_YouTube_VideoEntry(); + $this->assertEquals(null, $newEntry->getFlashPlayerUrl()); + } + + public function testGetVideoDuration() { + $this->entry->transferFromXML($this->entryText); + $videoEntry = $this->entry; + $this->assertEquals(255, $videoEntry->getVideoDuration()); + + $newEntry = new Zend_Gdata_YouTube_VideoEntry(); + $this->assertEquals(null, $newEntry->getVideoDuration()); + } + + public function testGetVideoViewCount() { + $this->entry->transferFromXML($this->entryText); + $videoEntry = $this->entry; + $this->assertEquals(113321, $videoEntry->getVideoViewCount()); + + $newEntry = new Zend_Gdata_YouTube_VideoEntry(); + $this->assertEquals(null, $newEntry->getVideoViewCount()); + } + + public function testGetVideoGeoLocation() { + $this->entry->transferFromXML($this->entryText); + $videoEntry = $this->entry; + $geoLocation = $videoEntry->getVideoGeoLocation(); + $this->assertEquals('37.398529052734375', $geoLocation['latitude']); + $this->assertEquals('-122.0635986328125', $geoLocation['longitude']); + + $newEntry = new Zend_Gdata_YouTube_VideoEntry(); + $this->assertEquals(null, $newEntry->getVideoGeoLocation()); + } + + public function testGetVideoRatingInfo() { + $this->entry->transferFromXML($this->entryText); + $videoEntry = $this->entry; + + $ratingInfo = $videoEntry->getVideoRatingInfo(); + + $this->assertEquals(4.77, $ratingInfo['average']); + $this->assertEquals(1005, $ratingInfo['numRaters']); + + $newEntry = new Zend_Gdata_YouTube_VideoEntry(); + $this->assertEquals(null, $newEntry->getVideoRatingInfo()); + } + + public function testGetVideoCategory() { + $this->entry->transferFromXML($this->entryText); + $videoEntry = $this->entry; + $this->assertEquals('Music', $videoEntry->getVideoCategory()); + + $newEntry = new Zend_Gdata_YouTube_VideoEntry(); + $this->assertEquals(null, $newEntry->getVideoCategory()); + } + + public function testSetVideoCategory() { + $this->entry->transferFromXML($this->entryText); + $videoEntry = $this->entry; + $newCategory = 'Comedy'; + $videoEntry->setVideoCategory($newCategory); + $this->assertEquals($videoEntry->getVideoCategory(), $newCategory); + } + + public function testConvertVideoEntryToAndFromString() { + $this->entry->transferFromXML($this->entryText); + $entryXml = $this->entry->saveXML(); + $newVideoEntry = new Zend_Gdata_YouTube_VideoEntry(); + $newVideoEntry->transferFromXML($entryXml); + $this->verifyAllSamplePropertiesAreCorrect($newVideoEntry); + $newVideoEntryXml = $newVideoEntry->saveXML(); + $this->assertEquals($entryXml, $newVideoEntryXml); + } + + public function testNoEmbed() { + $this->entry->transferFromXML($this->entryText); + $videoEntry = $this->entry; + $this->assertNotEquals(null, $videoEntry->getNoEmbed()); + } + + public function testVideoState() { + $this->entry->transferFromXML($this->entryText); + $videoEntry = $this->entry; + + $videoState = $videoEntry->getVideoState(); + $this->assertTrue($videoState instanceof Zend_Gdata_YouTube_Extension_State); + + $this->assertEquals('rejected', $videoState->getName()); + $this->assertEquals('inappropriate', $videoState->getReasonCode()); + $this->assertEquals('http://www.youtube.com/t/community_guidelines', $videoState->getHelpUrl()); + $this->assertEquals('The content of this video may violate the terms of use.', + $videoState->getText()); + } + + public function testVideoPrivate() { + $this->entry->transferFromXml($this->privateEntryText); + $videoEntry = $this->entry; + + $this->assertTrue($videoEntry->isVideoPrivate()); + } + + public function testSetVideoPrivate() { + $this->entry->transferFromXml($this->entryText); + $videoEntry = $this->entry; + $videoEntry->setVideoPrivate(); + + $this->assertTrue($videoEntry->isVideoPrivate()); + } + + public function testSetVideoPublic() { + $this->entry->transferFromXml($this->privateEntryText); + $videoEntry = $this->entry; + $videoEntry->setVideoPublic(); + + $this->assertFalse($videoEntry->isVideoPrivate()); + } + + public function testRetrieveCommentsFeedUrl() { + $this->entry->transferFromXML($this->entryText); + $commentsFeedUrl = $this->entry->getVideoCommentFeedUrl(); + $this->assertEquals($commentsFeedUrl, + 'http://gdata.youtube.com/feeds/videos/UMFI1hdm96E/comments'); + } + + public function testAddVideoEntryRating() + { + $this->entry->transferFromXML($this->entryText); + $ratingValue = 2; + $entryWithRating = $this->entry->setVideoRating($ratingValue); + $this->assertTrue( + $entryWithRating instanceof Zend_Gdata_YouTube_VideoEntry); + + $rating = $entryWithRating->getRating(); + $this->assertTrue( + $rating instanceof Zend_Gdata_Extension_Rating); + + $this->assertEquals($rating->getValue(), $ratingValue); + } + +} diff --git a/zend/tests/Zend/Gdata/YouTube/VideoFeedTest.php b/zend/tests/Zend/Gdata/YouTube/VideoFeedTest.php new file mode 100644 index 0000000..f7cea0c --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/VideoFeedTest.php @@ -0,0 +1,109 @@ +feedText = file_get_contents( + 'Zend/Gdata/YouTube/_files/VideoFeedDataSample1.xml', + true); + $this->feed = new Zend_Gdata_YouTube_VideoFeed(); + } + + private function verifyAllSamplePropertiesAreCorrect ($videoFeed) { + $this->assertEquals('http://gdata.youtube.com/feeds/users/davidchoimusic/uploads', + $videoFeed->id->text); + $this->assertEquals('2007-09-21T02:27:22.638Z', $videoFeed->updated->text); + $this->assertEquals('http://schemas.google.com/g/2005#kind', $videoFeed->category[0]->scheme); + $this->assertEquals('http://gdata.youtube.com/schemas/2007#video', $videoFeed->category[0]->term); + $this->assertEquals('http://www.youtube.com/img/pic_youtubelogo_123x63.gif', $videoFeed->logo->text); + $this->assertEquals('text', $videoFeed->title->type); + $this->assertEquals('Davidchoimusic\'s Videos', $videoFeed->title->text);; + $this->assertEquals('self', $videoFeed->getLink('self')->rel); + $this->assertEquals('application/atom+xml', $videoFeed->getLink('self')->type); + $this->assertEquals('http://gdata.youtube.com/feeds/users/davidchoimusic/uploads?start-index=1&max-results=5', $videoFeed->getLink('self')->href); + $this->assertEquals('davidchoimusic', $videoFeed->author[0]->name->text); + $this->assertEquals('http://gdata.youtube.com/feeds/users/davidchoimusic', $videoFeed->author[0]->uri->text); + $this->assertEquals(54, $videoFeed->totalResults->text); + $this->assertEquals(1, $videoFeed->startIndex->text); + $this->assertEquals(5, $videoFeed->itemsPerPage->text); + } + + public function testEmptyEntryShouldHaveNoExtensionElements() { + $this->assertTrue(is_array($this->feed->extensionElements)); + $this->assertTrue(count($this->feed->extensionElements) == 0); + } + + public function testEmptyEntryShouldHaveNoExtensionAttributes() { + $this->assertTrue(is_array($this->feed->extensionAttributes)); + $this->assertTrue(count($this->feed->extensionAttributes) == 0); + } + + public function testSampleEntryShouldHaveNoExtensionElements() { + $this->feed->transferFromXML($this->feedText); + $this->assertTrue(is_array($this->feed->extensionElements)); + $this->assertTrue(count($this->feed->extensionElements) == 0); + } + + public function testSampleEntryShouldHaveNoExtensionAttributes() { + $this->feed->transferFromXML($this->feedText); + $this->assertTrue(is_array($this->feed->extensionAttributes)); + $this->assertTrue(count($this->feed->extensionAttributes) == 0); + } + + public function testEmptyVideoFeedToAndFromStringShouldMatch() { + $entryXml = $this->feed->saveXML(); + $newVideoFeed = new Zend_Gdata_YouTube_VideoFeed(); + $newVideoFeed->transferFromXML($entryXml); + $newVideoFeedXml = $newVideoFeed->saveXML(); + $this->assertTrue($entryXml == $newVideoFeedXml); + } + + public function testSamplePropertiesAreCorrect () { + $this->feed->transferFromXML($this->feedText); + $this->verifyAllSamplePropertiesAreCorrect($this->feed); + } + + public function testConvertVideoFeedToAndFromString() { + $this->feed->transferFromXML($this->feedText); + $entryXml = $this->feed->saveXML(); + $newVideoFeed = new Zend_Gdata_YouTube_VideoFeed(); + $newVideoFeed->transferFromXML($entryXml); + $this->verifyAllSamplePropertiesAreCorrect($newVideoFeed); + $newVideoFeedXml = $newVideoFeed->saveXML(); + $this->assertEquals($entryXml, $newVideoFeedXml); + } + +} diff --git a/zend/tests/Zend/Gdata/YouTube/VideoQueryTest.php b/zend/tests/Zend/Gdata/YouTube/VideoQueryTest.php new file mode 100644 index 0000000..e119e0a --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/VideoQueryTest.php @@ -0,0 +1,277 @@ +newVideoQuery(); + $query->setOrderBy('viewCount'); + $query->setVideoQuery('foobar'); + $expectedString = '?orderby=viewCount&vq=foobar'; + $this->assertEquals($expectedString, $query->getQueryString()); + } + + public function testQueryStringConstructionV2() + { + $yt = new Zend_Gdata_YouTube(); + $query = $yt->newVideoQuery(); + $query->setOrderBy('viewCount'); + $query->setVideoQuery('version2'); + $expectedString = '?orderby=viewCount&q=version2'; + $this->assertEquals($expectedString, $query->getQueryString(2)); + } + + public function testSafeSearchQueryV2() + { + $yt = new Zend_Gdata_YouTube(); + $query = $yt->newVideoQuery(); + $exceptionCaught = false; + $query->setRacy('include'); + try { + $query->getQueryString(2); + } catch (Zend_Gdata_App_VersionException $e) { + $exceptionCaught = true; + } + $this->assertTrue($exceptionCaught, 'Zend_Gdata_App_VersionException' . + ' expected but not found'); + } + + public function testLocationRadiusV1() + { + $yt = new Zend_Gdata_YouTube(); + $query = $yt->newVideoQuery(); + $exceptionCaught = false; + $query->setLocationRadius('1km'); + try { + $query->getQueryString(1); + } catch (Zend_Gdata_App_VersionException $e) { + $exceptionCaught = true; + } + $this->assertTrue($exceptionCaught, 'Zend_Gdata_App_VersionException' . + ' expected but not found'); + } + + public function testLocationV2() + { + $yt = new Zend_Gdata_YouTube(); + $query = $yt->newVideoQuery(); + $query->setLocation('-37.122,122.01'); + $expectedString = '?location=-37.122%2C122.01'; + $this->assertEquals($expectedString, $query->getQueryString(2)); + } + + public function testLocationExceptionOnNonNumericV2() + { + $yt = new Zend_Gdata_YouTube(); + $query = $yt->newVideoQuery(); + $exceptionCaught = false; + + try { + $query->setLocation('mars'); + } catch (Zend_Gdata_App_InvalidArgumentException $e) { + $exceptionCaught = true; + } + + $this->assertTrue($exceptionCaught, 'Expected Zend_Gdata_App_' . + 'IllegalArgumentException when using alpha in setLocation'); + } + + public function testLocationExceptionOnOnlyOneCoordinateV2() + { + $yt = new Zend_Gdata_YouTube(); + $query = $yt->newVideoQuery(); + $exceptionCaught = false; + + try { + $query->setLocation('-25.001'); + } catch (Zend_Gdata_App_InvalidArgumentException $e) { + $exceptionCaught = true; + } + + $this->assertTrue($exceptionCaught, 'Expected Zend_Gdata_App_' . + 'IllegalArgumentException when using only 1 coordinate ' . + 'in setLocation'); + } + + public function testUploaderExceptionOnInvalidV2() + { + $yt = new Zend_Gdata_YouTube(); + $query = $yt->newVideoQuery(); + $exceptionCaught = false; + + try { + $query->setUploader('invalid'); + } catch (Zend_Gdata_App_InvalidArgumentException $e) { + $exceptionCaught = true; + } + + $this->assertTrue($exceptionCaught, 'Expected Zend_Gdata_App_' . + 'IllegalArgumentException when using invalid string in ' . + 'setUploader.'); + } + + public function testProjectionPresentInV2Query() + { + $yt = new Zend_Gdata_YouTube(); + $query = $yt->newVideoQuery(); + $query->setVideoQuery('foo'); + $expectedString = 'https://gdata.youtube.com/feeds/api/videos?q=foo'; + $this->assertEquals($expectedString, $query->getQueryUrl(2)); + } + + public function testSafeSearchParametersInV2() + { + $yt = new Zend_Gdata_YouTube(); + $query = $yt->newVideoQuery(); + $exceptionCaught = false; + try { + $query->setSafeSearch('invalid'); + } catch (Zend_Gdata_App_InvalidArgumentException $e) { + $exceptionCaught = true; + } + $this->assertTrue($exceptionCaught, 'Expected Zend_Gdata_App_' . + 'InvalidArgumentException when using invalid value for ' . + 'safeSearch.'); + } + + /** + * @group ZF-8720 + * @expectedException Zend_Gdata_App_InvalidArgumentException + */ + public function testVideoQuerySetLocationException() + { + $yt = new Zend_Gdata_YouTube(); + $query = $yt->newVideoQuery(); + $location = 'foobar'; + $this->assertNull($query->setLocation($location)); + } + + /** + * @group ZF-8720 + * @expectedException Zend_Gdata_App_InvalidArgumentException + */ + public function testVideoQuerySetLocationExceptionV2() + { + $yt = new Zend_Gdata_YouTube(); + $query = $yt->newVideoQuery(); + $location = '-100x,-200y'; + $this->assertNull($query->setLocation($location)); + } + + /** + * @group ZF-8720 + * @expectedException Zend_Gdata_App_InvalidArgumentException + */ + public function testVideoQuerySetLocationExceptionV3() + { + $yt = new Zend_Gdata_YouTube(); + $query = $yt->newVideoQuery(); + $location = '-100x,-200y!'; + $this->assertNull($query->setLocation($location)); + } + + /** + * @group ZF-8720 + */ + public function testQueryExclamationMarkRemoveBug() + { + $yt = new Zend_Gdata_YouTube(); + $query = $yt->newVideoQuery(); + + $location = '37.42307,-122.08427'; + $this->assertNull($query->setLocation($location)); + $this->assertEquals($location, $query->getLocation()); + + $location = '37.42307,-122.08427!'; + $this->assertNull($query->setLocation($location)); + $this->assertEquals($location, $query->getLocation()); + } + + /** + * @group ZF-12500 + */ + public function testQueryUrlForFeedTypRelated() + { + $yt = new Zend_Gdata_YouTube(); + + // Query + $query = $yt->newVideoQuery(); + $query->setFeedType('related', 'foo'); + + // Test + $this->assertSame( + 'https://gdata.youtube.com/feeds/api/videos/foo/related', + $query->getQueryUrl() + ); + } + + /** + * @group ZF-12500 + */ + public function testQueryUrlForFeedTypResponses() + { + $yt = new Zend_Gdata_YouTube(); + + // Query + $query = $yt->newVideoQuery(); + $query->setFeedType('responses', 'foo'); + + // Test + $this->assertSame( + 'https://gdata.youtube.com/feeds/api/videos/foo/responses', + $query->getQueryUrl() + ); + } + + /** + * @group ZF-12500 + */ + public function testQueryUrlForFeedTypComments() + { + $yt = new Zend_Gdata_YouTube(); + + // Query + $query = $yt->newVideoQuery(); + $query->setFeedType('comments', 'foo'); + + // Test + $this->assertSame( + 'https://gdata.youtube.com/feeds/api/videos/foo/comments', + $query->getQueryUrl() + ); + } +} diff --git a/zend/tests/Zend/Gdata/YouTube/_files/ActivityEntryDataSample1.xml b/zend/tests/Zend/Gdata/YouTube/_files/ActivityEntryDataSample1.xml new file mode 100644 index 0000000..a975d7d --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/_files/ActivityEntryDataSample1.xml @@ -0,0 +1,23 @@ + + + tag:youtube.com,2008:event:Z2RweXRob24xMTIzNDMwMDAyMzI5NTQ2Nzg2MA%3D%3D + 2009-01-16T09:13:49.000-08:00 + + + tayzonzay has favorited a video + + + + + tayzonzay + http://gdata.youtube.com/feeds/api/users/tayzonzay + + z3U0kuLH974 + foo + + \ No newline at end of file diff --git a/zend/tests/Zend/Gdata/YouTube/_files/ActivityFeedDataSample1.xml b/zend/tests/Zend/Gdata/YouTube/_files/ActivityFeedDataSample1.xml new file mode 100644 index 0000000..5e25ddb --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/_files/ActivityFeedDataSample1.xml @@ -0,0 +1,47 @@ + + + 2009-01-28T09:13:49.000-08:00 + + + + + + Activity of tayzonzay + http://www.youtube.com/img/pic_youtubelogo_123x63.gif + + YouTube + http://www.youtube.com/ + + YouTube data API + 12 + 1 + 25 + + 2009-01-16T09:13:49.000-08:00 + + + tayzonzay has favorited a video + + + + + tayzonzay + http://gdata.youtube.com/feeds/api/users/tayzonzay + + z3U0kuLH974 + + \ No newline at end of file diff --git a/zend/tests/Zend/Gdata/YouTube/_files/CommentEntryDataSample1.xml b/zend/tests/Zend/Gdata/YouTube/_files/CommentEntryDataSample1.xml new file mode 100644 index 0000000..f36f905 --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/_files/CommentEntryDataSample1.xml @@ -0,0 +1,20 @@ + + + http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments/CE0314DEBFFC9052 + 2007-09-02T18:00:04.000-07:00 + 2007-09-02T18:00:04.000-07:00 + + how to turn ... + how to turn rejection and heartbreak into something positive is the big mystery of life but you're managed to turn it to your advantage with a beautiful song. Who was she? + + + + + reneemathome + http://gdata.youtube.com/feeds/users/reneemathome + + diff --git a/zend/tests/Zend/Gdata/YouTube/_files/CommentFeedDataSample1.xml b/zend/tests/Zend/Gdata/YouTube/_files/CommentFeedDataSample1.xml new file mode 100644 index 0000000..d865ed0 --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/_files/CommentFeedDataSample1.xml @@ -0,0 +1,112 @@ + + + http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments + 2007-09-21T02:32:55.032Z + + Comments on '"That Girl" - Original Song - Acoustic Version' + http://www.youtube.com/img/pic_youtubelogo_123x63.gif + + + + + + + YouTube + http://www.youtube.com/ + + YouTube data API + 100 + 1 + 4 + + + http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments/CE0314DEBFFC9052 + 2007-09-02T18:00:04.000-07:00 + 2007-09-02T18:00:04.000-07:00 + + how to turn ... + how to turn rejection and heartbreak into + something positive is the big mystery of life but you're + managed to turn it to your advantage with a beautiful song. Who + was she? + + + + + reneemathome + http://gdata.youtube.com/feeds/users/reneemathome + + + + + http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments/405F5D8E73538763 + 2007-09-02T20:51:52.000-07:00 + 2007-09-02T20:51:52.000-07:00 + + The stars are ... + The stars are flying... Make something + with this!!!:) + + + + + minoujill + http://gdata.youtube.com/feeds/users/minoujill + + + + + http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments/DA7550644FFCF2EC + 2007-09-02T22:22:27.000-07:00 + 2007-09-02T22:22:27.000-07:00 + + awesome song! + awesome song! + + + + + beeGoaTee + http://gdata.youtube.com/feeds/users/beeGoaTee + + + + + http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments/B99ACB2520430E90 + 2007-09-03T10:46:45.000-07:00 + 2007-09-03T10:46:45.000-07:00 + + This is GOOD!! + This is GOOD!! + + + + + Grosh62 + http://gdata.youtube.com/feeds/users/Grosh62 + + + diff --git a/zend/tests/Zend/Gdata/YouTube/_files/ContactEntryDataSample1.xml b/zend/tests/Zend/Gdata/YouTube/_files/ContactEntryDataSample1.xml new file mode 100644 index 0000000..e375401 --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/_files/ContactEntryDataSample1.xml @@ -0,0 +1,26 @@ + + + http://gdata.youtube.com/feeds/users/davidchoimusic/contacts/testuser + 1970-01-14T04:17:17.804-08:00 + 2007-09-21T02:44:41.134Z + + + testuser + + + + + davidchoimusic + + http://gdata.youtube.com/feeds/users/davidchoimusic + + testuser + accepted + diff --git a/zend/tests/Zend/Gdata/YouTube/_files/ContactFeedDataSample1.xml b/zend/tests/Zend/Gdata/YouTube/_files/ContactFeedDataSample1.xml new file mode 100644 index 0000000..23c9010 --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/_files/ContactFeedDataSample1.xml @@ -0,0 +1,51 @@ + + + http://gdata.youtube.com/feeds/users/davidchoimusic/contacts + 2007-09-21T02:44:41.135Z + + davidchoimusic's Contacts + http://www.youtube.com/img/pic_youtubelogo_123x63.gif + + + + + + davidchoimusic + http://gdata.youtube.com/feeds/users/davidchoimusic + + YouTube data API + 1558 + 1 + 5 + + http://gdata.youtube.com/feeds/users/davidchoimusic/contacts/testuser + 1970-01-14T04:17:17.804-08:00 + 2007-09-21T02:44:41.134Z + + + testuser + + + + + davidchoimusic + + http://gdata.youtube.com/feeds/users/davidchoimusic + + testuser + accepted + + diff --git a/zend/tests/Zend/Gdata/YouTube/_files/FormUploadTokenResponseSample.xml b/zend/tests/Zend/Gdata/YouTube/_files/FormUploadTokenResponseSample.xml new file mode 100644 index 0000000..5dfb1f8 --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/_files/FormUploadTokenResponseSample.xml @@ -0,0 +1 @@ +http://uploads.gdata.youtube.com/action/FormDataUpload/AIwbF1_JjEQ9cGTjEAd5FKwV42SeNWJexmc5y7XR-eFj24uqbqU6NRcxKJW_4R-sYISLxQAIwbFAQ21fImpR2iYPaFnfuCvfbCB3qBxl5qXiZlpH3lfkungiSPoyw1iOM1gFB6Nx-wmY-kjprNT3qtdp7LJCLfngn11Ne_X9Jd44Vz8AzygtEtaDGyib5tnri0O0-V5pwcAPCHIJurOMsOpA2zInW8V8qHk2S2LheXfTXVbqc0Li9iCBpsoBGbykYU0moNoyGAaKRbSBD0oPnCv6v9Rll5Zjvivi2hQt-Br2JDb9wVeLv3qyAFaeyN6X6k32RyaAHs_n8d8d_oSriQmvS8g1HxSCS4dnoGL7tafQ4SBqnrQEb-hxFeu1ZrAwCLv diff --git a/zend/tests/Zend/Gdata/YouTube/_files/InboxEntryDataSample1.xml b/zend/tests/Zend/Gdata/YouTube/_files/InboxEntryDataSample1.xml new file mode 100644 index 0000000..6007c66 --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/_files/InboxEntryDataSample1.xml @@ -0,0 +1,82 @@ + + + + http://gdata.youtube.com/feeds/api/users/andyland74/inbox/ffb9a5f32cd5f55 + + 2008-06-10T13:55:32.000-07:00 + + andyland74sFriend sent you a video! + Check out this video! + + + + + + + + + + andyland74sFriend + + http://gdata.youtube.com/feeds/api/users/andyland74sFriend + + + + Learning the ABCs + + A great method for teaching kids the alphabet. + + alphabet, teaching, children + + + Education + + + + + + + + + + + + + + + Check out this video! + \ No newline at end of file diff --git a/zend/tests/Zend/Gdata/YouTube/_files/InboxEntryDataSampleV2.xml b/zend/tests/Zend/Gdata/YouTube/_files/InboxEntryDataSampleV2.xml new file mode 100644 index 0000000..d2d17b8 --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/_files/InboxEntryDataSampleV2.xml @@ -0,0 +1,88 @@ + + + tag:youtube,2008:user:andyland74:inbox:D_uaXzLRX1U + 2008-06-10T13:55:32.000-07:00 + 2008-06-10T13:55:32.000-07:00 + 2008-06-10T20:55:32.000Z + + + + andyland74sFriend sent you a video! + Check out this video! + + + + + + + + + + + andyland74sFriend + http://gdata.youtube.com/feeds/api/users/andyland74sFriend + + + Learning the ABCs + + A great method for teaching kids the alphabet. + + alphabet, teaching, children + + jXE6G9CYcJs + andyland74sFriend + + Education + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/zend/tests/Zend/Gdata/YouTube/_files/InboxFeedDataSample1.xml b/zend/tests/Zend/Gdata/YouTube/_files/InboxFeedDataSample1.xml new file mode 100755 index 0000000..99374f1 --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/_files/InboxFeedDataSample1.xml @@ -0,0 +1,107 @@ + + + http://gdata.youtube.com/feeds/api/users/default/inbox + 2008-06-10T20:55:40.271Z + + Inbox of andyland74 + http://www.youtube.com/img/pic_youtubelogo_123x63.gif + + + + + andyland74 + http://gdata.youtube.com/feeds/api/users/andyland74 + + YouTube data API + 1 + 1 + 25 + + + http://gdata.youtube.com/feeds/api/users/andyland74/inbox/ffb9a5f32cd5f55 + + 2008-06-10T13:55:32.000-07:00 + + andyland74sFriend sent you a video! + Check out this video! + + + + + + + + + + andyland74sFriend + + http://gdata.youtube.com/feeds/api/users/andyland74sFriend + + + + Learning the ABCs + + A great method for teaching kids the alphabet. + + alphabet, teaching, children + + + Education + + + + + + + + + + + + + + + Check out this video! + + \ No newline at end of file diff --git a/zend/tests/Zend/Gdata/YouTube/_files/InboxFeedDataSampleV2.xml b/zend/tests/Zend/Gdata/YouTube/_files/InboxFeedDataSampleV2.xml new file mode 100755 index 0000000..57f0b47 --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/_files/InboxFeedDataSampleV2.xml @@ -0,0 +1,119 @@ + + + tag:youtube,2008:user:andyland74:inbox + 2008-07-21T17:54:30.236Z + + Inbox of andyland74 + http://www.youtube.com/img/pic_youtubelogo_123x63.gif + + + + + + + andyland74 + http://gdata.youtube.com/feeds/api/users/andyland74 + + YouTube data API + 1 + 1 + 25 + + tag:youtube,2008:user:andyland74:inbox:D_uaXzLRX1U + 2008-06-10T13:55:32.000-07:00 + 2008-06-10T13:55:32.000-07:00 + 2008-06-10T20:55:32.000Z + + + + andyland74sFriend sent you a video! + Check out this video! + + + + + + + + + + + andyland74sFriend + http://gdata.youtube.com/feeds/api/users/andyland74sFriend + + + Learning the ABCs + + A great method for teaching kids the alphabet. + + alphabet, teaching, children + + jXE6G9CYcJs + andyland74sFriend + + Education + + + + + + + + + + + + + + + + diff --git a/zend/tests/Zend/Gdata/YouTube/_files/PlaylistListEntryDataSample1.xml b/zend/tests/Zend/Gdata/YouTube/_files/PlaylistListEntryDataSample1.xml new file mode 100644 index 0000000..2beed6c --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/_files/PlaylistListEntryDataSample1.xml @@ -0,0 +1,30 @@ + + + + http://gdata.youtube.com/feeds/users/testuser/playlists/46A2F8C9B36B6FE7 + 2007-01-29T22:42:12.000-08:00 + 2007-09-20T13:42:19.000-07:00 + + + YouTube Musicians + Music from talented people on YouTube. + + + + + testuser + http://gdata.youtube.com/feeds/users/testuser + + Music from talented people on YouTube. + + diff --git a/zend/tests/Zend/Gdata/YouTube/_files/PlaylistListEntryDataSampleV2.xml b/zend/tests/Zend/Gdata/YouTube/_files/PlaylistListEntryDataSampleV2.xml new file mode 100644 index 0000000..44cae2d --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/_files/PlaylistListEntryDataSampleV2.xml @@ -0,0 +1,16 @@ + + +tag:youtube.com,2008:user:googledevelopers:playlist:8E2186857EE27746 +2007-08-23T21:48:43.000Z +2008-12-10T09:56:03.000Z + +Non-google Interviews +This playlist contains interviews with people outside of Google. + + + + +googledevelopershttp://gdata.youtube.com/feeds/api/users/googledevelopers +8E2186857EE27746 +1 + \ No newline at end of file diff --git a/zend/tests/Zend/Gdata/YouTube/_files/PlaylistListFeedDataSample1.xml b/zend/tests/Zend/Gdata/YouTube/_files/PlaylistListFeedDataSample1.xml new file mode 100644 index 0000000..e18908e --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/_files/PlaylistListFeedDataSample1.xml @@ -0,0 +1,79 @@ + + + http://gdata.youtube.com/feeds/users/testuser/playlists + 2007-09-20T20:59:47.530Z + + testuser's Playlists + http://www.youtube.com/img/pic_youtubelogo_123x63.gif + + + + + + testuser + http://gdata.youtube.com/feeds/users/testuser + + YouTube + data API + 2 + 1 + 25 + + + http://gdata.youtube.com/feeds/users/testuser/playlists/A0F668D93B388F99 + 2007-01-17T14:13:22.000-08:00 + 2007-02-04T21:56:42.000-08:00 + + Korean/Chinese Playlist + Testing characters + + + + + testuser + http://gdata.youtube.com/feeds/users/testuser + + Testing characters + + + + + http://gdata.youtube.com/feeds/users/testuser/playlists/46A2F8C9B36B6FE7 + 2007-01-29T22:42:12.000-08:00 + 2007-09-20T13:42:19.000-07:00 + + + YouTube Musicians + Music from talented people on YouTube. + + + + + testuser + http://gdata.youtube.com/feeds/users/testuser + + Music from talented people on YouTube. + + + diff --git a/zend/tests/Zend/Gdata/YouTube/_files/PlaylistListFeedDataSampleV2.xml b/zend/tests/Zend/Gdata/YouTube/_files/PlaylistListFeedDataSampleV2.xml new file mode 100644 index 0000000..3a0d148 --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/_files/PlaylistListFeedDataSampleV2.xml @@ -0,0 +1,553 @@ + + + tag:youtube.com,2008:user:GoogleDevelopers:playlists + 2008-12-10T09:56:03.000Z + + Playlists of GoogleDevelopers + http://www.youtube.com/img/pic_youtubelogo_123x63.gif + + + + + + + + + GoogleDevelopers + http://gdata.youtube.com/feeds/api/users/googledevelopers + + YouTube data API + 70 +1 + 25 + + tag:youtube.com,2008:user:GoogleDevelopers:playlist:8E2186857EE27746 + 2007-08-23T21:48:43.000Z + 2008-12-10T09:56:03.000Z + + Non-google Interviews + This playlist contains interviews with people outside of Google. + + + + + +GoogleDevelopers +http://gdata.youtube.com/feeds/api/users/googledevelopers + + 8E2186857EE27746 + 1 + + + tag:youtube.com,2008:user:GoogleDevelopers:playlist:4AE5C0D23C2EB82D + 2007-08-23T21:50:19.000Z + 2008-12-11T14:04:33.000Z + + + + From Google Engineers + These videos are interviews straight from the horses mouth... the Google teams themselves. + + + + + +GoogleDevelopers +http://gdata.youtube.com/feeds/api/users/googledevelopers + + 4AE5C0D23C2EB82D + 5 + + + tag:youtube.com,2008:user:GoogleDevelopers:playlist:2C63610CE65A92B9 + 2007-08-28T16:11:35.000Z + 2008-12-12T18:47:53.000Z + + + + + Google Code For Educators + Videos from Google Code For Educators + + + + + +GoogleDevelopers +http://gdata.youtube.com/feeds/api/users/googledevelopers + + 2C63610CE65A92B9 + 5 + + + tag:youtube.com,2008:user:GoogleDevelopers:playlist:D9740C0183D07BE6 + 2007-08-30T00:03:01.000Z + 2008-12-08T21:49:25.000Z + + + + + Gears + All videos related to Gears + + + + + +GoogleDevelopers +http://gdata.youtube.com/feeds/api/users/googledevelopers + + D9740C0183D07BE6 + 10 + + + tag:youtube.com,2008:user:GoogleDevelopers:playlist:3A74996A44A8FA83 + 2007-10-12T22:26:05.000Z + 2008-12-12T18:48:33.000Z + + + + +Google Summer of Code +The Google Summer of Code is an annual program in which Google awards stipends to students who successfully complete a free software / open-source coding project during the summer. This playlist contains videos that touch on the Summer of Code. + + + + + +GoogleDevelopers +http://gdata.youtube.com/feeds/api/users/googledevelopers + +3A74996A44A8FA83 +2 + + +tag:youtube.com,2008:user:GoogleDevelopers:playlist:0559F3902CC876AE +2007-10-15T22:04:22.000Z +2008-12-10T11:49:44.000Z + + + + + +Google Mashup Editor +Videos related to the Google Mashup Editor + + + + + +GoogleDevelopers +http://gdata.youtube.com/feeds/api/users/googledevelopers + +0559F3902CC876AE +2 + + +tag:youtube.com,2008:user:GoogleDevelopers:playlist:327240CFB48BEC5D +2007-10-15T22:16:04.000Z +2008-12-07T14:19:41.000Z + + + + + +Google Gadgets +Content on all types of gadgets (desktop, igoogle, and embedable!) + + + + + +GoogleDevelopers +http://gdata.youtube.com/feeds/api/users/googledevelopers + +327240CFB48BEC5D +4 + + +tag:youtube.com,2008:user:GoogleDevelopers:playlist:EC7C82F4E9ACC351 +2007-10-15T22:17:03.000Z +2008-12-10T14:18:17.000Z + + + + + + +Google Maps and Earth +All things Geo + + + + + +GoogleDevelopers +http://gdata.youtube.com/feeds/api/users/googledevelopers + +EC7C82F4E9ACC351 +16 + + +tag:youtube.com,2008:user:GoogleDevelopers:playlist:968FABA11F2EDEA1 +2007-10-15T22:18:00.000Z +2008-12-04T21:40:22.000Z + + + + + + +Google Web Toolkit +Content on the Google Web Toolkit + + + + + +GoogleDevelopers +http://gdata.youtube.com/feeds/api/users/googledevelopers + +968FABA11F2EDEA1 +34 + + +tag:youtube.com,2008:user:GoogleDevelopers:playlist:E6DE6EC9A373AF57 +2007-10-15T22:20:18.000Z +2008-12-12T16:53:20.000Z + + + + + + +Google Data APIs +All things related to Google Data APIs + + + + + +GoogleDevelopers +http://gdata.youtube.com/feeds/api/users/googledevelopers + +E6DE6EC9A373AF57 +24 + + +tag:youtube.com,2008:user:GoogleDevelopers:playlist:CCAE880913CAFE9B +2007-10-15T22:24:17.000Z +2008-12-12T19:55:04.000Z + + + + + +AdSense APIs +Content related to our ad APIs + + + + + +GoogleDevelopers +http://gdata.youtube.com/feeds/api/users/googledevelopers + +CCAE880913CAFE9B +1 + + +tag:youtube.com,2008:user:GoogleDevelopers:playlist:72CF07D200AA2AFA +2007-10-17T18:36:51.000Z +2008-12-09T02:59:12.000Z + + + +YouTube +Content related to YouTube APIs + + + + + +GoogleDevelopers +http://gdata.youtube.com/feeds/api/users/googledevelopers + +72CF07D200AA2AFA +18 + + +tag:youtube.com,2008:user:GoogleDevelopers:playlist:BC2ECF70FE499266 +2007-10-17T18:38:13.000Z +2008-12-10T09:56:12.000Z + + +Open Source at Google +Content related to open source. + + + + + +GoogleDevelopers +http://gdata.youtube.com/feeds/api/users/googledevelopers + +BC2ECF70FE499266 +8 + + +tag:youtube.com,2008:user:GoogleDevelopers:playlist:79B6967AC7A09B42 +2007-10-17T18:40:07.000Z +2008-11-30T15:48:20.000Z + + + +Google Search +Content released to Search APIs + + + + + +GoogleDevelopers +http://gdata.youtube.com/feeds/api/users/googledevelopers + +79B6967AC7A09B42 +2 + + +tag:youtube.com,2008:user:GoogleDevelopers:playlist:DA15B72EA2633F26 +2007-10-17T18:41:25.000Z +2008-12-11T14:37:00.000Z + + + +Google AJAX APIs +Content related to the various Ajax APIs + + + + + +GoogleDevelopers +http://gdata.youtube.com/feeds/api/users/googledevelopers + +DA15B72EA2633F26 +5 + + +tag:youtube.com,2008:user:GoogleDevelopers:playlist:18E9C145F20ED640 +2007-10-17T18:42:21.000Z +2008-12-12T18:47:55.000Z + + +Google Mobile +Content related to mobile development and Google + + + + + +GoogleDevelopers +http://gdata.youtube.com/feeds/api/users/googledevelopers + +18E9C145F20ED640 +1 + + +tag:youtube.com,2008:user:GoogleDevelopers:playlist:74D78B3235613DCB +2007-10-17T18:44:32.000Z +2008-12-12T18:48:36.000Z + + +Gmail +Content related to the Gmail product. + + + + + +GoogleDevelopers +http://gdata.youtube.com/feeds/api/users/googledevelopers + +74D78B3235613DCB +1 + + +tag:youtube.com,2008:user:GoogleDevelopers:playlist:7F19205748B0A698 +2007-10-19T18:45:08.000Z +2008-12-12T18:48:40.000Z + + + + +Google Base +Content related to the Google Base product + + + + + +GoogleDevelopers +http://gdata.youtube.com/feeds/api/users/googledevelopers + +7F19205748B0A698 +2 + + +tag:youtube.com,2008:user:GoogleDevelopers:playlist:59127FA00275EB77 +2007-10-29T19:26:57.000Z +2008-12-03T17:30:36.000Z + + +FeedBurner +FeedBurner API videos + + + + + +GoogleDevelopers +http://gdata.youtube.com/feeds/api/users/googledevelopers + +59127FA00275EB77 +1 + + +tag:youtube.com,2008:user:GoogleDevelopers:playlist:A31A1098FDE85663 +2007-10-29T23:52:25.000Z +2008-12-11T09:55:28.000Z + + +Google Apps +Google Apps User Videos + + + + + +GoogleDevelopers +http://gdata.youtube.com/feeds/api/users/googledevelopers + +A31A1098FDE85663 +3 + + +tag:youtube.com,2008:user:GoogleDevelopers:playlist:CF46C525B4C90C17 +2007-10-30T01:19:18.000Z +2008-12-04T21:39:22.000Z + + + +Google AJAX Feed API +AJAX Feed API + + + + + +GoogleDevelopers +http://gdata.youtube.com/feeds/api/users/googledevelopers + +CF46C525B4C90C17 +2 + + +tag:youtube.com,2008:user:GoogleDevelopers:playlist:5F0F046F77B7B62A +2007-11-02T15:29:38.000Z +2008-12-12T12:58:06.000Z + + +OpenSocial +Tutorials on how to build OpenSocial applications, videos from our Campfire One launch as well as interviews with some of our partners: Slide, Ning, Hi5, Plaxo, Flixster, iLike, Salesforce, LinkedIn, RockYou and more. + + + + + +GoogleDevelopers +http://gdata.youtube.com/feeds/api/users/googledevelopers + +5F0F046F77B7B62A +48 + + +tag:youtube.com,2008:user:GoogleDevelopers:playlist:586D322B5E2764CF +2007-11-13T19:41:21.000Z +2008-12-12T18:57:21.000Z + + + + + + + + +Android +Demos and tutorials about the new Android platform. + + + + + +GoogleDevelopers +http://gdata.youtube.com/feeds/api/users/googledevelopers + +586D322B5E2764CF +32 + + +tag:youtube.com,2008:user:GoogleDevelopers:playlist:8B1C566EDD2DCB77 +2007-11-28T21:45:37.000Z +2008-12-12T18:47:52.000Z + + + + + + + + + + + + + + + + +OpenSocial Interviews +We brought in a bunch of developers and partners to talk about OpenSocial and demo their stuff :) Big Thanks to Shelfari, E-junkie, Ning, Flixster, Plaxo, iLike, FotoFlexer, LinkedIn, Hi5, Qloud, Bleacher Report, Slide, RockYou, Oberon, Chronus, and Hungry Machine! + + + + + +GoogleDevelopers +http://gdata.youtube.com/feeds/api/users/googledevelopers + +8B1C566EDD2DCB77 +16 + + +tag:youtube.com,2008:user:GoogleDevelopers:playlist:8F1A9670BA923DF3 +2007-12-04T18:07:07.000Z +2008-12-12T18:48:36.000Z + + + + +Google Mac +Content related to Google Mac development, including the Google Mac Playground. + + + + + +GoogleDevelopers +http://gdata.youtube.com/feeds/api/users/googledevelopers + +8F1A9670BA923DF3 +3 + + \ No newline at end of file diff --git a/zend/tests/Zend/Gdata/YouTube/_files/PlaylistListVideoEntryDataSampleV2.xml b/zend/tests/Zend/Gdata/YouTube/_files/PlaylistListVideoEntryDataSampleV2.xml new file mode 100644 index 0000000..de65064 --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/_files/PlaylistListVideoEntryDataSampleV2.xml @@ -0,0 +1,66 @@ + + + tag:youtube.com,2008:playlist:CCAE880913CAFE9B + 2008-12-12T19:55:04.000Z + + + + + + AdSense APIs + Content related to our ad APIs + http://www.youtube.com/img/pic_youtubelogo_123x63.gif + + + + + GoogleDevelopershttp://gdata.youtube.com/feeds/api/users/googledevelopers + YouTube data API + 1 + 1 + 25 + CCAE880913CAFE9B + + AdSense APIs + Content related to our ad APIs + + + + tag:youtube.com,2008:playlist:CCAE880913CAFE9B:C63BCCC84EBE64BD + 2008-12-12T19:56:19.635Z + + + + + Google Developer Day - Brazil - AdSense + + + + + + GoogleDevelopershttp://gdata.youtube.com/feeds/api/users/googledevelopers + + Google Developer Day - Brazil - AdSense + Roberto Grosman - O Google AdSense oferece aos editores de sites, de qualquer tamanho, uma forma rápida e fácil de exibir anúncios Google nas suas páginas de conteúdo e ganhar dinheiro. Os anúncios são relevantes, por que estão relacionados àquilo que os usuários procuram no seu site ou combinam com as características e interesses dos visitantes que o seu conteúdo normalmente atrai. Você pode monetizar e otimizar as suas páginas de conteúdo ao mesmo tempo. Esta palestra tem como objetivo apresentar a ferramenta AdSense e suas vantagens. + adsense, google + + RTQDqPtErB0 + 2007-06-01T14:33:00.000Z + + GoogleDeveloperDay + Howto + + + + + + + + + + + + + 1 + + \ No newline at end of file diff --git a/zend/tests/Zend/Gdata/YouTube/_files/PlaylistVideoEntryDataSample1.xml b/zend/tests/Zend/Gdata/YouTube/_files/PlaylistVideoEntryDataSample1.xml new file mode 100644 index 0000000..5449374 --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/_files/PlaylistVideoEntryDataSample1.xml @@ -0,0 +1,109 @@ + + + + http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/efb9b9a8dd4c2b21 + 2007-09-20T22:56:57.061Z + + "Crazy (Gnarles Barkley)" - Acoustic Cover + <div style="color: #000000;font-family: + Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; + width: 555px;"><table cellspacing="0" cellpadding="0" + border="0"><tbody><tr><td width="140" + valign="top" rowspan="2"><div style="border: 1px solid + #999999; margin: 0px 10px 5px 0px;"><a + href="http://www.youtube.com/watch?v=UMFI1hdm96E"><img + alt="" + src="http://img.youtube.com/vi/UMFI1hdm96E/2.jpg"></a></div></td> + <td width="256" valign="top"><div style="font-size: + 12px; font-weight: bold;"><a style="font-size: 15px; + font-weight: bold; font-decoration: none;" + href="http://www.youtube.com/watch?v=UMFI1hdm96E">&quot;Crazy + (Gnarles Barkley)&quot; - Acoustic Cover</a> + <br></div> <div style="font-size: 12px; margin: + 3px 0px;"><span>Gnarles Barkley acoustic cover + http://www.myspace.com/davidchoimusic</span></div></td> + <td style="font-size: 11px; line-height: 1.4em; + padding-left: 20px; padding-top: 1px;" width="146" + valign="top"><div><span style="color: #666666; + font-size: 11px;">From:</span> <a + href="http://www.youtube.com/profile?user=davidchoimusic">davidchoimusic</a></div> + <div><span style="color: #666666; font-size: + 11px;">Views:</span> 113321</div> <div + style="white-space: nowrap;text-align: left"><img + style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_half_11x11.gif"></div> + <div style="font-size: 11px;">1005 <span style="color: + #666666; font-size: + 11px;">ratings</span></div></td></tr> + <tr><td><span style="color: #666666; font-size: + 11px;">Time:</span> <span style="color: #000000; + font-size: 11px; font-weight: + bold;">04:15</span></td> <td + style="font-size: 11px; padding-left: 20px;"><span + style="color: #666666; font-size: 11px;">More + in</span> <a + href="http://www.youtube.com/categories_portal?c=10">Music</a></td></tr></tbody></table></div> + + + + + + + davidchoimusic + + http://gdata.youtube.com/feeds/users/davidchoimusic + + + "Crazy (Gnarles Barkley)" - Acoustic Cover + Gnarles Barkley acoustic cover http://www.myspace.com/davidchoimusic + music, singing, gnarls, barkley, acoustic, cover + + + Music + + + + + + + + + + + + + 1 + diff --git a/zend/tests/Zend/Gdata/YouTube/_files/PlaylistVideoEntryDataSampleV2.xml b/zend/tests/Zend/Gdata/YouTube/_files/PlaylistVideoEntryDataSampleV2.xml new file mode 100644 index 0000000..aeb880c --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/_files/PlaylistVideoEntryDataSampleV2.xml @@ -0,0 +1,89 @@ + + + +tag:youtube.com,2008:playlist:4E6265CEF8BAA793:579617126485907C +2008-12-16T18:32:03.434Z + + + + + + + + +Paris Police Find Dynamite in Department Store + + + + + + + +zfgdata +http://gdata.youtube.com/feeds/api/users/zfgdata + + +Paris Police Find +French police found. +department, dynamite, explosives, find + +Lur391T5ApY +2008-12-16T17:01:42.000Z + +AssociatedPress + +News + + + + + + + + + + +New York, NY +2008-12-16 + + + +1 + \ No newline at end of file diff --git a/zend/tests/Zend/Gdata/YouTube/_files/PlaylistVideoFeedDataSample1.xml b/zend/tests/Zend/Gdata/YouTube/_files/PlaylistVideoFeedDataSample1.xml new file mode 100644 index 0000000..3c47b3e --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/_files/PlaylistVideoFeedDataSample1.xml @@ -0,0 +1,1495 @@ + + + + http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7 + 2007-09-20T13:42:19.000-07:00 + + + YouTube Musicians + Music from talented people on YouTube. + + http://www.youtube.com/img/pic_youtubelogo_123x63.gif + + + + + testuser + http://gdata.youtube.com/feeds/users/testuser + + YouTube + data API + 13 + 1 + 25 + + + http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/efb9b9a8dd4c2b21 + 2007-09-20T22:56:57.061Z + + "Crazy (Gnarles Barkley)" - Acoustic + Cover + <div style="color: #000000;font-family: + Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; + width: 555px;"><table cellspacing="0" cellpadding="0" + border="0"><tbody><tr><td width="140" + valign="top" rowspan="2"><div style="border: 1px solid + #999999; margin: 0px 10px 5px 0px;"><a + href="http://www.youtube.com/watch?v=UMFI1hdm96E"><img + alt="" + src="http://img.youtube.com/vi/UMFI1hdm96E/2.jpg"></a></div></td> + <td width="256" valign="top"><div style="font-size: + 12px; font-weight: bold;"><a style="font-size: 15px; + font-weight: bold; font-decoration: none;" + href="http://www.youtube.com/watch?v=UMFI1hdm96E">&quot;Crazy + (Gnarles Barkley)&quot; - Acoustic Cover</a> + <br></div> <div style="font-size: 12px; margin: + 3px 0px;"><span>Gnarles Barkley acoustic cover + http://www.myspace.com/davidchoimusic</span></div></td> + <td style="font-size: 11px; line-height: 1.4em; + padding-left: 20px; padding-top: 1px;" width="146" + valign="top"><div><span style="color: #666666; + font-size: 11px;">From:</span> <a + href="http://www.youtube.com/profile?user=davidchoimusic">davidchoimusic</a></div> + <div><span style="color: #666666; font-size: + 11px;">Views:</span> 113321</div> <div + style="white-space: nowrap;text-align: left"><img + style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_half_11x11.gif"></div> + <div style="font-size: 11px;">1005 <span style="color: + #666666; font-size: + 11px;">ratings</span></div></td></tr> + <tr><td><span style="color: #666666; font-size: + 11px;">Time:</span> <span style="color: #000000; + font-size: 11px; font-weight: + bold;">04:15</span></td> <td + style="font-size: 11px; padding-left: 20px;"><span + style="color: #666666; font-size: 11px;">More + in</span> <a + href="http://www.youtube.com/categories_portal?c=10">Music</a></td></tr></tbody></table></div> + + + + + + + davidchoimusic + + http://gdata.youtube.com/feeds/users/davidchoimusic + + + "Crazy (Gnarles Barkley)" - + Acoustic Cover + Gnarles Barkley acoustic + cover + http://www.myspace.com/davidchoimusic + music, singing, gnarls, barkley, acoustic, + cover + + + Music + + + + + + + + + + + + + 1 + + + + http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/c9d8e923d586c337 + 2007-09-20T22:56:57.061Z + + gnals barkley + <div style="color: #000000;font-family: + Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; + width: 555px;"><table cellspacing="0" cellpadding="0" + border="0"><tbody><tr><td width="140" + valign="top" rowspan="2"><div style="border: 1px solid + #999999; margin: 0px 10px 5px 0px;"><a + href="http://www.youtube.com/watch?v=waQuw1P7VU8"><img + alt="" + src="http://img.youtube.com/vi/waQuw1P7VU8/2.jpg"></a></div></td> + <td width="256" valign="top"><div style="font-size: + 12px; font-weight: bold;"><a style="font-size: 15px; + font-weight: bold; font-decoration: none;" + href="http://www.youtube.com/watch?v=waQuw1P7VU8">gnals + barkley</a> <br></div> <div + style="font-size: 12px; margin: 3px 0px;"><span>Me + singing Crazy by gnarls + barkley</span></div></td> <td + style="font-size: 11px; line-height: 1.4em; padding-left: 20px; + padding-top: 1px;" width="146" + valign="top"><div><span style="color: #666666; + font-size: 11px;">From:</span> <a + href="http://www.youtube.com/profile?user=esmeedenters">esmeedenters</a></div> + <div><span style="color: #666666; font-size: + 11px;">Views:</span> 219224</div> <div + style="white-space: nowrap;text-align: left"><img + style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_half_11x11.gif"></div> + <div style="font-size: 11px;">1753 <span style="color: + #666666; font-size: + 11px;">ratings</span></div></td></tr> + <tr><td><span style="color: #666666; font-size: + 11px;">Time:</span> <span style="color: #000000; + font-size: 11px; font-weight: + bold;">02:59</span></td> <td + style="font-size: 11px; padding-left: 20px;"><span + style="color: #666666; font-size: 11px;">More + in</span> <a + href="http://www.youtube.com/categories_portal?c=10">Music</a></td></tr></tbody></table></div> + + + + + + + esmeedenters + http://gdata.youtube.com/feeds/users/esmeedenters + + + gnals barkley + Me singing Crazy by gnarls + barkley + music, singing, gnarls, + barkley + + + Music + + + + + + + + + + + + + 2 + + + + http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/8574b0cf3b5045b9 + 2007-09-20T22:56:57.061Z + + Can't take my eyes off of you + <div style="color: #000000;font-family: + Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; + width: 555px;"><table cellspacing="0" cellpadding="0" + border="0"><tbody><tr><td width="140" + valign="top" rowspan="2"><div style="border: 1px solid + #999999; margin: 0px 10px 5px 0px;"><a + href="http://www.youtube.com/watch?v=xjidkN6kleU"><img + alt="" + src="http://img.youtube.com/vi/xjidkN6kleU/2.jpg"></a></div></td> + <td width="256" valign="top"><div style="font-size: + 12px; font-weight: bold;"><a style="font-size: 15px; + font-weight: bold; font-decoration: none;" + href="http://www.youtube.com/watch?v=xjidkN6kleU">Can&#39;t + take my eyes off of you</a> <br></div> + <div style="font-size: 12px; margin: 3px + 0px;"><span>Lauryn Hill Cover - Can&#39;t take my + eyes off of you. my way--- a good + way?</span></div></td> <td + style="font-size: 11px; line-height: 1.4em; padding-left: 20px; + padding-top: 1px;" width="146" + valign="top"><div><span style="color: #666666; + font-size: 11px;">From:</span> <a + href="http://www.youtube.com/profile?user=munilicious">munilicious</a></div> + <div><span style="color: #666666; font-size: + 11px;">Views:</span> 12968</div> <div + style="white-space: nowrap;text-align: left"><img + style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_half_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_empty_11x11.gif"></div> + <div style="font-size: 11px;">34 <span style="color: + #666666; font-size: + 11px;">ratings</span></div></td></tr> + <tr><td><span style="color: #666666; font-size: + 11px;">Time:</span> <span style="color: #000000; + font-size: 11px; font-weight: + bold;">02:18</span></td> <td + style="font-size: 11px; padding-left: 20px;"><span + style="color: #666666; font-size: 11px;">More + in</span> <a + href="http://www.youtube.com/categories_portal?c=10">Music</a></td></tr></tbody></table></div> + + + + + + + munilicious + http://gdata.youtube.com/feeds/users/munilicious + + + Can't take my eyes off of + you + Lauryn Hill Cover - Can't + take my eyes off of you. my way--- a good + way? + Lauryn, Hill, Can't, take, my, eyes, off, of, + you + + + Music + + + + + + + + + + + + + 3 + + + + http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/6d42a26a97a53c78 + 2007-09-20T22:56:57.062Z + + hanging by a moment (cover) + <div style="color: #000000;font-family: + Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; + width: 555px;"><table cellspacing="0" cellpadding="0" + border="0"><tbody><tr><td width="140" + valign="top" rowspan="2"><div style="border: 1px solid + #999999; margin: 0px 10px 5px 0px;"><a + href="http://www.youtube.com/watch?v=MOxExzhhW0c"><img + alt="" + src="http://img.youtube.com/vi/MOxExzhhW0c/2.jpg"></a></div></td> + <td width="256" valign="top"><div style="font-size: + 12px; font-weight: bold;"><a style="font-size: 15px; + font-weight: bold; font-decoration: none;" + href="http://www.youtube.com/watch?v=MOxExzhhW0c">hanging by + a moment (cover)</a> <br></div> <div + style="font-size: 12px; margin: 3px 0px;"><span>my + sister(guitar) and me jamming + lifehouse</span></div></td> <td + style="font-size: 11px; line-height: 1.4em; padding-left: 20px; + padding-top: 1px;" width="146" + valign="top"><div><span style="color: #666666; + font-size: 11px;">From:</span> <a + href="http://www.youtube.com/profile?user=lauwarm">lauwarm</a></div> + <div><span style="color: #666666; font-size: + 11px;">Views:</span> 7186</div> <div + style="white-space: nowrap;text-align: left"><img + style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_empty_11x11.gif"></div> + <div style="font-size: 11px;">24 <span style="color: + #666666; font-size: + 11px;">ratings</span></div></td></tr> + <tr><td><span style="color: #666666; font-size: + 11px;">Time:</span> <span style="color: #000000; + font-size: 11px; font-weight: + bold;">00:30</span></td> <td + style="font-size: 11px; padding-left: 20px;"><span + style="color: #666666; font-size: 11px;">More + in</span> <a + href="http://www.youtube.com/categories_portal?c=10">Music</a></td></tr></tbody></table></div> + + + + + + + lauwarm + http://gdata.youtube.com/feeds/users/lauwarm + + + hanging by a moment + (cover) + my sister(guitar) and me + jamming lifehouse + lifehouse, hanging, by, moment, cover, + acoustic + + + Music + + + + + + + + + + + + + 4 + + + + http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/f78779d50b24db79 + 2007-09-20T22:56:57.062Z + + I'LL BE-MEN'S OCTET (ACAPELLA) + <div style="color: #000000;font-family: + Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; + width: 555px;"><table cellspacing="0" cellpadding="0" + border="0"><tbody><tr><td width="140" + valign="top" rowspan="2"><div style="border: 1px solid + #999999; margin: 0px 10px 5px 0px;"><a + href="http://www.youtube.com/watch?v=_KHqQc1nn_0"><img + alt="" + src="http://img.youtube.com/vi/_KHqQc1nn_0/2.jpg"></a></div></td> + <td width="256" valign="top"><div style="font-size: + 12px; font-weight: bold;"><a style="font-size: 15px; + font-weight: bold; font-decoration: none;" + href="http://www.youtube.com/watch?v=_KHqQc1nn_0">I&#39;LL + BE-MEN&#39;S OCTET (ACAPELLA)</a> + <br></div> <div style="font-size: 12px; margin: + 3px 0px;"><span>UC BERKELEY&#39;S MEN&#39;S + OCTET (ACAPELLA)</span></div></td> <td + style="font-size: 11px; line-height: 1.4em; padding-left: 20px; + padding-top: 1px;" width="146" + valign="top"><div><span style="color: #666666; + font-size: 11px;">From:</span> <a + href="http://www.youtube.com/profile?user=boredom">boredom</a></div> + <div><span style="color: #666666; font-size: + 11px;">Views:</span> 46416</div> <div + style="white-space: nowrap;text-align: left"><img + style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_half_11x11.gif"></div> + <div style="font-size: 11px;">116 <span style="color: + #666666; font-size: + 11px;">ratings</span></div></td></tr> + <tr><td><span style="color: #666666; font-size: + 11px;">Time:</span> <span style="color: #000000; + font-size: 11px; font-weight: + bold;">04:06</span></td> <td + style="font-size: 11px; padding-left: 20px;"><span + style="color: #666666; font-size: 11px;">More + in</span> <a + href="http://www.youtube.com/categories_portal?c=10">Music</a></td></tr></tbody></table></div> + + + + + + + boredom + http://gdata.youtube.com/feeds/users/boredom + + + I'LL BE-MEN'S OCTET + (ACAPELLA) + UC BERKELEY'S MEN'S OCTET + (ACAPELLA) + ACAPELLA, berkeley, octet + + + Music + + + + + + + + + + + + + 5 + + + + http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/d5fead6a034eb51c + 2007-09-20T22:56:57.062Z + + Kiss the Girl + <div style="color: #000000;font-family: + Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; + width: 555px;"><table cellspacing="0" cellpadding="0" + border="0"><tbody><tr><td width="140" + valign="top" rowspan="2"><div style="border: 1px solid + #999999; margin: 0px 10px 5px 0px;"><a + href="http://www.youtube.com/watch?v=EV1_qPBuDt8"><img + alt="" + src="http://img.youtube.com/vi/EV1_qPBuDt8/2.jpg"></a></div></td> + <td width="256" valign="top"><div style="font-size: + 12px; font-weight: bold;"><a style="font-size: 15px; + font-weight: bold; font-decoration: none;" + href="http://www.youtube.com/watch?v=EV1_qPBuDt8">Kiss the + Girl</a> <br></div> <div style="font-size: + 12px; margin: 3px 0px;"><span>Alma College&#39;s + Scots on the Rocks sing their acapella rendition of Kiss the + Girl from the Little + Mermaid</span></div></td> <td + style="font-size: 11px; line-height: 1.4em; padding-left: 20px; + padding-top: 1px;" width="146" + valign="top"><div><span style="color: #666666; + font-size: 11px;">From:</span> <a + href="http://www.youtube.com/profile?user=cmorris">cmorris</a></div> + <div><span style="color: #666666; font-size: + 11px;">Views:</span> 37218</div> <div + style="white-space: nowrap;text-align: left"><img + style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_half_11x11.gif"></div> + <div style="font-size: 11px;">312 <span style="color: + #666666; font-size: + 11px;">ratings</span></div></td></tr> + <tr><td><span style="color: #666666; font-size: + 11px;">Time:</span> <span style="color: #000000; + font-size: 11px; font-weight: + bold;">03:16</span></td> <td + style="font-size: 11px; padding-left: 20px;"><span + style="color: #666666; font-size: 11px;">More + in</span> <a + href="http://www.youtube.com/categories_portal?c=10">Music</a></td></tr></tbody></table></div> + + + + + + + cmorris + http://gdata.youtube.com/feeds/users/cmorris + + + Kiss the Girl + Alma College's Scots on the + Rocks sing their acapella rendition of Kiss the Girl from the + Little Mermaid + acapella + + + Music + + + + + + + + + + + + + 6 + + + + http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/618d7dba982c0d7e + 2007-09-20T22:56:57.063Z + + Oasis "Wonderwall" Acoustic Cover by + ortoPilot + <div style="color: #000000;font-family: + Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; + width: 555px;"><table cellspacing="0" cellpadding="0" + border="0"><tbody><tr><td width="140" + valign="top" rowspan="2"><div style="border: 1px solid + #999999; margin: 0px 10px 5px 0px;"><a + href="http://www.youtube.com/watch?v=t4EaHIpjTTY"><img + alt="" + src="http://img.youtube.com/vi/t4EaHIpjTTY/2.jpg"></a></div></td> + <td width="256" valign="top"><div style="font-size: + 12px; font-weight: bold;"><a style="font-size: 15px; + font-weight: bold; font-decoration: none;" + href="http://www.youtube.com/watch?v=t4EaHIpjTTY">Oasis + &quot;Wonderwall&quot; Acoustic Cover by + ortoPilot</a> <br></div> <div + style="font-size: 12px; margin: 3px 0px;"><span>Oasis + &quot;Wonderwall&quot; Acoustic Cover by ortoPilot + acoustic version of wonderwall influenced by RYAN ADAMS mp3 + download and TABS @ www.ortoPilot.com enjoy! if you like this + vid, SUBSCRIBE to my vids, + cheers!</span></div></td> <td + style="font-size: 11px; line-height: 1.4em; padding-left: 20px; + padding-top: 1px;" width="146" + valign="top"><div><span style="color: #666666; + font-size: 11px;">From:</span> <a + href="http://www.youtube.com/profile?user=ortoPilot">ortoPilot</a></div> + <div><span style="color: #666666; font-size: + 11px;">Views:</span> 92395</div> <div + style="white-space: nowrap;text-align: left"><img + style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_half_11x11.gif"></div> + <div style="font-size: 11px;">521 <span style="color: + #666666; font-size: + 11px;">ratings</span></div></td></tr> + <tr><td><span style="color: #666666; font-size: + 11px;">Time:</span> <span style="color: #000000; + font-size: 11px; font-weight: + bold;">04:01</span></td> <td + style="font-size: 11px; padding-left: 20px;"><span + style="color: #666666; font-size: 11px;">More + in</span> <a + href="http://www.youtube.com/categories_portal?c=10">Music</a></td></tr></tbody></table></div> + + + + + + + ortoPilot + http://gdata.youtube.com/feeds/users/ortoPilot + + + Oasis "Wonderwall" Acoustic Cover + by ortoPilot + Oasis "Wonderwall" Acoustic + Cover by ortoPilot acoustic version of wonderwall influenced + by RYAN ADAMS mp3 download and TABS @ www.ortoPilot.com + enjoy! if you like this vid, SUBSCRIBE to my vids, + cheers! + acoustic, guitar, cover, oasis, wonderwall, + ortopilot, matt, hutchison, live, tab, tabs, + tutorial + + + Music + + + + + + + + + + + + + 7 + + + + http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/4bfaab0ffb00dfdd + 2007-09-20T22:56:57.063Z + + Pancakes! + <div style="color: #000000;font-family: + Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; + width: 555px;"><table cellspacing="0" cellpadding="0" + border="0"><tbody><tr><td width="140" + valign="top" rowspan="2"><div style="border: 1px solid + #999999; margin: 0px 10px 5px 0px;"><a + href="http://www.youtube.com/watch?v=PnCVZozHTG8"><img + alt="" + src="http://img.youtube.com/vi/PnCVZozHTG8/2.jpg"></a></div></td> + <td width="256" valign="top"><div style="font-size: + 12px; font-weight: bold;"><a style="font-size: 15px; + font-weight: bold; font-decoration: none;" + href="http://www.youtube.com/watch?v=PnCVZozHTG8">Pancakes!</a> + <br></div> <div style="font-size: 12px; margin: + 3px 0px;"><span>A short music video about making + pancakes =) This video has been on ABC&#39;s &quot;Good + Morning America&quot; show, 16th August. + http://abcnews.go.com/Video/playerIndex?id=2318825 It has also + been aired on Fox news in America, Sky News, and Five News in + Britain and on ABC (Austrailain Broadcasting Company) in + Australia. I live in Scotland, these are British pancakes which + are like Crépes, to clear up the confusion. Lemon + and Sugar is very popular on pacakes here. It took over a week + to make this, it&#39;s the most heavily editied project I + have done yet, and it was not easy at all, but I have created + something that I&#39;m very proud of =) Song written, + performed and produced by me, video written, edited and filmed + by me. MP3 available on my website! James Provan Thanks to + Yukeh for the the voice that says &quot;GiR - it&#39;s + time for pancakes!&quot; at the + start.</span></div></td> <td + style="font-size: 11px; line-height: 1.4em; padding-left: 20px; + padding-top: 1px;" width="146" + valign="top"><div><span style="color: #666666; + font-size: 11px;">From:</span> <a + href="http://www.youtube.com/profile?user=GiR2007">GiR2007</a></div> + <div><span style="color: #666666; font-size: + 11px;">Views:</span> 2249048</div> <div + style="white-space: nowrap;text-align: left"><img + style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_half_11x11.gif"></div> + <div style="font-size: 11px;">17754 <span + style="color: #666666; font-size: + 11px;">ratings</span></div></td></tr> + <tr><td><span style="color: #666666; font-size: + 11px;">Time:</span> <span style="color: #000000; + font-size: 11px; font-weight: + bold;">02:22</span></td> <td + style="font-size: 11px; padding-left: 20px;"><span + style="color: #666666; font-size: 11px;">More + in</span> <a + href="http://www.youtube.com/categories_portal?c=1">Film + &amp; + Animation</a></td></tr></tbody></table></div> + + + + + + + GiR2007 + http://gdata.youtube.com/feeds/users/GiR2007 + + + Pancakes! + A short music video about + making pancakes =) This video has been on ABC's "Good Morning + America" show, 16th August. + http://abcnews.go.com/Video/playerIndex?id=2318825 It has + also been aired on Fox news in America, Sky News, and Five + News in Britain and on ABC (Austrailain Broadcasting Company) + in Australia. I live in Scotland, these are British pancakes + which are like Crépes, to clear up the confusion. + Lemon and Sugar is very popular on pacakes here. It took over + a week to make this, it's the most heavily editied project I + have done yet, and it was not easy at all, but I have created + something that I'm very proud of =) Song written, performed + and produced by me, video written, edited and filmed by me. + MP3 available on my website! James Provan Thanks to Yukeh for + the the voice that says "GiR - it's time for pancakes!" at + the start. + stop, motion, pancakes, GiR2007, food, tasty, + nutella, jam, maple, syrup, animation, GMA, good, morning, + america, goodmorning + + + Film + + + + + + + + + + + + + + 8 + + + + http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/46632a732cae0cbc + 2007-09-20T22:56:57.063Z + + Ana Free - Chained + <div style="color: #000000;font-family: + Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; + width: 555px;"><table cellspacing="0" cellpadding="0" + border="0"><tbody><tr><td width="140" + valign="top" rowspan="2"><div style="border: 1px solid + #999999; margin: 0px 10px 5px 0px;"><a + href="http://www.youtube.com/watch?v=_6ceUy9lVdM"><img + alt="" + src="http://img.youtube.com/vi/_6ceUy9lVdM/2.jpg"></a></div></td> + <td width="256" valign="top"><div style="font-size: + 12px; font-weight: bold;"><a style="font-size: 15px; + font-weight: bold; font-decoration: none;" + href="http://www.youtube.com/watch?v=_6ceUy9lVdM">Ana Free - + Chained</a> <br></div> <div + style="font-size: 12px; margin: 3px 0px;"><span>The + second upload of the day.. :) All is explained in the video, no + point in writing it here! Take care *** + Ana</span></div></td> <td + style="font-size: 11px; line-height: 1.4em; padding-left: 20px; + padding-top: 1px;" width="146" + valign="top"><div><span style="color: #666666; + font-size: 11px;">From:</span> <a + href="http://www.youtube.com/profile?user=anafree">anafree</a></div> + <div><span style="color: #666666; font-size: + 11px;">Views:</span> 688963</div> <div + style="white-space: nowrap;text-align: left"><img + style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_empty_11x11.gif"></div> + <div style="font-size: 11px;">4530 <span style="color: + #666666; font-size: + 11px;">ratings</span></div></td></tr> + <tr><td><span style="color: #666666; font-size: + 11px;">Time:</span> <span style="color: #000000; + font-size: 11px; font-weight: + bold;">03:11</span></td> <td + style="font-size: 11px; padding-left: 20px;"><span + style="color: #666666; font-size: 11px;">More + in</span> <a + href="http://www.youtube.com/categories_portal?c=10">Music</a></td></tr></tbody></table></div> + + + + + + + anafree + http://gdata.youtube.com/feeds/users/anafree + + + Ana Free - Chained + The second upload of the + day.. :) All is explained in the video, no point in writing + it here! Take care *** Ana + anafree, ana, free, chained, original, + acoustic, love + + + Music + + + + + + + + + + + + + 9 + + + + http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/e67d5bf916676e20 + 2007-09-20T22:56:57.064Z + + Ana Free (Bic Runga - Sway + <div style="color: #000000;font-family: + Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; + width: 555px;"><table cellspacing="0" cellpadding="0" + border="0"><tbody><tr><td width="140" + valign="top" rowspan="2"><div style="border: 1px solid + #999999; margin: 0px 10px 5px 0px;"><a + href="http://www.youtube.com/watch?v=ihQW-pWlkJw"><img + alt="" + src="http://img.youtube.com/vi/ihQW-pWlkJw/2.jpg"></a></div></td> + <td width="256" valign="top"><div style="font-size: + 12px; font-weight: bold;"><a style="font-size: 15px; + font-weight: bold; font-decoration: none;" + href="http://www.youtube.com/watch?v=ihQW-pWlkJw">Ana Free + (Bic Runga - Sway</a> <br></div> <div + style="font-size: 12px; margin: 3px 0px;"><span>This + is Sway by Bic Runga, difficult to sing and I guess to play + aswell..:) Hope you enjoy + it!</span></div></td> <td + style="font-size: 11px; line-height: 1.4em; padding-left: 20px; + padding-top: 1px;" width="146" + valign="top"><div><span style="color: #666666; + font-size: 11px;">From:</span> <a + href="http://www.youtube.com/profile?user=anafree">anafree</a></div> + <div><span style="color: #666666; font-size: + 11px;">Views:</span> 282936</div> <div + style="white-space: nowrap;text-align: left"><img + style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_half_11x11.gif"></div> + <div style="font-size: 11px;">2224 <span style="color: + #666666; font-size: + 11px;">ratings</span></div></td></tr> + <tr><td><span style="color: #666666; font-size: + 11px;">Time:</span> <span style="color: #000000; + font-size: 11px; font-weight: + bold;">03:24</span></td> <td + style="font-size: 11px; padding-left: 20px;"><span + style="color: #666666; font-size: 11px;">More + in</span> <a + href="http://www.youtube.com/categories_portal?c=10">Music</a></td></tr></tbody></table></div> + + + + + + + anafree + http://gdata.youtube.com/feeds/users/anafree + + + Ana Free (Bic Runga - + Sway + This is Sway by Bic Runga, + difficult to sing and I guess to play aswell..:) Hope you + enjoy it! + bic, runga, sway, ana, free, anafree, + acoustic, singing + + + Music + + + + + + + + + + + + + 10 + + + + http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/a3011180d79eff53 + 2007-09-20T22:56:57.064Z + + I'm falling in love (u can buy the mp3 at + justinsteere.com) + <div style="color: #000000;font-family: + Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; + width: 555px;"><table cellspacing="0" cellpadding="0" + border="0"><tbody><tr><td width="140" + valign="top" rowspan="2"><div style="border: 1px solid + #999999; margin: 0px 10px 5px 0px;"><a + href="http://www.youtube.com/watch?v=oXjInYHk2j0"><img + alt="" + src="http://img.youtube.com/vi/oXjInYHk2j0/2.jpg"></a></div></td> + <td width="256" valign="top"><div style="font-size: + 12px; font-weight: bold;"><a style="font-size: 15px; + font-weight: bold; font-decoration: none;" + href="http://www.youtube.com/watch?v=oXjInYHk2j0">I&#39;m + falling in love (u can buy the mp3 at + justinsteere.com)</a> <br></div> <div + style="font-size: 12px; margin: 3px 0px;"><span>this + is an original acoustic song. to purchase this song and others + check out justinsteere.com VOTE FOR THIS VIDEO AT famecast.com + (just search my name and click on vote for artist) + myspace.com/jsteere subscribe for instant video updates. more + videos coming soon. all the money i make from the mp3 downloads + is going towards making my real cd in november. enjoy + :)</span></div></td> <td style="font-size: + 11px; line-height: 1.4em; padding-left: 20px; padding-top: + 1px;" width="146" valign="top"><div><span + style="color: #666666; font-size: 11px;">From:</span> + <a + href="http://www.youtube.com/profile?user=bunetaybaz">bunetaybaz</a></div> + <div><span style="color: #666666; font-size: + 11px;">Views:</span> 653489</div> <div + style="white-space: nowrap;text-align: left"><img + style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_half_11x11.gif"></div> + <div style="font-size: 11px;">4654 <span style="color: + #666666; font-size: + 11px;">ratings</span></div></td></tr> + <tr><td><span style="color: #666666; font-size: + 11px;">Time:</span> <span style="color: #000000; + font-size: 11px; font-weight: + bold;">03:17</span></td> <td + style="font-size: 11px; padding-left: 20px;"><span + style="color: #666666; font-size: 11px;">More + in</span> <a + href="http://www.youtube.com/categories_portal?c=10">Music</a></td></tr></tbody></table></div> + + + + + + + bunetaybaz + http://gdata.youtube.com/feeds/users/bunetaybaz + + + I'm falling in love (u can buy the + mp3 at justinsteere.com) + this is an original acoustic + song. to purchase this song and others check out + justinsteere.com VOTE FOR THIS VIDEO AT famecast.com (just + search my name and click on vote for artist) + myspace.com/jsteere subscribe for instant video updates. more + videos coming soon. all the money i make from the mp3 + downloads is going towards making my real cd in november. + enjoy :) + justin, steere, jason, mraz, im, yours, dax, + flame, brookers, david, gray, josh, groban, you, and, I, + both, right, kind, of, phrase, better + + + Music + + + + + + + + + + + + + + 11 + + + + http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/798565c7d1c75453 + 2007-09-20T22:56:57.064Z + + When I Loved You + <div style="color: #000000;font-family: + Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; + width: 555px;"><table cellspacing="0" cellpadding="0" + border="0"><tbody><tr><td width="140" + valign="top" rowspan="2"><div style="border: 1px solid + #999999; margin: 0px 10px 5px 0px;"><a + href="http://www.youtube.com/watch?v=KjMRf4egAyA"><img + alt="" + src="http://img.youtube.com/vi/KjMRf4egAyA/2.jpg"></a></div></td> + <td width="256" valign="top"><div style="font-size: + 12px; font-weight: bold;"><a style="font-size: 15px; + font-weight: bold; font-decoration: none;" + href="http://www.youtube.com/watch?v=KjMRf4egAyA">When I + Loved You</a> <br></div> <div + style="font-size: 12px; margin: 3px 0px;"><span>As + promised a new song EVERY Sunday...another original (just a + sample) I promise I&#39;ll get Sex Machine up as soon as I + can! + www.myspace.com/mishalmmoore</span></div></td> + <td style="font-size: 11px; line-height: 1.4em; + padding-left: 20px; padding-top: 1px;" width="146" + valign="top"><div><span style="color: #666666; + font-size: 11px;">From:</span> <a + href="http://www.youtube.com/profile?user=mishalmooremusic">mishalmooremusic</a></div> + <div><span style="color: #666666; font-size: + 11px;">Views:</span> 715030</div> <div + style="white-space: nowrap;text-align: left"><img + style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_empty_11x11.gif"></div> + <div style="font-size: 11px;">2988 <span style="color: + #666666; font-size: + 11px;">ratings</span></div></td></tr> + <tr><td><span style="color: #666666; font-size: + 11px;">Time:</span> <span style="color: #000000; + font-size: 11px; font-weight: + bold;">02:38</span></td> <td + style="font-size: 11px; padding-left: 20px;"><span + style="color: #666666; font-size: 11px;">More + in</span> <a + href="http://www.youtube.com/categories_portal?c=10">Music</a></td></tr></tbody></table></div> + + + + + + + mishalmooremusic + + http://gdata.youtube.com/feeds/users/mishalmooremusic + + + When I Loved You + As promised a new song EVERY + Sunday...another original (just a sample) I promise I'll get + Sex Machine up as soon as I can! + www.myspace.com/mishalmmoore + mishal, moore, when, i, loved, + you + + + Music + + + + + + + + + + + + + + 12 + + + + http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/2c0c020593e15124 + 2007-09-20T22:56:57.065Z + + CONCEIT- Scissors & Glue ON THE RISE + CONTEST WINNER + <div style="color: #000000;font-family: + Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; + width: 555px;"><table cellspacing="0" cellpadding="0" + border="0"><tbody><tr><td width="140" + valign="top" rowspan="2"><div style="border: 1px solid + #999999; margin: 0px 10px 5px 0px;"><a + href="http://www.youtube.com/watch?v=R_ruSmFFdAY"><img + alt="" + src="http://img.youtube.com/vi/R_ruSmFFdAY/2.jpg"></a></div></td> + <td width="256" valign="top"><div style="font-size: + 12px; font-weight: bold;"><a style="font-size: 15px; + font-weight: bold; font-decoration: none;" + href="http://www.youtube.com/watch?v=R_ruSmFFdAY">CONCEIT- + Scissors &amp; Glue ON THE RISE CONTEST WINNER</a> + <br></div> <div style="font-size: 12px; margin: + 3px 0px;"><span>Conceit - Scissors &amp; Glue + Prod. Memo of the Molemen from the WASTED TALENT MIXTAPE + straight out the SAN FRANCISCO BAY AREA!!! Machete Vox - Gurp + City - Strangeface - Kill Technology Much love 2 LORDS CREW UM + 86&#39;in Promo Download: + http://www.zshare.net/audio/3603976e3994ff/ Wasted Talent + Mixtape available @ myspace.com/conceit + gurpcity.net</span></div></td> <td + style="font-size: 11px; line-height: 1.4em; padding-left: 20px; + padding-top: 1px;" width="146" + valign="top"><div><span style="color: #666666; + font-size: 11px;">From:</span> <a + href="http://www.youtube.com/profile?user=conceit">conceit</a></div> + <div><span style="color: #666666; font-size: + 11px;">Views:</span> 188729</div> <div + style="white-space: nowrap;text-align: left"><img + style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_half_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_empty_11x11.gif"></div> + <div style="font-size: 11px;">680 <span style="color: + #666666; font-size: + 11px;">ratings</span></div></td></tr> + <tr><td><span style="color: #666666; font-size: + 11px;">Time:</span> <span style="color: #000000; + font-size: 11px; font-weight: + bold;">02:22</span></td> <td + style="font-size: 11px; padding-left: 20px;"><span + style="color: #666666; font-size: 11px;">More + in</span> <a + href="http://www.youtube.com/categories_portal?c=10">Music</a></td></tr></tbody></table></div> + + + + + + + conceit + http://gdata.youtube.com/feeds/users/conceit + + + CONCEIT- Scissors & Glue ON THE + RISE CONTEST WINNER + Conceit - Scissors & Glue + Prod. Memo of the Molemen from the WASTED TALENT MIXTAPE + straight out the SAN FRANCISCO BAY AREA!!! Machete Vox - Gurp + City - Strangeface - Kill Technology Much love 2 LORDS CREW + UM 86'in Promo Download: + http://www.zshare.net/audio/3603976e3994ff/ Wasted Talent + Mixtape available @ myspace.com/conceit + gurpcity.net + rap, music, contest, 50, cent, conceit, sf, + bay, area, ontherise, wasted, talent, gurp, city, machete, + vox + + + Music + + + + + + + + + + + + + 13 + + diff --git a/zend/tests/Zend/Gdata/YouTube/_files/SubscriptionEntryDataSample1.xml b/zend/tests/Zend/Gdata/YouTube/_files/SubscriptionEntryDataSample1.xml new file mode 100644 index 0000000..b2db6ec --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/_files/SubscriptionEntryDataSample1.xml @@ -0,0 +1,29 @@ + + + + http://gdata.youtube.com/feeds/users/testuser/subscriptions/35bbde297dba88db + 2007-03-02T11:58:22.000-08:00 + 2007-03-02T11:58:22.000-08:00 + + + Videos published by : BBC + + + + + testuser + http://gdata.youtube.com/feeds/users/testuser + + + diff --git a/zend/tests/Zend/Gdata/YouTube/_files/SubscriptionEntryDataSampleV2.xml b/zend/tests/Zend/Gdata/YouTube/_files/SubscriptionEntryDataSampleV2.xml new file mode 100644 index 0000000..4845693 --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/_files/SubscriptionEntryDataSampleV2.xml @@ -0,0 +1,33 @@ + + + +tag:youtube.com,2008:user:googledevelopers:subscription:Z1Lm-S9gkRQ +2007-11-16T15:15:17.000-08:00 +2007-11-16T15:15:17.000-08:00 + + +Videos published by : androiddevelopers + + + + + +GoogleDevelopers + +http://gdata.youtube.com/feeds/api/users/googledevelopers + +androiddevelopers +50 + + diff --git a/zend/tests/Zend/Gdata/YouTube/_files/SubscriptionEntryDataSample_channelV2.xml b/zend/tests/Zend/Gdata/YouTube/_files/SubscriptionEntryDataSample_channelV2.xml new file mode 100644 index 0000000..4845693 --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/_files/SubscriptionEntryDataSample_channelV2.xml @@ -0,0 +1,33 @@ + + + +tag:youtube.com,2008:user:googledevelopers:subscription:Z1Lm-S9gkRQ +2007-11-16T15:15:17.000-08:00 +2007-11-16T15:15:17.000-08:00 + + +Videos published by : androiddevelopers + + + + + +GoogleDevelopers + +http://gdata.youtube.com/feeds/api/users/googledevelopers + +androiddevelopers +50 + + diff --git a/zend/tests/Zend/Gdata/YouTube/_files/SubscriptionEntryDataSample_favoritesV2.xml b/zend/tests/Zend/Gdata/YouTube/_files/SubscriptionEntryDataSample_favoritesV2.xml new file mode 100644 index 0000000..0120c3e --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/_files/SubscriptionEntryDataSample_favoritesV2.xml @@ -0,0 +1,30 @@ + + +tag:youtube.com,2008:user:zfgdata:subscription:S_KBJ3ylYwc +2008-12-15T14:59:26.000-08:00 +2008-12-15T14:59:26.000-08:00 + + +Favorites of : NBA + + + + + +zfgdata +http://gdata.youtube.com/feeds/api/users/zfgdata + +NBA + + \ No newline at end of file diff --git a/zend/tests/Zend/Gdata/YouTube/_files/SubscriptionEntryDataSample_playlistV2.xml b/zend/tests/Zend/Gdata/YouTube/_files/SubscriptionEntryDataSample_playlistV2.xml new file mode 100644 index 0000000..dbec414 --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/_files/SubscriptionEntryDataSample_playlistV2.xml @@ -0,0 +1,32 @@ + + +tag:youtube.com,2008:user:zfgdata:subscription:i_2YXxZb9Zg +2007-09-20T21:03:52.000-07:00 +2007-09-20T21:03:52.000-07:00 + + +From Google Engineers + + + + + +zfgdata +http://gdata.youtube.com/feeds/api/users/zfgdata + +From Google Engineers +GoogleDevelopers +4AE5C0D23C2EB82D + + \ No newline at end of file diff --git a/zend/tests/Zend/Gdata/YouTube/_files/SubscriptionEntryDataSample_queryV2.xml b/zend/tests/Zend/Gdata/YouTube/_files/SubscriptionEntryDataSample_queryV2.xml new file mode 100644 index 0000000..4f4fc87 --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/_files/SubscriptionEntryDataSample_queryV2.xml @@ -0,0 +1,31 @@ + + + +tag:youtube.com,2008:user:zfgdata:subscription:59NG0lkr7r4 +2008-12-15T14:48:39.000-08:00 +2008-12-15T14:48:39.000-08:00 + + +Videos matching : google + + + + + +zfgdata + +http://gdata.youtube.com/feeds/api/users/zfgdata + +google + \ No newline at end of file diff --git a/zend/tests/Zend/Gdata/YouTube/_files/SubscriptionFeedDataSample1.xml b/zend/tests/Zend/Gdata/YouTube/_files/SubscriptionFeedDataSample1.xml new file mode 100644 index 0000000..6200054 --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/_files/SubscriptionFeedDataSample1.xml @@ -0,0 +1,105 @@ + + + + http://gdata.youtube.com/feeds/users/testuser/subscriptions + 2007-09-20T22:12:45.193Z + + testuser's Subscriptions + + http://www.youtube.com/img/pic_youtubelogo_123x63.gif + + + + + + testuser + http://gdata.youtube.com/feeds/users/testuser + + YouTube + data API + 3 + 1 + 25 + + + http://gdata.youtube.com/feeds/users/testuser/subscriptions/35bbde297dba88db + 2007-03-02T11:58:22.000-08:00 + 2007-03-02T11:58:22.000-08:00 + + + Videos published by : BBC + + + + + testuser + http://gdata.youtube.com/feeds/users/testuser + + + + + + http://gdata.youtube.com/feeds/users/testuser/subscriptions/742853a3468b2418 + 2007-09-18T21:39:36.000-07:00 + 2007-09-18T21:39:36.000-07:00 + + + Videos published by : communitychannel + + + + + testuser + http://gdata.youtube.com/feeds/users/testuser + + + + + + http://gdata.youtube.com/feeds/users/testuser/subscriptions/98263c1ed3e31828 + 2007-09-20T13:45:29.000-07:00 + 2007-09-20T13:45:29.000-07:00 + + + Videos published by : ucberkeley + + + + + testuser + http://gdata.youtube.com/feeds/users/testuser + + + + diff --git a/zend/tests/Zend/Gdata/YouTube/_files/SubscriptionFeedDataSampleV2.xml b/zend/tests/Zend/Gdata/YouTube/_files/SubscriptionFeedDataSampleV2.xml new file mode 100644 index 0000000..c8ac727 --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/_files/SubscriptionFeedDataSampleV2.xml @@ -0,0 +1,138 @@ + + +tag:youtube.com,2008:user:zfgdata:subscriptions +2007-09-20T21:01:13.000-07:00 + +Subscriptions of zfgdata +http://www.youtube.com/img/pic_youtubelogo_123x63.gif + + + + + + + +zfgdata +http://gdata.youtube.com/feeds/api/users/zfgdata + +YouTube +data API +8 +1 +25 + +tag:youtube.com,2008:user:zfgdata:subscription:_Jkf5no0ZW0 +2007-09-20T21:01:13.000-07:00 +2007-09-20T21:01:13.000-07:00 + + +Videos published by : tonyrain + + + + + +zfgdata +http://gdata.youtube.com/feeds/api/users/zfgdata + +tonyrain +13 + + + +tag:youtube.com,2008:user:zfgdata:subscription:S_KBJ3ylYwc +2008-12-15T14:59:26.000-08:00 +2008-12-15T14:59:26.000-08:00 + + +Favorites of : NBA + + + + + +zfgdata +http://gdata.youtube.com/feeds/api/users/zfgdata + +NBA + + + +tag:youtube.com,2008:user:zfgdata:subscription:i_2YXxZb9Zg +2007-09-20T21:03:52.000-07:00 +2007-09-20T21:03:52.000-07:00 + + +From Google Engineers + + + + + +zfgdata +http://gdata.youtube.com/feeds/api/users/zfgdata + +From Google Engineers +GoogleDevelopers +4AE5C0D23C2EB82D + + + + +tag:youtube.com,2008:user:zfgdata:subscription:59NG0lkr7r4 +2008-12-15T14:48:39.000-08:00 +2008-12-15T14:48:39.000-08:00 + + +Videos matching : google + + + + + +zfgdata + +http://gdata.youtube.com/feeds/api/users/zfgdata + +google + + \ No newline at end of file diff --git a/zend/tests/Zend/Gdata/YouTube/_files/UserProfileEntryDataSample1.xml b/zend/tests/Zend/Gdata/YouTube/_files/UserProfileEntryDataSample1.xml new file mode 100644 index 0000000..384ac3f --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/_files/UserProfileEntryDataSample1.xml @@ -0,0 +1,47 @@ + + + http://gdata.youtube.com/feeds/users/darcy + 2006-03-19T11:35:56.000-08:00 + 2007-08-13T12:37:03.000-07:00 + + Darcy + + + + Fitzwilliam Darcy + http://gdata.youtube.com/feeds/users/darcy + + + 32 + A person of great interest + darcy + Pride and Prejudice + Self employed + Reading, arguing with Liz + Steventon + Longbourn in Hertfordshire, Pemberley in Derbyshire + Pride and Prejudice, 2005 + Air Con Varizzioni, The Pleasure of the Town + Gentleman + Home schooling + m + taken + + + + + + + + diff --git a/zend/tests/Zend/Gdata/YouTube/_files/UserProfileEntryDataSampleV2.xml b/zend/tests/Zend/Gdata/YouTube/_files/UserProfileEntryDataSampleV2.xml new file mode 100644 index 0000000..a6d1f88 --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/_files/UserProfileEntryDataSampleV2.xml @@ -0,0 +1,71 @@ + + +tag:youtube.com,2008:user:zfgdata +2007-09-20T21:00:09.000-07:00 +2008-12-15T13:30:56.000-08:00 + + +zfgdata Channel + + + + + +zfgdata +http://gdata.youtube.com/feeds/api/users/zfgdata + +Lonely +TestAccount +I'm a lonely test account, with little to do but sit +around and wait for people to use me. I get bored in between +releases and often sleep to pass the time. Please use me more +often, as I love to show off my talent in breaking your +code. +32 +zfgdata +crime and punishment, ps i love you, the stand +f +Google +software engineering, information architecture, +photography, travel +Mountain View, CA +San Francisco, CA 94114, US +monk, heroes, law and order, top gun +imogen heap, frou frou, thievory corp, morcheeba, +barenaked ladies +Developer Programs +taken +University of the World + + + + + + + + + + \ No newline at end of file diff --git a/zend/tests/Zend/Gdata/YouTube/_files/VideoEntryDataSample1.xml b/zend/tests/Zend/Gdata/YouTube/_files/VideoEntryDataSample1.xml new file mode 100644 index 0000000..5840187 --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/_files/VideoEntryDataSample1.xml @@ -0,0 +1,138 @@ + + + http://gdata.youtube.com/feeds/videos/UMFI1hdm96E + 2007-01-07T01:50:15.000Z + 2007-01-07T01:50:15.000Z + + + + + + + + + "Crazy (Gnarles Barkley)" - Acoustic Cover + <div style="color: #000000;font-family: + Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; + width: 555px;"><table cellspacing="0" cellpadding="0" + border="0"><tbody><tr><td width="140" + valign="top" rowspan="2"><div style="border: 1px solid + #999999; margin: 0px 10px 5px 0px;"><a + href="http://www.youtube.com/watch?v=UMFI1hdm96E"><img + alt="" + src="http://img.youtube.com/vi/UMFI1hdm96E/2.jpg"></a></div></td> + <td width="256" valign="top"><div style="font-size: + 12px; font-weight: bold;"><a style="font-size: 15px; + font-weight: bold; font-decoration: none;" + href="http://www.youtube.com/watch?v=UMFI1hdm96E">&quot;Crazy + (Gnarles Barkley)&quot; - Acoustic Cover</a> + <br></div> <div style="font-size: 12px; margin: + 3px 0px;"><span>Gnarles Barkley acoustic cover + http://www.myspace.com/davidchoimusic</span></div></td> + <td style="font-size: 11px; line-height: 1.4em; padding-left: + 20px; padding-top: 1px;" width="146" + valign="top"><div><span style="color: #666666; + font-size: 11px;">From:</span> <a + href="http://www.youtube.com/profile?user=davidchoimusic">davidchoimusic</a></div> + <div><span style="color: #666666; font-size: + 11px;">Views:</span> 113321</div> <div + style="white-space: nowrap;text-align: left"><img + style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_half_11x11.gif"></div> + <div style="font-size: 11px;">1005 <span style="color: + #666666; font-size: + 11px;">ratings</span></div></td></tr> + <tr><td><span style="color: #666666; font-size: + 11px;">Time:</span> <span style="color: #000000; + font-size: 11px; font-weight: + bold;">04:15</span></td> <td style="font-size: + 11px; padding-left: 20px;"><span style="color: #666666; + font-size: 11px;">More in</span> <a + href="http://www.youtube.com/categories_portal?c=10">Music</a></td></tr></tbody></table></div> + + + + + + davidchoimusic + http://gdata.youtube.com/feeds/users/davidchoimusic + + + "Crazy (Gnarles Barkley)" - Acoustic Cover + Gnarles Barkley acoustic cover http://www.myspace.com/davidchoimusic + music, singing, gnarls, barkley, acoustic, cover + + + Music + + DeveloperTag1 + + + + + + + + + + + + 37.398529052734375 -122.0635986328125 + + + 2008-09-25 + + + + + + yes + + The content of this video may violate the terms of use. + + diff --git a/zend/tests/Zend/Gdata/YouTube/_files/VideoEntryDataSamplePrivate.xml b/zend/tests/Zend/Gdata/YouTube/_files/VideoEntryDataSamplePrivate.xml new file mode 100755 index 0000000..905883f --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/_files/VideoEntryDataSamplePrivate.xml @@ -0,0 +1,139 @@ + + + http://gdata.youtube.com/feeds/videos/UMFI1hdm96E + 2007-01-07T01:50:15.000Z + 2007-01-07T01:50:15.000Z + + + + + + + + + "Crazy (Gnarles Barkley)" - Acoustic Cover + <div style="color: #000000;font-family: + Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; + width: 555px;"><table cellspacing="0" cellpadding="0" + border="0"><tbody><tr><td width="140" + valign="top" rowspan="2"><div style="border: 1px solid + #999999; margin: 0px 10px 5px 0px;"><a + href="http://www.youtube.com/watch?v=UMFI1hdm96E"><img + alt="" + src="http://img.youtube.com/vi/UMFI1hdm96E/2.jpg"></a></div></td> + <td width="256" valign="top"><div style="font-size: + 12px; font-weight: bold;"><a style="font-size: 15px; + font-weight: bold; font-decoration: none;" + href="http://www.youtube.com/watch?v=UMFI1hdm96E">&quot;Crazy + (Gnarles Barkley)&quot; - Acoustic Cover</a> + <br></div> <div style="font-size: 12px; margin: + 3px 0px;"><span>Gnarles Barkley acoustic cover + http://www.myspace.com/davidchoimusic</span></div></td> + <td style="font-size: 11px; line-height: 1.4em; padding-left: + 20px; padding-top: 1px;" width="146" + valign="top"><div><span style="color: #666666; + font-size: 11px;">From:</span> <a + href="http://www.youtube.com/profile?user=davidchoimusic">davidchoimusic</a></div> + <div><span style="color: #666666; font-size: + 11px;">Views:</span> 113321</div> <div + style="white-space: nowrap;text-align: left"><img + style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_half_11x11.gif"></div> + <div style="font-size: 11px;">1005 <span style="color: + #666666; font-size: + 11px;">ratings</span></div></td></tr> + <tr><td><span style="color: #666666; font-size: + 11px;">Time:</span> <span style="color: #000000; + font-size: 11px; font-weight: + bold;">04:15</span></td> <td style="font-size: + 11px; padding-left: 20px;"><span style="color: #666666; + font-size: 11px;">More in</span> <a + href="http://www.youtube.com/categories_portal?c=10">Music</a></td></tr></tbody></table></div> + + + + + + davidchoimusic + http://gdata.youtube.com/feeds/users/davidchoimusic + + + "Crazy (Gnarles Barkley)" - Acoustic Cover + Gnarles Barkley acoustic cover http://www.myspace.com/davidchoimusic + music, singing, gnarls, barkley, acoustic, cover + + + Music + + DeveloperTag1 + + + + + + + + + + + + + 37.398529052734375 -122.0635986328125 + + + 2008-09-25 + + + + + + yes + + The content of this video may violate the terms of use. + + diff --git a/zend/tests/Zend/Gdata/YouTube/_files/VideoEntryDataSampleV2.xml b/zend/tests/Zend/Gdata/YouTube/_files/VideoEntryDataSampleV2.xml new file mode 100644 index 0000000..a833310 --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/_files/VideoEntryDataSampleV2.xml @@ -0,0 +1,63 @@ + + +tag:youtube.com,2008:video:UMFI1hdm96E +2007-01-07T01:50:15.000Z +2008-12-08T04:04:33.000Z + + + + + + + + +"Crazy (Gnarles Barkley)" - Acoustic Cover + + + + + + + davidchoimusichttp://gdata.youtube.com/feeds/api/users/davidchoimusic + + + "Crazy (Gnarles Barkley)" - Acoustic Cover + Gnarles Barkley acoustic cover http://www.myspace.com/davidchoimusic + 1 + + DeveloperTag1 + acoustic, barkley, cover, gnarls, music, singing + + UMFI1hdm96E + 2007-01-07T01:50:15.000Z + + davidchoimusic + Music + + + + + + + + + + + + + 37.398529052734375 -122.0635986328125 + + + 2008-09-25 + + + + \ No newline at end of file diff --git a/zend/tests/Zend/Gdata/YouTube/_files/VideoFeedDataSample1.xml b/zend/tests/Zend/Gdata/YouTube/_files/VideoFeedDataSample1.xml new file mode 100644 index 0000000..33ec9c7 --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTube/_files/VideoFeedDataSample1.xml @@ -0,0 +1,743 @@ + + + http://gdata.youtube.com/feeds/users/davidchoimusic/uploads + 2007-09-21T02:27:22.638Z + + Davidchoimusic's Videos + http://www.youtube.com/img/pic_youtubelogo_123x63.gif + + + + + + + davidchoimusic + http://gdata.youtube.com/feeds/users/davidchoimusic + + YouTube data API + 54 + 1 + 5 + + http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg + 2007-01-11T00:17:31.000Z + 2007-01-11T00:17:31.000Z + + + + + + + + + + "That Girl" - Original Song - Acoustic + Version + <div style="color: #000000;font-family: + Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; + width: 555px;"><table cellspacing="0" cellpadding="0" + border="0"><tbody><tr><td width="140" + valign="top" rowspan="2"><div style="border: 1px solid + #999999; margin: 0px 10px 5px 0px;"><a + href="http://www.youtube.com/watch?v=Lnio-pqLPgg"><img + alt="" + src="http://img.youtube.com/vi/Lnio-pqLPgg/2.jpg"></a></div></td> + <td width="256" valign="top"><div style="font-size: + 12px; font-weight: bold;"><a style="font-size: 15px; + font-weight: bold; font-decoration: none;" + href="http://www.youtube.com/watch?v=Lnio-pqLPgg">&quot;That + Girl&quot; - Original Song - Acoustic Version</a> + <br></div> <div style="font-size: 12px; margin: + 3px 0px;"><span>For the full version, check out + http://www.myspace.com/musicchester mp3 + http://www.broadjam.com/davidchoi That Girl Oh tonight + I&#39;m feeling fine I&#39;m alone just wasting time no + Friday movie nights or romantic candlelight I&#39;m just + having conversations with the thoughts in my head all I hear + are angels crying oh won&#39;t they just sing instead It + would be wrong for me to say I don&#39;t need that girl by + my side I don&#39;t need that girl in my life I + don&#39;t want to talk it out or hold her when she cries I + don&#39;t want to say she&#39;s my kind I don&#39;t + want to say that she&#39;s mine I don&#39;t want to + tell her that I love her more than life more than life, love + her more than life Honestly, this won&#39;t do how is she + doing? I tell myself I&#39;m feeling swell but I know + I&#39;m such a fool I&#39;ll just take it as a new + beginning but you know I don&#39;t feel that way who will + take all this pain away? I know it&#39;s wrong for me to + say Chorus Talk about a sin was the day I walked into the other + side I would run back in I wouldn&#39;t waste no time I + know it&#39;s wrong for me to say Chorus + www.myspace.com/davidchoimusic</span></div></td> + <td style="font-size: 11px; line-height: 1.4em; + padding-left: 20px; padding-top: 1px;" width="146" + valign="top"><div><span style="color: #666666; + font-size: 11px;">From:</span> <a + href="http://www.youtube.com/profile?user=davidchoimusic">davidchoimusic</a></div> + <div><span style="color: #666666; font-size: + 11px;">Views:</span> 437209</div> <div + style="white-space: nowrap;text-align: left"><img + style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_half_11x11.gif"></div> + <div style="font-size: 11px;">2981 <span style="color: + #666666; font-size: + 11px;">ratings</span></div></td></tr> + <tr><td><span style="color: #666666; font-size: + 11px;">Time:</span> <span style="color: #000000; + font-size: 11px; font-weight: + bold;">03:40</span></td> <td + style="font-size: 11px; padding-left: 20px;"><span + style="color: #666666; font-size: 11px;">More + in</span> <a + href="http://www.youtube.com/categories_portal?c=10">Music</a></td></tr></tbody></table></div> + + + + + + davidchoimusic + + http://gdata.youtube.com/feeds/users/davidchoimusic + + + "That Girl" - Original Song - + Acoustic Version + For the full version, check + out http://www.myspace.com/musicchester mp3 + http://www.broadjam.com/davidchoi That Girl Oh tonight I'm + feeling fine I'm alone just wasting time no Friday movie + nights or romantic candlelight I'm just having conversations + with the thoughts in my head all I hear are angels crying oh + won't they just sing instead It would be wrong for me to say + I don't need that girl by my side I don't need that girl in + my life I don't want to talk it out or hold her when she + cries I don't want to say she's my kind I don't want to say + that she's mine I don't want to tell her that I love her more + than life more than life, love her more than life Honestly, + this won't do how is she doing? I tell myself I'm feeling + swell but I know I'm such a fool I'll just take it as a new + beginning but you know I don't feel that way who will take + all this pain away? I know it's wrong for me to say Chorus + Talk about a sin was the day I walked into the other side I + would run back in I wouldn't waste no time I know it's wrong + for me to say Chorus + www.myspace.com/davidchoimusic + That, Girl, Original, Song, Acoustic, + Version, davidchoimusic + + + Music + + + + + + + + + + + + + + + http://gdata.youtube.com/feeds/videos/FWPzxVMQU8g + 2006-12-30T23:20:14.000Z + 2006-12-30T23:20:14.000Z + + + + + + + + + + + + "You Tube" (A Love Song) - Original Song - + Acoustic Version + <div style="color: #000000;font-family: + Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; + width: 555px;"><table cellspacing="0" cellpadding="0" + border="0"><tbody><tr><td width="140" + valign="top" rowspan="2"><div style="border: 1px solid + #999999; margin: 0px 10px 5px 0px;"><a + href="http://www.youtube.com/watch?v=FWPzxVMQU8g"><img + alt="" + src="http://img.youtube.com/vi/FWPzxVMQU8g/2.jpg"></a></div></td> + <td width="256" valign="top"><div style="font-size: + 12px; font-weight: bold;"><a style="font-size: 15px; + font-weight: bold; font-decoration: none;" + href="http://www.youtube.com/watch?v=FWPzxVMQU8g">&quot;You + Tube&quot; (A Love Song) - Original Song - Acoustic + Version</a> <br></div> <div + style="font-size: 12px; margin: 3px + 0px;"><span>http://www.youtube.com/subscription_center?add_user=davidchoimusic + http://www.myspace.com/davidchoimusic If you want to be updated + on new videos, hit the orange &quot;subscribe&quot; + button on the top right corner! + ================================ &quot;You Tube&quot; + (A Love Song) When I wake up in the morning youtube when I + dream at night, youtube in the middle of the day, youtube you + consume my life, youtube I can&#39;t help, but think of you + I just love the things you do allow the people, to post our + videos, we love you youtube I like the founders some Asian and + some white dude but more than you I love youtube When I wake up + in the morning youtube when I dream at night, youtube in the + middle of the day, youtube you consume my life, youtube + youtube, you can comment all over me youtube, will you make + passionate love to me you can respond to my video if + you&#39;d like I&#39;ll post one right back, oh I think + I might could you add me to your favorites and I&#39;ll + post on your bulletin maybe send you a message if you promise + to write me back I&#39;ll log in and out to please you oh + you know the things I&#39;ll do oh youtube, oh youtube When + I wake up in the morning youtube when I dream at night, youtube + in the middle of the day, youtube you consume my life, + youtube</span></div></td> <td + style="font-size: 11px; line-height: 1.4em; padding-left: 20px; + padding-top: 1px;" width="146" + valign="top"><div><span style="color: #666666; + font-size: 11px;">From:</span> <a + href="http://www.youtube.com/profile?user=davidchoimusic">davidchoimusic</a></div> + <div><span style="color: #666666; font-size: + 11px;">Views:</span> 1495035</div> <div + style="white-space: nowrap;text-align: left"><img + style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_half_11x11.gif"></div> + <div style="font-size: 11px;">10995 <span + style="color: #666666; font-size: + 11px;">ratings</span></div></td></tr> + <tr><td><span style="color: #666666; font-size: + 11px;">Time:</span> <span style="color: #000000; + font-size: 11px; font-weight: + bold;">02:57</span></td> <td + style="font-size: 11px; padding-left: 20px;"><span + style="color: #666666; font-size: 11px;">More + in</span> <a + href="http://www.youtube.com/categories_portal?c=10">Music</a></td></tr></tbody></table></div> + + + + + + davidchoimusic + + http://gdata.youtube.com/feeds/users/davidchoimusic + + + "You Tube" (A Love Song) - Original + Song - Acoustic Version + + http://www.youtube.com/subscription_center?add_user=davidchoimusic + http://www.myspace.com/davidchoimusic If you want to be + updated on new videos, hit the orange "subscribe" button on + the top right corner! ================================ "You + Tube" (A Love Song) When I wake up in the morning youtube + when I dream at night, youtube in the middle of the day, + youtube you consume my life, youtube I can't help, but think + of you I just love the things you do allow the people, to + post our videos, we love you youtube I like the founders some + Asian and some white dude but more than you I love youtube + When I wake up in the morning youtube when I dream at night, + youtube in the middle of the day, youtube you consume my + life, youtube youtube, you can comment all over me youtube, + will you make passionate love to me you can respond to my + video if you'd like I'll post one right back, oh I think I + might could you add me to your favorites and I'll post on + your bulletin maybe send you a message if you promise to + write me back I'll log in and out to please you oh you know + the things I'll do oh youtube, oh youtube When I wake up in + the morning youtube when I dream at night, youtube in the + middle of the day, youtube you consume my life, + youtube + You, Tube, (A, Love, Song), Original, Song, + Acoustic, Version + + + Music + + + + + + + + + + + + + + + http://gdata.youtube.com/feeds/videos/uWVuAl_aFRo + 2007-07-13T06:28:11.000Z + 2007-07-13T06:28:11.000Z + + + + + + + + + + + + "Beautiful Girls" - Sean Kingston - Acoustic + Cover + <div style="color: #000000;font-family: + Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; + width: 555px;"><table cellspacing="0" cellpadding="0" + border="0"><tbody><tr><td width="140" + valign="top" rowspan="2"><div style="border: 1px solid + #999999; margin: 0px 10px 5px 0px;"><a + href="http://www.youtube.com/watch?v=uWVuAl_aFRo"><img + alt="" + src="http://img.youtube.com/vi/uWVuAl_aFRo/2.jpg"></a></div></td> + <td width="256" valign="top"><div style="font-size: + 12px; font-weight: bold;"><a style="font-size: 15px; + font-weight: bold; font-decoration: none;" + href="http://www.youtube.com/watch?v=uWVuAl_aFRo">&quot;Beautiful + Girls&quot; - Sean Kingston - Acoustic Cover</a> + <br></div> <div style="font-size: 12px; margin: + 3px 0px;"><span>Click Link to Subscribe! + http://www.youtube.com/subscription_center?add_user=davidchoimusic + http://www.myspace.com/davidchoimusic I really like this song + so I covered it. I will not smile for you + :)</span></div></td> <td style="font-size: + 11px; line-height: 1.4em; padding-left: 20px; padding-top: + 1px;" width="146" valign="top"><div><span + style="color: #666666; font-size: 11px;">From:</span> + <a + href="http://www.youtube.com/profile?user=davidchoimusic">davidchoimusic</a></div> + <div><span style="color: #666666; font-size: + 11px;">Views:</span> 124571</div> <div + style="white-space: nowrap;text-align: left"><img + style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_half_11x11.gif"></div> + <div style="font-size: 11px;">1201 <span style="color: + #666666; font-size: + 11px;">ratings</span></div></td></tr> + <tr><td><span style="color: #666666; font-size: + 11px;">Time:</span> <span style="color: #000000; + font-size: 11px; font-weight: + bold;">04:23</span></td> <td + style="font-size: 11px; padding-left: 20px;"><span + style="color: #666666; font-size: 11px;">More + in</span> <a + href="http://www.youtube.com/categories_portal?c=10">Music</a></td></tr></tbody></table></div> + + + + + + davidchoimusic + + http://gdata.youtube.com/feeds/users/davidchoimusic + + + "Beautiful Girls" - Sean Kingston - + Acoustic Cover + Click Link to Subscribe! + http://www.youtube.com/subscription_center?add_user=davidchoimusic + http://www.myspace.com/davidchoimusic I really like this song + so I covered it. I will not smile for you + :) + davidchoimusic, beautiful, girls, sean, + kingston, acoustic, cover, video, suicidal + + + Music + + + + + + + + + + + + + + + http://gdata.youtube.com/feeds/videos/_PCgDBIgPbo + 2007-02-15T20:40:24.000Z + 2007-02-15T20:40:24.000Z + + + + + + + + Vlog - "That Girl" - Guitar Chords + <div style="color: #000000;font-family: + Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; + width: 555px;"><table cellspacing="0" cellpadding="0" + border="0"><tbody><tr><td width="140" + valign="top" rowspan="2"><div style="border: 1px solid + #999999; margin: 0px 10px 5px 0px;"><a + href="http://www.youtube.com/watch?v=_PCgDBIgPbo"><img + alt="" + src="http://img.youtube.com/vi/_PCgDBIgPbo/2.jpg"></a></div></td> + <td width="256" valign="top"><div style="font-size: + 12px; font-weight: bold;"><a style="font-size: 15px; + font-weight: bold; font-decoration: none;" + href="http://www.youtube.com/watch?v=_PCgDBIgPbo">Vlog - + &quot;That Girl&quot; - Guitar Chords</a> + <br></div> <div style="font-size: 12px; margin: + 3px 0px;"><span>Vlog - &quot;That Girl&quot; - + Guitar Chords Finally here! Enjoy! + http://www.myspace.com/davidchoimusic + http://www.broadjam.com/davidchoi</span></div></td> + <td style="font-size: 11px; line-height: 1.4em; + padding-left: 20px; padding-top: 1px;" width="146" + valign="top"><div><span style="color: #666666; + font-size: 11px;">From:</span> <a + href="http://www.youtube.com/profile?user=davidchoimusic">davidchoimusic</a></div> + <div><span style="color: #666666; font-size: + 11px;">Views:</span> 76681</div> <div + style="white-space: nowrap;text-align: left"><img + style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_half_11x11.gif"></div> + <div style="font-size: 11px;">384 <span style="color: + #666666; font-size: + 11px;">ratings</span></div></td></tr> + <tr><td><span style="color: #666666; font-size: + 11px;">Time:</span> <span style="color: #000000; + font-size: 11px; font-weight: + bold;">05:38</span></td> <td + style="font-size: 11px; padding-left: 20px;"><span + style="color: #666666; font-size: 11px;">More + in</span> <a + href="http://www.youtube.com/categories_portal?c=10">Music</a></td></tr></tbody></table></div> + + + + + + davidchoimusic + + http://gdata.youtube.com/feeds/users/davidchoimusic + + + Vlog - "That Girl" - Guitar + Chords + Vlog - "That Girl" - Guitar + Chords Finally here! Enjoy! + http://www.myspace.com/davidchoimusic + http://www.broadjam.com/davidchoi + Vlog, That, Girl, Guitar, + Chords + + + Music + + + + + + + + + + + + + + + http://gdata.youtube.com/feeds/videos/DdGyPZ0v7Ng + 2007-08-12T00:59:18.000Z + 2007-08-12T00:59:18.000Z + + + + + + + + + + + + + Beat Making with David Choi + <div style="color: #000000;font-family: + Arial, Helvetica, sans-serif; font-size:12px; font-size: 12px; + width: 555px;"><table cellspacing="0" cellpadding="0" + border="0"><tbody><tr><td width="140" + valign="top" rowspan="2"><div style="border: 1px solid + #999999; margin: 0px 10px 5px 0px;"><a + href="http://www.youtube.com/watch?v=DdGyPZ0v7Ng"><img + alt="" + src="http://img.youtube.com/vi/DdGyPZ0v7Ng/2.jpg"></a></div></td> + <td width="256" valign="top"><div style="font-size: + 12px; font-weight: bold;"><a style="font-size: 15px; + font-weight: bold; font-decoration: none;" + href="http://www.youtube.com/watch?v=DdGyPZ0v7Ng">Beat + Making with David Choi</a> <br></div> <div + style="font-size: 12px; margin: 3px 0px;"><span>Click + Link to Subscribe! + http://www.youtube.com/subscription_center?add_user=davidchoimusic + http://www.myspace.com/davidchoimusic Just a quick little beat + I made to show you guys the general idea behind beat making. + And yes, the skin is real + :)</span></div></td> <td style="font-size: + 11px; line-height: 1.4em; padding-left: 20px; padding-top: + 1px;" width="146" valign="top"><div><span + style="color: #666666; font-size: 11px;">From:</span> + <a + href="http://www.youtube.com/profile?user=davidchoimusic">davidchoimusic</a></div> + <div><span style="color: #666666; font-size: + 11px;">Views:</span> 22559</div> <div + style="white-space: nowrap;text-align: left"><img + style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_full_11x11.gif"> + <img style="border: 0px none; margin: 0px; padding: 0px; + vertical-align: middle; font-size: 11px;" align="top" alt="" + src="http://gdata.youtube.com/static/images/icn_star_half_11x11.gif"></div> + <div style="font-size: 11px;">371 <span style="color: + #666666; font-size: + 11px;">ratings</span></div></td></tr> + <tr><td><span style="color: #666666; font-size: + 11px;">Time:</span> <span style="color: #000000; + font-size: 11px; font-weight: + bold;">09:51</span></td> <td + style="font-size: 11px; padding-left: 20px;"><span + style="color: #666666; font-size: 11px;">More + in</span> <a + href="http://www.youtube.com/categories_portal?c=10">Music</a></td></tr></tbody></table></div> + + + + + + davidchoimusic + + http://gdata.youtube.com/feeds/users/davidchoimusic + + + Beat Making with David + Choi + Click Link to Subscribe! + http://www.youtube.com/subscription_center?add_user=davidchoimusic + http://www.myspace.com/davidchoimusic Just a quick little + beat I made to show you guys the general idea behind beat + making. And yes, the skin is real :) + how, to, Beat, Making, with, David, Choi, + davidchoimusic, pro, tools + + + Music + + + + + + + + + + + + + + diff --git a/zend/tests/Zend/Gdata/YouTubeOnlineTest.php b/zend/tests/Zend/Gdata/YouTubeOnlineTest.php new file mode 100644 index 0000000..2aa296a --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTubeOnlineTest.php @@ -0,0 +1,1049 @@ +ytAccount = constant('TESTS_ZEND_GDATA_YOUTUBE_ACCOUNT'); + $this->user = constant('TESTS_ZEND_GDATA_CLIENTLOGIN_EMAIL'); + $this->pass = constant('TESTS_ZEND_GDATA_CLIENTLOGIN_PASSWORD'); + $this->subscriptionTypeSchema = 'http://gdata.youtube.com/schemas/' . + '2007/subscriptiontypes.cat'; + $this->gdata = new Zend_Gdata_YouTube(); + } + + public function tearDown() + { + } + + public function testRetrieveSubScriptionFeed() + { + $feed = $this->gdata->getSubscriptionFeed($this->ytAccount); + $this->assertTrue($feed->totalResults->text > 0); + $this->assertEquals('Subscriptions of ' . $this->ytAccount, + $feed->title->text); + $this->assertTrue(count($feed->entry) > 0); + foreach ($feed->entry as $entry) { + $this->assertTrue($entry->title->text != ''); + } + } + + public function testRetrieveContactFeed() + { + $feed = $this->gdata->getContactFeed($this->ytAccount); + $this->assertTrue($feed->totalResults->text > 0); + $this->assertEquals('Contacts of ' . $this->ytAccount, + $feed->title->text); + $this->assertTrue(count($feed->entry) > 0); + foreach ($feed->entry as $entry) { + $this->assertTrue($entry->title->text != ''); + } + $this->assertEquals('ytgdatatest1', $feed->entry[0]->username->text); + } + + public function testRetrieveUserVideos() + { + $feed = $this->gdata->getUserUploads($this->ytAccount); + $this->assertEquals('Uploads by ' . $this->ytAccount, + $feed->title->text); + $this->assertTrue(count($feed->entry) === 1); + } + + public function testRetrieveVideoFeed() + { + $feed = $this->gdata->getVideoFeed(); + + $query = new Zend_Gdata_YouTube_VideoQuery(); + $query->setVideoQuery('puppy'); + $feed = $this->gdata->getVideoFeed($query); + foreach ($feed as $videoEntry) { + $videoResponsesLink = $videoEntry->getVideoResponsesLink(); + $videoRatingsLink = $videoEntry->getVideoRatingsLink(); + $videoComplaintsLink = $videoEntry->getVideoComplaintsLink(); + } + + $feed = $this->gdata->getVideoFeed($query->getQueryUrl()); + } + + public function testRetrieveVideoEntry() + { + $entry = $this->gdata->getVideoEntry('66wj2g5yz0M'); + $this->assertEquals('TestMovie', $entry->title->text); + + $entry = $this->gdata->getVideoEntry(null, 'https://gdata.youtube.com/feeds/api/videos/66wj2g5yz0M'); + $this->assertEquals('TestMovie', $entry->title->text); + } + + public function testRetrieveOtherFeeds() + { + $feed = $this->gdata->getRelatedVideoFeed('66wj2g5yz0M'); + $feed = $this->gdata->getVideoResponseFeed('66wj2g5yz0M'); + $feed = $this->gdata->getVideoCommentFeed('66wj2g5yz0M'); + $feed = $this->gdata->getWatchOnMobileVideoFeed(); + $feed = $this->gdata->getUserFavorites($this->ytAccount); + } + + public function testRetrieveUserProfile() + { + $entry = $this->gdata->getUserProfile($this->ytAccount); + $this->assertEquals($this->ytAccount . ' Channel', $entry->title->text); + $this->assertEquals($this->ytAccount, $entry->username->text); + $this->assertEquals('I\'m a lonely test account, with little to do but sit around and wait for people to use me. I get bored in between releases and often sleep to pass the time. Please use me more often, as I love to show off my talent in breaking your code.', + $entry->description->text); + $this->assertEquals(32, $entry->age->text); + $this->assertEquals('crime and punishment, ps i love you, the stand', $entry->books->text); + $this->assertEquals('Google', $entry->company->text); + $this->assertEquals('software engineering, information architecture, photography, travel', $entry->hobbies->text); + $this->assertEquals('Mountain View, CA', $entry->hometown->text); + $this->assertEquals('San Francisco, CA 94114, US', $entry->location->text); + $this->assertEquals('monk, heroes, law and order, top gun', $entry->movies->text); + $this->assertEquals('imogen heap, frou frou, thievory corp, morcheeba, barenaked ladies', $entry->music->text); + $this->assertEquals('Developer Programs', $entry->occupation->text); + $this->assertEquals('University of the World', $entry->school->text); + $this->assertEquals('f', $entry->gender->text); + $this->assertEquals('taken', $entry->relationship->text); + } + + public function testRetrieveAndUpdatePlaylistList() + { + + $service = Zend_Gdata_YouTube::AUTH_SERVICE_NAME; + $authenticationURL= 'https://www.google.com/youtube/accounts/ClientLogin'; + $httpClient = Zend_Gdata_ClientLogin::getHttpClient( + $this->user, + $this->pass, + $service, + null, // client + 'Google-UnitTests-1.0', // source + null, // loginToken + null, // loginCaptcha + $authenticationURL); + + $this->gdata = new Zend_Gdata_YouTube($httpClient, + 'Google-UnitTests-1.0', 'ytapi-gdataops-12345-u78960r7-0', + 'AI39si6c-ZMGFZ5fkDAEJoCNHP9LOM2LSO1XuycZF7Eyu1IuvkioESq' . + 'zRcf3voDLymIUGIrxdMx2aTufdbf5D7E51NyLYyfeaw'); + + $this->gdata->setMajorProtocolVersion(2); + $feed = $this->gdata->getPlaylistListFeed($this->ytAccount); + $this->assertTrue($feed->totalResults->text > 0); + $this->assertEquals('Playlists of ' . $this->ytAccount, + $feed->title->text); + $this->assertTrue(count($feed->entry) > 0); + $i = 0; + foreach ($feed->entry as $entry) { + $this->assertTrue($entry->title->text != ''); + if ($i == 0) { + $entry->title->setText('new playlist title'); + $entry->save(); + } + $i++; + } + } + + public function testRetrievePlaylistV2() + { + $this->gdata->setMajorProtocolVersion(2); + $feed = $this->gdata->getPlaylistListFeed($this->ytAccount); + $firstEntry = $feed->entries[0]; + $this->assertTrue($firstEntry instanceof Zend_Gdata_YouTube_PlaylistListEntry); + $this->assertTrue($firstEntry->getSummary()->text != null); + } + + public function testRetrievePlaylistVideoFeed() + { + $listFeed = $this->gdata->getPlaylistListFeed($this->ytAccount); + + $feed = $this->gdata->getPlaylistVideoFeed($listFeed->entry[0]->feedLink[0]->href); + $this->assertTrue($feed->totalResults->text > 0); + $this->assertTrue(count($feed->entry) > 0); + foreach ($feed->entry as $entry) { + $this->assertTrue($entry->title->text != ''); + } + } + + public function testRetrieveTopRatedVideos() + { + $feed = $this->gdata->getTopRatedVideoFeed(); + $this->assertTrue($feed->totalResults->text > 10); + $this->assertEquals('Top Rated', $feed->title->text); + $this->assertTrue(count($feed->entry) > 0); + foreach ($feed->entry as $entry) { + $this->assertTrue($entry->rating->average > 3); + $this->assertEquals(1, $entry->rating->min); + $this->assertEquals(5, $entry->rating->max); + $this->assertTrue($entry->rating->numRaters > 2); + } + } + + public function testRetrieveTopRatedVideosV2() + { + $this->gdata->setMajorProtocolVersion(2); + $feed = $this->gdata->getTopRatedVideoFeed(); + $client = $this->gdata->getHttpClient(); + $positionOfAPIProjection = strpos( + $client->getLastRequest(), "/feeds/api/"); + $this->assertTrue(is_numeric($positionOfAPIProjection)); + } + + public function testRetrieveMostViewedVideosV2() + { + $this->gdata->setMajorProtocolVersion(2); + $feed = $this->gdata->getMostViewedVideoFeed(); + $client = $this->gdata->getHttpClient(); + $positionOfAPIProjection = strpos( + $client->getLastRequest(), "/feeds/api/"); + $this->assertTrue(is_numeric($positionOfAPIProjection)); + } + + public function testRetrieveRecentlyFeaturedVideosV2() + { + $this->gdata->setMajorProtocolVersion(2); + $feed = $this->gdata->getRecentlyFeaturedVideoFeed(); + $client = $this->gdata->getHttpClient(); + $positionOfAPIProjection = strpos( + $client->getLastRequest(), "/feeds/api/"); + $this->assertTrue(is_numeric($positionOfAPIProjection)); + } + + public function testWatchOnMobileVideosV2() + { + $this->gdata->setMajorProtocolVersion(2); + $feed = $this->gdata->getWatchOnMobileVideoFeed(); + $client = $this->gdata->getHttpClient(); + $positionOfAPIProjection = strpos( + $client->getLastRequest(), "/feeds/api/"); + $this->assertTrue(is_numeric($positionOfAPIProjection)); + } + + public function testRetrieveMostViewedVideos() + { + $feed = $this->gdata->getMostViewedVideoFeed(); + $this->assertTrue($feed->totalResults->text > 10); + $this->assertEquals('Most Viewed', $feed->title->text); + $this->assertTrue(count($feed->entry) > 0); + foreach ($feed->entry as $entry) { + if ($entry->rating) { + $this->assertEquals(1, $entry->rating->min); + $this->assertEquals(5, $entry->rating->max); + } + } + } + /** + * @group ZF-9479 + */ + public function testPerformV2Query() + { + $this->gdata->setMajorProtocolVersion(2); + $query = $this->gdata->newVideoQuery(); + $query->videoQuery = 'zend framework'; + $query->startIndex = 0; + $query->maxResults = 10; + $query->orderBy = 'viewCount'; + $query->safeSearch = 'strict'; + $videoFeed = $this->gdata->getVideoFeed($query); + $this->assertTrue(count($videoFeed->entry) > 0, + 'Could not retrieve a single entry for location search:' . + $query->getQueryUrl(2)); + } + + public function testPerformV2Query_Location() + { + $this->gdata->setMajorProtocolVersion(2); + $query = $this->gdata->newVideoQuery(); + // Setting location to New York City + $query->setLocation('-37.0625,-95.677068'); + $query->setLocationRadius('1000km'); + $videoFeed = $this->gdata->getVideoFeed($query); + $this->assertTrue(count($videoFeed->entry) > 0, + 'Could not retrieve a single entry for location search:' . + $query->getQueryUrl(2)); + } + + public function testPerformV2Query_SafeSearch() + { + $this->gdata->setMajorProtocolVersion(2); + $query = $this->gdata->newVideoQuery(); + $query->setSafeSearch('strict'); + $videoFeed = $this->gdata->getVideoFeed($query); + $this->assertTrue(count($videoFeed->entry) > 0, + 'Could not retrieve a single entry for safeSearch=strict search:' . + $query->getQueryUrl(2)); + } + + public function testPeformV2Query_Uploader() + { + $this->gdata->setMajorProtocolVersion(2); + $query = $this->gdata->newVideoQuery(); + $query->setUploader('partner'); + $videoFeed = $this->gdata->getVideoFeed($query); + $this->assertTrue(count($videoFeed->entry) > 0, + 'Could not retrieve a single entry for uploader=partner search:' . + $query->getQueryUrl(2)); + + foreach($videoFeed as $videoEntry) { + $mg = $videoEntry->getMediaGroup(); + $this->assertEquals('partner', + $mg->getMediaCredit()->getYTtype()); + } + } + + public function testAddUpdateAndDeletePlaylistV2() + { + $service = Zend_Gdata_YouTube::AUTH_SERVICE_NAME; + $authenticationURL = + 'https://www.google.com/youtube/accounts/ClientLogin'; + $httpClient = Zend_Gdata_ClientLogin::getHttpClient( + $this->user, + $this->pass, + $service, + null, // client + 'Google-UnitTests-1.0', // source + null, // $loginToken + null, // loginCaptcha + $authenticationURL); + + $yt = new Zend_Gdata_YouTube( + $httpClient, 'Google-UnitTests-1.0', + 'ytapi-gdataops-12345-u78960r7-0', + 'AI39si6c-ZMGFZ5fkDAEJoCNHP9LOM2LSO1XuycZF7E' . + 'yu1IuvkioESqzRcf3voDLymIUGIrxdMx2aTufdbf5D7E51NyLYyfeaw'); + + $yt->setMajorProtocolVersion(2); + $feed = $yt->getPlaylistListFeed($this->ytAccount); + + // Add new + $newPlaylist = $yt->newPlaylistListEntry(); + $newPlaylist->setMajorProtocolVersion(2); + $titleString = $this->generateRandomString(10); + $newPlaylist->title = $yt->newTitle()->setText($titleString); + $newPlaylist->summary = $yt->newSummary()->setText('testing'); + $postUrl = 'https://gdata.youtube.com/feeds/api/users/default/playlists'; + $successfulInsertion = true; + + try { + $yt->insertEntry($newPlaylist, $postUrl); + } catch (Zend_Gdata_App_Exception $e) { + $successfulInsertion = false; + } + + $this->assertTrue($successfulInsertion, 'Failed to insert a new ' . + 'playlist.'); + + $playlistListFeed = $yt->getPlaylistListFeed('default'); + + $playlistFound = false; + $newPlaylistEntry = null; + + foreach ($playlistListFeed as $playlistListEntry) { + if ($playlistListEntry->title->text == $titleString) { + $playlistFound = true; + $newPlaylistEntry = $playlistListEntry; + break; + } + } + + $this->assertTrue($playlistFound, 'Could not find the newly inserted ' . + 'playlist.'); + + // Update it + $newTitle = $this->generateRandomString(10); + $newPlaylistEntry->title->setText($newTitle); + $updatedSuccesfully = true; + try { + $newPlaylistEntry->save(); + } catch (Zend_Gdata_App_Exception $e) { + $updatedSuccesfully = false; + } + + $this->assertTrue($updatedSuccesfully, 'Could not succesfully update ' . + 'a new playlist.'); + + // Delete it + $deletedSuccesfully = true; + try { + $newPlaylistEntry->delete(); + } catch (Zend_Gdata_App_Exception $e) { + $deletedSuccesfully = false; + } + + $this->assertTrue($deletedSuccesfully, 'Could not succesfully delete ' . + 'a new playlist.'); + } + + public function testAddAndDeleteSubscriptionToChannelV2() + { + $service = Zend_Gdata_YouTube::AUTH_SERVICE_NAME; + $authenticationURL = + 'https://www.google.com/youtube/accounts/ClientLogin'; + $httpClient = Zend_Gdata_ClientLogin::getHttpClient( + $this->user, + $this->pass, + $service, + null, // client + 'Google-UnitTests-1.0', // source + null, // loginToken + null, // loginCaptcha + $authenticationURL); + + $yt = new Zend_Gdata_YouTube( + $httpClient, 'Google-UnitTests-1.0', + 'ytapi-gdataops-12345-u78960r7-0', + 'AI39si6c-ZMGFZ5fkDAEJoCNHP9LOM2LSO1XuycZF7E' . + 'yu1IuvkioESqzRcf3voDLymIUGIrxdMx2aTufdbf5D7E51NyLYyfeaw'); + + $yt->setMajorProtocolVersion(2); + + $channelToSubscribeTo = 'AssociatedPress'; + + // Test for deletion first in case something went wrong + // last time the test was run (network, etc...) + $subscriptionFeed = $yt->getSubscriptionFeed($this->ytAccount); + $successDeletionUpFront = true; + $message = null; + foreach($subscriptionFeed as $subscriptionEntry) { + $subscriptionType = null; + $categories = $subscriptionEntry->getCategory(); + // examine the correct category element since there are multiple + foreach($categories as $category) { + if ($category->getScheme() == + 'http://gdata.youtube.com/schemas/2007/' . + 'subscriptiontypes.cat') { + $subscriptionType = $category->getTerm(); + } + } + if ($subscriptionType == 'channel') { + if ($subscriptionEntry->getUsername()->text == + $channelToSubscribeTo) { + try { + $subscriptionEntry->delete(); + } catch (Zend_App_Exception $e) { + $message = $e->getMessage(); + $successDeletionUpFront = false; + } + } + } + } + $this->assertTrue($successDeletionUpFront, 'Found existing ' . + 'subscription in unit test, could not delete prior to running ' . + 'test -- ' . $message); + + // Channel + $newSubscription = $yt->newSubscriptionEntry(); + $newSubscription->category = array( + $yt->newCategory('channel', + $this->subscriptionTypeSchema)); + $newSubscription->setUsername($yt->newUsername( + $channelToSubscribeTo)); + + $postUrl = + 'https://gdata.youtube.com/feeds/api/users/default/subscriptions'; + + $successPosting = true; + $message = null; + $insertedSubscription = null; + try { + $insertedSubscription = $yt->insertEntry( + $newSubscription, $postUrl, + 'Zend_Gdata_YouTube_SubscriptionEntry'); + } catch (Zend_App_Exception $e) { + $message = $e->getMessage(); + $successPosting = false; + } + + $this->assertTrue($successPosting, $message); + + // Delete it + $successDeletion = true; + $message = null; + try { + $insertedSubscription->delete(); + } catch (Zend_App_Exception $e) { + $message = $e->getMessage(); + $successDeletion = false; + } + + $this->assertTrue($successDeletion, $message); + } + + public function testAddAndDeleteSubscriptionToFavoritesV2() + { + $service = Zend_Gdata_YouTube::AUTH_SERVICE_NAME; + $authenticationURL = + 'https://www.google.com/youtube/accounts/ClientLogin'; + $httpClient = Zend_Gdata_ClientLogin::getHttpClient( + $username = $this->user, + $password = $this->pass, + $service = $service, + $client = null, + $source = 'Google-UnitTests-1.0', + $loginToken = null, + $loginCaptcha = null, + $authenticationURL); + + $yt = new Zend_Gdata_YouTube( + $httpClient, 'Google-UnitTests-1.0', + 'ytapi-gdataops-12345-u78960r7-0', + 'AI39si6c-ZMGFZ5fkDAEJoCNHP9LOM2LSO1XuycZF7E' . + 'yu1IuvkioESqzRcf3voDLymIUGIrxdMx2aTufdbf5D7E51NyLYyfeaw'); + + $yt->setMajorProtocolVersion(2); + + $usernameOfFavoritesToSubscribeTo = 'CBS'; + + // Test for deletion first in case something went wrong + // last time the test was run (network, etc...) + $subscriptionFeed = $yt->getSubscriptionFeed($this->ytAccount); + $successDeletionUpFront = true; + $message = null; + foreach($subscriptionFeed as $subscriptionEntry) { + $subscriptionType = null; + $categories = $subscriptionEntry->getCategory(); + // examine the correct category element since there are multiple + foreach($categories as $category) { + if ($category->getScheme() == + 'http://gdata.youtube.com/schemas/2007/' . + 'subscriptiontypes.cat') { + $subscriptionType = $category->getTerm(); + } + } + if ($subscriptionType == 'favorites') { + if ($subscriptionEntry->getUsername()->text == + $usernameOfFavoritesToSubscribeTo) { + try { + $subscriptionEntry->delete(); + } catch (Zend_App_Exception $e) { + $message = $e->getMessage(); + $successDeletionUpFront = false; + } + } + } + } + $this->assertTrue($successDeletionUpFront, 'Found existing ' . + 'subscription in unit test, could not delete prior to running ' . + 'test -- ' . $message); + + // CBS's favorites + $newSubscription = $yt->newSubscriptionEntry(); + $newSubscription->category = array( + $yt->newCategory('favorites', + $this->subscriptionTypeSchema)); + $newSubscription->setUsername($yt->newUsername( + $usernameOfFavoritesToSubscribeTo)); + + $postUrl = + 'https://gdata.youtube.com/feeds/api/users/default/subscriptions'; + + $successPosting = true; + $message = null; + $insertedSubscription = null; + try { + $insertedSubscription = $yt->insertEntry( + $newSubscription, $postUrl, + 'Zend_Gdata_YouTube_SubscriptionEntry'); + } catch (Zend_App_Exception $e) { + $message = $e->getMessage(); + $successPosting = false; + } + + $this->assertTrue($successPosting, $message); + + // Delete it + $successDeletion = true; + $message = null; + try { + $insertedSubscription->delete(); + } catch (Zend_App_Exception $e) { + $message = $e->getMessage(); + $successDeletion = false; + } + + $this->assertTrue($successDeletion, $message); + } + + public function testAddAndDeleteSubscriptionToPlaylistV2() + { + $service = Zend_Gdata_YouTube::AUTH_SERVICE_NAME; + $authenticationURL = + 'https://www.google.com/youtube/accounts/ClientLogin'; + $httpClient = Zend_Gdata_ClientLogin::getHttpClient( + $username = $this->user, + $password = $this->pass, + $service = $service, + $client = null, + $source = 'Google-UnitTests-1.0', + $loginToken = null, + $loginCaptcha = null, + $authenticationURL); + + $yt = new Zend_Gdata_YouTube( + $httpClient, 'Google-UnitTests-1.0', + 'ytapi-gdataops-12345-u78960r7-0', + 'AI39si6c-ZMGFZ5fkDAEJoCNHP9LOM2LSO1XuycZF7E' . + 'yu1IuvkioESqzRcf3voDLymIUGIrxdMx2aTufdbf5D7E51NyLYyfeaw'); + + $yt->setMajorProtocolVersion(2); + $playlistIdToSubscribeTo = '7A2BB4AFFEBED2A4'; + + // Test for deletion first in case something went wrong + // last time the test was run (network, etc...) + $subscriptionFeed = $yt->getSubscriptionFeed($this->ytAccount); + $successDeletionUpFront = true; + $message = null; + foreach($subscriptionFeed as $subscriptionEntry) { + $subscriptionType = null; + $categories = $subscriptionEntry->getCategory(); + // examine the correct category element since there are multiple + foreach($categories as $category) { + if ($category->getScheme() == + 'http://gdata.youtube.com/schemas/2007/' . + 'subscriptiontypes.cat') { + $subscriptionType = $category->getTerm(); + } + } + if ($subscriptionType == 'playlist') { + if ($subscriptionEntry->getPlaylistId()->text == + $playlistIdToSubscribeTo) { + try { + $subscriptionEntry->delete(); + } catch (Zend_App_Exception $e) { + $message = $e->getMessage(); + $successDeletionUpFront = false; + } + } + } + } + $this->assertTrue($successDeletionUpFront, 'Found existing ' . + 'subscription in unit test, could not delete prior to running ' . + 'test -- ' . $message); + + // Playlist of McGyver videos + $newSubscription = $yt->newSubscriptionEntry(); + $newSubscription->setMajorProtocolVersion(2); + $newSubscription->category = array( + $yt->newCategory('playlist', + $this->subscriptionTypeSchema)); + $newSubscription->setPlaylistId($yt->newPlaylistId( + $playlistIdToSubscribeTo)); + + $postUrl = + 'https://gdata.youtube.com/feeds/api/users/default/subscriptions'; + + $successPosting = true; + $message = null; + $insertedSubscription = null; + try { + $insertedSubscription = $yt->insertEntry( + $newSubscription, $postUrl, + 'Zend_Gdata_YouTube_SubscriptionEntry'); + } catch (Zend_App_Exception $e) { + $message = $e->getMessage(); + $successPosting = false; + } + + $this->assertTrue($successPosting, $message); + + // Delete it + $successDeletion = true; + $message = null; + try { + $insertedSubscription->delete(); + } catch (Zend_App_Exception $e) { + $message = $e->getMessage(); + $successDeletion = false; + } + + $this->assertTrue($successDeletion, $message); + } + + public function testAddAndDeleteSubscriptionToQueryV2() + { + $developerKey = constant('TESTS_ZEND_GDATA_YOUTUBE_DEVELOPER_KEY'); + $clientId = constant('TESTS_ZEND_GDATA_YOUTUBE_CLIENT_ID'); + + $service = Zend_Gdata_YouTube::AUTH_SERVICE_NAME; + $authenticationURL = + 'https://www.google.com/youtube/accounts/ClientLogin'; + $httpClient = Zend_Gdata_ClientLogin::getHttpClient( + $username = $this->user, + $password = $this->pass, + $service = $service, + $client = null, + $source = 'Google-UnitTests-1.0', + $loginToken = null, + $loginCaptcha = null, + $authenticationURL); + + $yt = new Zend_Gdata_YouTube($httpClient, 'Google-UnitTests-1.0', $clientId, $developerKey); + + $yt->setMajorProtocolVersion(2); + $queryStringToSubscribeTo = 'zend'; + + // Test for deletion first in case something went wrong + // last time the test was run (network, etc...) + $subscriptionFeed = $yt->getSubscriptionFeed($this->ytAccount); + $successDeletionUpFront = true; + $message = null; + foreach($subscriptionFeed as $subscriptionEntry) { + $subscriptionType = null; + $categories = $subscriptionEntry->getCategory(); + // examine the correct category element since there are multiple + foreach($categories as $category) { + if ($category->getScheme() == + 'http://gdata.youtube.com/schemas/2007/' . + 'subscriptiontypes.cat') { + $subscriptionType = $category->getTerm(); + } + } + if ($subscriptionType == 'query') { + if ($subscriptionEntry->getQueryString() == + $queryStringToSubscribeTo) { + try { + $subscriptionEntry->delete(); + } catch (Zend_App_Exception $e) { + $message = $e->getMessage(); + $successDeletionUpFront = false; + } + } + } + } + $this->assertTrue($successDeletionUpFront, 'Found existing ' . + 'subscription in unit test, could not delete prior to running ' . + 'test -- ' . $message); + + // Query + $newSubscription = $yt->newSubscriptionEntry(); + $newSubscription->category = array( + $yt->newCategory('query', + $this->subscriptionTypeSchema)); + $newSubscription->setQueryString($yt->newQueryString( + $queryStringToSubscribeTo)); + + $postUrl = + 'https://gdata.youtube.com/feeds/api/users/default/subscriptions'; + + $successPosting = true; + $message = null; + $insertedSubscription = null; + try { + $insertedSubscription = $yt->insertEntry( + $newSubscription, $postUrl, + 'Zend_Gdata_YouTube_SubscriptionEntry'); + } catch (Zend_App_Exception $e) { + $message = $e->getMessage(); + $successPosting = false; + } + + $this->assertTrue($successPosting, $message); + + // Delete it + $successDeletion = true; + $message = null; + try { + $insertedSubscription->delete(); + } catch (Zend_App_Exception $e) { + $message = $e->getMessage(); + $successDeletion = false; + } + + $this->assertTrue($successDeletion, $message); + } + + public function generateRandomString($length) + { + $outputString = null; + for($i = 0; $i < $length; $i++) { + $outputString .= chr(rand(65,90)); + } + return $outputString; + } + + public function testRetrieveActivityFeed() + { + $developerKey = constant( + 'TESTS_ZEND_GDATA_YOUTUBE_DEVELOPER_KEY'); + $clientId = constant( + 'TESTS_ZEND_GDATA_YOUTUBE_CLIENT_ID'); + $client = Zend_Gdata_ClientLogin::getHttpClient( + $this->user, $this->pass, 'youtube' , null, 'ZF_UnitTest', null, null, + 'https://www.google.com/youtube/accounts/ClientLogin'); + + $youtube = new Zend_Gdata_YouTube($client, 'ZF_UnitTest', + $clientId, $developerKey); + $youtube->setMajorProtocolVersion(2); + + $feed = $youtube->getActivityForUser($this->ytAccount); + $this->assertTrue($feed instanceof Zend_Gdata_YouTube_ActivityFeed); + $this->assertTrue((count($feed->entries) > 0)); + $this->assertEquals('Activity of ' . $this->ytAccount, + $feed->title->text); + } + + public function testExceptionIfNotUsingDeveloperKey() + { + $exceptionThrown = false; + $youtube = new Zend_Gdata_YouTube(); + $youtube->setMajorProtocolVersion(2); + try { + $youtube->getActivityForUser($this->ytAccount); + } catch (Zend_Gdata_App_HttpException $e) { + $exceptionThrown = true; + } + $this->assertTrue($exceptionThrown, 'Was expecting an exception when ' . + 'making a request to the YouTube Activity feed without a ' . + 'developer key.'); + } + + public function testRetrieveActivityFeedForMultipleUsers() + { + $developerKey = constant( + 'TESTS_ZEND_GDATA_YOUTUBE_DEVELOPER_KEY'); + $clientId = constant( + 'TESTS_ZEND_GDATA_YOUTUBE_CLIENT_ID'); + $client = Zend_Gdata_ClientLogin::getHttpClient( + $this->user, $this->pass, 'youtube' , null, 'ZF_UnitTest', null, null, + 'https://www.google.com/youtube/accounts/ClientLogin'); + + $youtube = new Zend_Gdata_YouTube($client, 'ZF_UnitTest', + $clientId, $developerKey); + $youtube->setMajorProtocolVersion(2); + + $feed = $youtube->getActivityForUser($this->ytAccount . + ',associatedpress'); + $this->assertTrue($feed instanceof Zend_Gdata_YouTube_ActivityFeed); + $this->assertTrue((count($feed->entries) > 0)); + $this->assertEquals('Activity of ' . $this->ytAccount . + ',associatedpress', $feed->title->text); + } + + public function testRetrieveFriendFeed() + { + $developerKey = constant( + 'TESTS_ZEND_GDATA_YOUTUBE_DEVELOPER_KEY'); + $clientId = constant( + 'TESTS_ZEND_GDATA_YOUTUBE_CLIENT_ID'); + $client = Zend_Gdata_ClientLogin::getHttpClient( + $this->user, $this->pass, 'youtube' , null, 'ZF_UnitTest', null, null, + 'https://www.google.com/youtube/accounts/ClientLogin'); + + $youtube = new Zend_Gdata_YouTube($client, 'ZF_UnitTest', + $clientId, $developerKey); + $youtube->setMajorProtocolVersion(2); + + $feed = $youtube->getFriendActivityForCurrentUser(); + $this->assertTrue($feed instanceof Zend_Gdata_YouTube_ActivityFeed); + $this->assertTrue((count($feed->entries) > 0)); + $this->assertEquals('Activity of the friends of ' . $this->ytAccount, + $feed->title->text); + } + + public function testThrowExceptionOnActivityFeedRequestForMoreThan20Users() + { + $exceptionThrown = false; + $listOfMoreThan20Users = null; + $youtube = new Zend_Gdata_YouTube(); + $youtube->setMajorProtocolVersion(2); + + for ($x = 0; $x < 30; $x++) { + $listOfMoreThan20Users .= "user$x"; + if ($x != 29) { + $listOfMoreThan20Users .= ","; + } + } + + try { + $youtube->getActivityForUser($listOfMoreThan20Users); + } catch (Zend_Gdata_App_InvalidArgumentException $e) { + $exceptionThrown = true; + } + $this->assertTrue($exceptionThrown, 'Was expecting an exception on ' . + 'a request to ->getActivityForUser when more than 20 users were ' . + 'specified in YouTube.php'); + } + + public function testGetInboxFeedForCurrentUserV1() + { + $developerKey = constant( + 'TESTS_ZEND_GDATA_YOUTUBE_DEVELOPER_KEY'); + $clientId = constant( + 'TESTS_ZEND_GDATA_YOUTUBE_CLIENT_ID'); + $client = Zend_Gdata_ClientLogin::getHttpClient( + $this->user, $this->pass, 'youtube' , null, 'ZF_UnitTest', null, null, + 'https://www.google.com/youtube/accounts/ClientLogin'); + + $youtube = new Zend_Gdata_YouTube($client, 'ZF_UnitTest', + $clientId, $developerKey); + + $inboxFeed = $youtube->getInboxFeedForCurrentUser(); + $this->assertTrue($inboxFeed instanceof Zend_Gdata_YouTube_InboxFeed); + $this->assertTrue(count($inboxFeed->entries) > 0, 'Test account ' . + $this->ytAccount . ' had no messages in their inbox.'); + + // get the first entry + $inboxFeed->rewind(); + $inboxEntry = $inboxFeed->current(); + $this->assertTrue( + $inboxEntry instanceof Zend_Gdata_YouTube_InboxEntry); + $this->assertTrue($inboxEntry->getTitle()->text != ''); + } + + public function testGetInboxFeedForCurrentUserV2() + { + $developerKey = constant( + 'TESTS_ZEND_GDATA_YOUTUBE_DEVELOPER_KEY'); + $clientId = constant( + 'TESTS_ZEND_GDATA_YOUTUBE_CLIENT_ID'); + $client = Zend_Gdata_ClientLogin::getHttpClient( + $this->user, $this->pass, 'youtube' , null, 'ZF_UnitTest', null, null, + 'https://www.google.com/youtube/accounts/ClientLogin'); + + $youtube = new Zend_Gdata_YouTube($client, 'ZF_UnitTest', + $clientId, $developerKey); + $youtube->setMajorProtocolVersion(2); + + $inboxFeed = $youtube->getInboxFeedForCurrentUser(); + $this->assertTrue($inboxFeed instanceof Zend_Gdata_YouTube_InboxFeed); + $this->assertTrue(count($inboxFeed->entries) > 0, 'Test account ' . + $this->ytAccount . ' had no messages in their inbox.'); + + // get the first entry + $inboxFeed->rewind(); + $inboxEntry = $inboxFeed->current(); + $this->assertTrue( + $inboxEntry instanceof Zend_Gdata_YouTube_InboxEntry); + $this->assertTrue($inboxEntry->getTitle()->text != ''); + } + + + public function testSendAMessageV2() + { + $developerKey = constant('TESTS_ZEND_GDATA_YOUTUBE_DEVELOPER_KEY'); + $clientId = constant('TESTS_ZEND_GDATA_YOUTUBE_CLIENT_ID'); + $client = Zend_Gdata_ClientLogin::getHttpClient( + $this->user, $this->pass, 'youtube' , null, 'ZF_UnitTest', null, null, + 'https://www.google.com/youtube/accounts/ClientLogin'); + + $youtube = new Zend_Gdata_YouTube($client, 'ZF_UnitTest', + $clientId, $developerKey); + $youtube->setMajorProtocolVersion(2); + + // get a video from the recently featured video feed + $videoFeed = $youtube->getRecentlyFeaturedVideoFeed(); + $videoEntry = $videoFeed->entry[0]; + $this->assertTrue($videoEntry instanceof Zend_Gdata_YouTube_VideoEntry); + + // sending message to gdpython (python client library unit test user) + $sentMessage = $youtube->sendVideoMessage( + 'Sending a v2 test message from Zend_Gdata_YouTubeOnlineTest.', + $videoEntry, null, 'gdpython'); + $this->assertTrue( + $sentMessage instanceof Zend_Gdata_YouTube_InboxEntry); + } + + public function testSendAMessageV1() + { + $developerKey = constant( + 'TESTS_ZEND_GDATA_YOUTUBE_DEVELOPER_KEY'); + $clientId = constant( + 'TESTS_ZEND_GDATA_YOUTUBE_CLIENT_ID'); + $client = Zend_Gdata_ClientLogin::getHttpClient( + $this->user, $this->pass, 'youtube' , null, 'ZF_UnitTest', null, null, + 'https://www.google.com/youtube/accounts/ClientLogin'); + + $youtube = new Zend_Gdata_YouTube($client, 'ZF_UnitTest', + $clientId, $developerKey); + $youtube->setMajorProtocolVersion(1); + + // get a video from the recently featured video feed + $videoFeed = $youtube->getRecentlyFeaturedVideoFeed(); + $videoEntry = $videoFeed->entry[0]; + $this->assertTrue($videoEntry instanceof Zend_Gdata_YouTube_VideoEntry); + + // sending message to gdpython (python client library unit test user) + $sentMessage = $youtube->sendVideoMessage( + 'Sending a v1 test message from Zend_Gdata_YouTubeOnlineTest.', + $videoEntry, null, 'gdpython'); + $this->assertTrue( + $sentMessage instanceof Zend_Gdata_YouTube_InboxEntry); + } + + public function testThrowExceptionOnSendingMessageWithoutVideo() + { + $exceptionCaught = false; + $this->gdata = new Zend_Gdata_YouTube(); + try { + $this->gdata->sendVideoMessage('Should fail', null, null, 'foo'); + } catch (Zend_Gdata_App_InvalidArgumentException $e) { + $exceptionCaught = true; + } + $this->assertTrue($exceptionCaught, 'Was expecting an exception if ' . + 'sending a message without a video'); + } + + public function testCommentOnAComment() + { + $developerKey = constant('TESTS_ZEND_GDATA_YOUTUBE_DEVELOPER_KEY'); + $clientId = constant('TESTS_ZEND_GDATA_YOUTUBE_CLIENT_ID'); + $client = Zend_Gdata_ClientLogin::getHttpClient( + $this->user, $this->pass, 'youtube' , null, 'ZF_UnitTest', null, null, + 'https://www.google.com/youtube/accounts/ClientLogin'); + $youtube = new Zend_Gdata_YouTube($client, 'ZF_UnitTest', + $clientId, $developerKey); + $youtube->setMajorProtocolVersion(2); + + $mostDiscussedFeed = $youtube->getVideoFeed( + 'https://gdata.youtube.com/feeds/api/standardfeeds/most_discussed'); + + // get first entry + $mostDiscussedFeed->rewind(); + $firstEntry = $mostDiscussedFeed->current(); + + $this->assertTrue($firstEntry instanceof Zend_Gdata_YouTube_VideoEntry); + + $commentFeed = $youtube->getVideoCommentFeed($firstEntry->getVideoId()); + + // get first comment + $commentFeed->rewind(); + $firstCommentEntry = $commentFeed->current(); + + $commentedComment = $youtube->replyToCommentEntry($firstCommentEntry, + 'awesome ! (ZFUnitTest-test)'); + $this->assertTrue( + $commentedComment instanceof Zend_Gdata_YouTube_CommentEntry); + } + +} diff --git a/zend/tests/Zend/Gdata/YouTubeTest.php b/zend/tests/Zend/Gdata/YouTubeTest.php new file mode 100644 index 0000000..772f35c --- /dev/null +++ b/zend/tests/Zend/Gdata/YouTubeTest.php @@ -0,0 +1,72 @@ +gdata = new Zend_Gdata_YouTube(null); + $this->responseText = file_get_contents( + 'Zend/Gdata/YouTube/_files/FormUploadTokenResponseSample.xml', + true); + } + + public function testGetFormUploadTokenResponseHandler() + { + $responseArray = Zend_Gdata_YouTube::parseFormUploadTokenResponse($this->responseText); + $this->assertEquals('https://uploads.gdata.youtube.com/action/FormDataUpload/AIwbF1_JjEQ9cGTjEAd5FKwV42SeNWJexmc5y7XR-eFj24uqbqU6NRcxKJW_4R-sYISLxQ', + $responseArray['url']); + $this->assertEquals('AIwbFAQ21fImpR2iYPaFnfuCvfbCB3qBxl5qXiZlpH3lfkungiSPoyw1iOM1gFB6Nx-wmY-kjprNT3qtdp7LJCLfngn11Ne_X9Jd44Vz8AzygtEtaDGyib5tnri0O0-V5pwcAPCHIJurOMsOpA2zInW8V8qHk2S2LheXfTXVbqc0Li9iCBpsoBGbykYU0moNoyGAaKRbSBD0oPnCv6v9Rll5Zjvivi2hQt-Br2JDb9wVeLv3qyAFaeyN6X6k32RyaAHs_n8d8d_oSriQmvS8g1HxSCS4dnoGL7tafQ4SBqnrQEb-hxFeu1ZrAwCLv', + $responseArray['token']); + } + + public function testSetClientIDAndDeveloperKeyHeader() + { + $applicationId = 'MyTestCompany-MyTestApp-0.1'; + $clientId = 'MyClientId'; + $developerKey = 'MyDeveloperKey'; + $httpClient = new Zend_Http_Client(); + $yt = new Zend_Gdata_YouTube($httpClient, $applicationId, $clientId, $developerKey); + + $this->assertTrue($yt instanceOf Zend_Gdata_YouTube); + $client = $yt->getHttpClient(); + + $this->assertEquals($client->getHeader('X-Gdata-Key'), 'key='. $developerKey); + $this->assertEquals($client->getHeader('X-Gdata-Client'), $clientId); + } +} diff --git a/zend/tests/Zend/Gdata/_files/AppSample1.txt b/zend/tests/Zend/Gdata/_files/AppSample1.txt new file mode 100644 index 0000000..0a4a317 --- /dev/null +++ b/zend/tests/Zend/Gdata/_files/AppSample1.txt @@ -0,0 +1,30 @@ +HTTP/1.1 200 OK +Content-Type: application/atom+xml; charset=UTF-8 +Last-Modified: Sun, 07 Sep 2008 17:53:51 GMT +Cache-Control: max-age=0 private +ETag: W/"CkcHQH8_fCp7ImA9WxRTGEw." +Gdata-Version: 1.2 +Date: Sun, 07 Sep 2008 21:23:39 GMT +Content-Length: 1450 +Server: GFE/1.3 + + + + + 12345678901234567890 + 2008-09-07T10:53:00.001-07:00 + 2008-09-07T10:53:51.144-07:00 + 2008-09-07T10:53:51.144-07:00 + Hello world + <p>Hello world!</p> + + + + + + + John Doe + http://www.blogger.com/profile/5555555555555555 + jdoe@example.com + + diff --git a/zend/tests/Zend/Gdata/_files/AppSample2.txt b/zend/tests/Zend/Gdata/_files/AppSample2.txt new file mode 100644 index 0000000..93f8f62 --- /dev/null +++ b/zend/tests/Zend/Gdata/_files/AppSample2.txt @@ -0,0 +1,29 @@ +HTTP/1.1 200 OK +Content-Type: application/atom+xml; charset=UTF-8 +Last-Modified: Sun, 07 Sep 2008 17:53:51 GMT +Cache-Control: max-age=0 private +ETag: W/"CkcHQH8_fCp7ImA9WxRTGEw." +Date: Sun, 07 Sep 2008 21:23:39 GMT +Content-Length: 1450 +Server: GFE/1.3 + + + + + 12345678901234567890 + 2008-09-07T10:53:00.001-07:00 + 2008-09-07T10:53:51.144-07:00 + 2008-09-07T10:53:51.144-07:00 + Hello world + <p>Hello world!</p> + + + + + + + John Doe + http://www.blogger.com/profile/5555555555555555 + jdoe@example.com + + diff --git a/zend/tests/Zend/Gdata/_files/AppSample3.txt b/zend/tests/Zend/Gdata/_files/AppSample3.txt new file mode 100644 index 0000000..acd0024 --- /dev/null +++ b/zend/tests/Zend/Gdata/_files/AppSample3.txt @@ -0,0 +1,68 @@ +HTTP/1.1 200 OK +Content-Type: application/atom+xml; charset=UTF-8 +Last-Modified: Sun, 07 Sep 2008 17:53:51 GMT +Cache-Control: max-age=0 private +ETag: W/"CkcHQH8_fCp7ImA9WxRTGEw." +Gdata-Version: 1.2 +Date: Sun, 07 Sep 2008 21:23:39 GMT +Content-Length: 1450 +Server: GFE/1.3 + + + + + tag:blogger.com,1999:blog-8273578352962669317 + 2008-11-11T20:09:14.238-08:00 + Test Blog + This is my description. + + + + + + John Doe + http://www.blogger.com/profile/05925487542352262450 + tmjdev@gmail.com + + Blogger + 30 + 1 + 25 + + tag:blogger.com,1999:blog-8273578352962669317.post-4858063079003295518 + 2008-11-11T20:09:00.001-08:00 + 2008-11-11T20:09:14.251-08:00 + 2008-11-11T20:09:14.251-08:00 + Test Image + FOO + + + + + + + John Doe + http://www.blogger.com/profile/05925487542352262450 + tmjdev@gmail.com + + 0 + + \ No newline at end of file diff --git a/zend/tests/Zend/Gdata/_files/AppSample4.txt b/zend/tests/Zend/Gdata/_files/AppSample4.txt new file mode 100644 index 0000000..a976632 --- /dev/null +++ b/zend/tests/Zend/Gdata/_files/AppSample4.txt @@ -0,0 +1,67 @@ +HTTP/1.1 200 OK +Content-Type: application/atom+xml; charset=UTF-8 +Last-Modified: Sun, 07 Sep 2008 17:53:51 GMT +Cache-Control: max-age=0 private +ETag: W/"CkcHQH8_fCp7ImA9WxRTGEw." +Date: Sun, 07 Sep 2008 21:23:39 GMT +Content-Length: 1450 +Server: GFE/1.3 + + + + + tag:blogger.com,1999:blog-8273578352962669317 + 2008-11-11T20:09:14.238-08:00 + Test Blog + This is my description. + + + + + + John Doe + http://www.blogger.com/profile/05925487542352262450 + tmjdev@gmail.com + + Blogger + 30 + 1 + 25 + + tag:blogger.com,1999:blog-8273578352962669317.post-4858063079003295518 + 2008-11-11T20:09:00.001-08:00 + 2008-11-11T20:09:14.251-08:00 + 2008-11-11T20:09:14.251-08:00 + Test Image + FOO + + + + + + + John Doe + http://www.blogger.com/profile/05925487542352262450 + tmjdev@gmail.com + + 0 + + \ No newline at end of file diff --git a/zend/tests/Zend/Gdata/_files/AttendeeStatusElementSample1.xml b/zend/tests/Zend/Gdata/_files/AttendeeStatusElementSample1.xml new file mode 100644 index 0000000..3ffc5e5 --- /dev/null +++ b/zend/tests/Zend/Gdata/_files/AttendeeStatusElementSample1.xml @@ -0,0 +1,2 @@ + + diff --git a/zend/tests/Zend/Gdata/_files/AttendeeTypeElementSample1.xml b/zend/tests/Zend/Gdata/_files/AttendeeTypeElementSample1.xml new file mode 100644 index 0000000..547f1ee --- /dev/null +++ b/zend/tests/Zend/Gdata/_files/AttendeeTypeElementSample1.xml @@ -0,0 +1,2 @@ + + diff --git a/zend/tests/Zend/Gdata/_files/CommentsElementSample1.xml b/zend/tests/Zend/Gdata/_files/CommentsElementSample1.xml new file mode 100644 index 0000000..67ffd1d --- /dev/null +++ b/zend/tests/Zend/Gdata/_files/CommentsElementSample1.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/zend/tests/Zend/Gdata/_files/DocsTest.csv b/zend/tests/Zend/Gdata/_files/DocsTest.csv new file mode 100755 index 0000000..d83012d --- /dev/null +++ b/zend/tests/Zend/Gdata/_files/DocsTest.csv @@ -0,0 +1,4 @@ +name,favoriteColor +fred,blue +john,red +doug,green diff --git a/zend/tests/Zend/Gdata/_files/EntryLinkElementSample1.xml b/zend/tests/Zend/Gdata/_files/EntryLinkElementSample1.xml new file mode 100644 index 0000000..d5ba138 --- /dev/null +++ b/zend/tests/Zend/Gdata/_files/EntryLinkElementSample1.xml @@ -0,0 +1,10 @@ + + + + + http://gmail.com/jo/contacts/Jo + + Jo March + + diff --git a/zend/tests/Zend/Gdata/_files/EntrySample1.xml b/zend/tests/Zend/Gdata/_files/EntrySample1.xml new file mode 100644 index 0000000..e1433bb --- /dev/null +++ b/zend/tests/Zend/Gdata/_files/EntrySample1.xml @@ -0,0 +1,20 @@ + + + + tag:blogger.com,1999:blog-8273578352962669317.post-6938730899689776686 + 2008-09-07T10:53:00.001-07:00 + 2008-09-07T10:53:51.144-07:00 + 2008-09-07T10:53:51.144-07:00 + Hello world + <p>Hello world!</p> + + + + + + + John Doe + http://www.blogger.com/profile/12345678901234567890 + jdoe@example.com + + diff --git a/zend/tests/Zend/Gdata/_files/EventStatusElementSample1.xml b/zend/tests/Zend/Gdata/_files/EventStatusElementSample1.xml new file mode 100644 index 0000000..e591595 --- /dev/null +++ b/zend/tests/Zend/Gdata/_files/EventStatusElementSample1.xml @@ -0,0 +1,2 @@ + + diff --git a/zend/tests/Zend/Gdata/_files/ExtendedPropertyElementSample1.xml b/zend/tests/Zend/Gdata/_files/ExtendedPropertyElementSample1.xml new file mode 100644 index 0000000..3acb821 --- /dev/null +++ b/zend/tests/Zend/Gdata/_files/ExtendedPropertyElementSample1.xml @@ -0,0 +1,3 @@ + + \ No newline at end of file diff --git a/zend/tests/Zend/Gdata/_files/FeedLinkElementSample1.xml b/zend/tests/Zend/Gdata/_files/FeedLinkElementSample1.xml new file mode 100644 index 0000000..d56687a --- /dev/null +++ b/zend/tests/Zend/Gdata/_files/FeedLinkElementSample1.xml @@ -0,0 +1,9 @@ + + + + 2007-06-19T00:48:41.230Z + + Comments for: Sample Event + + + diff --git a/zend/tests/Zend/Gdata/_files/FeedSampleV1.xml b/zend/tests/Zend/Gdata/_files/FeedSampleV1.xml new file mode 100644 index 0000000..be92553 --- /dev/null +++ b/zend/tests/Zend/Gdata/_files/FeedSampleV1.xml @@ -0,0 +1,58 @@ + + + + tag:blogger.com,1999:blog-8273578352962669317 + 2008-11-11T20:09:14.238-08:00 + Test Blog + This is my description. + + + + + + John Doe + http://www.blogger.com/profile/05925487542352262450 + tmjdev@gmail.com + + Blogger + 30 + 1 + 25 + + tag:blogger.com,1999:blog-8273578352962669317.post-4858063079003295518 + 2008-11-11T20:09:00.001-08:00 + 2008-11-11T20:09:14.251-08:00 + 2008-11-11T20:09:14.251-08:00 + Test Image + FOO + + + + + + + John Doe + http://www.blogger.com/profile/05925487542352262450 + tmjdev@gmail.com + + 0 + + \ No newline at end of file diff --git a/zend/tests/Zend/Gdata/_files/FeedSampleV2.xml b/zend/tests/Zend/Gdata/_files/FeedSampleV2.xml new file mode 100644 index 0000000..a9b2fe3 --- /dev/null +++ b/zend/tests/Zend/Gdata/_files/FeedSampleV2.xml @@ -0,0 +1,58 @@ + + + + tag:blogger.com,1999:blog-8273578352962669317 + 2008-11-11T20:09:14.238-08:00 + Test Blog + This is my description. + + + + + + John Doe + http://www.blogger.com/profile/05925487542352262450 + tmjdev@gmail.com + + Blogger + 30 + 1 + 25 + + tag:blogger.com,1999:blog-8273578352962669317.post-4858063079003295518 + 2008-11-11T20:09:00.001-08:00 + 2008-11-11T20:09:14.251-08:00 + 2008-11-11T20:09:14.251-08:00 + Test Image + FOO + + + + + + + John Doe + http://www.blogger.com/profile/05925487542352262450 + tmjdev@gmail.com + + 0 + + \ No newline at end of file diff --git a/zend/tests/Zend/Gdata/_files/MediaMimeStreamSample1.txt b/zend/tests/Zend/Gdata/_files/MediaMimeStreamSample1.txt new file mode 100644 index 0000000..5c42df7 --- /dev/null +++ b/zend/tests/Zend/Gdata/_files/MediaMimeStreamSample1.txt @@ -0,0 +1 @@ +aaa---fakeBinary---bbb \ No newline at end of file diff --git a/zend/tests/Zend/Gdata/_files/OpenSearchItemsPerPageElementSample1.xml b/zend/tests/Zend/Gdata/_files/OpenSearchItemsPerPageElementSample1.xml new file mode 100644 index 0000000..6c7aa60 --- /dev/null +++ b/zend/tests/Zend/Gdata/_files/OpenSearchItemsPerPageElementSample1.xml @@ -0,0 +1,2 @@ + +25 diff --git a/zend/tests/Zend/Gdata/_files/OpenSearchStartIndexElementSample1.xml b/zend/tests/Zend/Gdata/_files/OpenSearchStartIndexElementSample1.xml new file mode 100644 index 0000000..4fd6673 --- /dev/null +++ b/zend/tests/Zend/Gdata/_files/OpenSearchStartIndexElementSample1.xml @@ -0,0 +1,2 @@ + +5 diff --git a/zend/tests/Zend/Gdata/_files/OpenSearchTotalResultsElementSample1.xml b/zend/tests/Zend/Gdata/_files/OpenSearchTotalResultsElementSample1.xml new file mode 100644 index 0000000..b3f0a0c --- /dev/null +++ b/zend/tests/Zend/Gdata/_files/OpenSearchTotalResultsElementSample1.xml @@ -0,0 +1,2 @@ + +12 diff --git a/zend/tests/Zend/Gdata/_files/OriginalEventElementSample1.xml b/zend/tests/Zend/Gdata/_files/OriginalEventElementSample1.xml new file mode 100644 index 0000000..7955fd5 --- /dev/null +++ b/zend/tests/Zend/Gdata/_files/OriginalEventElementSample1.xml @@ -0,0 +1,4 @@ + + + + diff --git a/zend/tests/Zend/Gdata/_files/RecurrenceElementSample1.xml b/zend/tests/Zend/Gdata/_files/RecurrenceElementSample1.xml new file mode 100644 index 0000000..d252ec7 --- /dev/null +++ b/zend/tests/Zend/Gdata/_files/RecurrenceElementSample1.xml @@ -0,0 +1,6 @@ + + +DTSTART;VALUE=DATE:20070501 +DTEND;VALUE=DATE:20070502 +RRULE:FREQ=WEEKLY;BYDAY=Tu;UNTIL=20070904 + diff --git a/zend/tests/Zend/Gdata/_files/RecurrenceExceptionElementSample1.xml b/zend/tests/Zend/Gdata/_files/RecurrenceExceptionElementSample1.xml new file mode 100644 index 0000000..768993c --- /dev/null +++ b/zend/tests/Zend/Gdata/_files/RecurrenceExceptionElementSample1.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/zend/tests/Zend/Gdata/_files/ReminderElementSample1.xml b/zend/tests/Zend/Gdata/_files/ReminderElementSample1.xml new file mode 100644 index 0000000..aaa4961 --- /dev/null +++ b/zend/tests/Zend/Gdata/_files/ReminderElementSample1.xml @@ -0,0 +1,2 @@ + + diff --git a/zend/tests/Zend/Gdata/_files/RsaCert.pem b/zend/tests/Zend/Gdata/_files/RsaCert.pem new file mode 100644 index 0000000..445542c --- /dev/null +++ b/zend/tests/Zend/Gdata/_files/RsaCert.pem @@ -0,0 +1,17 @@ +-----BEGIN CERTIFICATE----- +MIICxTCCAi6gAwIBAgIJALIWLob1fh/YMA0GCSqGSIb3DQEBBQUAMEwxCzAJBgNV +BAYTAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEYMBYG +A1UEAxMPd3d3LmV4YW1wbGUuY29tMB4XDTA4MDYyOTIwMDEyMVoXDTA5MDYyOTIw +MDEyMVowTDELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3Vu +dGFpbiBWaWV3MRgwFgYDVQQDEw93d3cuZXhhbXBsZS5jb20wgZ8wDQYJKoZIhvcN +AQEBBQADgY0AMIGJAoGBAN8jNUSm/KkypB2sTIRIob/GPVJAeDUSFOQ+HOT0sruM +lf0RzY8wLBQdVshLfq1PsdE49jPavnOR9+CBI4f1LUC24XUcDQ0W1MTltdOrx1Rr +FWQHrNE6R19N2eYLC0o0VBJhp4o6VERr8MhKiQT4GqtZjJpycF/G0M5ysDZCvaA9 +AgMBAAGjga4wgaswHQYDVR0OBBYEFH3/umQGqQAzS6zm8Vi29FKuk9K/MHwGA1Ud +IwR1MHOAFH3/umQGqQAzS6zm8Vi29FKuk9K/oVCkTjBMMQswCQYDVQQGEwJVUzEL +MAkGA1UECBMCQ0ExFjAUBgNVBAcTDU1vdW50YWluIFZpZXcxGDAWBgNVBAMTD3d3 +dy5leGFtcGxlLmNvbYIJALIWLob1fh/YMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcN +AQEFBQADgYEAwBPAqlfAM0prZ7GNfVkFjxZv5/HALtcd54CYIiSk0FHFMmRrQbDr +DgaMcB4TVVF9ldVoRqvP4MpB4/SzYlEHMctjrJwbdVLZl7zACuTElsl4yr+Dzv6h +zVj1cIz9+lzwPZ8e0HJRRWmdEe+zoCed5iUigtEViMUvhszLzLcGmEc= +-----END CERTIFICATE----- diff --git a/zend/tests/Zend/Gdata/_files/RsaKey.pem b/zend/tests/Zend/Gdata/_files/RsaKey.pem new file mode 100644 index 0000000..b2deeca --- /dev/null +++ b/zend/tests/Zend/Gdata/_files/RsaKey.pem @@ -0,0 +1,15 @@ +-----BEGIN RSA PRIVATE KEY----- +MIICXwIBAAKBgQDfIzVEpvypMqQdrEyESKG/xj1SQHg1EhTkPhzk9LK7jJX9Ec2P +MCwUHVbIS36tT7HROPYz2r5zkffggSOH9S1AtuF1HA0NFtTE5bXTq8dUaxVkB6zR +OkdfTdnmCwtKNFQSYaeKOlREa/DISokE+BqrWYyacnBfxtDOcrA2Qr2gPQIDAQAB +AoGBAMetwyJvaJSk67ZeFI8gTBbIeOGdLbUYPDfP2Z2N2E/7S9GO1+u2CQvrAVj2 +LiM7uP1owvG+Y0Yarr5p8fjdj6K4FBFZIsv7ugm9+lhwHMQXBMT8RdnPUtAupzRT +YuNlJgBluFyV2C6JZakmHKbn+RJxTnBAiWAMe+8zXQTNlhXBAkEA/0yk2o6q4yTR +hMg9REHyA8mNlZYgFm41tJmNIoshK+xWEyx+mvKEt3VHdkz0kDqzZo5XR/PoqH8P +FTsVntGyTQJBAN+/+Ckiw5XCBkeJMVmuynSP+PXXViczzBZiTJQeMf+ja+uL9XXH +cf2Y1Hg+0YGdr+NzGb3EKxH+CzLaaz3ZPbECQQDmFXUdZCauv6f0O2K7+ZLbxvJL +NhmFHZ5ZPWntD+a9ZynL7fXMP3VMwe29uG1Q7xZv/yi6OCAeeyRkxfMeR26hAkEA +y80hjuZ5W/kkmxgdeWC6S72vuM1xTbfiVykmM2vlgsIp1Jzg8Wy/KYyBSx182yD0 +SqpWcgEycesB7EoCkI1FoQJBALU/zXYUn0Jmh/qKruPo+7PwyQqgiO+muWoYxVC2 +vYdtqvvIAKUhERjA8vkbPdqp4zzjjzs6hjTeOmGqmmrFhxk= +-----END RSA PRIVATE KEY----- diff --git a/zend/tests/Zend/Gdata/_files/TransparencyElementSample1.xml b/zend/tests/Zend/Gdata/_files/TransparencyElementSample1.xml new file mode 100644 index 0000000..fe9028d --- /dev/null +++ b/zend/tests/Zend/Gdata/_files/TransparencyElementSample1.xml @@ -0,0 +1,2 @@ + + diff --git a/zend/tests/Zend/Gdata/_files/VisibilityElementSample1.xml b/zend/tests/Zend/Gdata/_files/VisibilityElementSample1.xml new file mode 100644 index 0000000..5c9c4b8 --- /dev/null +++ b/zend/tests/Zend/Gdata/_files/VisibilityElementSample1.xml @@ -0,0 +1,2 @@ + + diff --git a/zend/tests/Zend/Gdata/_files/WhenElementSample1.xml b/zend/tests/Zend/Gdata/_files/WhenElementSample1.xml new file mode 100644 index 0000000..2ecf824 --- /dev/null +++ b/zend/tests/Zend/Gdata/_files/WhenElementSample1.xml @@ -0,0 +1,2 @@ + + diff --git a/zend/tests/Zend/Gdata/_files/WhereElementSample1.xml b/zend/tests/Zend/Gdata/_files/WhereElementSample1.xml new file mode 100644 index 0000000..1b01f15 --- /dev/null +++ b/zend/tests/Zend/Gdata/_files/WhereElementSample1.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/zend/tests/Zend/Gdata/_files/WhoElementSample1.xml b/zend/tests/Zend/Gdata/_files/WhoElementSample1.xml new file mode 100644 index 0000000..8df4880 --- /dev/null +++ b/zend/tests/Zend/Gdata/_files/WhoElementSample1.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/zend/tests/Zend/Gdata/_files/testImage.jpg b/zend/tests/Zend/Gdata/_files/testImage.jpg new file mode 100644 index 0000000..b378f7a Binary files /dev/null and b/zend/tests/Zend/Gdata/_files/testImage.jpg differ -- cgit v1.2.3