diff options
| author | Horus3 | 2014-02-24 16:42:14 +0100 |
|---|---|---|
| committer | Horus3 | 2014-02-24 16:42:14 +0100 |
| commit | 06f945f27840b53e57795dadbc38e76f7e11ab1c (patch) | |
| tree | 689d5c7f4ffa15460c7e90f47c6a7dd59ce4e8bd /zend/tests/Zend/Gdata | |
| download | random-06f945f27840b53e57795dadbc38e76f7e11ab1c.tar.gz | |
init
Diffstat (limited to 'zend/tests/Zend/Gdata')
279 files changed, 33731 insertions, 0 deletions
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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +if (!defined('PHPUnit_MAIN_METHOD')) { + define('PHPUnit_MAIN_METHOD', 'Zend_Gdata_AllTests::main'); +} + +/** + * Tests of the authentication URL generator + */ +require_once 'Zend/Gdata/AuthSubTest.php'; + +/** + * + */
+require_once 'Zend/Gdata/Analytics/AccountFeedTest.php'; +require_once 'Zend/Gdata/Analytics/AccountQueryTest.php'; +require_once 'Zend/Gdata/Analytics/DataFeedTest.php'; +require_once 'Zend/Gdata/Analytics/DataQueryTest.php'; + +/** + * Tests that do not require online access to servers + */ +require_once 'Zend/Gdata/AppTest.php'; +require_once 'Zend/Gdata/App/UtilTest.php'; +require_once 'Zend/Gdata/App/BaseTest.php'; +require_once 'Zend/Gdata/App/AuthorTest.php'; +require_once 'Zend/Gdata/App/CategoryTest.php'; +require_once 'Zend/Gdata/App/ContentTest.php'; +require_once 'Zend/Gdata/App/ControlTest.php'; +require_once 'Zend/Gdata/App/EntryTest.php'; +require_once 'Zend/Gdata/App/FeedTest.php'; +require_once 'Zend/Gdata/App/GeneratorTest.php'; +require_once 'Zend/Gdata/App/CaptchaRequiredExceptionTest.php'; +require_once 'Zend/Gdata/GdataTest.php'; +require_once 'Zend/Gdata/QueryTest.php'; + +require_once 'Zend/Gdata/AttendeeStatusTest.php'; +require_once 'Zend/Gdata/AttendeeTypeTest.php'; +require_once 'Zend/Gdata/CommentsTest.php'; +require_once 'Zend/Gdata/EntryTest.php'; +require_once 'Zend/Gdata/FeedTest.php'; +require_once 'Zend/Gdata/EntryLinkTest.php'; +require_once 'Zend/Gdata/EventStatusTest.php'; +require_once 'Zend/Gdata/ExtendedPropertyTest.php'; +require_once 'Zend/Gdata/FeedLinkTest.php'; +require_once 'Zend/Gdata/OpenSearchItemsPerPageTest.php'; +require_once 'Zend/Gdata/OpenSearchStartIndexTest.php'; +require_once 'Zend/Gdata/OpenSearchTotalResultsTest.php'; +require_once 'Zend/Gdata/OriginalEventTest.php'; +require_once 'Zend/Gdata/RecurrenceTest.php'; +require_once 'Zend/Gdata/RecurrenceExceptionTest.php'; +require_once 'Zend/Gdata/ReminderTest.php'; +require_once 'Zend/Gdata/TransparencyTest.php'; +require_once 'Zend/Gdata/VisibilityTest.php'; +require_once 'Zend/Gdata/WhenTest.php'; +require_once 'Zend/Gdata/WhereTest.php'; +require_once 'Zend/Gdata/WhoTest.php'; + +require_once 'Zend/Gdata/CalendarTest.php'; +require_once 'Zend/Gdata/CalendarFeedTest.php'; +require_once 'Zend/Gdata/CalendarEventTest.php'; +require_once 'Zend/Gdata/CalendarFeedCompositeTest.php'; +require_once 'Zend/Gdata/Calendar/EventQueryTest.php'; +require_once 'Zend/Gdata/Calendar/EventQueryExceptionTest.php'; +require_once 'Zend/Gdata/Calendar/EventEntryTest.php'; +require_once 'Zend/Gdata/Calendar/AccessLevelTest.php'; +require_once 'Zend/Gdata/Calendar/ColorTest.php'; +require_once 'Zend/Gdata/Calendar/HiddenTest.php'; +require_once 'Zend/Gdata/Calendar/LinkTest.php'; +require_once 'Zend/Gdata/Calendar/SelectedTest.php'; +require_once 'Zend/Gdata/Calendar/SendEventNotificationsTest.php'; +require_once 'Zend/Gdata/Calendar/TimezoneTest.php'; +require_once 'Zend/Gdata/Calendar/WebContentTest.php'; +require_once 'Zend/Gdata/Calendar/QuickAddTest.php'; + +require_once 'Zend/Gdata/Spreadsheets/ColCountTest.php'; +require_once 'Zend/Gdata/Spreadsheets/RowCountTest.php'; +require_once 'Zend/Gdata/Spreadsheets/CellTest.php'; +require_once 'Zend/Gdata/Spreadsheets/CustomTest.php'; +require_once 'Zend/Gdata/Spreadsheets/WorksheetEntryTest.php'; +require_once 'Zend/Gdata/Spreadsheets/CellEntryTest.php'; +require_once 'Zend/Gdata/Spreadsheets/ListEntryTest.php'; +require_once 'Zend/Gdata/Spreadsheets/SpreadsheetFeedTest.php'; +require_once 'Zend/Gdata/Spreadsheets/WorksheetFeedTest.php'; +require_once 'Zend/Gdata/Spreadsheets/CellFeedTest.php'; +require_once 'Zend/Gdata/Spreadsheets/ListFeedTest.php'; +require_once 'Zend/Gdata/Spreadsheets/DocumentQueryTest.php'; +require_once 'Zend/Gdata/Spreadsheets/CellQueryTest.php'; +require_once 'Zend/Gdata/Spreadsheets/ListQueryTest.php'; + +require_once 'Zend/Gdata/Docs/DocumentListFeedTest.php'; +require_once 'Zend/Gdata/Docs/DocumentListEntryTest.php'; +require_once 'Zend/Gdata/Docs/QueryTest.php'; + +require_once 'Zend/Gdata/Photos/PhotosAlbumEntryTest.php'; +require_once 'Zend/Gdata/Photos/PhotosAlbumFeedTest.php'; +require_once 'Zend/Gdata/Photos/PhotosAlbumQueryTest.php'; +require_once 'Zend/Gdata/Photos/PhotosCommentEntryTest.php'; +require_once 'Zend/Gdata/Photos/PhotosPhotoEntryTest.php'; +require_once 'Zend/Gdata/Photos/PhotosPhotoFeedTest.php'; +require_once 'Zend/Gdata/Photos/PhotosPhotoQueryTest.php'; +require_once 'Zend/Gdata/Photos/PhotosTagEntryTest.php'; +require_once 'Zend/Gdata/Photos/PhotosUserEntryTest.php'; +require_once 'Zend/Gdata/Photos/PhotosUserFeedTest.php'; +require_once 'Zend/Gdata/Photos/PhotosUserQueryTest.php'; + +require_once 'Zend/Gdata/GappsTest.php'; +require_once 'Zend/Gdata/Gapps/EmailListEntryTest.php'; +require_once 'Zend/Gdata/Gapps/EmailListFeedTest.php'; +require_once 'Zend/Gdata/Gapps/EmailListQueryTest.php'; +require_once 'Zend/Gdata/Gapps/EmailListRecipientEntryTest.php'; +require_once 'Zend/Gdata/Gapps/EmailListRecipientFeedTest.php'; +require_once 'Zend/Gdata/Gapps/EmailListRecipientQueryTest.php'; +require_once 'Zend/Gdata/Gapps/EmailListTest.php'; +require_once 'Zend/Gdata/Gapps/ErrorTest.php'; +require_once 'Zend/Gdata/Gapps/GroupEntryTest.php'; +require_once 'Zend/Gdata/Gapps/GroupFeedTest.php'; +require_once 'Zend/Gdata/Gapps/GroupQueryTest.php'; +require_once 'Zend/Gdata/Gapps/LoginTest.php'; +require_once 'Zend/Gdata/Gapps/MemberEntryTest.php'; +require_once 'Zend/Gdata/Gapps/MemberFeedTest.php'; +require_once 'Zend/Gdata/Gapps/MemberQueryTest.php'; +require_once 'Zend/Gdata/Gapps/NameTest.php'; +require_once 'Zend/Gdata/Gapps/NicknameEntryTest.php'; +require_once 'Zend/Gdata/Gapps/NicknameFeedTest.php'; +require_once 'Zend/Gdata/Gapps/NicknameQueryTest.php'; +require_once 'Zend/Gdata/Gapps/NicknameTest.php'; +require_once 'Zend/Gdata/Gapps/OwnerEntryTest.php'; +require_once 'Zend/Gdata/Gapps/OwnerFeedTest.php'; +require_once 'Zend/Gdata/Gapps/OwnerQueryTest.php'; +require_once 'Zend/Gdata/Gapps/PropertyTest.php'; +require_once 'Zend/Gdata/Gapps/QuotaTest.php'; +require_once 'Zend/Gdata/Gapps/ServiceExceptionTest.php'; +require_once 'Zend/Gdata/Gapps/UserEntryTest.php'; +require_once 'Zend/Gdata/Gapps/UserFeedTest.php'; +require_once 'Zend/Gdata/Gapps/UserQueryTest.php'; + +require_once 'Zend/Gdata/YouTube/PlaylistListFeedTest.php'; +require_once 'Zend/Gdata/YouTube/PlaylistListEntryTest.php'; +require_once 'Zend/Gdata/YouTube/SubscriptionFeedTest.php'; +require_once 'Zend/Gdata/YouTube/SubscriptionEntryTest.php'; +require_once 'Zend/Gdata/YouTube/PlaylistVideoEntryTest.php'; +require_once 'Zend/Gdata/YouTube/VideoEntryTest.php'; +require_once 'Zend/Gdata/YouTube/PlaylistVideoFeedTest.php'; +require_once 'Zend/Gdata/YouTube/VideoFeedTest.php'; +require_once 'Zend/Gdata/YouTube/UserProfileEntryTest.php'; +require_once 'Zend/Gdata/YouTube/CommentFeedTest.php'; +require_once 'Zend/Gdata/YouTube/CommentEntryTest.php'; +require_once 'Zend/Gdata/YouTube/ContactFeedTest.php'; +require_once 'Zend/Gdata/YouTube/ContactEntryTest.php'; +require_once 'Zend/Gdata/YouTube/VideoQueryTest.php'; +require_once 'Zend/Gdata/YouTube/ActivityFeedTest.php'; +require_once 'Zend/Gdata/YouTube/ActivityEntryTest.php'; + +require_once 'Zend/Gdata/Books/CollectionFeedTest.php'; +require_once 'Zend/Gdata/Books/CollectionEntryTest.php'; +require_once 'Zend/Gdata/Books/VolumeFeedTest.php'; +require_once 'Zend/Gdata/Books/VolumeEntryTest.php'; + +/** + * Tests that do require online access to servers + * and authentication credentials + */ +require_once 'Zend/Gdata/GdataOnlineTest.php'; +require_once 'Zend/Gdata/CalendarOnlineTest.php'; +require_once 'Zend/Gdata/SpreadsheetsOnlineTest.php'; +require_once 'Zend/Gdata/DocsOnlineTest.php'; +require_once 'Zend/Gdata/PhotosOnlineTest.php'; +require_once 'Zend/Gdata/GappsOnlineTest.php'; +require_once 'Zend/Gdata/YouTubeOnlineTest.php'; +require_once 'Zend/Gdata/BooksOnlineTest.php'; +require_once 'Zend/Gdata/SkipTests.php'; + +/** + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + */ +class Zend_Gdata_AllTests +{ + + public static function main() + { + PHPUnit_TextUI_TestRunner::run(self::suite()); + } + + public static function suite() + { + $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Gdata'); + + /** + * Tests of the authentication URL generator + */ + $suite->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Analytics + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id$ + */ + +require_once 'Zend/Gdata/Analytics.php'; +require_once 'Zend/Http/Client.php'; + +/** + * @category Zend + * @package Zend_Gdata_Analytics + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Analytics + */ +class Zend_Gdata_Analytics_AccountFeedTest extends PHPUnit_Framework_TestCase +{ + /** @var AccountFeed */ + public $accountFeed; + + public function setUp() + { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Analytics + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id$ + */ + +require_once 'Zend/Gdata/Analytics.php'; + +/** + * @category Zend + * @package Zend_Gdata_Analytics + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Analytics + */ +class Zend_GData_Analytics_AccountQueryTest extends PHPUnit_Framework_TestCase +{ + /** + * @var Zend_GData_Analytics_AccountQuery + */ + public $accountQuery; + + public function setUp() + { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Analytics + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id$ + */ + +require_once 'Zend/Gdata/Analytics.php'; +require_once 'Zend/Http/Client.php'; + +/** + * @category Zend + * @package Zend_Gdata_Analytics + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Analytics + */ +class Zend_Gdata_Analytics_DataFeedTest extends PHPUnit_Framework_TestCase +{ + public $testData = array( + 'foobarbaz.de' => 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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Analytics + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id$ + */ + +require_once 'Zend/Gdata/Analytics.php'; + +/** + * @category Zend + * @package Zend_Gdata_Analytics + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Analytics + */ +class Zend_GData_Analytics_DataQueryTest extends PHPUnit_Framework_TestCase +{ + + /** + * @var Zend_GData_Analytics_DataQuery + */ + public $dataQuery; + + public function setUp() + { + $this->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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<feed gd:kind="analytics#accounts" xmlns="http://www.w3.org/2005/Atom" xmlns:dxp="http://schemas.google.com/analytics/2009" xmlns:gd="http://schemas.google.com/g/2005" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/"> + <id>https://www.googleapis.com/analytics/v2.4/management/accounts</id> + <updated>2012-07-13T16:53:15.150Z</updated> + <title type="text">Google Analytics Accounts for mail@storkki.de</title> + <link rel="self" type="application/atom+xml" href="https://www.googleapis.com/analytics/v2.4/management/accounts" /> + <author> + <name>Google Analytics</name> + </author> + <generator>Google Analytics</generator> + <openSearch:totalResults>2</openSearch:totalResults> + <openSearch:startIndex>1</openSearch:startIndex> + <openSearch:itemsPerPage>1000</openSearch:itemsPerPage> + <entry gd:kind="analytics#account"> + <id>https://www.googleapis.com/analytics/v2.4/management/accounts/876543</id> + <updated>2010-03-02T16:04:23.720Z</updated> + <title type="text">Google Analytics Account foobarbaz</title> + <link rel="self" type="application/atom+xml" href="https://www.googleapis.com/analytics/v2.4/management/accounts/876543" /> + <link rel="http://schemas.google.com/ga/2009#child" type="application/atom+xml" gd:targetKind="analytics#webproperties" href="https://www.googleapis.com/analytics/v2.4/management/accounts/876543/webproperties" /> + <dxp:property name="ga:accountId" value="876543" /> + <dxp:property name="ga:accountName" value="foobarbaz" /> + </entry> + <entry gd:kind="analytics#account"> + <id>https://www.googleapis.com/analytics/v2.4/management/accounts/23456789</id> + <updated>2011-05-17T06:53:24.385Z</updated> + <title type="text">Google Analytics Account brain dump</title> + <link rel="self" type="application/atom+xml" href="https://www.googleapis.com/analytics/v2.4/management/accounts/23456789" /> + <link rel="http://schemas.google.com/ga/2009#child" type="application/atom+xml" gd:targetKind="analytics#webproperties" href="https://www.googleapis.com/analytics/v2.4/management/accounts/23456789/webproperties" /> + <dxp:property name="ga:accountId" value="23456789" /> + <dxp:property name="ga:accountName" value="brain dump" /> + </entry> +</feed>
\ 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dxp="http://schemas.google.com/analytics/2009" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/"> + <id>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</id> + <updated>2012-07-13T17:05:16.454Z</updated> + <title type="text">Google Analytics Data for Profile 45678912</title> + <link rel="self" type="application/atom+xml" href="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" /> + <author> + <name>Google Analytics</name> + </author> + <generator>Google Analytics</generator> + <openSearch:totalResults>4</openSearch:totalResults> + <openSearch:startIndex>1</openSearch:startIndex> + <openSearch:itemsPerPage>50</openSearch:itemsPerPage> + <dxp:aggregates> + <dxp:metric name="ga:bounces" type="integer" value="9" /> + <dxp:metric name="ga:visits" type="integer" value="20" /> + </dxp:aggregates> + <dxp:containsSampledData>false</dxp:containsSampledData> + <dxp:dataSource> + <dxp:property name="ga:profileId" value="45678912" /> + <dxp:property name="ga:webPropertyId" value="UA-23456789-1" /> + <dxp:property name="ga:accountName" value="foobar" /> + <dxp:tableId>ga:45678912</dxp:tableId> + <dxp:tableName>www.foobar.de</dxp:tableName> + </dxp:dataSource> + <dxp:endDate>2011-05-31</dxp:endDate> + <dxp:startDate>2011-05-01</dxp:startDate> + <entry> + <id>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</id> + <updated>2012-07-13T17:05:16.454Z</updated> + <title type="text">ga:medium=referral | ga:source=foobarbaz.de | ga:browserVersion=4.0.1 | ga:month=05</title> + <link rel="alternate" type="text/html" href="http://www.google.com/analytics" /> + <dxp:dimension name="ga:medium" value="referral" /> + <dxp:dimension name="ga:source" value="foobarbaz.de" /> + <dxp:dimension name="ga:browserVersion" value="4.0.1" /> + <dxp:dimension name="ga:month" value="05" /> + <dxp:metric name="ga:bounces" type="integer" value="5" /> + <dxp:metric name="ga:visits" type="integer" value="12" /> + </entry> + <entry> + <id>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</id> + <updated>2012-07-13T17:05:16.454Z</updated> + <title type="text">ga:medium=referral | ga:source=foobar.de | ga:browserVersion=3.6.17 | ga:month=05</title> + <link rel="alternate" type="text/html" href="http://www.google.com/analytics" /> + <dxp:dimension name="ga:medium" value="referral" /> + <dxp:dimension name="ga:source" value="foobar.de" /> + <dxp:dimension name="ga:browserVersion" value="3.6.17" /> + <dxp:dimension name="ga:month" value="05" /> + <dxp:metric name="ga:bounces" type="integer" value="1" /> + <dxp:metric name="ga:visits" type="integer" value="3" /> + </entry> + <entry> + <id>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</id> + <updated>2012-07-13T17:05:16.454Z</updated> + <title type="text">ga:medium=referral | ga:source=foobarbaz.ch | ga:browserVersion=3.5.19 | ga:month=05</title> + <link rel="alternate" type="text/html" href="http://www.google.com/analytics" /> + <dxp:dimension name="ga:medium" value="referral" /> + <dxp:dimension name="ga:source" value="foobarbaz.ch" /> + <dxp:dimension name="ga:browserVersion" value="3.5.19" /> + <dxp:dimension name="ga:month" value="05" /> + <dxp:metric name="ga:bounces" type="integer" value="1" /> + <dxp:metric name="ga:visits" type="integer" value="1" /> + </entry> + <entry> + <id>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</id> + <updated>2012-07-13T17:05:16.454Z</updated> + <title type="text">ga:medium=referral | ga:source=baz.ch | ga:browserVersion=3.6.17 | ga:month=05</title> + <link rel="alternate" type="text/html" href="http://www.google.com/analytics" /> + <dxp:dimension name="ga:medium" value="referral" /> + <dxp:dimension name="ga:source" value="baz.ch" /> + <dxp:dimension name="ga:browserVersion" value="3.6.17" /> + <dxp:dimension name="ga:month" value="05" /> + <dxp:metric name="ga:bounces" type="integer" value="1" /> + <dxp:metric name="ga:visits" type="integer" value="1" /> + </entry> +</feed>
\ 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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_App + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/App/Extension/Author.php'; +require_once 'Zend/Gdata/App.php'; + +/** + * @category Zend + * @package Zend_Gdata_App + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_App + */ +class Zend_Gdata_App_AuthorTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_App + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/App/MockBase.php'; + +/** + * @category Zend + * @package Zend_Gdata_App + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_App + */ +class Zend_Gdata_App_BaseTest extends PHPUnit_Framework_TestCase +{ + public function setUp() + { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_App + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + + require_once 'Zend/Gdata/App/CaptchaRequiredException.php'; + +/** + * @category Zend + * @package Zend_Gdata_App + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_App + */ +class Zend_Gdata_App_CaptchaRequiredExceptionTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_App + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/App/Extension/Category.php'; +require_once 'Zend/Gdata/App.php'; + +/** + * @category Zend + * @package Zend_Gdata_App + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_App + */ +class Zend_Gdata_App_CategoryTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_App + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/App/Extension/Content.php'; +require_once 'Zend/Gdata/App.php'; + +/** + * @category Zend + * @package Zend_Gdata_App + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_App + */ +class Zend_Gdata_App_ContentTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 = '<img src="http://www.example.com/image.jpg"/>'; + $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('<img src="http://www.example.com/image.jpg"/>', $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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_App + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/App/Extension/Control.php'; +require_once 'Zend/Gdata/App/Extension/Draft.php'; +require_once 'Zend/Gdata/App.php'; + +/** + * @category Zend + * @package Zend_Gdata_App + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_App + */ +class Zend_Gdata_App_ControlTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_App + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/App/Entry.php'; +require_once 'Zend/Gdata/App.php'; +require_once 'Zend/Gdata/TestUtility/MockHttpClient.php'; +require_once 'Zend/Gdata/HttpClient.php'; + +/** + * @category Zend + * @package Zend_Gdata_App + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_App + */ +class Zend_Gdata_App_EntryTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() + { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @feed Zend + * @category Zend + * @package Zend_Gdata_App + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/App/Feed.php'; +require_once 'Zend/Gdata/App.php'; + +/** + * @category Zend + * @package Zend_Gdata_App + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_App + */ +class Zend_Gdata_App_FeedTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_App + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/App/Extension/Generator.php'; +require_once 'Zend/Gdata/App/Extension/Draft.php'; +require_once 'Zend/Gdata/App.php'; + +/** + * @category Zend + * @package Zend_Gdata_App + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_App + */ +class Zend_Gdata_App_GeneratorTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_App + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/App.php'; +require_once 'Zend/Gdata/Spreadsheets.php'; +require_once 'Zend/Http/Client.php'; +require_once 'Zend/Gdata/ClientLogin.php'; + +/** + * @category Zend + * @package Zend_Gdata_App + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_App + */ +class Zend_Gdata_App_HttpExceptionTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() + { + $user = constant('TESTS_ZEND_GDATA_CLIENTLOGIN_EMAIL'); + $pass = constant('TESTS_ZEND_GDATA_CLIENTLOGIN_PASSWORD'); + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_App + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/App/Base.php'; + +/** + * Minimal implementation of Zend_Gdata_App_Base + * + * @category Zend + * @package Zend_Gdata + * @subpackage Unittests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + */ + +class Zend_Gdata_App_MockBase extends Zend_Gdata_App_Base +{ + // This space intentionally left blank. +} diff --git a/zend/tests/Zend/Gdata/App/UtilTest.php b/zend/tests/Zend/Gdata/App/UtilTest.php new file mode 100644 index 0000000..9d97a53 --- /dev/null +++ b/zend/tests/Zend/Gdata/App/UtilTest.php @@ -0,0 +1,229 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_App + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Http/Client.php'; +require_once 'Zend/Gdata/App/Util.php'; +require_once 'Zend/Gdata/App/Exception.php'; + +/** + * @category Zend + * @package Zend_Gdata_App + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_App + */ +class Zend_Gdata_App_UtilTest extends PHPUnit_Framework_TestCase +{ + + public function testFormatTimestampFromString() + { + // assert that a correctly formatted timestamp is not modified + $date = Zend_Gdata_App_Util::formatTimestamp('2006-12-01'); + $this->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 @@ +<?xml version="1.0" encoding="utf-8"?> +<author xmlns="http://www.w3.org/2005/Atom"> + <name xmlns="http://www.w3.org/2005/Atom">John Doe</name> + <email xmlns="http://www.w3.org/2005/Atom">johndoes@someemailadress.com</email> + <uri xmlns="http://www.w3.org/2005/Atom">http://www.google.com</uri> +</author> 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 @@ +<?xml version="1.0" encoding="utf-8"?> +<category scheme="http://schemas.google.com/g/2005#kind" + term="http://schemas.google.com/g/2005#event" + label="event kind"></category> 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 @@ +<?xml version="1.0" encoding="utf-8"?> +<content type="image/png" + src="http://www.example.com/image.png"/> 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 @@ +<?xml version="1.0" encoding="utf-8"?> +<content type="xhtml"><img src="http://www.example.com/image.jpg"/></content> 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 @@ +<?xml version="1.0" encoding="utf-8"?> +<control xmlns="http://www.w3.org/2005/Atom" xmlns:app="http://purl.org/atom/app#"> + <app:draft>yes</app:draft> +</control> 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 @@ +<?xml version="1.0" encoding="utf-8"?> +<entry xmlns="http://www.w3.org/2005/Atom"> + <title>Atom draft-07 snapshot</title> + <link rel="alternate" type="text/html" + href="http://example.org/2005/04/02/atom"/> + <link rel="enclosure" type="audio/mpeg" length="1337" + href="http://example.org/audio/ph34r_my_podcast.mp3"/> + <id>tag:example.org,2003:3.2397</id> + <updated>2005-07-31T12:29:29Z</updated> + <published>2003-12-13T08:29:29-04:00</published> + <author> + <name>Mark Pilgrim</name> + <uri>http://example.org/</uri> + <email>f8dy@example.com</email> + </author> + <contributor> + <name>Sam Ruby</name> + </contributor> + <contributor> + <name>Joe Gregorio</name> + </contributor> + <content type="xhtml" xml:lang="en" + xml:base="http://diveintomark.org/"> + <div xmlns="http://www.w3.org/1999/xhtml"> + <p><i>[Update: The Atom draft is finished.]</i></p> + </div> + </content> +</entry> 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 + +<?xml version="1.0" encoding="UTF-8"?> +<?xml-stylesheet href="http://www.google.com/url?sa=D&q=http://www.blogger.com/styles/atom.css" type="text/css"?> +<entry xmlns="http://www.w3.org/2005/Atom" xmlns:gd="http://schemas.google.com/g/2005" gd:etag="W/"CkcHQH8_fCp7ImA9WxRTGEw.""> + <id>tag:blogger.com,1999:blog-8273578352962669317.post-6938730899689776686</id> + <published>2008-09-07T10:53:00.001-07:00</published> + <updated>2008-09-07T10:53:51.144-07:00</updated> + <app:edited xmlns:app="http://www.w3.org/2007/app">2008-09-07T10:53:51.144-07:00</app:edited> + <title>Hello world</title> + <content type="html"><p>Hello world!</p></content> + <link rel="alternate" type="text/html" href="http://www.google.com/url?sa=D&q=http://example.blogspot.com/2008/09/hello-world.html" title="Hello world"/> + <link rel="replies" type="text/html" href="http://www.google.com/url?sa=D&q=http://www.blogger.com/comment.g%3FblogID%3D12345678901234567890%26amp%3BpostID%3D09876543210987654321" title="0 Comments"/> + <link rel="replies" type="application/atom+xml" href="http://www.google.com/url?sa=D&q=http://example.blogspot.com/feeds/12345678901234567890/comments/default" title="Post Comments"/> + <link rel="self" type="application/atom+xml" href="http://www.google.com/url?sa=D&q=http://example.blogspot.com/feeds/posts/default/12345678901234567890"/> + <link rel="edit" type="application/atom+xml" href="http://www.google.com/url?sa=D&q=http://www.blogger.com/feeds/12345678901234567890/posts/default/09876543210987654321%3Fv%3D2"/> + <author> + <name>John Doe</name> + <uri>http://www.blogger.com/profile/12345678901234567890</uri> + <email>jdoe@example.com</email> + </author> +</entry> 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 @@ +<?xml version="1.0" encoding="utf-8"?> +<feed xmlns="http://www.w3.org/2005/Atom"> + <title type="text">dive into mark</title> + <subtitle type="html"> + A <em>lot</em> of effort + went into making this effortless + </subtitle> + <updated>2005-07-31T12:29:29Z</updated> + <id>tag:example.org,2003:3</id> + <link rel="alternate" type="text/html" + hreflang="en" href="http://example.org/"/> + <link rel="self" type="application/atom+xml" + href="http://example.org/feed.atom"/> + <rights>Copyright (c) 2003, Mark Pilgrim</rights> + <generator uri="http://www.example.com/" version="1.0"> + Example Toolkit + </generator> + <entry> + <title>Atom draft-07 snapshot</title> + <link rel="alternate" type="text/html" + href="http://example.org/2005/04/02/atom"/> + <link rel="enclosure" type="audio/mpeg" length="1337" + href="http://example.org/audio/ph34r_my_podcast.mp3"/> + <id>tag:example.org,2003:3.2397</id> + <updated>2005-07-31T12:29:29Z</updated> + <published>2003-12-13T08:29:29-04:00</published> + <author> + <name>Mark Pilgrim</name> + <uri>http://example.org/</uri> + <email>f8dy@example.com</email> + </author> + <contributor> + <name>Sam Ruby</name> + </contributor> + <contributor> + <name>Joe Gregorio</name> + </contributor> + <content type="xhtml" xml:lang="en" + xml:base="http://diveintomark.org/"> + <div xmlns="http://www.w3.org/1999/xhtml"> + <p><i>[Update: The Atom draft is finished.]</i></p> + </div> + </content> + </entry> +</feed> 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 @@ +<?xml version="1.0" encoding="utf-8"?> +<generator xmlns="http://www.w3.org/2005/Atom" uri="http://code.google.com/apis/gdata/" version="1.0">Google data APIs</generator> 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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/App.php'; +require_once 'Zend/Gdata/HttpClient.php'; +require_once 'Zend/Gdata/TestUtility/MockHttpClient.php'; + +/** + * @category Zend + * @package Zend_Gdata_App + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_App + */ +class Zend_Gdata_AppTest extends PHPUnit_Framework_TestCase +{ + public function setUp() + { + $this->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('<id>12345678901234567890</id>', $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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Extension/AttendeeStatus.php'; +require_once 'Zend/Gdata.php'; + +/** + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + */ +class Zend_Gdata_AttendeeStatusTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Extension/AttendeeType.php'; +require_once 'Zend/Gdata.php'; + +/** + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + */ +class Zend_Gdata_AttendeeTypeTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/AuthSub.php'; +require_once 'Zend/Gdata/HttpClient.php'; + +/** + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_AuthSub + */ +class Zend_Gdata_AuthSubTest extends PHPUnit_Framework_TestCase +{ + /** + * Dummy token used during testing + * @var type string + */ + protected $token = 'DQAAFPHOW7DCTN'; + + + public function setUp() + { + } + + public function testNormalGetAuthSubTokenUri() + { + $uri = Zend_Gdata_AuthSub::getAuthSubTokenUri( + 'http://www.example.com/foo.php', //next + 'http://www.google.com/calendar/feeds', //scope + 0, //secure + 1); //session + + // 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('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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Books + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Books.php'; +require_once 'Zend/Gdata/Books/CollectionEntry.php'; + +/** + * @category Zend + * @package Zend_Gdata_Books + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Books + */ +class Zend_Gdata_Books_CollectionEntryTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() + { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Books + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Books.php'; +require_once 'Zend/Gdata/Books/CollectionFeed.php'; + +/** + * @category Zend + * @package Zend_Gdata_Books + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Books + */ +class Zend_Gdata_Books_CollectionFeedTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() + { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Books + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Books/VolumeEntry.php'; +require_once 'Zend/Gdata/Books.php'; + +/** + * @category Zend + * @package Zend_Gdata_Books + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Books + */ +class Zend_Gdata_Books_VolumeEntryTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Books + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Books/VolumeFeed.php'; +require_once 'Zend/Gdata/Books.php'; + +/** + * @category Zend + * @package Zend_Gdata_Books + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Books + */ +class Zend_Gdata_Books_VolumeFeedTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<entry xmlns="http://www.w3.org/2005/Atom" xmlns:gbs="http://schemas.google.com/books/2008" xmlns:dc="http://purl.org/dc/terms" xmlns:gd="http://schemas.google.com/g/2005"> + <id>http://www.google.com/books/feeds/volumes/Mfer_MFwQrkC</id> + <updated>2008-10-07T15:28:15.000Z</updated> + <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/books/2008#volume"/> + <title type="text">Hamlet</title> + <link rel="http://schemas.google.com/books/2008/thumbnail" type="image/jpeg" href="http://bks1.books.google.com/books?id=Mfer_MFwQrkC&printsec=frontcover&img=1&zoom=5&sig=ACfU3U1o90VpMryPI7WKSyIhmAWdC1uDtw&source=gbs_gdata"/> + <link rel="http://schemas.google.com/books/2008/info" type="text/html" href="http://books.google.com/books?id=Mfer_MFwQrkC&ie=ISO-8859-1&source=gbs_gdata"/> + <link rel="http://schemas.google.com/books/2008/annotation" type="application/atom+xml" href="http://www.google.com/books/feeds/users/me/volumes"/> + <link rel="alternate" type="text/html" href="http://books.google.com/books?id=Mfer_MFwQrkC&ie=ISO-8859-1"/> + <link rel="self" type="application/atom+xml" href="http://www.google.com/books/feeds/volumes/Mfer_MFwQrkC"/> + <gbs:embeddability value="http://schemas.google.com/books/2008#embeddable"/> + <gd:rating min="1" max="5" average="4.00"/> + <gbs:viewability value="http://schemas.google.com/books/2008#view_partial"/> + <gbs:review type="text">Bad review...</gbs:review> + <dc:creator>William Shakespeare</dc:creator> + <dc:creator>Roma Gill</dc:creator> + <dc:date>2002-02</dc:date> + <dc:description>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.</dc:description> + <dc:format>178 pages</dc:format> + <dc:identifier>Mfer_MFwQrkC</dc:identifier> + <dc:identifier>ISBN:0198320493</dc:identifier> + <dc:language>en</dc:language> + <dc:publisher>Oxford University Press</dc:publisher> + <dc:subject>Denmark</dc:subject> + <dc:subject>Hamlet (Legendary character)/ Drama</dc:subject> + <dc:subject>Murder victims' families/ Drama</dc:subject> + <dc:subject>Juvenile Nonfiction / Drama</dc:subject> + <dc:subject>Drama / English, Irish, Scottish, Welsh</dc:subject> + <dc:subject>Drama / Shakespeare</dc:subject> + <dc:title>Hamlet</dc:title> +</entry> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:gbs="http://schemas.google.com/books/2008" xmlns:dc="http://purl.org/dc/terms" xmlns:gd="http://schemas.google.com/g/2005"> + <id>http://www.google.com/books/feeds/volumes</id> + <updated>2008-10-07T16:41:52.000Z</updated> + <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/books/2008#volume"/> + <title type="text">Search results for Hamlet</title> + <link rel="alternate" type="text/html" href="http://www.google.com"/> + <link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://www.google.com/books/feeds/volumes"/> + <link rel="self" type="application/atom+xml" href="http://www.google.com/books/feeds/volumes?q=Hamlet&start-index=3&max-results=5"/> + <link rel="previous" type="application/atom+xml" href="http://www.google.com/books/feeds/volumes?q=Hamlet&start-index=1&max-results=5"/> + <link rel="next" type="application/atom+xml" href="http://www.google.com/books/feeds/volumes?q=Hamlet&start-index=8&max-results=5"/> + <author> + <name>Google Books Search</name> + <uri>http://www.google.com</uri> + </author> + <generator version="beta">Google Book Search data API</generator> + <openSearch:totalResults>512</openSearch:totalResults> + <openSearch:startIndex>3</openSearch:startIndex> + <openSearch:itemsPerPage>5</openSearch:itemsPerPage> + <entry> + <id>http://www.google.com/books/feeds/volumes/aCI_v2-QH04C</id> + <updated>2008-10-07T16:41:52.000Z</updated> + <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/books/2008#volume"/> + <title type="text">Hamlet</title> + <link rel="http://schemas.google.com/books/2008/thumbnail" type="image/jpeg" href="http://bks5.books.google.com/books?id=aCI_v2-QH04C&printsec=frontcover&img=1&zoom=5&sig=ACfU3U0hzA5WuX9ycsuiMYHnFC_52g2uSQ&source=gbs_gdata"/> + <link rel="http://schemas.google.com/books/2008/info" type="text/html" href="http://books.google.com/books?id=aCI_v2-QH04C&dq=Hamlet&ie=ISO-8859-1&source=gbs_gdata"/> + <link rel="http://schemas.google.com/books/2008/preview" type="text/html" href="http://books.google.com/books?id=aCI_v2-QH04C&printsec=frontcover&dq=Hamlet&ie=ISO-8859-1&sig=ACfU3U2Y_WCBPl33EgHiwDjc-epagCyfUQ&source=gbs_gdata"/> + <link rel="http://schemas.google.com/books/2008/annotation" type="application/atom+xml" href="http://www.google.com/books/feeds/users/me/volumes"/> + <link rel="alternate" type="text/html" href="http://books.google.com/books?id=aCI_v2-QH04C&dq=Hamlet&ie=ISO-8859-1"/> + <link rel="self" type="application/atom+xml" href="http://www.google.com/books/feeds/volumes/aCI_v2-QH04C"/> + <gbs:embeddability value="http://schemas.google.com/books/2008#embeddable"/> + <gbs:viewability value="http://schemas.google.com/books/2008#view_partial"/> + <dc:creator>William Shakespeare</dc:creator> + <dc:creator>Barbara Mowat</dc:creator> + <dc:creator>Paul Werstine</dc:creator> + <dc:date>2003-07-01</dc:date> + <dc:description>Each edition includes:• Freshly edited text based on the best early printed version of the play• Full explanatory notes conveniently placed on pages facing...</dc:description> + <dc:format>400 pages</dc:format> + <dc:identifier>aCI_v2-QH04C</dc:identifier> + <dc:identifier>ISBN:074347712X</dc:identifier> + <dc:publisher>Washington Square Press</dc:publisher> + <dc:subject>Fiction</dc:subject> + <dc:title>Hamlet</dc:title> + <dc:title>Prince of Denmark</dc:title> + </entry> + <entry> + <id>http://www.google.com/books/feeds/volumes/VBoVAAAAYAAJ</id> + <updated>2008-10-07T16:41:52.000Z</updated> + <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/books/2008#volume"/> + <title type="text">Hamlet</title> + <link rel="http://schemas.google.com/books/2008/thumbnail" type="image/jpeg" href="http://bks6.books.google.com/books?id=VBoVAAAAYAAJ&printsec=frontcover&img=1&zoom=5&sig=ACfU3U35P7EolTO0Anl72daruQ1LnQaNNQ&source=gbs_gdata"/> + <link rel="http://schemas.google.com/books/2008/info" type="text/html" href="http://books.google.com/books?id=VBoVAAAAYAAJ&dq=Hamlet&ie=ISO-8859-1&source=gbs_gdata"/> + <link rel="http://schemas.google.com/books/2008/preview" type="text/html" href="http://books.google.com/books?id=VBoVAAAAYAAJ&printsec=frontcover&dq=Hamlet&ie=ISO-8859-1&source=gbs_gdata"/> + <link rel="http://schemas.google.com/books/2008/annotation" type="application/atom+xml" href="http://www.google.com/books/feeds/users/me/volumes"/> + <link rel="alternate" type="text/html" href="http://books.google.com/books?id=VBoVAAAAYAAJ&dq=Hamlet&ie=ISO-8859-1"/> + <link rel="self" type="application/atom+xml" href="http://www.google.com/books/feeds/volumes/VBoVAAAAYAAJ"/> + <gbs:embeddability value="http://schemas.google.com/books/2008#embeddable"/> + <gbs:viewability value="http://schemas.google.com/books/2008#view_all_pages"/> + <dc:creator>William Shakespeare</dc:creator> + <dc:creator>George Pierce Baker</dc:creator> + <dc:date>1913</dc:date> + <dc:format>219 pages</dc:format> + <dc:identifier>VBoVAAAAYAAJ</dc:identifier> + <dc:identifier>HARVARD:32044100887074</dc:identifier> + <dc:subject>Hamlet (Legendary character)</dc:subject> + <dc:title>Hamlet</dc:title> + <dc:title>Prince of Denmark</dc:title> + </entry> + <entry> + <id>http://www.google.com/books/feeds/volumes/S5YvAgAACAAJ</id> + <updated>2008-10-07T16:41:52.000Z</updated> + <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/books/2008#volume"/> + <title type="text">Hamlet</title> + <link rel="http://schemas.google.com/books/2008/info" type="text/html" href="http://books.google.com/books?id=S5YvAgAACAAJ&dq=Hamlet&ie=ISO-8859-1&source=gbs_gdata"/> + <link rel="http://schemas.google.com/books/2008/preview" type="text/html" href="http://books.google.com/books?id=S5YvAgAACAAJ&dq=Hamlet&ie=ISO-8859-1&source=gbs_gdata"/> + <link rel="http://schemas.google.com/books/2008/annotation" type="application/atom+xml" href="http://www.google.com/books/feeds/users/me/volumes"/> + <link rel="alternate" type="text/html" href="http://books.google.com/books?id=S5YvAgAACAAJ&dq=Hamlet&ie=ISO-8859-1"/> + <link rel="self" type="application/atom+xml" href="http://www.google.com/books/feeds/volumes/S5YvAgAACAAJ"/> + <gbs:embeddability value="http://schemas.google.com/books/2008#not_embeddable"/> + <gbs:viewability value="http://schemas.google.com/books/2008#view_no_pages"/> + <dc:creator>William Shakespeare</dc:creator> + <dc:date>1995-05-01</dc:date> + <dc:description>Among Shakespeare&#39;s plays, &quot;Hamlet&quot; is considered by many hismasterpiece.</dc:description> + <dc:identifier>S5YvAgAACAAJ</dc:identifier> + <dc:identifier>ISBN:0811468259</dc:identifier> + <dc:publisher>Heinemann/Raintree</dc:publisher> + <dc:subject>Juvenile Fiction</dc:subject> + <dc:title>Hamlet</dc:title> + </entry> + <entry> + <id>http://www.google.com/books/feeds/volumes/Hxk3SFdOJr4C</id> + <updated>2008-10-07T16:41:52.000Z</updated> + <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/books/2008#volume"/> + <title type="text">Hamlet</title> + <link rel="http://schemas.google.com/books/2008/thumbnail" type="image/jpeg" href="http://bks7.books.google.com/books?id=Hxk3SFdOJr4C&printsec=frontcover&img=1&zoom=5&sig=ACfU3U01kEvsaU9Xwylt1L1LRcm90LN5Uw&source=gbs_gdata"/> + <link rel="http://schemas.google.com/books/2008/info" type="text/html" href="http://books.google.com/books?id=Hxk3SFdOJr4C&dq=Hamlet&ie=ISO-8859-1&source=gbs_gdata"/> + <link rel="http://schemas.google.com/books/2008/preview" type="text/html" href="http://books.google.com/books?id=Hxk3SFdOJr4C&printsec=frontcover&dq=Hamlet&ie=ISO-8859-1&sig=ACfU3U03yzRV9AE_v9QFehA7JEQQN-cMIg&source=gbs_gdata"/> + <link rel="http://schemas.google.com/books/2008/annotation" type="application/atom+xml" href="http://www.google.com/books/feeds/users/me/volumes"/> + <link rel="alternate" type="text/html" href="http://books.google.com/books?id=Hxk3SFdOJr4C&dq=Hamlet&ie=ISO-8859-1"/> + <link rel="self" type="application/atom+xml" href="http://www.google.com/books/feeds/volumes/Hxk3SFdOJr4C"/> + <gbs:embeddability value="http://schemas.google.com/books/2008#embeddable"/> + <gbs:viewability value="http://schemas.google.com/books/2008#view_partial"/> + <dc:creator>William Shakespeare</dc:creator> + <dc:creator>Alan Durband</dc:creator> + <dc:date>1987-05-01</dc:date> + <dc:description>The significance of the plays is reinforced by sections discussing Shakespeare&#39;s life, works and theatre.</dc:description> + <dc:format>336 pages</dc:format> + <dc:identifier>Hxk3SFdOJr4C</dc:identifier> + <dc:identifier>ISBN:0748703462</dc:identifier> + <dc:publisher>Nelson Thornes Ltd</dc:publisher> + <dc:subject>Drama</dc:subject> + <dc:title>Hamlet</dc:title> + <dc:title>Shakespeare Made Easy</dc:title> + </entry> + <entry> + <id>http://www.google.com/books/feeds/volumes/lZE0AAAAMAAJ</id> + <updated>2008-10-07T16:41:52.000Z</updated> + <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/books/2008#volume"/> + <title type="text">Julius Caesar</title> + <link rel="http://schemas.google.com/books/2008/thumbnail" type="image/jpeg" href="http://bks8.books.google.com/books?id=lZE0AAAAMAAJ&printsec=frontcover&img=1&zoom=5&sig=ACfU3U1wZVOn_xoKk7kHn4apYEK_1GmZDg&source=gbs_gdata"/> + <link rel="http://schemas.google.com/books/2008/info" type="text/html" href="http://books.google.com/books?id=lZE0AAAAMAAJ&dq=Hamlet&ie=ISO-8859-1&source=gbs_gdata"/> + <link rel="http://schemas.google.com/books/2008/preview" type="text/html" href="http://books.google.com/books?id=lZE0AAAAMAAJ&printsec=frontcover&dq=Hamlet&ie=ISO-8859-1&source=gbs_gdata"/> + <link rel="http://schemas.google.com/books/2008/annotation" type="application/atom+xml" href="http://www.google.com/books/feeds/users/me/volumes"/> + <link rel="alternate" type="text/html" href="http://books.google.com/books?id=lZE0AAAAMAAJ&dq=Hamlet&ie=ISO-8859-1"/> + <link rel="self" type="application/atom+xml" href="http://www.google.com/books/feeds/volumes/lZE0AAAAMAAJ"/> + <gbs:embeddability value="http://schemas.google.com/books/2008#embeddable"/> + <gbs:viewability value="http://schemas.google.com/books/2008#view_all_pages"/> + <dc:creator>William Shakespeare</dc:creator> + <dc:creator>Samuel Thurber</dc:creator> + <dc:creator>Arthur Wilson Verity</dc:creator> + <dc:date>1895</dc:date> + <dc:description>Tan leather binding, gold-embossed, with gilt pattern insert and coat of arms on cover.</dc:description> + <dc:format>123 pages</dc:format> + <dc:identifier>lZE0AAAAMAAJ</dc:identifier> + <dc:identifier>UOM:39015063516275</dc:identifier> + <dc:subject>Conspiracies</dc:subject> + <dc:title>Julius Caesar</dc:title> + </entry> +</feed> 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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Books + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Books.php'; +require_once 'Zend/Http/Client.php'; +require_once 'Zend/Gdata/ClientLogin.php'; + +/** + * @category Zend + * @package Zend_Gdata_Books + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Books + */ +class Zend_Gdata_BooksOnlineTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() + { + $user = constant('TESTS_ZEND_GDATA_CLIENTLOGIN_EMAIL'); + $pass = constant('TESTS_ZEND_GDATA_CLIENTLOGIN_PASSWORD'); + $service = Zend_Gdata_Books::AUTH_SERVICE_NAME; + $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service); + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Books + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Books.php'; +require_once 'Zend/Http/Client.php'; + +/** + * @category Zend + * @package Zend_Gdata_Books + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Books + */ +class Zend_Gdata_BooksTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() + { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Calendar + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Calendar/Extension/AccessLevel.php'; +require_once 'Zend/Gdata/Calendar.php'; + +/** + * @category Zend + * @package Zend_Gdata_Calendar + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Calendar + */ +class Zend_Gdata_Calendar_AccessLevelTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Calendar + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Calendar/Extension/Color.php'; +require_once 'Zend/Gdata/Calendar.php'; + +/** + * @category Zend + * @package Zend_Gdata_Calendar + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Calendar + */ +class Zend_Gdata_Calendar_ColorTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @feed Zend + * @category Zend + * @package Zend_Gdata_Calendar + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Calendar/EventEntry.php'; +require_once 'Zend/Gdata/Calendar.php'; + +/** + * @category Zend + * @package Zend_Gdata_Calendar + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Calendar + */ +class Zend_Gdata_Calendar_EventEntryTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 = '<img src="http://www.example.com/image.jpg"/>'; + $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('<img src="http://www.example.com/image.jpg"/>', $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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Calendar + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Calendar.php'; +require_once 'Zend/Gdata/Calendar/EventQuery.php'; +require_once 'Zend/Http/Client.php'; + +/** + * @category Zend + * @package Zend_Gdata_Calendar + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Calendar + */ +class Zend_Gdata_Calendar_EventQueryExceptionTest extends PHPUnit_Framework_TestCase +{ + + const GOOGLE_DEVELOPER_CALENDAR = 'developer-calendar@google.com'; + + public function setUp() + { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Calendar + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Calendar.php'; +require_once 'Zend/Gdata/Calendar/EventQuery.php'; +require_once 'Zend/Http/Client.php'; + +/** + * @category Zend + * @package Zend_Gdata_Calendar + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Calendar + */ +class Zend_Gdata_Calendar_EventQueryTest extends PHPUnit_Framework_TestCase +{ + + const GOOGLE_DEVELOPER_CALENDAR = 'developer-calendar@google.com'; + const ZEND_CONFERENCE_EVENT = 'bn2h4o4mc3a03ci4t48j3m56pg'; + const ZEND_CONFERENCE_EVENT_COMMENT = 'i9q87onko1uphfs7i21elnnb4g'; + const SAMPLE_RFC3339 = "2007-06-05T18:38:00"; + public function setUp() + { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Calendar + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Calendar/Extension/Hidden.php'; +require_once 'Zend/Gdata/Calendar.php'; + +/** + * @category Zend + * @package Zend_Gdata_Calendar + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Calendar + */ +class Zend_Gdata_Calendar_HiddenTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Calendar + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Calendar/Extension/Link.php'; +require_once 'Zend/Gdata/Calendar/Extension/WebContent.php'; +require_once 'Zend/Gdata/Calendar.php'; + +/** + * @category Zend + * @package Zend_Gdata_Calendar + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Calendar + */ +class Zend_Gdata_Calendar_LinkTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Calendar + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Calendar/Extension/QuickAdd.php'; +require_once 'Zend/Gdata/Calendar.php'; + +/** + * @category Zend + * @package Zend_Gdata_Calendar + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Calendar + */ +class Zend_Gdata_Calendar_QuickAddTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Calendar + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Calendar/Extension/Selected.php'; +require_once 'Zend/Gdata/Calendar.php'; + +/** + * @category Zend + * @package Zend_Gdata_Calendar + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Calendar + */ +class Zend_Gdata_Calendar_SelectedTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Calendar + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Calendar/Extension/SendEventNotifications.php'; +require_once 'Zend/Gdata/Calendar.php'; + +/** + * @category Zend + * @package Zend_Gdata_Calendar + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Calendar + */ +class Zend_Gdata_Calendar_SendEventNotificationsTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Calendar + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Calendar/Extension/Timezone.php'; +require_once 'Zend/Gdata/Calendar.php'; + +/** + * @category Zend + * @package Zend_Gdata_Calendar + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Calendar + */ +class Zend_Gdata_Calendar_TimezoneTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Calendar + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Calendar/Extension/WebContent.php'; +require_once 'Zend/Gdata/Calendar.php'; + +/** + * @category Zend + * @package Zend_Gdata_Calendar + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Calendar + */ +class Zend_Gdata_Calendar_WebContentTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?xml version="1.0" encoding="utf-8" ?> +<accesslevel xmlns="http://schemas.google.com/gCal/2005" value="owner"/> 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 @@ +<?xml version="1.0" encoding="utf-8" ?> +<color xmlns="http://schemas.google.com/gCal/2005" value="#5A6986"/> 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 @@ +<?xml version='1.0' encoding='utf-8'?> +<entry xmlns='http://www.w3.org/2005/Atom' +xmlns:gd='http://schemas.google.com/g/2005' +xmlns:gCal='http://schemas.google.com/gCal/2005'> + <id> + http://www.google.com/calendar/feeds/default/private/full/s0dtsvq4pe15ku09jideg67fv4_20070509T193000Z</id> + <published>2007-05-09T16:32:03.000Z</published> + <updated>2007-05-09T16:34:33.000Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://schemas.google.com/g/2005#event'></category> + <title type='text'>www2007 recurring</title> + <content type='text'></content> + <link rel='alternate' type='text/html' + href='http://www.google.com/calendar/event?eid=czBkdHN2cTRwZTE1a3UwOWppZGVnNjdmdjRfMjAwNzA1MDlUMTkzMDAwWiBnZGF0YS5vcHMudGVzdEBt' + title='alternate'></link> + <link rel='self' type='application/atom+xml' + href='http://www.google.com/calendar/feeds/default/private/full/s0dtsvq4pe15ku09jideg67fv4_20070509T193000Z'> + </link> + <link rel='edit' type='application/atom+xml' + href='http://www.google.com/calendar/feeds/default/private/full/s0dtsvq4pe15ku09jideg67fv4_20070509T193000Z/63314411673'> + </link> + <author> + <name>gdata ops</name> + <email>gdata.ops.test@gmail.com</email> + </author> + <gd:originalEvent id='s0dtsvq4pe15ku09jideg67fv4' + href='http://www.google.com/calendar/feeds/default/private/full/s0dtsvq4pe15ku09jideg67fv4'> + <gd:when startTime='2007-05-09T14:30:00.000-05:00'></gd:when> + </gd:originalEvent> + <gd:comments> + <gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/s0dtsvq4pe15ku09jideg67fv4_20070509T193000Z/comments'> + </gd:feedLink> + </gd:comments> + <gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'> + </gd:eventStatus> + <gd:visibility value='http://schemas.google.com/g/2005#event.default'> + </gd:visibility> + <gd:transparency value='http://schemas.google.com/g/2005#event.opaque'> + </gd:transparency> + <gCal:sendEventNotifications value='false'> + </gCal:sendEventNotifications> + <gCal:timezone value='America/Los_Angeles'> + </gCal:timezone> + <gd:when startTime='2007-05-09T17:30:00.000-05:00' + endTime='2007-05-09T18:30:00.000-05:00'> + <gd:reminder minutes='10' method='alert'></gd:reminder> + <gd:reminder minutes='10' method='email'></gd:reminder> + </gd:when> + <gd:where valueString='Down by the river'></gd:where> + <gd:extendedProperty name='http://frank.schemas/2005#prop' value='Mantek' /> +</entry> 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 @@ +<?xml version="1.0"?> +<feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:gd="http://schemas.google.com/g/2005" xmlns:gCal="http://schemas.google.com/gCal/2005"> + <id>http://www.google.com/calendar/feeds/default/private/composite</id> + <updated>2007-05-31T01:15:00.000Z</updated> + <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/g/2005#event"/> + <title type="text">GData Ops Demo's Composite View</title> + <subtitle type="text">GData Is Awesome</subtitle> + <link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://www.google.com/calendar/feeds/default/private/composite"/> + <link rel="self" type="application/atom+xml" href="http://www.google.com/calendar/feeds/default/private/composite?max-results=25"/> + <author> + <name>GData Ops Demo</name> + <email>gdata.ops.demo@gmail.com</email> + </author> + <generator version="1.0" uri="http://www.google.com/calendar">Google Calendar</generator> + <openSearch:totalResults>7</openSearch:totalResults> + <openSearch:startIndex>1</openSearch:startIndex> + <openSearch:itemsPerPage>25</openSearch:itemsPerPage> + <gCal:timezone value="America/Chicago"/> + <entry> + <id> + http://www.google.com/calendar/feeds/default/private/composite/5v9l3sqdqt0b7mg1nhnmgdfup8</id> + <published>2007-09-14T15:37:53.000Z</published> + <updated>2007-09-14T15:37:53.000Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://schemas.google.com/g/2005#event' /> + <title type='text'>Specialized Event</title> + <content type='text'></content> + <link rel='alternate' type='text/html' + href='http://www.google.com/calendar/event?eid=NXY5bDNzcWRxdDBiN21nMW5obm1nZGZ1cDhfMjAwNzA5MTNUMTUwMDAwWiBnZGF0YS5vcHMuZGVtb0Bt' + title='alternate' /> + <link rel='self' type='application/atom+xml' + href='http://www.google.com/calendar/feeds/default/private/composite/5v9l3sqdqt0b7mg1nhnmgdfup8' /> + <author> + <name>GData Ops Demo</name> + <email>gdata.ops.demo@gmail.com</email> + </author> + <gd:recurrence>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</gd:recurrence> + <gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed' /> + <gd:visibility value='http://schemas.google.com/g/2005#event.default' /> + <gd:transparency value='http://schemas.google.com/g/2005#event.opaque' /> + <gCal:uid value='5v9l3sqdqt0b7mg1nhnmgdfup8@google.com' /> + <gCal:sequence value='0' /> + <gd:reminder minutes='10' method='sms' /> + <gd:reminder minutes='10' method='alert' /> + <gCal:sendEventNotifications value="false"/> + <gd:recurrenceException specialized='false'> + <gd:entryLink> + <entry> + <id>5v9l3sqdqt0b7mg1nhnmgdfup8_20070914T150000Z</id> + <published>2007-09-14T15:37:53.000Z</published> + <updated>2007-09-14T15:41:06.000Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://schemas.google.com/g/2005#event' /> + <title type='text'>Specialized Event</title> + <content type='text'></content> + <link rel='alternate' type='text/html' + href='http://www.google.com/calendar/event?eid=NXY5bDNzcWRxdDBiN21nMW5obm1nZGZ1cDhfMjAwNzA5MTRUMTUwMDAwWiBnZGF0YS5vcHMuZGVtb0Bt' + title='alternate' /> + <author> + <name>GData Ops Demo</name> + <email>gdata.ops.demo@gmail.com</email> + </author> + <gd:originalEvent id='5v9l3sqdqt0b7mg1nhnmgdfup8' + href='http://www.google.com/calendar/feeds/default/private/composite/5v9l3sqdqt0b7mg1nhnmgdfup8'> + + <gd:when startTime='2007-09-14T08:00:00.000-07:00' /> + </gd:originalEvent> + <gd:comments> + <gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/5v9l3sqdqt0b7mg1nhnmgdfup8_20070914T150000Z/comments'> + + <feed> + <id> + http://www.google.com/calendar/feeds/default/private/full/5v9l3sqdqt0b7mg1nhnmgdfup8_20070914T150000Z/comments</id> + <updated>2007-09-14T15:42:41.390Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://schemas.google.com/g/2005#message' /> + <title type='text'>Comments for: Specialized + Event</title> + <link rel='alternate' type='text/html' + href='http://www.google.com/calendar/feeds/default/private/full/5v9l3sqdqt0b7mg1nhnmgdfup8_20070914T150000Z/comments' + title='alternate' /> + </feed> + </gd:feedLink> + </gd:comments> + <gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed' /> + <gd:visibility value='http://schemas.google.com/g/2005#event.default' /> + <gd:transparency value='http://schemas.google.com/g/2005#event.opaque' /> + <gCal:uid value='5v9l3sqdqt0b7mg1nhnmgdfup8@google.com' /> + <gCal:sequence value='0' /> + <gd:when startTime='2007-09-14T08:00:00.000-07:00' + endTime='2007-09-14T09:00:00.000-07:00'> + <gd:reminder minutes='10' method='alert' /> + </gd:when> + <gd:who rel='http://schemas.google.com/g/2005#event.attendee' + valueString='gdata ops' email='gdata.ops.test@gmail.com'> + <gd:attendeeStatus value='http://schemas.google.com/g/2005#event.invited' /> + </gd:who> + <gd:who rel='http://schemas.google.com/g/2005#event.organizer' + valueString='GData Ops Demo' + email='gdata.ops.demo@gmail.com'> + <gd:attendeeStatus value='http://schemas.google.com/g/2005#event.accepted' /> + </gd:who> + <gd:where valueString='' /> + </entry> + </gd:entryLink> + </gd:recurrenceException> + <gd:who rel='http://schemas.google.com/g/2005#event.organizer' + valueString='GData Ops Demo' email='gdata.ops.demo@gmail.com'> + <gd:attendeeStatus value='' /> + </gd:who> + <gd:where valueString='' /> + </entry> + <entry> + <id>http://www.google.com/calendar/feeds/default/private/composite/sh6kv08egsls7mc5tf6np8hi9c</id> + <published>2007-05-24T20:49:14.000Z</published> + <updated>2007-05-24T20:49:14.000Z</updated> + <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/g/2005#event"/> + <category scheme="http://schemas.google.com/g/2005" term="http://schemas.google.com/g/2005#event"/> + <title type="text">Tennis Game</title> + <content type="text">Meet for a quick lesson.</content> + <link rel="alternate" type="text/html" href="http://www.google.com/calendar/event?eid=c2g2a3YwOGVnc2xzN21jNXRmNm5wOGhpOWNfMjAwNzA1MDEgZ2RhdGEub3BzLnRlc3RAbQ" title="alternate"/> + <link rel="self" type="application/atom+xml" href="http://www.google.com/calendar/feeds/default/private/composite/sh6kv08egsls7mc5tf6np8hi9c"/> + <author> + <name>GData Ops Demo</name> + <email>gdata.ops.demo@gmail.com</email> + </author> + <gd:recurrence>DTSTART;VALUE=DATE:20070501 DTEND;VALUE=DATE:20070502 RRULE:FREQ=WEEKLY;BYDAY=Tu;UNTIL=20070904</gd:recurrence> + <gd:eventStatus value="http://schemas.google.com/g/2005#event.confirmed"/> + <gd:visibility value="http://schemas.google.com/g/2005#event.default"/> + <gd:transparency value="http://schemas.google.com/g/2005#event.opaque"/> + <gCal:sendEventNotifications value="false"/> + <gd:where valueString="South Tennis Courts"/> + </entry> + <entry> + <id>http://www.google.com/calendar/feeds/default/private/composite/lq2ai6imsbq209q3aeturho50g</id> + <published>2007-05-09T16:44:38.000Z</published> + <updated>2007-05-17T10:33:49.000Z</updated> + <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/g/2005#event"/> + <title type="text">all day event may 24</title> + <content type="text"/> + <link rel="alternate" type="text/html" href="http://www.google.com/calendar/event?eid=bHEyYWk2aW1zYnEyMDlxM2FldHVyaG81MGcgZ2RhdGEub3BzLnRlc3RAbQ" title="alternate"/> + <link rel="self" type="application/atom+xml" href="http://www.google.com/calendar/feeds/default/private/composite/lq2ai6imsbq209q3aeturho50g"/> + <author> + <name>GData Ops Demo</name> + <email>gdata.ops.demo@gmail.com</email> + </author> + <gd:comments> + <gd:feedLink href="http://www.google.com/calendar/feeds/default/private/full/lq2ai6imsbq209q3aeturho50g/comments"> + <feed> + <updated>2007-05-31T01:15:13.249Z</updated> + <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/g/2005#message"/> + <title type="text">Comments for: all day event may 24</title> + <link rel="alternate" type="text/html" href="http://www.google.com/calendar/feeds/default/private/full/lq2ai6imsbq209q3aeturho50g/comments" title="alternate"/> + <entry> + <id>dfr2c8pbtb8g6uphrsrlpao7mc</id> + <published>2007-05-23T20:38:08.000Z</published> + <updated>2007-05-23T20:38:08.000Z</updated> + <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/g/2005#message"/> + <content type="html"><p>This is my comments!</p></content> + <author> + <name>User 1</name> + <email>user1@nowhere.invalid</email> + </author> + </entry> + <entry> + <id>i9q87onko1uphfs7i21elnnb4g</id> + <published>2007-06-01T21:21:47.000Z</published> + <updated>2007-06-01T21:21:47.000Z</updated> + <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/g/2005#message"/> + <content type="html"><p>This is a user supplied comment.</p></content> + <author> + <name>User 2</name> + <email>user2@nowhere.invalid</email> + </author> + </entry> + </feed> + </gd:feedLink> + </gd:comments> + <gd:eventStatus value="http://schemas.google.com/g/2005#event.confirmed"/> + <gd:visibility value="http://schemas.google.com/g/2005#event.default"/> + <gd:transparency value="http://schemas.google.com/g/2005#event.transparent"/> + <gCal:sendEventNotifications value="false"/> + <gd:when startTime="2007-05-24" endTime="2007-05-25"> + <gd:reminder minutes="10" method="alert"/> + <gd:reminder minutes="10" method="email"/> + </gd:when> + <gd:where valueString="Mountain View, California"/> + </entry> + <entry> + <id>http://www.google.com/calendar/feeds/default/private/composite/4v2a4eddoqja2727ptkq78euq8</id> + <published>2007-05-09T16:43:58.000Z</published> + <updated>2007-05-17T10:33:49.000Z</updated> + <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/g/2005#event"/> + <title type="text">all day event may 23</title> + <content type="text"/> + <link rel="alternate" type="text/html" href="http://www.google.com/calendar/event?eid=NHYyYTRlZGRvcWphMjcyN3B0a3E3OGV1cTggZ2RhdGEub3BzLnRlc3RAbQ" title="alternate"/> + <link rel="self" type="application/atom+xml" href="http://www.google.com/calendar/feeds/default/private/composite/4v2a4eddoqja2727ptkq78euq8"/> + <author> + <name>GData Ops Demo</name> + <email>gdata.ops.demo@gmail.com</email> + </author> + <gd:comments> + <gd:feedLink href="http://www.google.com/calendar/feeds/default/private/full/4v2a4eddoqja2727ptkq78euq8/comments"> + <feed> + <updated>2007-05-31T01:15:13.250Z</updated> + <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/g/2005#message"/> + <title type="text">Comments for: all day event may 23</title> + <link rel="alternate" type="text/html" href="http://www.google.com/calendar/feeds/default/private/full/4v2a4eddoqja2727ptkq78euq8/comments" title="alternate"/> + </feed> + </gd:feedLink> + </gd:comments> + <gd:eventStatus value="http://schemas.google.com/g/2005#event.confirmed"/> + <gd:visibility value="http://schemas.google.com/g/2005#event.default"/> + <gd:transparency value="http://schemas.google.com/g/2005#event.transparent"/> + <gCal:sendEventNotifications value="false"/> + <gd:when startTime="2007-05-23" endTime="2007-05-24"> + <gd:reminder minutes="10" method="alert"/> + <gd:reminder minutes="10" method="email"/> + </gd:when> + <gd:where/> + </entry> + <entry> + <id>http://www.google.com/calendar/feeds/default/private/composite/14gfovd20fqvtj1d1np7ei9tbg</id> + <published>2007-05-09T16:43:53.000Z</published> + <updated>2007-05-17T10:33:49.000Z</updated> + <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/g/2005#event"/> + <title type="text">all day event may 22</title> + <content type="text"/> + <link rel="alternate" type="text/html" href="http://www.google.com/calendar/event?eid=MTRnZm92ZDIwZnF2dGoxZDFucDdlaTl0YmcgZ2RhdGEub3BzLnRlc3RAbQ" title="alternate"/> + <link rel="self" type="application/atom+xml" href="http://www.google.com/calendar/feeds/default/private/composite/14gfovd20fqvtj1d1np7ei9tbg"/> + <author> + <name>GData Ops Demo</name> + <email>gdata.ops.demo@gmail.com</email> + </author> + <gd:comments> + <gd:feedLink href="http://www.google.com/calendar/feeds/default/private/full/14gfovd20fqvtj1d1np7ei9tbg/comments"> + <feed> + <updated>2007-05-31T01:15:13.250Z</updated> + <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/g/2005#message"/> + <title type="text">Comments for: all day event may 22</title> + <link rel="alternate" type="text/html" href="http://www.google.com/calendar/feeds/default/private/full/14gfovd20fqvtj1d1np7ei9tbg/comments" title="alternate"/> + </feed> + </gd:feedLink> + </gd:comments> + <gd:eventStatus value="http://schemas.google.com/g/2005#event.confirmed"/> + <gd:visibility value="http://schemas.google.com/g/2005#event.default"/> + <gd:transparency value="http://schemas.google.com/g/2005#event.transparent"/> + <gCal:sendEventNotifications value="false"/> + <gd:when startTime="2007-05-22" endTime="2007-05-23"> + <gd:reminder minutes="10" method="alert"/> + <gd:reminder minutes="10" method="email"/> + </gd:when> + <gd:where/> + </entry> + <entry> + <id>http://www.google.com/calendar/feeds/default/private/composite/s0dtsvq4pe15ku09jideg67fv4_20070509T193000Z</id> + <published>2007-05-09T16:32:03.000Z</published> + <updated>2007-05-09T16:34:33.000Z</updated> + <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/g/2005#event"/> + <title type="text">www2007 recurring</title> + <content type="text"/> + <link rel="alternate" type="text/html" href="http://www.google.com/calendar/event?eid=czBkdHN2cTRwZTE1a3UwOWppZGVnNjdmdjRfMjAwNzA1MDlUMTkzMDAwWiBnZGF0YS5vcHMudGVzdEBt" title="alternate"/> + <link rel="self" type="application/atom+xml" href="http://www.google.com/calendar/feeds/default/private/composite/s0dtsvq4pe15ku09jideg67fv4_20070509T193000Z"/> + <author> + <name>GData Ops Demo</name> + <email>gdata.ops.demo@gmail.com</email> + </author> + <gd:originalEvent id="s0dtsvq4pe15ku09jideg67fv4" href="http://www.google.com/calendar/feeds/default/private/composite/s0dtsvq4pe15ku09jideg67fv4"> + <gd:when startTime="2007-05-09T14:30:00.000-05:00"/> + </gd:originalEvent> + <gd:comments> + <gd:feedLink href="http://www.google.com/calendar/feeds/default/private/full/s0dtsvq4pe15ku09jideg67fv4_20070509T193000Z/comments"> + <feed> + <updated>2007-05-31T01:15:13.251Z</updated> + <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/g/2005#message"/> + <title type="text">Comments for: www2007 recurring</title> + <link rel="alternate" type="text/html" href="http://www.google.com/calendar/feeds/default/private/full/s0dtsvq4pe15ku09jideg67fv4_20070509T193000Z/comments" title="alternate"/> + </feed> + </gd:feedLink> + </gd:comments> + <gd:eventStatus value="http://schemas.google.com/g/2005#event.confirmed"/> + <gd:visibility value="http://schemas.google.com/g/2005#event.default"/> + <gd:transparency value="http://schemas.google.com/g/2005#event.opaque"/> + <gCal:sendEventNotifications value="false"/> + <gd:when startTime="2007-05-09T17:30:00.000-05:00" endTime="2007-05-09T18:30:00.000-05:00"> + <gd:reminder minutes="10" method="alert"/> + <gd:reminder minutes="10" method="email"/> + </gd:when> + <gd:where valueString=""/> + </entry> + <entry> + <id>http://www.google.com/calendar/feeds/default/private/composite/s0dtsvq4pe15ku09jideg67fv4</id> + <published>2007-05-09T16:32:03.000Z</published> + <updated>2007-05-09T16:32:03.000Z</updated> + <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/g/2005#event"/> + <title type="text">www2007 recurring</title> + <content type="text"/> + <link rel="alternate" type="text/html" href="http://www.google.com/calendar/event?eid=czBkdHN2cTRwZTE1a3UwOWppZGVnNjdmdjRfMjAwNzA1MDhUMTkzMDAwWiBnZGF0YS5vcHMudGVzdEBt" title="alternate"/> + <link rel="self" type="application/atom+xml" href="http://www.google.com/calendar/feeds/default/private/composite/s0dtsvq4pe15ku09jideg67fv4"/> + <author> + <name>GData Ops Demo</name> + <email>gdata.ops.demo@gmail.com</email> + </author> + <gd:recurrence>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</gd:recurrence> + <gd:eventStatus value="http://schemas.google.com/g/2005#event.confirmed"/> + <gd:visibility value="http://schemas.google.com/g/2005#event.default"/> + <gd:transparency value="http://schemas.google.com/g/2005#event.opaque"/> + <gCal:sendEventNotifications value="false"/> + <gd:reminder minutes="10" method="alert"/> + <gd:reminder minutes="10" method="email"/> + <gd:recurrenceException specialized="true"> + <gd:entryLink> + <entry> + <id>s0dtsvq4pe15ku09jideg67fv4_20070509T193000Z</id> + <published>2007-05-09T16:32:03.000Z</published> + <updated>2007-05-09T16:34:33.000Z</updated> + <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/g/2005#event"/> + <title type="text">www2007 recurring</title> + <content type="text"/> + <link rel="alternate" type="text/html" href="http://www.google.com/calendar/event?eid=czBkdHN2cTRwZTE1a3UwOWppZGVnNjdmdjRfMjAwNzA1MDlUMTkzMDAwWiBnZGF0YS5vcHMudGVzdEBt" title="alternate"/> + <author> + <name>GData Ops Demo</name> + <email>gdata.ops.demo@gmail.com</email> + </author> + <gd:originalEvent id="s0dtsvq4pe15ku09jideg67fv4" href="http://www.google.com/calendar/feeds/default/private/composite/s0dtsvq4pe15ku09jideg67fv4"> + <gd:when startTime="2007-05-09T14:30:00.000-05:00"/> + </gd:originalEvent> + <gd:comments> + <gd:feedLink href="http://www.google.com/calendar/feeds/default/private/full/s0dtsvq4pe15ku09jideg67fv4_20070509T193000Z/comments"> + <feed> + <updated>2007-05-31T01:15:13.259Z</updated> + <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/g/2005#message"/> + <title type="text">Comments for: www2007 recurring</title> + <link rel="alternate" type="text/html" href="http://www.google.com/calendar/feeds/default/private/full/s0dtsvq4pe15ku09jideg67fv4_20070509T193000Z/comments" title="alternate"/> + </feed> + </gd:feedLink> + </gd:comments> + <gd:eventStatus value="http://schemas.google.com/g/2005#event.confirmed"/> + <gd:visibility value="http://schemas.google.com/g/2005#event.default"/> + <gd:transparency value="http://schemas.google.com/g/2005#event.opaque"/> + <gCal:sendEventNotifications value="false"/> + <gd:when startTime="2007-05-09T17:30:00.000-05:00" endTime="2007-05-09T18:30:00.000-05:00"> + <gd:reminder minutes="10" method="alert"/> + <gd:reminder minutes="10" method="email"/> + </gd:when> + <gd:where valueString=""/> + </entry> + </gd:entryLink> + </gd:recurrenceException> + <gd:where valueString=""/> + </entry> +</feed> + 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 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hidden xmlns="http://schemas.google.com/gCal/2005" value="false"/> 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 @@ +<?xml version="1.0" encoding="utf-8" ?> +<atom:link xmlns:atom="http://www.w3.org/2005/Atom" + rel="http://schemas.google.com/gCal/2005/webContent" + title="Independence Day" + href="http://www.google.com/calendar/images/google-holiday.gif" + type="image/gif"> + <gCal:webContent xmlns:gCal="http://schemas.google.com/gCal/2005" + url="http://www.google.com/logos/july4th06.gif" + width="276" height="120" /> +</atom:link>
\ 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 @@ +<?xml version="1.0"?>
+<feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:gd="http://schemas.google.com/g/2005" xmlns:gCal="http://schemas.google.com/gCal/2005">
+ <id>http://www.google.com/calendar/feeds/default</id>
+ <updated>2007-05-30T00:23:26.998Z</updated>
+ <title type="text">GData Ops Demo's Calendar List</title>
+ <link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://www.google.com/calendar/feeds/default"/>
+ <link rel="http://schemas.google.com/g/2005#post" type="application/atom+xml" href="http://www.google.com/calendar/feeds/default"/>
+ <link rel="self" type="application/atom+xml" href="http://www.google.com/calendar/feeds/default"/>
+ <author>
+ <name>GData Ops Demo</name>
+ <email>gdata.ops.demo@gmail.com</email>
+ <uri>http://test.address.invalid/</uri>
+ </author>
+ <generator version="1.0" uri="http://www.google.com/calendar">Google Calendar</generator>
+ <openSearch:startIndex>1</openSearch:startIndex>
+ <entry>
+ <id>http://www.google.com/calendar/feeds/default/gdata.ops.demo%40gmail.com</id>
+ <published>2007-05-30T00:23:27.006Z</published>
+ <updated>2007-05-30T00:20:38.000Z</updated>
+ <title type="text">GData Ops Demo</title>
+ <link rel="alternate" type="application/atom+xml" href="http://www.google.com/calendar/feeds/gdata.ops.demo%40gmail.com/private/full"/>
+ <link rel="http://schemas.google.com/acl/2007#accessControlList" type="application/atom+xml" href="http://www.google.com/calendar/feeds/gdata.ops.demo%41gmail.com/acl/full"/>
+ <link rel="self" type="application/atom+xml" href="http://www.google.com/calendar/feeds/default/gdata.ops.demo%40gmail.com"/>
+ <author>
+ <name>GData Ops Demo</name>
+ <email>gdata.ops.demo@gmail.com</email>
+ </author>
+ <gCal:timezone value="America/Chicago"/>
+ <gCal:hidden value="false"/>
+ <gCal:color value="#2952A3"/>
+ <gCal:selected value="true"/>
+ <gCal:accesslevel value="owner"/>
+ </entry>
+ <entry>
+ <id>http://www.google.com/calendar/feeds/default/ri3u1buho56d1k2papoec4c16s%40group.calendar.google.com</id>
+ <published>2007-05-30T00:23:27.005Z</published>
+ <updated>2007-05-30T00:20:38.000Z</updated>
+ <title type="text">My Other Awesome Calendar</title>
+ <summary type="text">This is my other calendar.</summary>
+ <link rel="alternate" type="application/atom+xml" href="http://www.google.com/calendar/feeds/ri3u1buho56d1k2papoec4c16s%40group.calendar.google.com/private/full"/>
+ <link rel="http://schemas.google.com/acl/2007#accessControlList" type="application/atom+xml" href="http://www.google.com/calendar/feeds/ri3u1buho56d1k2papoec4c16s%40group.calendar.google.com/acl/full"/>
+ <link rel="self" type="application/atom+xml" href="http://www.google.com/calendar/feeds/default/ri3u1buho56d1k2papoec4c16s%40group.calendar.google.com"/>
+ <author>
+ <name>GData Ops Demo</name>
+ <email>gdata.ops.demo@gmail.com</email>
+ </author>
+ <gCal:timezone value="America/Chicago"/>
+ <gCal:hidden value="false"/>
+ <gCal:color value="#A32929"/>
+ <gCal:selected value="true"/>
+ <gCal:accesslevel value="owner"/>
+ <gd:where valueString="Palo Alto, California"/>
+ </entry>
+ <entry>
+ <id>http://www.google.com/calendar/feeds/default/5fcmq8mrd633rulib1jgtuuk90%40group.calendar.google.com</id>
+ <published>2007-05-30T00:23:27.005Z</published>
+ <updated>2007-05-22T05:35:47.000Z</updated>
+ <title type="text">Sample Calendar A</title>
+ <summary type="text"/>
+ <link rel="alternate" type="application/atom+xml" href="http://www.google.com/calendar/feeds/5fcmq8mrd633rulib1jgtuuk90%40group.calendar.google.com/private/full"/>
+ <link rel="http://schemas.google.com/acl/2007#accessControlList" type="application/atom+xml" href="http://www.google.com/calendar/feeds/5fcmq8mrd633rulib1jgtuuk90%40group.calendar.google.com/acl/full"/>
+ <link rel="self" type="application/atom+xml" href="http://www.google.com/calendar/feeds/default/5fcmq8mrd633rulib1jgtuuk90%40group.calendar.google.com"/>
+ <author>
+ <name>GData Ops Demo</name>
+ <email>gdata.ops.demo@gmail.com</email>
+ </author>
+ <gCal:timezone value="America/Los_Angeles"/>
+ <gCal:hidden value="false"/>
+ <gCal:color value="#5A6986"/>
+ <gCal:selected value="false"/>
+ <gCal:accesslevel value="owner"/>
+ <gd:where valueString=""/>
+ </entry>
+ <entry>
+ <id>http://www.google.com/calendar/feeds/default/a2f8cl1m7ottkhmoita51gu9cc%40group.calendar.google.com</id>
+ <published>2007-05-30T00:23:27.005Z</published>
+ <updated>2007-05-21T07:31:41.000Z</updated>
+ <title type="text">Sample Calendar B</title>
+ <summary type="text"/>
+ <link rel="alternate" type="application/atom+xml" href="http://www.google.com/calendar/feeds/a2f8cl1m7ottkhmoita51gu9cc%40group.calendar.google.com/private/full"/>
+ <link rel="http://schemas.google.com/acl/2007#accessControlList" type="application/atom+xml" href="http://www.google.com/calendar/feeds/a2f8cl1m7ottkhmoita51gu9cc%40group.calendar.google.com/acl/full"/>
+ <link rel="self" type="application/atom+xml" href="http://www.google.com/calendar/feeds/default/a2f8cl1m7ottkhmoita51gu9cc%40group.calendar.google.com"/>
+ <author>
+ <name>GData Ops Demo</name>
+ <email>gdata.ops.demo@gmail.com</email>
+ </author>
+ <gCal:timezone value="America/Los_Angeles"/>
+ <gCal:hidden value="false"/>
+ <gCal:color value="#5A6986"/>
+ <gCal:selected value="false"/>
+ <gCal:accesslevel value="owner"/>
+ <gd:where valueString=""/>
+ </entry>
+ <entry>
+ <id>http://www.google.com/calendar/feeds/default/rndpkbg35nhelu9fbp63u9sgp0%40group.calendar.google.com</id>
+ <published>2007-05-30T00:23:27.006Z</published>
+ <updated>2007-05-22T21:02:34.000Z</updated>
+ <title type="text">Sample Calendar C</title>
+ <summary type="text"/>
+ <link rel="alternate" type="application/atom+xml" href="http://www.google.com/calendar/feeds/rndpkbg35nhelu9fbp63u9sgp0%40group.calendar.google.com/private/full"/>
+ <link rel="http://schemas.google.com/acl/2007#accessControlList" type="application/atom+xml" href="http://www.google.com/calendar/feeds/rndpkbg35nhelu9fbp63u9sgp0%40group.calendar.google.com/acl/full"/>
+ <link rel="self" type="application/atom+xml" href="http://www.google.com/calendar/feeds/default/rndpkbg35nhelu9fbp63u9sgp0%40group.calendar.google.com"/>
+ <author>
+ <name>GData Ops Demo</name>
+ <email>gdata.ops.demo@gmail.com</email>
+ </author>
+ <gCal:timezone value="America/Los_Angeles"/>
+ <gCal:hidden value="false"/>
+ <gCal:color value="#B1440E"/>
+ <gCal:selected value="true"/>
+ <gCal:accesslevel value="owner"/>
+ <gd:where valueString=""/>
+ </entry>
+ <entry>
+ <id>http://www.google.com/calendar/feeds/default/u4u5cksnpp1vufdarpupn5um5s%40group.calendar.google.com</id>
+ <published>2007-05-30T00:23:27.006Z</published>
+ <updated>2007-05-17T10:12:36.000Z</updated>
+ <title type="text">Sample Calendar D</title>
+ <summary type="text"/>
+ <link rel="alternate" type="application/atom+xml" href="http://www.google.com/calendar/feeds/u4u5cksnpp1vufdarpupn5um5s%40group.calendar.google.com/private/full"/>
+ <link rel="http://schemas.google.com/acl/2007#accessControlList" type="application/atom+xml" href="http://www.google.com/calendar/feeds/u4u5cksnpp1vufdarpupn5um5s%40group.calendar.google.com/acl/full"/>
+ <link rel="self" type="application/atom+xml" href="http://www.google.com/calendar/feeds/default/u4u5cksnpp1vufdarpupn5um5s%40group.calendar.google.com"/>
+ <author>
+ <name>GData Ops Demo</name>
+ <email>gdata.ops.demo@gmail.com</email>
+ </author>
+ <gCal:timezone value="America/Los_Angeles"/>
+ <gCal:hidden value="false"/>
+ <gCal:color value="#528800"/>
+ <gCal:selected value="false"/>
+ <gCal:accesslevel value="owner"/>
+ <gd:where valueString=""/>
+ </entry>
+ <entry>
+ <id>http://www.google.com/calendar/feeds/default/ibdlf33v6fj62rgfucib6s181s%40group.calendar.google.com</id>
+ <published>2007-05-30T00:23:27.006Z</published>
+ <updated>2007-05-17T10:52:01.000Z</updated>
+ <title type="text">Sample Calender E</title>
+ <summary type="text"/>
+ <link rel="alternate" type="application/atom+xml" href="http://www.google.com/calendar/feeds/ibdlf33v6fj62rgfucib6s181s%40group.calendar.google.com/private/full"/>
+ <link rel="http://schemas.google.com/acl/2007#accessControlList" type="application/atom+xml" href="http://www.google.com/calendar/feeds/ibdlf33v6fj62rgfucib6s181s%40group.calendar.google.com/acl/full"/>
+ <link rel="self" type="application/atom+xml" href="http://www.google.com/calendar/feeds/default/ibdlf33v6fj62rgfucib6s181s%40group.calendar.google.com"/>
+ <author>
+ <name>GData Ops Demo</name>
+ <email>gdata.ops.demo@gmail.com</email>
+ </author>
+ <gCal:timezone value="America/Chicago"/>
+ <gCal:hidden value="false"/>
+ <gCal:color value="#5A6986"/>
+ <gCal:selected value="false"/>
+ <gCal:accesslevel value="owner"/>
+ <gd:where valueString=""/>
+ </entry>
+ <entry>
+ <id>http://www.google.com/calendar/feeds/default/usa__en%40holiday.calendar.google.com</id>
+ <published>2007-05-30T00:23:27.006Z</published>
+ <updated>2007-05-17T09:48:29.000Z</updated>
+ <title type="text">US Holidays</title>
+ <link rel="alternate" type="application/atom+xml" href="http://www.google.com/calendar/feeds/usa__en%40holiday.calendar.google.com/private/full"/>
+ <link rel="self" type="application/atom+xml" href="http://www.google.com/calendar/feeds/default/usa__en%40holiday.calendar.google.com"/>
+ <author>
+ <name>GData Ops Demo</name>
+ <email>gdata.ops.demo@gmail.com</email>
+ </author>
+ <gCal:timezone value="America/Los_Angeles"/>
+ <gCal:hidden value="false"/>
+ <gCal:color value="#5A6986"/>
+ <gCal:selected value="false"/>
+ <gCal:accesslevel value="read"/>
+ </entry>
+ <entry>
+ <id>http://www.google.com/calendar/feeds/default/7u5mocvk4et2vgtjte1dtcff2o%40group.calendar.google.com</id>
+ <published>2007-05-30T00:23:27.005Z</published>
+ <updated>2007-05-30T00:20:02.000Z</updated>
+ <title type="text">My Awesome Calendar</title>
+ <summary type="text">This is my awesome calendar</summary>
+ <link rel="alternate" type="application/atom+xml" href="http://www.google.com/calendar/feeds/7u5mocvk4et2vgtjte1dtcff2o%40group.calendar.google.com/private/full"/>
+ <link rel="http://schemas.google.com/acl/2007#accessControlList" type="application/atom+xml" href="http://www.google.com/calendar/feeds/7u5mocvk4et2vgtjte1dtcff2o%40group.calendar.google.com/acl/full"/>
+ <link rel="self" type="application/atom+xml" href="http://www.google.com/calendar/feeds/default/7u5mocvk4et2vgtjte1dtcff2o%40group.calendar.google.com"/>
+ <author>
+ <name>GData Ops Demo</name>
+ <email>gdata.ops.demo@gmail.com</email>
+ </author>
+ <gCal:timezone value="America/Los_Angeles"/>
+ <gCal:hidden value="false"/>
+ <gCal:color value="#5A6986"/>
+ <gCal:selected value="false"/>
+ <gCal:accesslevel value="owner"/>
+ <gd:where valueString="Mountain View, California"/>
+ </entry>
+</feed>
+
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 @@ +<?xml version="1.0" encoding="utf-8" ?> +<quickadd xmlns="http://schemas.google.com/gCal/2005" value="true"/> 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 @@ +<?xml version="1.0" encoding="utf-8" ?> +<selected xmlns="http://schemas.google.com/gCal/2005" value="false"/> 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 @@ +<?xml version="1.0" encoding="utf-8" ?> +<sendEventNotifications xmlns="http://schemas.google.com/gCal/2005" value="false"/> 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 @@ +<?xml version='1.0' encoding='utf-8'?> +<feed xmlns='http://www.w3.org/2005/Atom' +xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' +xmlns:gd='http://schemas.google.com/g/2005' +xmlns:gCal='http://schemas.google.com/gCal/2005'> + <id> + http://www.google.com/calendar/feeds/default/private/full</id> + <updated>2007-03-20T21:29:57.000Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://schemas.google.com/g/2005#event'></category> + <title type='text'>GData Ops Demo</title> + <subtitle type='text'>Demo Feed</subtitle> + <link rel='http://schemas.google.com/g/2005#feed' + type='application/atom+xml' + href='http://www.google.com/calendar/feeds/default/private/full'> + </link> + <link rel='http://schemas.google.com/g/2005#post' + type='application/atom+xml' + href='http://www.google.com/calendar/feeds/default/private/full'> + </link> + <link rel='self' type='application/atom+xml' + href='http://www.google.com/calendar/feeds/default/private/full?updated-min=2001-01-01&max-results=25'> + </link> + <author> + <name>GData Ops Demo</name> + <email>gdata.ops.demo@gmail.com</email> + <uri>http://test.address.invalid/</uri> + </author> + <generator version='1.0' uri='http://www.google.com/calendar'> + Google Calendar</generator> + <openSearch:totalResults>10</openSearch:totalResults> + <openSearch:startIndex>1</openSearch:startIndex> + <openSearch:itemsPerPage>25</openSearch:itemsPerPage> + <gCal:timezone value='America/Los_Angeles'></gCal:timezone> + <entry> + <id> + http://www.google.com/calendar/feeds/default/private/full/o99flmgmkfkfrr8u745ghr3100</id> + <published>2007-03-20T21:29:52.000Z</published> + <updated>2007-03-20T21:29:57.000Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://schemas.google.com/g/2005#event'></category> + <title type='text'>test deleted</title> + <content type='text'></content> + <link rel='alternate' type='text/html' + href='http://www.google.com/calendar/event?eid=bzk5ZmxtZ21rZmtmcnI4dTc0NWdocjMxMDAgZ2RhdGEub3BzLmRlbW9AbQ' + title='alternate'></link> + <link rel='self' type='application/atom+xml' + href='http://www.google.com/calendar/feeds/default/private/full/o99flmgmkfkfrr8u745ghr3100'> + </link> + <link rel='edit' type='application/atom+xml' + href='http://www.google.com/calendar/feeds/default/private/full/o99flmgmkfkfrr8u745ghr3100/63310109397'> + </link> + <author> + <name>GData Ops Demo</name> + <email>gdata.ops.demo@gmail.com</email> + </author> + <gCal:sendEventNotifications value='false'> + </gCal:sendEventNotifications> + <gd:eventStatus value='http://schemas.google.com/g/2005#event.canceled'> + </gd:eventStatus> + <gd:comments> + <gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/o99flmgmkfkfrr8u745ghr3100/comments'> + </gd:feedLink> + </gd:comments> + <gd:visibility value='http://schemas.google.com/g/2005#event.default'> + </gd:visibility> + <gd:transparency value='http://schemas.google.com/g/2005#event.opaque'> + </gd:transparency> + <gd:when startTime='2007-03-23T12:00:00.000-07:00' + endTime='2007-03-23T13:00:00.000-07:00'> + <gd:reminder minutes='10'></gd:reminder> + </gd:when> + <gd:where></gd:where> + </entry> + <entry> + <id> + http://www.google.com/calendar/feeds/default/private/full/2qt3ao5hbaq7m9igr5ak9esjo0</id> + <published>2007-03-20T21:26:04.000Z</published> + <updated>2007-03-20T21:28:46.000Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://schemas.google.com/g/2005#event'></category> + <title type='text'>Afternoon at Dolores Park with Kim</title> + <content type='text'>This will be fun.</content> + <link rel='alternate' type='text/html' + href='http://www.google.com/calendar/event?eid=MnF0M2FvNWhiYXE3bTlpZ3I1YWs5ZXNqbzAgZ2RhdGEub3BzLmRlbW9AbQ' + title='alternate'></link> + <link rel='self' type='application/atom+xml' + href='http://www.google.com/calendar/feeds/default/private/full/2qt3ao5hbaq7m9igr5ak9esjo0'> + </link> + <link rel='edit' type='application/atom+xml' + href='http://www.google.com/calendar/feeds/default/private/full/2qt3ao5hbaq7m9igr5ak9esjo0/63310109326'> + </link> + <author> + <name>GData Ops Demo</name> + <email>gdata.ops.demo@gmail.com</email> + </author> + <gCal:sendEventNotifications value='false'> + </gCal:sendEventNotifications> + <gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'> + </gd:eventStatus> + <gd:comments> + <gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/2qt3ao5hbaq7m9igr5ak9esjo0/comments'> + </gd:feedLink> + </gd:comments> + <gd:visibility value='http://schemas.google.com/g/2005#event.private'> + </gd:visibility> + <gd:transparency value='http://schemas.google.com/g/2005#event.opaque'> + </gd:transparency> + <gd:who rel='http://schemas.google.com/g/2005#event.organizer' + valueString='GData Ops Demo' email='gdata.ops.demo@gmail.com'> + <gd:attendeeStatus value='http://schemas.google.com/g/2005#event.accepted'> + </gd:attendeeStatus> + </gd:who> + <gd:who rel='http://schemas.google.com/g/2005#event.attendee' + valueString='Ryan Boyd (API)' email='api.rboyd@gmail.com'> + <gd:attendeeStatus value='http://schemas.google.com/g/2005#event.invited'> + </gd:attendeeStatus> + </gd:who> + <gd:when startTime='2007-03-24T12:00:00.000-07:00' + endTime='2007-03-24T15:00:00.000-07:00'> + <gd:reminder minutes='20' method="alert"></gd:reminder> + </gd:when> + <gd:where valueString='Dolores Park with Kim'></gd:where> + <gCal:quickadd value="true" /> + </entry> + <entry> + <id> + http://www.google.com/calendar/feeds/default/private/full/uvsqhg7klnae40v50vihr1pvos</id> + <published>2007-03-20T21:28:37.000Z</published> + <updated>2007-03-20T21:28:37.000Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://schemas.google.com/g/2005#event'></category> + <title type='text'>Team meeting</title> + <content type='text'></content> + <link rel='alternate' type='text/html' + href='http://www.google.com/calendar/event?eid=dXZzcWhnN2tsbmFlNDB2NTB2aWhyMXB2b3NfMjAwNzAzMjNUMTYwMDAwWiBnZGF0YS5vcHMuZGVtb0Bt' + title='alternate'></link> + <link rel='self' type='application/atom+xml' + href='http://www.google.com/calendar/feeds/default/private/full/uvsqhg7klnae40v50vihr1pvos'> + </link> + <link rel='edit' type='application/atom+xml' + href='http://www.google.com/calendar/feeds/default/private/full/uvsqhg7klnae40v50vihr1pvos/63310109317'> + </link> + <author> + <name>GData Ops Demo</name> + <email>gdata.ops.demo@gmail.com</email> + </author> + <gd:recurrence>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</gd:recurrence> + <gCal:sendEventNotifications value='true'> + </gCal:sendEventNotifications> + <gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'> + </gd:eventStatus> + <gd:visibility value='http://schemas.google.com/g/2005#event.public'> + </gd:visibility> + <gd:transparency value='http://schemas.google.com/g/2005#event.opaque'> + </gd:transparency> + <gd:reminder minutes='10'></gd:reminder> + <gd:where valueString=''></gd:where> + </entry> + <entry> + <id> + http://www.google.com/calendar/feeds/default/private/full/st4vk9kiffs6rasrl32e4a7alo</id> + <published>2007-03-20T21:25:46.000Z</published> + <updated>2007-03-20T21:25:46.000Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://schemas.google.com/g/2005#event'></category> + <title type='text'>Movie with Kim and danah</title> + <content type='text'></content> + <link rel='alternate' type='text/html' + href='http://www.google.com/calendar/event?eid=c3Q0dms5a2lmZnM2cmFzcmwzMmU0YTdhbG8gZ2RhdGEub3BzLmRlbW9AbQ' + title='alternate'></link> + <link rel='self' type='application/atom+xml' + href='http://www.google.com/calendar/feeds/default/private/full/st4vk9kiffs6rasrl32e4a7alo'> + </link> + <link rel='edit' type='application/atom+xml' + href='http://www.google.com/calendar/feeds/default/private/full/st4vk9kiffs6rasrl32e4a7alo/63310109146'> + </link> + <author> + <name>GData Ops Demo</name> + <email>gdata.ops.demo@gmail.com</email> + </author> + <gCal:sendEventNotifications value='false'> + </gCal:sendEventNotifications> + <gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'> + </gd:eventStatus> + <gd:comments> + <gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/st4vk9kiffs6rasrl32e4a7alo/comments'> + </gd:feedLink> + </gd:comments> + <gd:visibility value='http://schemas.google.com/g/2005#event.default'> + </gd:visibility> + <gd:transparency value='http://schemas.google.com/g/2005#event.opaque'> + </gd:transparency> + <gd:when startTime='2007-03-24T20:00:00.000-07:00' + endTime='2007-03-24T21:00:00.000-07:00'> + <gd:reminder minutes='10'></gd:reminder> + </gd:when> + <gd:where></gd:where> + </entry> + <entry> + <id> + http://www.google.com/calendar/feeds/default/private/full/ofl1e45ubtsoh6gtu127cls2oo</id> + <published>2007-03-20T21:24:43.000Z</published> + <updated>2007-03-20T21:25:08.000Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://schemas.google.com/g/2005#event'></category> + <title type='text'>Dinner with Kim and Sarah</title> + <content type='text'></content> + <link rel='alternate' type='text/html' + href='http://www.google.com/calendar/event?eid=b2ZsMWU0NXVidHNvaDZndHUxMjdjbHMyb28gZ2RhdGEub3BzLmRlbW9AbQ' + title='alternate'></link> + <link rel='self' type='application/atom+xml' + href='http://www.google.com/calendar/feeds/default/private/full/ofl1e45ubtsoh6gtu127cls2oo'> + </link> + <link rel='edit' type='application/atom+xml' + href='http://www.google.com/calendar/feeds/default/private/full/ofl1e45ubtsoh6gtu127cls2oo/63310109108'> + </link> + <author> + <name>GData Ops Demo</name> + <email>gdata.ops.demo@gmail.com</email> + </author> + <gCal:sendEventNotifications value='false'> + </gCal:sendEventNotifications> + <gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'> + </gd:eventStatus> + <gd:comments> + <gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/ofl1e45ubtsoh6gtu127cls2oo/comments'> + </gd:feedLink> + </gd:comments> + <gd:visibility value='http://schemas.google.com/g/2005#event.default'> + </gd:visibility> + <gd:transparency value='http://schemas.google.com/g/2005#event.opaque'> + </gd:transparency> + <gd:when startTime='2007-03-20T19:00:00.000-07:00' + endTime='2007-03-20T21:30:00.000-07:00'> + <gd:reminder minutes='10'></gd:reminder> + </gd:when> + <gd:where></gd:where> + </entry> + <entry> + <id> + http://www.google.com/calendar/feeds/default/private/full/b69s2avfi2joigsclecvjlc91g</id> + <published>2007-03-20T21:24:19.000Z</published> + <updated>2007-03-20T21:25:05.000Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://schemas.google.com/g/2005#event'></category> + <title type='text'>Dinner with Jane and John</title> + <content type='text'></content> + <link rel='alternate' type='text/html' + href='http://www.google.com/calendar/event?eid=YjY5czJhdmZpMmpvaWdzY2xlY3ZqbGM5MWcgZ2RhdGEub3BzLmRlbW9AbQ' + title='alternate'></link> + <link rel='self' type='application/atom+xml' + href='http://www.google.com/calendar/feeds/default/private/full/b69s2avfi2joigsclecvjlc91g'> + </link> + <link rel='edit' type='application/atom+xml' + href='http://www.google.com/calendar/feeds/default/private/full/b69s2avfi2joigsclecvjlc91g/63310109105'> + </link> + <author> + <name>GData Ops Demo</name> + <email>gdata.ops.demo@gmail.com</email> + </author> + <gCal:sendEventNotifications value='false'> + </gCal:sendEventNotifications> + <gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'> + </gd:eventStatus> + <gd:comments> + <gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/b69s2avfi2joigsclecvjlc91g/comments'> + </gd:feedLink> + </gd:comments> + <gd:visibility value='http://schemas.google.com/g/2005#event.default'> + </gd:visibility> + <gd:transparency value='http://schemas.google.com/g/2005#event.opaque'> + </gd:transparency> + <gd:when startTime='2007-03-22T17:00:00.000-07:00' + endTime='2007-03-22T19:30:00.000-07:00'> + <gd:reminder minutes='10'></gd:reminder> + </gd:when> + <gd:where></gd:where> + </entry> + <entry> + <id> + http://www.google.com/calendar/feeds/default/private/full/u9p66kkiotn8bqh9k7j4rcnjjc</id> + <published>2007-03-20T21:24:33.000Z</published> + <updated>2007-03-20T21:24:33.000Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://schemas.google.com/g/2005#event'></category> + <title type='text'>Tennis with Elizabeth</title> + <content type='text'></content> + <link rel='alternate' type='text/html' + href='http://www.google.com/calendar/event?eid=dTlwNjZra2lvdG44YnFoOWs3ajRyY25qamMgZ2RhdGEub3BzLmRlbW9AbQ' + title='alternate'></link> + <link rel='self' type='application/atom+xml' + href='http://www.google.com/calendar/feeds/default/private/full/u9p66kkiotn8bqh9k7j4rcnjjc'> + </link> + <link rel='edit' type='application/atom+xml' + href='http://www.google.com/calendar/feeds/default/private/full/u9p66kkiotn8bqh9k7j4rcnjjc/63310109073'> + </link> + <author> + <name>GData Ops Demo</name> + <email>gdata.ops.demo@gmail.com</email> + </author> + <gCal:sendEventNotifications value='false'> + </gCal:sendEventNotifications> + <gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'> + </gd:eventStatus> + <gd:comments> + <gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/u9p66kkiotn8bqh9k7j4rcnjjc/comments'> + </gd:feedLink> + </gd:comments> + <gd:visibility value='http://schemas.google.com/g/2005#event.default'> + </gd:visibility> + <gd:transparency value='http://schemas.google.com/g/2005#event.opaque'> + </gd:transparency> + <gd:when startTime='2007-03-24T10:00:00.000-07:00' + endTime='2007-03-24T11:00:00.000-07:00'> + <gd:reminder minutes='10'></gd:reminder> + </gd:when> + <gd:where></gd:where> + </entry> + <entry> + <id> + http://www.google.com/calendar/feeds/default/private/full/76oj2kceidob3s708tvfnuaq3c</id> + <published>2007-03-20T21:24:00.000Z</published> + <updated>2007-03-20T21:24:00.000Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://schemas.google.com/g/2005#event'></category> + <title type='text'>Lunch with Jenn</title> + <content type='text'></content> + <link rel='alternate' type='text/html' + href='http://www.google.com/calendar/event?eid=NzZvajJrY2VpZG9iM3M3MDh0dmZudWFxM2MgZ2RhdGEub3BzLmRlbW9AbQ' + title='alternate'></link> + <link rel='self' type='application/atom+xml' + href='http://www.google.com/calendar/feeds/default/private/full/76oj2kceidob3s708tvfnuaq3c'> + </link> + <link rel='edit' type='application/atom+xml' + href='http://www.google.com/calendar/feeds/default/private/full/76oj2kceidob3s708tvfnuaq3c/63310109040'> + </link> + <author> + <name>GData Ops Demo</name> + <email>gdata.ops.demo@gmail.com</email> + </author> + <gCal:sendEventNotifications value='false'> + </gCal:sendEventNotifications> + <gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'> + </gd:eventStatus> + <gd:comments> + <gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/76oj2kceidob3s708tvfnuaq3c/comments'> + </gd:feedLink> + </gd:comments> + <gd:visibility value='http://schemas.google.com/g/2005#event.default'> + </gd:visibility> + <gd:transparency value='http://schemas.google.com/g/2005#event.opaque'> + </gd:transparency> + <gd:when startTime='2007-03-20T11:30:00.000-07:00' + endTime='2007-03-20T12:30:00.000-07:00'> + <gd:reminder minutes='10'></gd:reminder> + </gd:when> + <gd:where></gd:where> + </entry> + <entry> + <id> + http://www.google.com/calendar/feeds/default/private/full/5np9ec8m7uoauk1vedh5mhodco</id> + <published>2007-03-20T07:50:02.000Z</published> + <updated>2007-03-20T20:39:26.000Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://schemas.google.com/g/2005#event'></category> + <title type='text'>test entry</title> + <content type='text'>test desc</content> + <link rel='alternate' type='text/html' + href='http://www.google.com/calendar/event?eid=NW5wOWVjOG03dW9hdWsxdmVkaDVtaG9kY28gZ2RhdGEub3BzLmRlbW9AbQ' + title='alternate'></link> + <link rel='self' type='application/atom+xml' + href='http://www.google.com/calendar/feeds/default/private/full/5np9ec8m7uoauk1vedh5mhodco'> + </link> + <link rel='edit' type='application/atom+xml' + href='http://www.google.com/calendar/feeds/default/private/full/5np9ec8m7uoauk1vedh5mhodco/63310106366'> + </link> + <author> + <name>GData Ops Demo</name> + <email>gdata.ops.demo@gmail.com</email> + </author> + <gCal:sendEventNotifications value='false'> + </gCal:sendEventNotifications> + <gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'> + </gd:eventStatus> + <gd:comments> + <gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/5np9ec8m7uoauk1vedh5mhodco/comments'> + </gd:feedLink> + </gd:comments> + <gd:visibility value='http://schemas.google.com/g/2005#event.private'> + </gd:visibility> + <gd:transparency value='http://schemas.google.com/g/2005#event.opaque'> + </gd:transparency> + <gd:who rel='http://schemas.google.com/g/2005#event.attendee' + valueString='Vivian Li' email='vli@google.com'> + <gd:attendeeStatus value='http://schemas.google.com/g/2005#event.declined'> + </gd:attendeeStatus> + </gd:who> + <gd:who rel='http://schemas.google.com/g/2005#event.organizer' + valueString='GData Ops Demo' email='gdata.ops.demo@gmail.com'> + <gd:attendeeStatus value='http://schemas.google.com/g/2005#event.accepted'> + </gd:attendeeStatus> + </gd:who> + <gd:when startTime='2007-03-21T08:00:00.000-07:00' + endTime='2007-03-21T09:00:00.000-07:00'> + <gd:reminder minutes='10'></gd:reminder> + </gd:when> + <gd:where valueString='anywhere'></gd:where> + </entry> + <entry> + <id> + http://www.google.com/calendar/feeds/default/private/full/fu6sl0rqakf3o0a13oo1i1a1mg</id> + <published>2007-02-14T23:23:37.000Z</published> + <updated>2007-02-14T23:25:30.000Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://schemas.google.com/g/2005#event'></category> + <title type='text'>test</title> + <content type='text'></content> + <link rel='alternate' type='text/html' + href='http://www.google.com/calendar/event?eid=ZnU2c2wwcnFha2YzbzBhMTNvbzFpMWExbWcgZ2RhdGEub3BzLmRlbW9AbQ' + title='alternate'></link> + <link rel='self' type='application/atom+xml' + href='http://www.google.com/calendar/feeds/default/private/full/fu6sl0rqakf3o0a13oo1i1a1mg'> + </link> + <link rel='edit' type='application/atom+xml' + href='http://www.google.com/calendar/feeds/default/private/full/fu6sl0rqakf3o0a13oo1i1a1mg/63307178730'> + </link> + <author> + <name>GData Ops Demo</name> + <email>gdata.ops.demo@gmail.com</email> + </author> + <gCal:sendEventNotifications value='false'> + </gCal:sendEventNotifications> + <gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'> + </gd:eventStatus> + <gd:comments> + <gd:feedLink href='http://www.google.com/calendar/feeds/default/private/full/fu6sl0rqakf3o0a13oo1i1a1mg/comments'> + </gd:feedLink> + </gd:comments> + <gd:visibility value='http://schemas.google.com/g/2005#event.default'> + </gd:visibility> + <gd:transparency value='http://schemas.google.com/g/2005#event.opaque'> + </gd:transparency> + <gd:when startTime='2007-02-15T08:30:00.000-08:00' + endTime='2007-02-15T09:30:00.000-08:00'> + <gd:reminder minutes='10'></gd:reminder> + </gd:when> + <gd:where></gd:where> + </entry> +</feed> 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 @@ +<?xml version="1.0" encoding="utf-8" ?> +<timezone xmlns="http://schemas.google.com/gCal/2005" value="America/Los_Angeles"/> 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 @@ +<?xml version="1.0" encoding="utf-8" ?> +<gCal:webContent xmlns:gCal="http://schemas.google.com/gCal/2005" + url="http://www.google.com/logos/july4th06.gif" + width="276" height="120" /> 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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Calendar + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Calendar.php'; +require_once 'Zend/Gdata/Calendar/EventFeed.php'; +require_once 'Zend/Http/Client.php'; +require_once 'Zend/Http/Client/Adapter/Test.php'; + +/** + * @category Zend + * @package Zend_Gdata_Calendar + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Calendar + */ +class Zend_Gdata_CalendarEventTest extends PHPUnit_Framework_TestCase +{ + protected $eventFeed = null; + + /** + * Called before each test to setup any fixtures. + */ + public function setUp() + { + $eventFeedText = file_get_contents( + 'Zend/Gdata/Calendar/_files/TestDataEventFeedSample1.xml', + true); + $this->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 <atom:author> 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 <atom:id> 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 <atom:published> 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 <atom:published> 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 <atom:title> 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 <atom:subtitle> 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 <gCal:timezone> 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 <openSearch:startIndex> 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 <openSearch:itemsPerPage> 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 <atom:content> 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 <gCal:sendEventNotifications> 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 <gd:eventStatus> 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 <gd:comments> 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 <gCal:visibility> 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 <gCal:transparency> 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 <gd:when> 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 <gd:where> 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 <gd:where> 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 <atom:generator> 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 <gd:quickadd> 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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Calendar + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Calendar.php'; +require_once 'Zend/Gdata/Calendar/EventFeed.php'; +require_once 'Zend/Http/Client.php'; +require_once 'Zend/Http/Client/Adapter/Test.php'; + +/** + * @category Zend + * @package Zend_Gdata_Calendar + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Calendar + */ +class Zend_Gdata_CalendarFeedCompositeTest extends PHPUnit_Framework_TestCase +{ + protected $eventFeed = null; + + /** + * Called before each test to setup any fixtures. + */ + public function setUp() + { + $eventFeedText = file_get_contents( + 'Zend/Gdata/Calendar/_files/EventFeedCompositeSample1.xml', + true); + $this->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 <atom:author> 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 <atom:id> 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 <atom:published> 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 <atom:updated> 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 <atom:title> 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 <atom:subtitle> 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 <gCal:timezone> 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 <gCal:eventStatus> 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 <gCal:visibility> 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 <gCal:transparency> 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 <gCal:sendEventNotifications> 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 <gd:when> 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 <gd:where> 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 <gd:comments> 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('<p>This is a user supplied comment.</p>', $comment->getContent()->text); + } + + /** + * Check for the existence of an <gd:where> 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 <openSearch:startIndex> 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 <openSearch:itemsPerPage> 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 <atom:generator> 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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Calendar + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Calendar.php'; +require_once 'Zend/Gdata/Calendar/EventFeed.php'; +require_once 'Zend/Http/Client.php'; +require_once 'Zend/Http/Client/Adapter/Test.php'; + +/** + * @category Zend + * @package Zend_Gdata_Calendar + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Calendar + */ +class Zend_Gdata_CalendarFeedTest extends PHPUnit_Framework_TestCase +{ + protected $listFeed = null; + + /** + * Called before each test to setup any fixtures. + */ + public function setUp() + { + $listFeedText = file_get_contents( + 'Zend/Gdata/Calendar/_files/ListFeedSample1.xml', + true); + $this->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 <atom:author> 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 <atom:id> 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 <atom:published> 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 <atom:published> 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 <atom:title> 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 <gCal:color> 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 <gCal:accessLevel> 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 <gCal:timezone> 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 <gCal:hidden> 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 <gCal:selected> 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 <openSearch:startIndex> 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 <gd:where> 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 <atom:summary> 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 <atom:generator> 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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Calendar + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Calendar.php'; +require_once 'Zend/Gdata/Calendar/EventEntry.php'; +require_once 'Zend/Gdata/ClientLogin.php'; +require_once 'Zend/Http/Client.php'; + +/** + * @category Zend + * @package Zend_Gdata_Calendar + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Calendar + */ +class Zend_Gdata_CalendarOnlineTest extends PHPUnit_Framework_TestCase +{ + + const GOOGLE_DEVELOPER_CALENDAR = 'developer-calendar@google.com'; + const ZEND_CONFERENCE_EVENT = 'bn2h4o4mc3a03ci4t48j3m56pg'; + + public function setUp() + { + $user = constant('TESTS_ZEND_GDATA_CLIENTLOGIN_EMAIL'); + $pass = constant('TESTS_ZEND_GDATA_CLIENTLOGIN_PASSWORD'); + $service = Zend_Gdata_Calendar::AUTH_SERVICE_NAME; + $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service); + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Calendar + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Calendar.php'; +require_once 'Zend/Gdata/Calendar/EventFeed.php'; +require_once 'Zend/Http/Client.php'; +require_once 'Zend/Http/Client/Adapter/Test.php'; + +/** + * @category Zend + * @package Zend_Gdata_Calendar + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Calendar + */ +class Zend_Gdata_CalendarTest extends PHPUnit_Framework_TestCase +{ + public function setUp() + { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Extension/Comments.php'; +require_once 'Zend/Gdata.php'; + +/** + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + */ +class Zend_Gdata_CommentsTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Docs + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Docs.php'; +require_once 'Zend/Http/Client.php'; +require_once 'Zend/Gdata/Docs/DocumentListEntry.php'; + +/** + * @category Zend + * @package Zend_Gdata_Docsj + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Docsj + */ +class Zend_Gdata_Docs_DocumentListEntryTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() + { + $this->doc = new Zend_Gdata_Docs_DocumentListEntry( + file_get_contents('Zend/Gdata/Docs/_files/TestDataDocumentListEntrySample.xml', true)); + } + + public function testToAndFromString() + { + $this->assertTrue($this->doc instanceof Zend_Gdata_Docs_DocumentListEntry); + $this->assertTrue($this->doc->title->text === 'Test Spreadsheet'); + + $newDoc = new Zend_Gdata_Docs_DocumentListEntry(); + $doc = new DOMDocument(); + $doc->loadXML($this->doc->saveXML()); + $newDoc->transferFromDom($doc->documentElement); + + $this->assertTrue($newDoc->title == $this->doc->title); + } + + public function testSetMediaSource() + { + // Service object to create the media file source. + $this->docsClient = new Zend_Gdata_Docs(null); + $mediaSource = $this->docsClient->newMediaFileSource('test_file_name'); + $mediaSource->setSlug('test slug'); + $mediaSource->setContentType('test content type'); + $this->doc->setMediaSource($mediaSource); + $this->assertTrue($this->doc->getMediaSource()->getContentType() === + 'test content type'); + $this->assertTrue($this->doc->getMediaSource()->getSlug() === + 'test slug'); + } + +} diff --git a/zend/tests/Zend/Gdata/Docs/DocumentListFeedTest.php b/zend/tests/Zend/Gdata/Docs/DocumentListFeedTest.php new file mode 100755 index 0000000..69b911b --- /dev/null +++ b/zend/tests/Zend/Gdata/Docs/DocumentListFeedTest.php @@ -0,0 +1,67 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Docs + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Docs.php'; +require_once 'Zend/Http/Client.php'; + +/** + * @category Zend + * @package Zend_Gdata_Docs + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Docs + */ +class Zend_Gdata_Docs_DocumentListFeedTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() + { + $this->docFeed = new Zend_Gdata_Docs_DocumentListFeed( + file_get_contents(dirname(__FILE__) . '/_files/TestDataDocumentListFeedSample.xml'), + true); + } + + public function testToAndFromString() + { + // There should be 2 entries in the feed. + $this->assertTrue(count($this->docFeed->entries) == 2); + $this->assertTrue($this->docFeed->entries->count() == 2); + foreach($this->docFeed->entries as $entry) + { + $this->assertTrue($entry instanceof Zend_Gdata_Docs_DocumentListEntry); + } + + $newDocFeed = new Zend_Gdata_Docs_DocumentListFeed(); + $doc = new DOMDocument(); + $doc->loadXML($this->docFeed->saveXML()); + $newDocFeed->transferFromDom($doc->documentElement); + + $this->assertTrue(count($newDocFeed->entries) == count($this->docFeed->entries)); + foreach($newDocFeed->entries as $entry) + { + $this->assertTrue($entry instanceof Zend_Gdata_Docs_DocumentListEntry); + } + } + +} diff --git a/zend/tests/Zend/Gdata/Docs/QueryTest.php b/zend/tests/Zend/Gdata/Docs/QueryTest.php new file mode 100755 index 0000000..37efa24 --- /dev/null +++ b/zend/tests/Zend/Gdata/Docs/QueryTest.php @@ -0,0 +1,77 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Docs + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Docs.php'; +require_once 'Zend/Gdata/Docs/Query.php'; +require_once 'Zend/Http/Client.php'; + +/** + * @category Zend + * @package Zend_Gdata_Docs + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Docs + */ +class Zend_Gdata_Docs_QueryTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() + { + $this->docQuery = new Zend_Gdata_Docs_Query(); + } + + public function testTitle() + { + $this->assertTrue($this->docQuery->getTitle() == null); + $this->docQuery->setTitle('test title'); + $this->assertTrue($this->docQuery->getTitle() == 'test title'); + $this->assertTrue($this->docQuery->getQueryString() == '?title=test+title'); + $this->docQuery->setTitle(null); + $this->assertTrue($this->docQuery->getTitle() == null); + } + + public function testTitleExact() + { + $this->assertTrue($this->docQuery->getTitleExact() == null); + $this->docQuery->setTitleExact('test title'); + $this->assertTrue($this->docQuery->getTitleExact() == 'test title'); + $this->assertTrue($this->docQuery->getQueryString() == '?title-exact=test+title'); + $this->docQuery->setTitleExact(null); + $this->assertTrue($this->docQuery->getTitleExact() == null); + } + + public function testProjection() + { + $this->assertTrue($this->docQuery->getProjection() == 'full'); + $this->docQuery->setProjection('abc'); + $this->assertTrue($this->docQuery->getProjection() == 'abc'); + } + + public function testVisibility() + { + $this->assertTrue($this->docQuery->getVisibility() == 'private'); + $this->docQuery->setVisibility('xyz'); + $this->assertTrue($this->docQuery->getVisibility() == 'xyz'); + } +} diff --git a/zend/tests/Zend/Gdata/Docs/_files/TestDataDocumentListEntrySample.xml b/zend/tests/Zend/Gdata/Docs/_files/TestDataDocumentListEntrySample.xml new file mode 100755 index 0000000..1860425 --- /dev/null +++ b/zend/tests/Zend/Gdata/Docs/_files/TestDataDocumentListEntrySample.xml @@ -0,0 +1,14 @@ +<entry xmlns="http://www.w3.org/2005/Atom">
+ <content src="http://foo.com/fm?fmcmd=102key=supercalifragilisticexpealidocious" type="text/html" />
+ <author>
+ <name>test.user</name>
+ <email>test.user@gmail.com</email>
+ </author>
+ <category label="spreadsheet" scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/docs/2007#spreadsheet" />
+ <id>http://docs.google.com/feeds/documents/private/full/spreadsheet%3Asupercalifragilisticexpealidocious</id>
+ <link href="http://foo.com/ccc?key=supercalifragilisticexpealidocious" rel="alternate" type="text/html" />
+ <link href="http://foo.com/feeds/worksheets/supercalifragilisticexpealidocious/private/full" rel="http://schemas.google.com/spreadsheets/2006#worksheetsfeed" type="application/atom+xml" />
+ <link href="http://docs.google.com/feeds/documents/private/full/spreadsheet%3Asupercalifragilisticexpealidocious" rel="self" type="application/atom+xml" />
+ <title type="text">Test Spreadsheet</title>
+ <updated>2007-07-03T18:03:32.045Z</updated>
+</entry>
diff --git a/zend/tests/Zend/Gdata/Docs/_files/TestDataDocumentListFeedSample.xml b/zend/tests/Zend/Gdata/Docs/_files/TestDataDocumentListFeedSample.xml new file mode 100755 index 0000000..d19a2f2 --- /dev/null +++ b/zend/tests/Zend/Gdata/Docs/_files/TestDataDocumentListFeedSample.xml @@ -0,0 +1,38 @@ +<ns0:feed xmlns:ns0="http://www.w3.org/2005/Atom">
+ <ns1:totalResults xmlns:ns1="http://a9.com/-/spec/opensearchrss/1.0/">2</ns1:totalResults>
+ <ns1:startIndex xmlns:ns1="http://a9.com/-/spec/opensearchrss/1.0/">1</ns1:startIndex>
+ <ns0:entry>
+ <ns0:content src="http://foo.com/fm?fmcmd=102&key=supercalifragilisticexpeadocious" type="text/html"/>
+ <ns0:author>
+ <ns0:name>test.user</ns0:name>
+ <ns0:email>test.user@gmail.com</ns0:email>
+ </ns0:author>
+ <ns0:category label="spreadsheet" scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/docs/2007#spreadsheet" />
+ <ns0:id>http://docs.google.com/feeds/documents/private/full/spreadsheet%3Asupercalifragilisticexpeadocious</ns0:id>
+ <ns0:link href="http://foo.com/ccc?key=supercalifragilisticexpeadocious" rel="alternate" type="text/html" />
+ <ns0:link href="http://foo.com/feeds/worksheets/supercalifragilisticexpeadocious/private/full" rel="http://schemas.google.com/spreadsheets/2006#worksheetsfeed" type="application/atom+xml" />
+ <ns0:link href="http://docs.google.com/feeds/documents/private/full/spreadsheet%3Asupercalifragilisticexpeadocious" rel="self" type="application/atom+xml" />
+ <ns0:title type="text">Test Spreadsheet</ns0:title>
+ <ns0:updated>2007-07-03T18:03:32.045Z</ns0:updated>
+ </ns0:entry>
+ <ns0:entry>
+ <ns0:content src="http://docs.google.com/RawDocContents?action=fetch&docID=gr00vy" type="text/html" />
+ <ns0:author>
+ <ns0:name>test.user</ns0:name>
+ <ns0:email>test.user@gmail.com</ns0:email>
+ </ns0:author>
+ <ns0:category label="document" scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/docs/2007#document" />
+ <ns0:id>http://docs.google.com/feeds/documents/private/full/document%3Agr00vy</ns0:id>
+ <ns0:link href="http://foobar.com/Doc?id=gr00vy" rel="alternate" type="text/html" />
+ <ns0:link href="http://docs.google.com/feeds/documents/private/full/document%3Agr00vy" rel="self" type="application/atom+xml" />
+ <ns0:title type="text">Test Document</ns0:title>
+ <ns0:updated>2007-07-03T18:02:50.338Z</ns0:updated>
+ </ns0:entry>
+ <ns0:id>http://docs.google.com/feeds/documents/private/full</ns0:id>
+ <ns0:link href="http://docs.google.com" rel="alternate" type="text/html" />
+ <ns0:link href="http://docs.google.com/feeds/documents/private/full" rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" />
+ <ns0:link href="http://docs.google.com/feeds/documents/private/full" rel="http://schemas.google.com/g/2005#post" type="application/atom+xml" />
+ <ns0:link href="http://docs.google.com/feeds/documents/private/full" rel="self" type="application/atom+xml" />
+ <ns0:title type="text">Available Documents - test.user@gmail.com</ns0:title>
+ <ns0:updated>2007-07-09T23:07:21.898Z</ns0:updated>
+</ns0:feed>
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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Docs + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Docs.php'; +require_once 'Zend/Http/Client.php'; +require_once 'Zend/Gdata/ClientLogin.php'; + +/** + * @category Zend + * @package Zend_Gdata_Docs + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Docs + */ +class Zend_Gdata_DocsOnlineTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() + { + $user = constant('TESTS_ZEND_GDATA_CLIENTLOGIN_EMAIL'); + $pass = constant('TESTS_ZEND_GDATA_CLIENTLOGIN_PASSWORD'); + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Docs + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Docs.php'; +require_once 'Zend/Gdata/HttpClient.php'; +require_once 'Zend/Gdata/TestUtility/MockHttpClient.php'; + +/** + * @category Zend + * @package Zend_Gdata_Docs + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Docs + */ +class Zend_Gdata_DocsTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() + { + $this->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, + "<atom:category term=\"http://schemas.google.com/docs/2007#folder\" scheme=\"http://schemas.google.com/g/2005#kind\"")); + + // Check to make sure the title is set + $this->assertNotEquals(false, strpos($request->body, + "<atom:title type=\"text\">Test Folder</atom:title>")); + } + + 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, + "<atom:category term=\"http://schemas.google.com/docs/2007#folder\" scheme=\"http://schemas.google.com/g/2005#kind\"")); + + // Check to make sure the title is set + $this->assertNotEquals(false, strpos($request->body, + "<atom:title type=\"text\">Test Folder</atom:title>")); + } + + +} 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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Extension/EntryLink.php'; +require_once 'Zend/Gdata.php'; + +/** + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + */ +class Zend_Gdata_EntryLinkTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Entry.php'; + +/** + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + */ +class Zend_Gdata_EntryTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Extension/EventStatus.php'; +require_once 'Zend/Gdata.php'; + +/** + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + */ +class Zend_Gdata_EventStatusTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Extension/ExtendedProperty.php'; +require_once 'Zend/Gdata.php'; + +/** + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + */ +class Zend_Gdata_ExtendedPropertyTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Extension/FeedLink.php'; +require_once 'Zend/Gdata.php'; + +/** + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + */ +class Zend_Gdata_FeedLinkTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata.php'; +require_once 'Zend/Gdata/Feed.php'; +require_once 'Zend/Gdata/App/Util.php'; + +/** + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + */ +class Zend_Gdata_FeedTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Gapps/EmailListEntry.php'; +require_once 'Zend/Gdata/Gapps.php'; + +/** + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Gapps + */ +class Zend_Gdata_Gapps_EmailListEntryTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Gapps.php'; +require_once 'Zend/Gdata/Gapps/EmailListFeed.php'; + +/** + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Gapps + */ +class Zend_Gdata_Gapps_EmailListFeedTest extends PHPUnit_Framework_TestCase +{ + protected $emailListFeed = null; + + /** + * Called before each test to setup any fixtures. + */ + public function setUp() + { + $emailListFeedText = file_get_contents( + 'Zend/Gdata/Gapps/_files/EmailListFeedDataSample1.xml', + true); + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Gapps.php'; +require_once 'Zend/Gdata/Gapps/EmailListQuery.php'; + +/** + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Gapps + */ +class Zend_Gdata_Gapps_EmailListQueryTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() + { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Gapps/EmailListRecipientEntry.php'; +require_once 'Zend/Gdata/Gapps.php'; + +/** + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Gapps + */ +class Zend_Gdata_Gapps_EmailListRecipientEntryTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Gapps.php'; +require_once 'Zend/Gdata/Gapps/EmailListRecipientFeed.php'; + +/** + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Gapps + */ +class Zend_Gdata_Gapps_EmailListRecipientFeedTest extends PHPUnit_Framework_TestCase +{ + protected $emailListRecipientFeed = null; + + /** + * Called before each test to setup any fixtures. + */ + public function setUp() + { + $emailListRecipientFeedText = file_get_contents( + 'Zend/Gdata/Gapps/_files/EmailListRecipientFeedDataSample1.xml', + true); + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Gapps.php'; +require_once 'Zend/Gdata/Gapps/EmailListRecipientQuery.php'; + +/** + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Gapps + */ +class Zend_Gdata_Gapps_EmailListRecipientQueryTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() + { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Gapps/Extension/EmailList.php'; +require_once 'Zend/Gdata.php'; + +/** + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Gapps + */ +class Zend_Gdata_Gapps_EmailListTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Gapps/Error.php'; +require_once 'Zend/Gdata/Gapps.php'; + +/** + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Gapps + */ +class Zend_Gdata_Gapps_ErrorTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id:$ + */ + +require_once 'Zend/Gdata/Gapps/GroupEntry.php'; +require_once 'Zend/Gdata/Gapps.php'; + +/** + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Gapps + */ +class Zend_Gdata_Gapps_GroupEntryTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id:$ + */ + +require_once 'Zend/Gdata/Gapps.php'; +require_once 'Zend/Gdata/Gapps/GroupFeed.php'; + +/** + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Gapps + */ +class Zend_Gdata_Gapps_GroupFeedTest extends PHPUnit_Framework_TestCase +{ + protected $groupFeed = null; + + /** + * Called before each test to setup any fixtures. + */ + public function setUp() + { + $groupFeedText = file_get_contents( + 'Zend/Gdata/Gapps/_files/GroupFeedDataSample1.xml', + true); + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Gapps.php'; +require_once 'Zend/Gdata/Gapps/GroupQuery.php'; + +/** + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Gapps + */ +class Zend_Gdata_Gapps_GroupQueryTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() + { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Gapps/Extension/Login.php'; +require_once 'Zend/Gdata.php'; + +/** + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Gapps + */ +class Zend_Gdata_Gapps_LoginTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id:$ + */ + +require_once 'Zend/Gdata/Gapps/MemberEntry.php'; +require_once 'Zend/Gdata/Gapps.php'; + +/** + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Gapps + */ +class Zend_Gdata_Gapps_MemberEntryTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id:$ + */ + +require_once 'Zend/Gdata/Gapps.php'; +require_once 'Zend/Gdata/Gapps/MemberFeed.php'; + +/** + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Gapps + */ +class Zend_Gdata_Gapps_MemberFeedTest extends PHPUnit_Framework_TestCase +{ + protected $memberFeed = null; + + /** + * Called before each test to setup any fixtures. + */ + public function setUp() + { + $memberFeedText = file_get_contents( + 'Zend/Gdata/Gapps/_files/MemberFeedDataSample1.xml', + true); + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Gapps.php'; +require_once 'Zend/Gdata/Gapps/MemberQuery.php'; + +/** + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Gapps + */ +class Zend_Gdata_Gapps_MemberQueryTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() + { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Gapps/Extension/Name.php'; +require_once 'Zend/Gdata.php'; + +/** + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Gapps + */ +class Zend_Gdata_Gapps_NameTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Gapps/NicknameEntry.php'; +require_once 'Zend/Gdata/Gapps.php'; + +/** + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Gapps + */ +class Zend_Gdata_Gapps_NicknameEntryTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Gapps.php'; +require_once 'Zend/Gdata/Gapps/NicknameFeed.php'; + +/** + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Gapps + */ +class Zend_Gdata_Gapps_NicknameFeedTest extends PHPUnit_Framework_TestCase +{ + protected $nicknameFeed = null; + + /** + * Called before each test to setup any fixtures. + */ + public function setUp() + { + $nicknameFeedText = file_get_contents( + 'Zend/Gdata/Gapps/_files/NicknameFeedDataSample1.xml', + true); + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Gapps.php'; +require_once 'Zend/Gdata/Gapps/NicknameQuery.php'; + +/** + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Gapps + */ +class Zend_Gdata_Gapps_NicknameQueryTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() + { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Gapps/Extension/Nickname.php'; +require_once 'Zend/Gdata.php'; + +/** + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Gapps + */ +class Zend_Gdata_Gapps_NicknameTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id:$ + */ + +require_once 'Zend/Gdata/Gapps/OwnerEntry.php'; +require_once 'Zend/Gdata/Gapps.php'; + +/** + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Gapps + */ +class Zend_Gdata_Gapps_OwnerEntryTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id:$ + */ + +require_once 'Zend/Gdata/Gapps.php'; +require_once 'Zend/Gdata/Gapps/OwnerFeed.php'; + +/** + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Gapps + */ +class Zend_Gdata_Gapps_OwnerFeedTest extends PHPUnit_Framework_TestCase +{ + protected $ownerFeed = null; + + /** + * Called before each test to setup any fixtures. + */ + public function setUp() + { + $ownerFeedText = file_get_contents( + 'Zend/Gdata/Gapps/_files/OwnerFeedDataSample1.xml', + true); + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Gapps.php'; +require_once 'Zend/Gdata/Gapps/OwnerQuery.php'; + +/** + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Gapps + */ +class Zend_Gdata_Gapps_OwnerQueryTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() + { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Gapps/Extension/Property.php'; +require_once 'Zend/Gdata.php'; + +/** + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Gapps + */ +class Zend_Gdata_Gapps_PropertyTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Gapps/Extension/Quota.php'; +require_once 'Zend/Gdata.php'; + +/** + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Gapps + */ +class Zend_Gdata_Gapps_QuotaTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Gapps/ServiceException.php'; +require_once 'Zend/Gdata/Gapps/Error.php'; +require_once 'Zend/Gdata/Gapps.php'; + +/** + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Gapps + */ +class Zend_Gdata_Gapps_ServiceExceptionTest extends PHPUnit_Framework_TestCase +{ + protected $fixture; + protected $data; + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Gapps/UserEntry.php'; +require_once 'Zend/Gdata/Gapps.php'; + +/** + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Gapps + */ +class Zend_Gdata_Gapps_UserEntryTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Gapps.php'; +require_once 'Zend/Gdata/Gapps/UserFeed.php'; + +/** + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Gapps + */ +class Zend_Gdata_Gapps_UserFeedTest extends PHPUnit_Framework_TestCase +{ + protected $userFeed = null; + + /** + * Called before each test to setup any fixtures. + */ + public function setUp() + { + $userFeedText = file_get_contents( + 'Zend/Gdata/Gapps/_files/UserFeedDataSample1.xml', + true); + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Gapps.php'; +require_once 'Zend/Gdata/Gapps/UserQuery.php'; + +/** + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Gapps + */ +class Zend_Gdata_Gapps_UserQueryTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() + { + $this->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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<AppsForYourDomainErrors> + <error errorCode="1301" invalidInput="ZF-4699719c8e74c" reason="EntityDoesNotExist" /> + <error errorCode="9925" invalidInput="Foo" reason="Bar" /> + <error errorCode="5235" invalidInput="HelloWorld" reason="Blah" /> +</AppsForYourDomainErrors> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<apps:emailList xmlns:apps="http://schemas.google.com/apps/2006" name="us-sales"/> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" + xmlns:apps="http://schemas.google.com/apps/2006" + xmlns:gd="http://schemas.google.com/g/2005"> + <atom:id>https://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-sales</atom:id> + <atom:updated>1970-01-01T00:00:00.000Z</atom:updated> + <atom:category scheme="http://schemas.google.com/g/2005#kind" + term="http://schemas.google.com/apps/2006#emailList"/> + <atom:title type="text">us-sales</atom:title> + <atom:link rel="self" type="application/atom+xml" + href="https://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-sales"/> + <atom:link rel="edit" type="application/atom+xml" + href="https://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-sales"/> + <apps:emailList name="us-sales"/> + <gd:feedLink rel="http://schemas.google.com/apps/2006#emailList.recipients" + href="http://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient/"/> +</atom:entry> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<atom:feed xmlns:atom="http://www.w3.org/2005/Atom" + xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" + xmlns:gd="http://schemas.google.com/g/2005"> + <atom:id> + http://apps-apis.google.com/a/feeds/example.com/emailList/2.0 + </atom:id> + <atom:updated>1970-01-01T00:00:00.000Z</atom:updated> + <atom:category scheme="http://schemas.google.com/g/2005#kind" + term="http://schemas.google.com/apps/2006#emailList"/> + <atom:title type="text">EmailLists</atom:title> + <atom:link rel="next" type="application/atom+xml" + href="http://apps-apis.google.com/a/feeds/example.com/emailList/2.0?startEmailListName=john"/> + <atom:link rel="http://schemas.google.com/g/2005#feed" + type="application/atom+xml" + href="http://apps-apis.google.com/a/feeds/example.com/emailList/2.0"/> + <atom:link rel="http://schemas.google.com/g/2005#post" + type="application/atom+xml" + href="http://apps-apis.google.com/a/feeds/example.com/emailList/2.0"/> + <atom:link rel="self" type="application/atom+xml" + href="http://apps-apis.google.com/a/feeds/example.com/emailList/2.0"/> + <openSearch:startIndex>1</openSearch:startIndex> + <atom:entry> + <atom:id> + http://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-sales + </atom:id> + <atom:updated>1970-01-01T00:00:00.000Z</atom:updated> + <atom:category scheme="http://schemas.google.com/g/2005#kind" + term="http://schemas.google.com/apps/2006#emailList"/> + <atom:title type="text">us-sales</atom:title> + <atom:link rel="self" type="application/atom+xml" + href="http://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-sales"/> + <atom:link rel="edit" type="application/atom+xml" + href="http://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-sales"/> + <apps:emailList name="us-sales"/> + <gd:feedLink rel="http://schemas.google.com/apps/2006#emailList.recipients" + href="http://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient/"/> + </atom:entry> + <atom:entry> + <atom:id> + http://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-eng + </atom:id> + <atom:updated>1970-01-01T00:00:00.000Z</atom:updated> + <atom:category scheme="http://schemas.google.com/g/2005#kind" + term="http://schemas.google.com/apps/2006#emailList"/> + <atom:title type="text">us-eng</atom:title> + <atom:link rel="self" type="application/atom+xml" + href="http://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-eng"/> + <atom:link rel="edit" type="application/atom+xml" + href="http://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-eng"/> + <apps:emailList name="us-eng"/> + <gd:feedLink rel="http://schemas.google.com/apps/2006#emailList.recipients" + href="http://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-eng/recipient/"/> + </atom:entry> +</atom:feed> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" + xmlns:apps="http://schemas.google.com/apps/2006" + xmlns:gd="http://schemas.google.com/g/2005"> + <atom:id>https://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient/SusanJones%40example.com</atom:id> + <atom:updated>1970-01-01T00:00:00.000Z</atom:updated> + <atom:category scheme="http://schemas.google.com/g/2005#kind" + term="http://schemas.google.com/apps/2006#emailList.recipient"/> + <atom:title type="text">SusanJones</atom:title> + <atom:link rel="self" type="application/atom+xml" + href="https://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient/SusanJones%40example.com"/> + <atom:link rel="edit" type="application/atom+xml" + href="https://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient/SusanJones%40example.com"/> + <gd:who email="SusanJones@example.com"/> +</atom:entry> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<atom:feed xmlns:atom="http://www.w3.org/2005/Atom" + xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" + xmlns:gd="http://schemas.google.com/g/2005"> + <atom:id> + http://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient + </atom:id> + <atom:updated>1970-01-01T00:00:00.000Z</atom:updated> + <atom:category scheme="http://schemas.google.com/g/2005#kind" + term="http://schemas.google.com/apps/2006#emailList.recipient"/> + <atom:title type="text">Recipients for email list us-sales</atom:title> + <atom:link rel="next" type="application/atom+xml" + href="http://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient/?startRecipient=terry@example.com"/> + <atom:link rel="http://schemas.google.com/g/2005#feed" + type="application/atom+xml" + href="http://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient"/> + <atom:link rel="http://schemas.google.com/g/2005#post" + type="application/atom+xml" + href="http://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient"/> + <atom:link rel="self" type="application/atom+xml" + href="http://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient"/> + <openSearch:startIndex>1</openSearch:startIndex> + <atom:entry> + <atom:id> + http://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient/joe%40example.com + </atom:id> + <atom:updated>1970-01-01T00:00:00.000Z</atom:updated> + <atom:category scheme="http://schemas.google.com/g/2005#kind" + term="http://schemas.google.com/apps/2006#emailList.recipient"/> + <atom:title type="text">joe@example.com</atom:title> + <atom:link rel="self" type="application/atom+xml" + href="http://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient/joe%40example.com"/> + <atom:link rel="edit" type="application/atom+xml" + href="http://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient/joe%40example.com"/> + <gd:who email="joe@example.com"/> + </atom:entry> + <atom:entry> + <atom:id> + http://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient/susan%40example.com + </atom:id> + <atom:updated>1970-01-01T00:00:00.000Z</atom:updated> + <atom:category scheme="http://schemas.google.com/g/2005#kind" + term="http://schemas.google.com/apps/2006#emailList.recipient"/> + <atom:title type="text">susan@example.com</atom:title> + <atom:link rel="self" type="application/atom+xml" + href="http://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient/susan%40example.com"/> + <atom:link rel="edit" type="application/atom+xml" + href="http://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient/susan%40example.com"/> + <gd:who email="susan@example.com"/> + </atom:entry> +</atom:feed> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" + xmlns:apps="http://schemas.google.com/apps/2006" + xmlns:gd="http://schemas.google.com/g/2005"> + <atom:id>https://www.google.com/a/feeds/group/2.0/example.com/us-sales</atom:id> + <atom:updated>1970-01-01T00:00:00.000Z</atom:updated> + <atom:link rel="self" type="application/atom+xml" href="https://www.google.com/a/feeds/group/2.0/example.com/us-sales"/> + <atom:link rel="edit" type="application/atom+xml" href="https://www.google.com/a/feeds/group/2.0/example.com/us-sales"/> + <apps:property name="groupId" value="us-sales"></apps:property> + <apps:property name="groupName" value="us-sales"></apps:property> + <apps:property name="description" value="UnitedStatesSalesTeam"></apps:property> + <apps:property name="emailPermission" value="Domain"></apps:property> +</atom:entry> + 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<atom:feed xmlns:atom="http://www.w3.org/2005/Atom" +xmlns:apps="http://schemas.google.com/apps/2006" +xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/"> + <atom:id>https://www.google.com/a/feeds/group/2.0/example.com</atom:id> + <atom:updated>2008-12-03T16:33:05.260Z</atom:updated> + <atom:link href="https://apps-apis.google.com/a/feeds/group/2.0/example.com" type="application/atom+xml" rel="http://schemas.google.com/g/2005#feed"></atom:link> + <atom:link href="https://apps-apis.google.com/a/feeds/group/2.0/example.com" type="application/atom+xml" rel="http://schemas.google.com/g/2005#post"></atom:link> + <atom:link href="https://apps-apis.google.com/a/feeds/group/2.0/example.com" type="application/atom+xml" rel="self"></atom:link> + <openSearch:startIndex>1</openSearch:startIndex> + <atom:entry> + <id>https://apps-apis.google.com/a/feeds/group/2.0/example.com/us-sales%40example.com</id> + <atom:updated>2008-12-03T16:33:05.261Z</atom:updated> + <atom:link href="https://apps-apis.google.com/a/feeds/group/2.0/example.com/us-sales%40example.com" type="application/atom+xml" rel="self"></atom:link> + <atom:link href="https://apps-apis.google.com/a/feeds/group/2.0/example.com/us-sales%40example.com" type="application/atom+xml" rel="edit"></atom:link> + <apps:property name="groupId" value="us-sales@example.com"></apps:property> + <apps:property name="groupName" value="US Sales"></apps:property> + <apps:property name="emailPermission" value="Anyone"></apps:property> + <apps:property name="description" value="United States Sales Team"></apps:property> + </atom:entry> + <atom:entry> + <atom:id>https://apps-apis.google.com/a/feeds/group/2.0/example.com/Staff-2435%40example.com</atom:id> + <atom:updated>2008-12-03T16:33:05.260Z</atom:updated> + <atom:link href="https://apps-apis.google.com/a/feeds/group/2.0/example.com/Staff-2435%40example.com" type="application/atom+xml" rel="self"></atom:link> + <atom:link href="https://apps-apis.google.com/a/feeds/group/2.0/example.com/Staff-2435%40example.com" type="application/atom+xml" rel="edit"></atom:link> + <apps:property name="groupId" value="Staff-2435@example.com"></apps:property> + <apps:property name="groupName" value="Staff 2435"></apps:property> + <apps:property name="emailPermission" value="Anyone"></apps:property> + <apps:property name="description" value=""></apps:property> + </atom:entry> +</atom:feed>
\ 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<apps:login xmlns:apps="http://schemas.google.com/apps/2006" userName="SusanJones-1321" password="123$$abc" hashFunctionName="SHA-1" suspended="false" admin="false" changePasswordAtNextLogin="false" agreedToTerms="true"/> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" + xmlns:apps="http://schemas.google.com/apps/2006" + xmlns:gd="http://schemas.google.com/g/2005"> + <atom:id>https://www.google.com/a/feeds/group/2.0/example.com/us-sales/member/suejones%40example.com</atom:id> + <atom:updated>1970-01-01T00:00:00.000Z</atom:updated> + <atom:link rel="self" type="application/atom+xml" href="https://www.google.com/a/feeds/group/2.0/example.com/us-sales/member/suejones%40example.com"/> + <atom:link rel="edit" type="application/atom+xml" href="https://www.google.com/a/feeds/group/2.0/example.com/us-sales/member/suejones%40example.com"/> + <apps:property name="memberId" value="suejones@example.com"/> + <apps:property name="memberType" value="User"/> + <apps:property name="directMember" value="true"/> +</atom:entry> + 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<atom:feed xmlns:atom="http://www.w3.org/2005/Atom" + xmlns:apps="http://schemas.google.com/apps/2006" + xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/"> + <atom:id>https://www.google.com/a/feeds/group/2.0/example.com/us-sales/member</atom:id> + <atom:link rel="https://schemas.google.com/g/2005#feed" type="application/atom+xml" + href="https://www.google.com/a/feeds/group/2.0/example.com/us-sales/member"/> + <openSearch:startIndex>1</openSearch:startIndex> + <atom:entry> + <atom:id>https://www.google.com/a/feeds/group/2.0/example.com/us-sales/member/suejones%40example.com</atom:id> + <atom:link rel="self" type="application/atom+xml" +href="https://www.google.com/a/feeds/group/2.0/example.com/us-sales/member/suejones%40example.com"/> + <atom:link rel="edit" type="application/atom+xml" +href="https://www.google.com/a/feeds/group/2.0/example.com/us-sales/member/suejones%40example.com"/> + <apps:property name="memberId" value="suejones@example.com"/> + <apps:property name="memberType" value="User"/> + <apps:property name="directMember" value="true"/> + </atom:entry> + <atom:entry> + <atom:id>https://www.google.com/a/feeds/group/2.0/example.com/us-sales/member/ca-sales%40example.com</atom:id> + <atom:link rel="self" type="application/atom+xml" +href="https://www.google.com/a/feeds/group/2.0/example.com/us-sales/member/ca-sales%40example.com"/> + <atom:link rel="edit" type="application/atom+xml" +href="https://www.google.com/a/feeds/group/2.0/example.com/us-sales/member/ca-sales%40example.com"/> + <apps:property name="memberId" value="ca-sales@example.com"/> + <apps:property name="memberType" value="Group"/> + <apps:property name="directMember" value="true"/> + </atom:entry> +</atom:feed>
\ 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<apps:name xmlns:apps="http://schemas.google.com/apps/2006" familyName="Jones" givenName="Susan"/> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<apps:nickname xmlns:apps="http://schemas.google.com/apps/2006" name="Jones"/> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" + xmlns:apps="http://schemas.google.com/apps/2006" + xmlns:gd="http://schemas.google.com/g/2005"> + <atom:id>https://apps-apis.google.com/a/feeds/example.com/nickname/2.0/Susy</atom:id> + <atom:updated>1970-01-01T00:00:00.000Z</atom:updated> + <atom:category scheme="http://schemas.google.com/g/2005#kind" + term="http://schemas.google.com/apps/2006#nickname"/> + <atom:title type="text">Susy</atom:title> + <atom:link rel="self" type="application/atom+xml" + href="https://apps-apis.google.com/a/feeds/example.com/nickname/2.0/Susy"/> + <atom:link rel="edit" type="application/atom+xml" + href="https://apps-apis.google.com/a/feeds/example.com/nickname/2.0/Susy"/> + <apps:nickname name="Susy"/> + <apps:login userName="SusanJones" suspended="false" admin="false" changePasswordAtNextLogin="false" agreedToTerms="true"/> +</atom:entry> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<atom:feed xmlns:atom="http://www.w3.org/2005/Atom" + xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" + xmlns:apps="http://schemas.google.com/apps/2006"> + <atom:id> + http://apps-apis.google.com/a/feeds/example.com/nickname/2.0 + </atom:id> + <atom:updated>1970-01-01T00:00:00.000Z</atom:updated> + <atom:category scheme="http://schemas.google.com/g/2005#kind" + term="http://schemas.google.com/apps/2006#nickname"/> + <atom:title type="text">Nicknames for user SusanJones</atom:title> + <atom:link rel="http://schemas.google.com/g/2005#feed" + type="application/atom+xml" + href="http://apps-apis.google.com/a/feeds/example.com/nickname/2.0"/> + <atom:link rel="http://schemas.google.com/g/2005#post" + type="application/atom+xml" + href="http://apps-apis.google.com/a/feeds/example.com/nickname/2.0"/> + <atom:link rel="self" type="application/atom+xml" + href="http://apps-apis.google.com/a/feeds/example.com/nickname/2.0?username=SusanJones"/> + <openSearch:startIndex>1</openSearch:startIndex> + <openSearch:itemsPerPage>2</openSearch:itemsPerPage> + <atom:entry> + <atom:id> + http://apps-apis.google.com/a/feeds/example.com/nickname/2.0/susy + </atom:id> + <atom:category scheme="http://schemas.google.com/g/2005#kind" + term="http://schemas.google.com/apps/2006#nickname"/> + <atom:title type="text">susy</atom:title> + <atom:link rel="self" type="application/atom+xml" + href="http://apps-apis.google.com/a/feeds/example.com/nickname/2.0/susy"/> + <atom:link rel="edit" type="application/atom+xml" + href="http://apps-apis.google.com/a/feeds/example.com/nickname/2.0/susy"/> + <apps:nickname name="susy"/> + <apps:login userName="SusanJones" suspended="false" admin="false" changePasswordAtNextLogin="false" agreedToTerms="true"/> + </atom:entry> + <atom:entry> + <atom:id> + http://apps-apis.google.com/a/feeds/example.com/nickname/2.0/suse + </atom:id> + <atom:category scheme="http://schemas.google.com/g/2005#kind" + term="http://schemas.google.com/apps/2006#nickname"/> + <atom:title type="text">suse</atom:title> + <atom:link rel="self" type="application/atom+xml" + href="http://apps-apis.google.com/a/feeds/example.com/nickname/2.0/suse"/> + <atom:link rel="edit" type="application/atom+xml" + href="http://apps-apis.google.com/a/feeds/example.com/nickname/2.0/suse"/> + <apps:nickname name="suse"/> + <apps:login userName="SusanJones" suspended="false" admin="false" changePasswordAtNextLogin="false" agreedToTerms="true"/> + </atom:entry> +</atom:feed> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" + xmlns:apps="http://schemas.google.com/apps/2006" + xmlns:gd="http://schemas.google.com/g/2005" > + <atom:id>https://www.google.com/a/feeds/group/2.0/example.com/us-sales/owner/joe%40example.com</atom:id> + <atom:updated>1970-01-01T00:00:00.000Z</atom:updated> + <atom:link rel="self" type="application/atom+xml" href="https://www.google.com/a/feeds/group/2.0/example.com/us-sales/owner/joe%40example.com"/> + <atom:link rel="edit" type="application/atom+xml" href="https://www.google.com/a/feeds/group/2.0/example.com/us-sales/owner/joe%40example.com"/> + <apps:property name="email" value="joe@example.com"/> +</atom:entry> 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 @@ +<?xml version='1.0' encoding='UTF-8'?> +<atom:feed xmlns:atom='http://www.w3.org/2005/Atom' + xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' + xmlns:apps='http://schemas.google.com/apps/2006'> + <atom:id>https://www.google.com/a/feeds/group/2.0/example.com/us-sales/owner</atom:id> + <atom:updated>1970-01-01T00:00:00.000Z</atom:updated> + <atom:link rel='http://schemas.google.com/g/2005#feed' + type='application/atom+xml' + href='https://www.google.com/a/feeds/group/2.0/example.com/us-sales/owner'/> + <atom:link rel='http://schemas.google.com/g/2005#post' + type='application/atom+xml' + href='https://www.google.com/a/feeds/group/2.0/example.com/us-sales/owner'/> + <atom:link rel='self' type='application/atom+xml' + href='https://www.google.com/a/feeds/group/2.0/example.com/us-sales/owner'/> + <openSearch:startIndex>1</openSearch:startIndex> + <atom:entry> + <atom:id>https://www.google.com/a/feeds/group/2.0/example.com/us-sales/owner/joe%40example.com</atom:id> + <atom:updated>1970-01-01T00:00:00.000Z</atom:updated> + <atom:link rel="self" type="application/atom+xml" href="https://www.google.com/a/feeds/group/2.0/example.com/us-sales/owner/joe%40example.com"/> + <atom:link rel="edit" type="application/atom+xml" href="https://www.google.com/a/feeds/group/2.0/example.com/us-sales/owner/joe%40example.com"/> + <apps:property name="email" value="joe@example.com"/> + </atom:entry> + <atom:entry> + <atom:id>https://www.google.com/a/feeds/group/2.0/example.com/us-sales/owner/suejones%40example.com</atom:id> + <atom:updated>1970-01-01T00:00:00.000Z</atom:updated> + <atom:link rel="self" type="application/atom+xml" href="https://www.google.com/a/feeds/group/2.0/example.com/us-sales/owner/suejones%40example.com"/> + <atom:link rel="edit" type="application/atom+xml" href="https://www.google.com/a/feeds/group/2.0/example.com/us-sales/owner/suejones%40example.com"/> + <apps:property name="email" value="suejones@example.com"/> + </atom:entry> +</atom:feed> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<apps:property xmlns:apps="http://schemas.google.com/apps/2006" name="Some Name" value="Some Value" /> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<apps:quota xmlns:apps="http://schemas.google.com/apps/2006" limit="2048"/> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" + xmlns:apps="http://schemas.google.com/apps/2006" + xmlns:gd="http://schemas.google.com/g/2005"> + <atom:id>https://apps-apis.google.com/a/feeds/example.com/user/2.0/SusanJones</atom:id> + <atom:updated>1970-01-01T00:00:00.000Z</atom:updated> + <atom:category scheme="http://schemas.google.com/g/2005#kind" + term="http://schemas.google.com/apps/2006#user"/> + <atom:title type="text">SusanJones</atom:title> + <atom:link rel="self" type="application/atom+xml" + href="https://apps-apis.google.com/a/feeds/example.com/user/2.0/SusanJones"/> + <atom:link rel="edit" type="application/atom+xml" + href="https://apps-apis.google.com/a/feeds/example.com/user/2.0/SusanJones"/> + <apps:login userName="SusanJones"/> + <apps:name familyName="Jones" givenName="Susan"/> + <gd:feedLink rel="http://schemas.google.com/apps/2006#user.nicknames" + href="https://apps-apis.google.com/a/feeds/example.com/nickname/2.0?username=Susy-1321"/> + <gd:feedLink rel="http://schemas.google.com/apps/2006#user.emailLists" href="https://apps-apis.google.com/a/feeds/example.com/emailList/2.0?recipient=us-sales@example.com"/> + <apps:quota limit="2048"/> +</atom:entry> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<atom:feed xmlns:atom="http://www.w3.org/2005/Atom" + xmlns:apps="http://schemas.google.com/apps/2006" + xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" + xmlns:gd="http://schemas.google.com/g/2005"> + <atom:id> + http://apps-apis.google.com/a/feeds/example.com/user/2.0 + </atom:id> + <atom:updated>1970-01-01T00:00:00.000Z</atom:updated> + <atom:category scheme="http://schemas.google.com/g/2005#kind" + term="http://schemas.google.com/apps/2006#user"/> + <atom:title type="text">Users</atom:title> + <atom:link rel="next" type="application/atom+xml" + href="http://apps-apis.google.com/a/feeds/example.com/user/2.0?startUsername=john"/> + <atom:link rel="http://schemas.google.com/g/2005#feed" + type="application/atom+xml" + href="http://apps-apis.google.com/a/feeds/example.com/user/2.0"/> + <atom:link rel="http://schemas.google.com/g/2005#post" + type="application/atom+xml" + href="http://apps-apis.google.com/a/feeds/example.com/user/2.0"/> + <atom:link rel="self" type="application/atom+xml" + href="http://apps-apis.google.com/a/feeds/example.com/user/2.0"/> + <openSearch:startIndex>1</openSearch:startIndex> + <atom:entry> + <atom:id> + http://apps-apis.google.com/a/feeds/example.com/user/2.0/SusanJones + </atom:id> + <atom:category scheme="http://schemas.google.com/g/2005#kind" + term="http://schemas.google.com/apps/2006#user"/> + <atom:title type="text">SusanJones</atom:title> + <atom:link rel="self" type="application/atom+xml" + href="http://apps-apis.google.com/a/feeds/example.com/user/2.0/SusanJones"/> + <atom:link rel="edit" type="application/atom+xml" + href="http://apps-apis.google.com/a/feeds/example.com/user/2.0/SusanJones"/> + <gd:who rel="http://schemas.google.com/apps/2006#user.recipient" + email="SusanJones@example.com"/> + <apps:login userName="SusanJones" suspended="false" admin="false" changePasswordAtNextLogin="false" agreedToTerms="true"/> + <apps:quota limit="2048"/> + <apps:name familyName="Jones" givenName="Susan"/> + <gd:feedLink rel="http://schemas.google.com/apps/2006#user.nicknames" + href="http://apps-apis.google.com/a/feeds/example.com/nickname/2.0?username=SusanJones"/> + <gd:feedLink rel="http://schemas.google.com/apps/2006#user.emailLists" + href="http://apps-apis.google.com/a/feeds/example.com/emailList/2.0?recipient=SusanJones@example.com"/> + </atom:entry> + <atom:entry> + <atom:id> + http://apps-apis.google.com/a/feeds/example.com/user/2.0/JohnSmith + </atom:id> + <atom:category scheme="http://schemas.google.com/g/2005#kind" + term="http://schemas.google.com/apps/2006#user"/> + <atom:title type="text">JohnSmith</atom:title> + <atom:link rel="self" type="application/atom+xml" + href="http://apps-apis.google.com/a/feeds/example.com/user/2.0/JohnSmith"/> + <atom:link rel="edit" type="application/atom+xml" + href="http://apps-apis.google.com/a/feeds/example.com/user/2.0/JohnSmith"/> + <gd:who rel="http://schemas.google.com/apps/2006#user.recipient" + email="JohnSmith@example.com"/> + <apps:login userName="JohnSmith" suspended="false" admin="false" changePasswordAtNextLogin="false" agreedToTerms="true"/> + <apps:quota limit="2048"/> + <apps:name familyName="Smith" givenName="John"/> + <gd:feedLink rel="http://schemas.google.com/apps/2006#user.nicknames" + href="http://apps-apis.google.com/a/feeds/example.com/nickname/2.0?username=JohnSmith"/> + <gd:feedLink rel="http://schemas.google.com/apps/2006#user.emailLists" + href="http://apps-apis.google.com/a/feeds/example.com/emailList/2.0?recipient=JohnSmith@example.com"/> + </atom:entry> +</atom:feed> 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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Gapps.php'; +require_once 'Zend/Gdata/Gapps/UserEntry.php'; +require_once 'Zend/Gdata/Gapps/UserQuery.php'; +require_once 'Zend/Gdata/ClientLogin.php'; +require_once 'Zend/Http/Client.php'; + +/** + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Gapps + */ +class Zend_Gdata_GappsOnlineTest extends PHPUnit_Framework_TestCase +{ + + const GIVEN_NAME = 'Zend_Gdata'; + const FAMILY_NAME = 'Automated Test Account'; + const PASSWORD = '4ohtladfl;'; + const PASSWORD_HASH = 'SHA-1'; + + public function setUp() + { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'TestHelper.php'; +require_once 'Zend/Gdata/Gapps.php'; +require_once 'Zend/Gdata/ClientLogin.php'; +require_once 'Zend/Http/Client.php'; + +/** + * @category Zend + * @package Zend_Gdata_Gapps + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Gapps + */ +class Zend_Gdata_GappsTest extends PHPUnit_Framework_TestCase +{ + const TEST_DOMAIN = 'nowhere.invalid'; + + public function setUp() + { + // These tests shouldn't be doing anything online, so we can use + // bogous auth credentials. + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Http/Client.php'; +require_once 'Zend/Gdata.php'; +require_once 'Zend/Gdata/App/MediaEntry.php'; +require_once 'Zend/Gdata/App/MediaFileSource.php'; +require_once 'Zend/Gdata/ClientLogin.php'; +require_once 'Zend/Gdata/App/InvalidArgumentException.php'; + +/** + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + */ +class Zend_Gdata_GdataOnlineTest extends PHPUnit_Framework_TestCase +{ + private $blog = null; // blog ID from config + + public function setUp() + { + $user = constant('TESTS_ZEND_GDATA_CLIENTLOGIN_EMAIL'); + $pass = constant('TESTS_ZEND_GDATA_CLIENTLOGIN_PASSWORD'); + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Http/Client.php'; +require_once 'Zend/Gdata.php'; + +/** + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + */ +class Zend_Gdata_GdataTest extends PHPUnit_Framework_TestCase +{ + + public function testDefaultHttpClient() + { + $gdata = new Zend_Gdata(); + $client = $gdata->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/MediaMimeStream.php'; + +/** + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + */ +class Zend_Gdata_MediaMimeStreamTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() + { + $this->locationOfFakeBinary = + 'Zend/Gdata/_files/MediaMimeStreamSample1.txt'; + $this->smallXMLString = '<xml><entry><title>foo</title></entry>'; + $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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_OpenSearch + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Extension/OpenSearchItemsPerPage.php'; +require_once 'Zend/Gdata.php'; + +/** + * @category Zend + * @package Zend_Gdata_OpenSearch + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_OpenSearch + */ +class Zend_Gdata_OpenSearchItemsPerPageTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_OpenSearch + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Extension/OpenSearchStartIndex.php'; +require_once 'Zend/Gdata.php'; + +/** + * @category Zend + * @package Zend_Gdata_OpenSearch + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_OpenSearch + */ +class Zend_Gdata_OpenSearchStartIndexTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_OpenSearch + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Extension/OpenSearchTotalResults.php'; +require_once 'Zend/Gdata.php'; + +/** + * @category Zend + * @package Zend_Gdata_OpenSearch + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_OpenSearch + */ +class Zend_Gdata_OpenSearchTotalResultsTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Extension/OriginalEvent.php'; +require_once 'Zend/Gdata.php'; + +/** + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + */ +class Zend_Gdata_OriginalEventTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Photos + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Photos.php'; +require_once 'Zend/Gdata/Photos/AlbumEntry.php'; +require_once 'Zend/Http/Client.php'; +require_once 'Zend/Http/Client/Adapter/Test.php'; + +/** + * @category Zend + * @package Zend_Gdata_Photos + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Photos + */ +class Zend_Gdata_Photos_PhotosAlbumEntryTest extends PHPUnit_Framework_TestCase +{ + + protected $albumEntry = null; + + /** + * Called before each test to setup any fixtures. + */ + public function setUp() + { + $albumEntryText = file_get_contents( + '_files/TestAlbumEntry.xml', + true); + $this->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 <atom:author> 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 <atom:id> 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 <atom:published> 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 <atom:updated> 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 <atom:title> 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 <gphoto:user> 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 <gphoto:nickname> 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 <gphoto:name> 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 <gphoto:id> 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 <gphoto:location> 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 <gphoto:access> 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 <gphoto:timestamp> 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 <gphoto:numphotos> 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 <gphoto:commentingEnabled> 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 <gphoto:commentCount> 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 <media:group> + */ + 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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Photos + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Photos.php'; +require_once 'Zend/Gdata/Photos/AlbumFeed.php'; +require_once 'Zend/Http/Client.php'; +require_once 'Zend/Http/Client/Adapter/Test.php'; + +/** + * @category Zend + * @package Zend_Gdata_Photos + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Photos + */ +class Zend_Gdata_Photos_PhotosAlbumFeedTest extends PHPUnit_Framework_TestCase +{ + + protected $albumFeed = null; + + /** + * Called before each test to setup any fixtures. + */ + public function setUp() + { + $albumFeedText = file_get_contents( + '_files/TestAlbumFeed.xml', + true); + $this->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 <atom:author> 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 <atom:id> 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 <atom:published> 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 <atom:updated> 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 <atom:title> 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 <atom:subtitle> 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 <atom:generator> 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 <atom:icon> 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 <gphoto:user> 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 <gphoto:nickname> 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 <gphoto:name> 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 <gphoto:id> 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 <gphoto:location> 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 <gphoto:access> 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 <gphoto:timestamp> 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 <gphoto:numphotos> 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 <gphoto:commentingEnabled> 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 <gphoto:commentCount> 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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Photos + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Photos.php'; +require_once 'Zend/Gdata/Photos/AlbumQuery.php'; +require_once 'Zend/Http/Client.php'; +require_once 'Zend/Http/Client/Adapter/Test.php'; + +/** + * @category Zend + * @package Zend_Gdata_Photos + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Photos + */ +class Zend_Gdata_Photos_PhotosAlbumQueryTest extends PHPUnit_Framework_TestCase +{ + + /** + * Check the consistency of an album feed request + */ + public function testSimpleAlbumQuery() + { + $queryString = "https://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1"; + + $query = new Zend_Gdata_Photos_AlbumQuery(); + $query->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Photos + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Photos.php'; +require_once 'Zend/Gdata/Photos/CommentEntry.php'; +require_once 'Zend/Http/Client.php'; +require_once 'Zend/Http/Client/Adapter/Test.php'; + +/** + * @category Zend + * @package Zend_Gdata_Photos + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Photos + */ +class Zend_Gdata_Photos_PhotosCommentEntryTest extends PHPUnit_Framework_TestCase +{ + + protected $commentEntry = null; + + /** + * Called before each test to setup any fixtures. + */ + public function setUp() + { + $commentEntryText = file_get_contents( + '_files/TestCommentEntry.xml', + true); + $this->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 <atom:id> 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 <atom:author> 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 <atom:published> 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 <atom:updated> 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 <atom:title> 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 <atom:content> 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 <gphoto:id> 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 <gphoto:photoid> 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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Photos + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Photos.php'; +require_once 'Zend/Gdata/Photos/PhotoEntry.php'; +require_once 'Zend/Http/Client.php'; +require_once 'Zend/Http/Client/Adapter/Test.php'; + +/** + * @category Zend + * @package Zend_Gdata_Photos + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Photos + */ +class Zend_Gdata_Photos_PhotosPhotoEntryTest extends PHPUnit_Framework_TestCase +{ + + protected $photoEntry = null; + + /** + * Called before each test to setup any fixtures. + */ + public function setUp() + { + $photoEntryText = file_get_contents( + '_files/TestPhotoEntry.xml', + true); + $this->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 <atom:id> 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 <atom:published> 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 <atom:updated> 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 <atom:title> 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 <gphoto:id> 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 <gphoto:version> 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 <gphoto:albumid> 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 <gphoto:width> 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 <gphoto:height> 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 <gphoto:size> 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 <gphoto:client> 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 <gphoto:checksum> 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 <gphoto:timestamp> 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 <gphoto:commentingEnabled> 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 <gphoto:commentCount> 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 <media:group> + */ + 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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Photos + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Photos.php'; +require_once 'Zend/Gdata/Photos/PhotoFeed.php'; +require_once 'Zend/Http/Client.php'; +require_once 'Zend/Http/Client/Adapter/Test.php'; + +/** + * @category Zend + * @package Zend_Gdata_Photos + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Photos + */ +class Zend_Gdata_Photos_PhotosPhotoFeedTest extends PHPUnit_Framework_TestCase +{ + + protected $photoFeed = null; + + /** + * Called before each test to setup any fixtures. + */ + public function setUp() + { + $photoFeedText = file_get_contents( + '_files/TestPhotoFeed.xml', + true); + $this->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 <atom:id> 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 <atom:updated> 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 <atom:title> 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 <atom:subtitle> 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 <atom:generator> 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 <atom:icon> 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 <gphoto:id> 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 <gphoto:version> 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 <gphoto:albumid> 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 <gphoto:timestamp> 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 <gphoto:width> 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 <gphoto:height> 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 <gphoto:size> 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 <gphoto:client> 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 <gphoto:checksum> 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 <gphoto:commentingEnabled> 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 <gphoto:commentCount> 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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Photos + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Photos.php'; +require_once 'Zend/Gdata/Photos/PhotoQuery.php'; +require_once 'Zend/Http/Client.php'; +require_once 'Zend/Http/Client/Adapter/Test.php'; + +/** + * @category Zend + * @package Zend_Gdata_Photos + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Photos + */ +class Zend_Gdata_Photos_PhotosPhotoQueryTest extends PHPUnit_Framework_TestCase +{ + + /** + * Check the consistency of a user feed request + */ + public function testSimplePhotoQuery() + { + $queryString = "https://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1/photoid/1"; + + $query = new Zend_Gdata_Photos_PhotoQuery(); + $query->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Photos + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Photos.php'; +require_once 'Zend/Gdata/Photos/TagEntry.php'; +require_once 'Zend/Http/Client.php'; +require_once 'Zend/Http/Client/Adapter/Test.php'; + +/** + * @category Zend + * @package Zend_Gdata_Photos + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Photos + */ +class Zend_Gdata_Photos_PhotosTagEntryTest extends PHPUnit_Framework_TestCase +{ + + protected $tagEntry = null; + + /** + * Called before each test to setup any fixtures. + */ + public function setUp() + { + $tagEntryText = file_get_contents( + '_files/TestTagEntry.xml', + true); + $this->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 <atom:id> 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 <atom:updated> 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 <atom:title> 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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Photos + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Photos.php'; +require_once 'Zend/Gdata/Photos/UserEntry.php'; +require_once 'Zend/Http/Client.php'; +require_once 'Zend/Http/Client/Adapter/Test.php'; + +/** + * @category Zend + * @package Zend_Gdata_Photos + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Photos + */ +class Zend_Gdata_Photos_PhotosUserEntryTest extends PHPUnit_Framework_TestCase +{ + + protected $userEntry = null; + + /** + * Called before each test to setup any fixtures. + */ + public function setUp() + { + $userEntryText = file_get_contents( + '_files/TestUserEntry.xml', + true); + $this->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 <atom:author> 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 <atom:id> 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 <atom:published> 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 <atom:updated> 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 <atom:title> 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 <gphoto:user> 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 <gphoto:nickname> 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 <gphoto:thumbnail> 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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Photos + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Photos.php'; +require_once 'Zend/Gdata/Photos/UserFeed.php'; +require_once 'Zend/Http/Client.php'; +require_once 'Zend/Http/Client/Adapter/Test.php'; + +/** + * @category Zend + * @package Zend_Gdata_Photos + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Photos + */ +class Zend_Gdata_Photos_PhotosUserFeedTest extends PHPUnit_Framework_TestCase +{ + + protected $userFeed = null; + + /** + * Called before each test to setup any fixtures. + */ + public function setUp() + { + $userFeedText = file_get_contents( + '_files/TestUserFeed.xml', + true); + $this->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 <atom:author> 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 <atom:id> 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 <atom:published> 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 <atom:updated> 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 <atom:title> 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 <atom:subtitle> 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 <atom:generator> 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 <atom:icon> 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 <gphoto:user> 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 <gphoto:nickname> 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 <gphoto:thumbnail> 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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Photos + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Photos.php'; +require_once 'Zend/Gdata/Photos/UserQuery.php'; +require_once 'Zend/Http/Client.php'; +require_once 'Zend/Http/Client/Adapter/Test.php'; + +/** + * @category Zend + * @package Zend_Gdata_Photos + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Photos + */ +class Zend_Gdata_Photos_PhotosUserQueryTest extends PHPUnit_Framework_TestCase +{ + + /** + * Check the consistency of a user feed request + */ + public function testSimpleUserQuery() + { + $queryString = "https://picasaweb.google.com/data/feed/api/user/sample.user"; + + $query = new Zend_Gdata_Photos_UserQuery(); + $query->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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<entry xmlns="http://www.w3.org/2005/Atom" xmlns:exif="http://schemas.google.com/photos/exif/2007" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:gml="http://www.opengis.net/gml" xmlns:georss="http://www.georss.org/georss" xmlns:photo="http://www.pheed.com/pheed/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:batch="http://schemas.google.com/gdata/batch" xmlns:gphoto="http://schemas.google.com/photos/2007"> + <id>http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1</id> + <published>2007-09-05T07:00:00.000Z</published> + <updated>2007-09-05T20:49:24.000Z</updated> + <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/photos/2007#album"/> + <title type="text">Test</title> + <summary type="text"/> + <rights type="text">public</rights> + <link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1"/> + <link rel="alternate" type="text/html" href="http://picasaweb.google.com/sample.user/Test"/> + <link rel="self" type="application/atom+xml" href="http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1"/> + <author> + <name>sample</name> + <uri>http://picasaweb.google.com/sample.user</uri> + </author> + <gphoto:id>1</gphoto:id> + <gphoto:name>Test</gphoto:name> + <gphoto:location/> + <gphoto:access>public</gphoto:access> + <gphoto:timestamp>1188975600000</gphoto:timestamp> + <gphoto:numphotos>2</gphoto:numphotos> + <gphoto:user>sample.user</gphoto:user> + <gphoto:nickname>sample</gphoto:nickname> + <gphoto:commentingEnabled>true</gphoto:commentingEnabled> + <gphoto:commentCount>0</gphoto:commentCount> + <media:group> + <media:title type="plain">Test</media:title> + <media:description type="plain"/> + <media:keywords/> + <media:content url="http://lh6.google.com/sample.user/Rt8WNoDZEJE/AAAAAAAAABk/HQGlDhpIgWo/Test.jpg" type="image/jpeg" medium="image"/> + <media:thumbnail url="http://lh6.google.com/sample.user/Rt8WNoDZEJE/AAAAAAAAABk/HQGlDhpIgWo/s160-c/Test.jpg" height="160" width="160"/> + <media:credit>sample</media:credit> + </media:group> + <georss:where> + <gml:Point> + <gml:pos>42.87194 13.56738</gml:pos> + </gml:Point> + </georss:where> +</entry> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:exif="http://schemas.google.com/photos/exif/2007" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:gml="http://www.opengis.net/gml" xmlns:georss="http://www.georss.org/georss" xmlns:photo="http://www.pheed.com/pheed/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:batch="http://schemas.google.com/gdata/batch" xmlns:gphoto="http://schemas.google.com/photos/2007"> + <id>http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1</id> + <updated>2007-09-21T18:23:05.000Z</updated> + <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/photos/2007#album"/> + <title type="text">Test</title> + <subtitle type="text"/> + <rights type="text">public</rights> + <icon>http://lh6.google.com/sample.user/Rt8WNoDZEJE/AAAAAAAAABk/HQGlDhpIgWo/s160-c/Test.jpg</icon> + <link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1"/> + <link rel="alternate" type="text/html" href="http://picasaweb.google.com/sample.user/Test"/> + <link rel="http://schemas.google.com/photos/2007#slideshow" type="application/x-shockwave-flash" href="http://picasaweb.google.com/s/c/bin/slideshow.swf?host=picasaweb.google.com&RGB=0x000000&feed=http%3A%2F%2Fpicasaweb.google.com%2Fdata%2Ffeed%2Fapi%2Fuser%2Fsample.user%2Falbumid%2F1%3Falt%3Drss"/> + <link rel="self" type="application/atom+xml" href="http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1?start-index=1&max-results=500&kind=photo%2Ctag"/> + <author> + <name>sample</name> + <uri>http://picasaweb.google.com/sample.user</uri> + </author> + <generator version="1.00" uri="http://picasaweb.google.com/">Picasaweb</generator> + <openSearch:totalResults>4</openSearch:totalResults> + <openSearch:startIndex>1</openSearch:startIndex> + <openSearch:itemsPerPage>500</openSearch:itemsPerPage> + <gphoto:id>1</gphoto:id> + <gphoto:name>Test</gphoto:name> + <gphoto:location/> + <gphoto:access>public</gphoto:access> + <gphoto:timestamp>1188975600000</gphoto:timestamp> + <gphoto:numphotos>2</gphoto:numphotos> + <gphoto:user>sample.user</gphoto:user> + <gphoto:nickname>sample</gphoto:nickname> + <gphoto:commentingEnabled>true</gphoto:commentingEnabled> + <gphoto:commentCount>0</gphoto:commentCount> + <entry> + <id>http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/2</id> + <published>2007-09-05T20:49:23.000Z</published> + <updated>2007-09-21T18:23:05.000Z</updated> + <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/photos/2007#photo"/> + <title type="text">Aqua Blue.jpg</title> + <summary type="text">Blue</summary> + <content type="image/jpeg" src="http://lh4.google.com/sample.user/Rt8WU4DZEKI/AAAAAAAAABY/IVgLqmnzJII/Aqua%20Blue.jpg"/> + <link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1/photoid/2"/> + <link rel="alternate" type="text/html" href="http://picasaweb.google.com/sample.user/Test/photo#2"/> + <link rel="self" type="application/atom+xml" href="http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/2"/> + <gphoto:id>2</gphoto:id> + <gphoto:version>1190398985145172</gphoto:version> + <gphoto:position>0.0</gphoto:position> + <gphoto:albumid>1</gphoto:albumid> + <gphoto:width>2560</gphoto:width> + <gphoto:height>1600</gphoto:height> + <gphoto:size>883405</gphoto:size> + <gphoto:client/> + <gphoto:checksum/> + <gphoto:timestamp>1189025362000</gphoto:timestamp> + <exif:tags> + <exif:flash>true</exif:flash> + <exif:imageUniqueID>c041ce17aaa637eb656c81d9cf526c24</exif:imageUniqueID> + </exif:tags> + <gphoto:commentingEnabled>true</gphoto:commentingEnabled> + <gphoto:commentCount>1</gphoto:commentCount> + <media:group> + <media:title type="plain">Aqua Blue.jpg</media:title> + <media:description type="plain">Blue</media:description> + <media:keywords>tag, test</media:keywords> + <media:content url="http://lh4.google.com/sample.user/Rt8WU4DZEKI/AAAAAAAAABY/IVgLqmnzJII/Aqua%20Blue.jpg" height="1600" width="2560" type="image/jpeg" medium="image"/> + <media:thumbnail url="http://lh4.google.com/sample.user/Rt8WU4DZEKI/AAAAAAAAABY/IVgLqmnzJII/s72/Aqua%20Blue.jpg" height="45" width="72"/> + <media:thumbnail url="http://lh4.google.com/sample.user/Rt8WU4DZEKI/AAAAAAAAABY/IVgLqmnzJII/s144/Aqua%20Blue.jpg" height="90" width="144"/> + <media:thumbnail url="http://lh4.google.com/sample.user/Rt8WU4DZEKI/AAAAAAAAABY/IVgLqmnzJII/s288/Aqua%20Blue.jpg" height="180" width="288"/> + <media:credit>sample</media:credit> + </media:group> + <georss:where> + <gml:Point> + <gml:pos>41.87194 12.56738</gml:pos> + </gml:Point> + </georss:where> + </entry> + <entry> + <id>http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/3</id> + <published>2007-09-05T20:49:24.000Z</published> + <updated>2007-09-21T18:19:38.000Z</updated> + <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/photos/2007#photo"/> + <title type="text">Aqua Graphite.jpg</title> + <summary type="text">Gray</summary> + <content type="image/jpeg" src="http://lh5.google.com/sample.user/Rt8WVIDZELI/AAAAAAAAABg/d7e0i7gvhNU/Aqua%20Graphite.jpg"/> + <link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1/photoid/3"/> + <link rel="alternate" type="text/html" href="http://picasaweb.google.com/sample.user/Test/photo#3"/> + <link rel="self" type="application/atom+xml" href="http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/3"/> + <gphoto:id>3</gphoto:id> + <gphoto:version>1190398778006402</gphoto:version> + <gphoto:position>1.0</gphoto:position> + <gphoto:albumid>1</gphoto:albumid> + <gphoto:width>2560</gphoto:width> + <gphoto:height>1600</gphoto:height> + <gphoto:size>798334</gphoto:size> + <gphoto:client/> + <gphoto:checksum/> + <gphoto:timestamp>1189025363000</gphoto:timestamp> + <exif:tags> + <exif:flash>true</exif:flash> + <exif:imageUniqueID>a5ce2e36b9df7d3cb081511c72e73926</exif:imageUniqueID> + </exif:tags> + <gphoto:commentingEnabled>true</gphoto:commentingEnabled> + <gphoto:commentCount>0</gphoto:commentCount> + <media:group> + <media:title type="plain">Aqua Graphite.jpg</media:title> + <media:description type="plain">Gray</media:description> + <media:keywords/> + <media:content url="http://lh5.google.com/sample.user/Rt8WVIDZELI/AAAAAAAAABg/d7e0i7gvhNU/Aqua%20Graphite.jpg" height="1600" width="2560" type="image/jpeg" medium="image"/> + <media:thumbnail url="http://lh5.google.com/sample.user/Rt8WVIDZELI/AAAAAAAAABg/d7e0i7gvhNU/s72/Aqua%20Graphite.jpg" height="45" width="72"/> + <media:thumbnail url="http://lh5.google.com/sample.user/Rt8WVIDZELI/AAAAAAAAABg/d7e0i7gvhNU/s144/Aqua%20Graphite.jpg" height="90" width="144"/> + <media:thumbnail url="http://lh5.google.com/sample.user/Rt8WVIDZELI/AAAAAAAAABg/d7e0i7gvhNU/s288/Aqua%20Graphite.jpg" height="180" width="288"/> + <media:credit>sample</media:credit> + </media:group> + </entry> + <entry> + <id>http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/tag/tag</id> + <updated>2007-09-05T20:49:24.000Z</updated> + <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/photos/2007#tag"/> + <title type="text">tag</title> + <summary type="text">tag</summary> + <link rel="alternate" type="text/html" href="http://picasaweb.google.com/lh/searchbrowse?q=tag&psc=G&uname=sample.user&filter=0"/> + <link rel="self" type="application/atom+xml" href="http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/tag/tag"/> + <author> + <name>sample</name> + <uri>http://picasaweb.google.com/sample.user</uri> + </author> + </entry> + <entry> + <id>http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/tag/test</id> + <updated>2007-09-05T20:49:24.000Z</updated> + <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/photos/2007#tag"/> + <title type="text">test</title> + <summary type="text">test</summary> + <link rel="alternate" type="text/html" href="http://picasaweb.google.com/lh/searchbrowse?q=test&psc=G&uname=sample.user&filter=0"/> + <link rel="self" type="application/atom+xml" href="http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/tag/test"/> + <author> + <name>sample</name> + <uri>http://picasaweb.google.com/sample.user</uri> + </author> + </entry> +</feed> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<entry xmlns="http://www.w3.org/2005/Atom" xmlns:gphoto="http://schemas.google.com/photos/2007"> + <id>http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/100/commentid/5</id> + <published>2007-09-21T18:22:53.000Z</published> + <updated>2007-09-21T18:22:53.000Z</updated> + <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/photos/2007#comment"/> + <title type="text">sample</title> + <summary type="text">test comment</summary> + <content type="text">test comment</content> + <link rel="alternate" type="text/html" href="http://picasaweb.google.com/sample.user/Test/photo#100"/> + <link rel="self" type="application/atom+xml" href="http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/100/commentid/5"/> + <author> + <name>sample</name> + <uri>http://picasaweb.google.com/sample.user</uri> + <gphoto:user>sample.user</gphoto:user> + <gphoto:nickname>sample</gphoto:nickname> + <gphoto:thumbnail>http://lh5.google.com/sample.user/AAAAuZnob5E/AAAAAAAAAAA/EtCbNCdLGxM/s48-c/sample.user</gphoto:thumbnail> + </author> + <gphoto:id>5</gphoto:id> + <gphoto:photoid>100</gphoto:photoid> +</entry> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<entry xmlns="http://www.w3.org/2005/Atom" xmlns:exif="http://schemas.google.com/photos/exif/2007" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:gml="http://www.opengis.net/gml" xmlns:georss="http://www.georss.org/georss" xmlns:photo="http://www.pheed.com/pheed/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:gphoto="http://schemas.google.com/photos/2007"> + <id>http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/100</id> + <published>2007-09-05T20:49:24.000Z</published> + <updated>2007-09-21T18:19:38.000Z</updated> + <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/photos/2007#photo"/> + <title type="text">Aqua Graphite.jpg</title> + <summary type="text">Gray</summary> + <content type="image/jpeg" src="http://lh5.google.com/sample.user/Rt8WVIDZELI/AAAAAAAAABg/d7e0i7gvhNU/Aqua%20Graphite.jpg"/> + <link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1/photoid/100"/> + <link rel="alternate" type="text/html" href="http://picasaweb.google.com/sample.user/Test/photo#100"/> + <link rel="self" type="application/atom+xml" href="http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/100"/> + <gphoto:id>100</gphoto:id> + <gphoto:version>1190398778006402</gphoto:version> + <gphoto:albumid>1</gphoto:albumid> + <gphoto:width>2560</gphoto:width> + <gphoto:height>1600</gphoto:height> + <gphoto:size>798334</gphoto:size> + <gphoto:client/> + <gphoto:checksum/> + <gphoto:timestamp>1189025363000</gphoto:timestamp> + <exif:tags> + <exif:fstop>11.0</exif:fstop> + <exif:exposure>0.0040</exif:exposure> + <exif:flash>true</exif:flash> + <exif:focallength>22.0</exif:focallength> + <exif:iso>200</exif:iso> + <exif:time>1180950900000</exif:time> + <exif:imageUniqueID>a5ce2e36b9df7d3cb081511c72e73926</exif:imageUniqueID> + <exif:distance>0.0</exif:distance> + <exif:make>Fictitious Camera Company</exif:make> + <exif:model>AMAZING-100D</exif:model> + </exif:tags> + <gphoto:commentingEnabled>true</gphoto:commentingEnabled> + <gphoto:commentCount>0</gphoto:commentCount> + <media:group> + <media:title type="plain">Aqua Graphite.jpg</media:title> + <media:description type="plain">Gray</media:description> + <media:keywords/> + <media:content url="http://lh5.google.com/sample.user/Rt8WVIDZELI/AAAAAAAAABg/d7e0i7gvhNU/Aqua%20Graphite.jpg" height="1600" width="2560" type="image/jpeg" medium="image"/> + <media:thumbnail url="http://lh5.google.com/sample.user/Rt8WVIDZELI/AAAAAAAAABg/d7e0i7gvhNU/s72/Aqua%20Graphite.jpg" height="45" width="72"/> + <media:thumbnail url="http://lh5.google.com/sample.user/Rt8WVIDZELI/AAAAAAAAABg/d7e0i7gvhNU/s144/Aqua%20Graphite.jpg" height="90" width="144"/> + <media:thumbnail url="http://lh5.google.com/sample.user/Rt8WVIDZELI/AAAAAAAAABg/d7e0i7gvhNU/s288/Aqua%20Graphite.jpg" height="180" width="288"/> + <media:credit>sample</media:credit> + </media:group> + <georss:where> + <gml:Point> + <gml:pos>41.87194 12.56738</gml:pos> + </gml:Point> + </georss:where> +</entry> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:exif="http://schemas.google.com/photos/exif/2007" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:gml="http://www.opengis.net/gml" xmlns:georss="http://www.georss.org/georss" xmlns:photo="http://www.pheed.com/pheed/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:gphoto="http://schemas.google.com/photos/2007"> + <id>http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1/photoid/100</id> + <updated>2007-09-21T18:23:05.000Z</updated> + <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/photos/2007#photo"/> + <title type="text">Aqua Blue.jpg</title> + <subtitle type="text">Blue</subtitle> + <icon>http://lh4.google.com/sample.user/Rt8WU4DZEKI/AAAAAAAAABY/IVgLqmnzJII/s288/Aqua%20Blue.jpg</icon> + <link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1/photoid/100"/> + <link rel="alternate" type="text/html" href="http://picasaweb.google.com/sample.user/Test/photo#100"/> + <link rel="self" type="application/atom+xml" href="http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1/photoid/100?start-index=1&max-results=500&kind=tag%2Ccomment"/> + <generator version="1.00" uri="http://picasaweb.google.com/">Picasaweb</generator> + <openSearch:totalResults>3</openSearch:totalResults> + <openSearch:startIndex>1</openSearch:startIndex> + <openSearch:itemsPerPage>500</openSearch:itemsPerPage> + <gphoto:id>100</gphoto:id> + <gphoto:version>1190398985145172</gphoto:version> + <gphoto:albumid>1</gphoto:albumid> + <gphoto:width>2560</gphoto:width> + <gphoto:height>1600</gphoto:height> + <gphoto:size>883405</gphoto:size> + <gphoto:client/> + <gphoto:checksum/> + <gphoto:timestamp>1189025362000</gphoto:timestamp> + <exif:tags> + <exif:flash>true</exif:flash> + <exif:imageUniqueID>c041ce17aaa637eb656c81d9cf526c24</exif:imageUniqueID> + </exif:tags> + <gphoto:commentingEnabled>true</gphoto:commentingEnabled> + <gphoto:commentCount>1</gphoto:commentCount> + <media:group> + <media:title type="plain">Aqua Blue.jpg</media:title> + <media:description type="plain">Blue</media:description> + <media:keywords>tag, test</media:keywords> + <media:content url="http://lh4.google.com/sample.user/Rt8WU4DZEKI/AAAAAAAAABY/IVgLqmnzJII/Aqua%20Blue.jpg" height="1600" width="2560" type="image/jpeg" medium="image"/> + <media:thumbnail url="http://lh4.google.com/sample.user/Rt8WU4DZEKI/AAAAAAAAABY/IVgLqmnzJII/s72/Aqua%20Blue.jpg" height="45" width="72"/> + <media:thumbnail url="http://lh4.google.com/sample.user/Rt8WU4DZEKI/AAAAAAAAABY/IVgLqmnzJII/s144/Aqua%20Blue.jpg" height="90" width="144"/> + <media:thumbnail url="http://lh4.google.com/sample.user/Rt8WU4DZEKI/AAAAAAAAABY/IVgLqmnzJII/s288/Aqua%20Blue.jpg" height="180" width="288"/> + <media:credit>sample</media:credit> + </media:group> + <entry> + <id>http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/100/tag/tag</id> + <updated>2007-09-21T18:23:05.000Z</updated> + <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/photos/2007#tag"/> + <title type="text">tag</title> + <summary type="text">tag</summary> + <link rel="alternate" type="text/html" href="http://picasaweb.google.com/lh/searchbrowse?q=tag&psc=G&uname=sample.user&filter=0"/> + <link rel="self" type="application/atom+xml" href="http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/100/tag/tag"/> + <author> + <name>sample</name> + <uri>http://picasaweb.google.com/sample.user</uri> + </author> + </entry> + <entry> + <id>http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/100/tag/test</id> + <updated>2007-09-21T18:23:05.000Z</updated> + <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/photos/2007#tag"/> + <title type="text">test</title> + <summary type="text">test</summary> + <link rel="alternate" type="text/html" href="http://picasaweb.google.com/lh/searchbrowse?q=test&psc=G&uname=sample.user&filter=0"/> + <link rel="self" type="application/atom+xml" href="http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/100/tag/test"/> + <author> + <name>sample</name> + <uri>http://picasaweb.google.com/sample.user</uri> + </author> + </entry> + <entry> + <id>http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/100/commentid/5</id> + <published>2007-09-21T18:22:53.000Z</published> + <updated>2007-09-21T18:22:53.000Z</updated> + <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/photos/2007#comment"/> + <title type="text">sample</title> + <summary type="text">test comment</summary> + <content type="text">test comment</content> + <link rel="alternate" type="text/html" href="http://picasaweb.google.com/sample.user/Test/photo#100"/> + <link rel="self" type="application/atom+xml" href="http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/100/commentid/5"/> + <author> + <name>sample</name> + <uri>http://picasaweb.google.com/sample.user</uri> + <gphoto:user>sample.user</gphoto:user> + <gphoto:nickname>sample</gphoto:nickname> + <gphoto:thumbnail>http://lh5.google.com/sample.user/AAAAuZnob5E/AAAAAAAAAAA/EtCbNCdLGxM/s48-c/sample.user</gphoto:thumbnail> + </author> + <gphoto:id>5</gphoto:id> + <gphoto:photoid>100</gphoto:photoid> + </entry> +</feed> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<entry xmlns="http://www.w3.org/2005/Atom" xmlns:gphoto="http://schemas.google.com/photos/2007"> + <id>http://picasaweb.google.com/data/entry/api/user/sample.user/tag/tag</id> + <updated>1970-01-01T00:01:01.000Z</updated> + <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/photos/2007#tag"/> + <title type="text">tag</title> + <summary type="text">tag</summary> + <link rel="alternate" type="text/html" href="http://picasaweb.google.com/lh/searchbrowse?q=tag&psc=G&uname=sample.user&filter=0"/> + <link rel="self" type="application/atom+xml" href="http://picasaweb.google.com/data/entry/api/user/sample.user/tag/tag"/> + <author> + <name>sample</name> + <uri>http://picasaweb.google.com/sample.user</uri> + </author> +</entry> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<entry xmlns="http://www.w3.org/2005/Atom" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:gml="http://www.opengis.net/gml" xmlns:georss="http://www.georss.org/georss" xmlns:photo="http://www.pheed.com/pheed/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:batch="http://schemas.google.com/gdata/batch" xmlns:gphoto="http://schemas.google.com/photos/2007"> + <id>http://picasaweb.google.com/data/entry/api/user/sample.user</id> + <published>2007-09-24T23:45:49.059Z</published> + <updated>2007-09-24T23:45:49.059Z</updated> + <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/photos/2007#user"/> + <title type="text">sample.user</title> + <summary type="text"/> + <link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://picasaweb.google.com/data/feed/api/user/sample.user"/> + <link rel="alternate" type="text/html" href="http://picasaweb.google.com/sample.user"/> + <link rel="self" type="application/atom+xml" href="http://picasaweb.google.com/data/entry/api/user/sample.user"/> + <author> + <name>sample</name> + <uri>http://picasaweb.google.com/sample.user</uri> + </author> + <gphoto:user>sample.user</gphoto:user> + <gphoto:nickname>sample</gphoto:nickname> + <gphoto:thumbnail>http://lh5.google.com/sample.user/AAAAuZnob5E/AAAAAAAAAAA/EtCbNCdLGxM/s64-c/sample.user</gphoto:thumbnail> +</entry> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:gml="http://www.opengis.net/gml" xmlns:georss="http://www.georss.org/georss" xmlns:photo="http://www.pheed.com/pheed/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:batch="http://schemas.google.com/gdata/batch" xmlns:gphoto="http://schemas.google.com/photos/2007"> + <id>http://picasaweb.google.com/data/feed/api/user/sample.user</id> + <updated>2007-09-20T21:09:39.111Z</updated> + <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/photos/2007#user"/> + <title type="text">sample.user</title> + <subtitle type="text"/> + <icon>http://lh5.google.com/sample.user/AAAAuZnob5E/AAAAAAAAAAA/EtCbNCdLGxM/s64-c/sample.user</icon> + <link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://picasaweb.google.com/data/feed/api/user/sample.user"/> + <link rel="alternate" type="text/html" href="http://picasaweb.google.com/sample.user"/> + <link rel="http://schemas.google.com/photos/2007#slideshow" type="application/x-shockwave-flash" href="http://picasaweb.google.com/s/c/bin/slideshow.swf?host=picasaweb.google.com&RGB=0x000000&feed=http%3A%2F%2Fpicasaweb.google.com%2Fdata%2Ffeed%2Fapi%2Fuser%2Fsample.user%3Falt%3Drss"/> + <link rel="self" type="application/atom+xml" href="http://picasaweb.google.com/data/feed/api/user/sample.user?start-index=1&max-results=100&kind=album%2Cphoto%2Ctag"/> + <author> + <name>sample</name> + <uri>http://picasaweb.google.com/sample.user</uri> + </author> + <generator version="1.00" uri="http://picasaweb.google.com/">Picasaweb</generator> + <openSearch:totalResults>4</openSearch:totalResults> + <openSearch:startIndex>1</openSearch:startIndex> + <openSearch:itemsPerPage>100</openSearch:itemsPerPage> + <gphoto:user>sample.user</gphoto:user> + <gphoto:nickname>sample</gphoto:nickname> + <gphoto:thumbnail>http://lh5.google.com/sample.user/AAAAuZnob5E/AAAAAAAAAAA/EtCbNCdLGxM/s64-c/sample.user</gphoto:thumbnail> + <entry> + <id>http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/100</id> + <published>2007-09-05T07:00:00.000Z</published> + <updated>2007-09-05T20:49:24.000Z</updated> + <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/photos/2007#album"/> + <title type="text">Test</title> + <summary type="text"/> + <rights type="text">public</rights> + <link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/100"/> + <link rel="alternate" type="text/html" href="http://picasaweb.google.com/sample.user/Test"/> + <link rel="self" type="application/atom+xml" href="http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/100"/> + <author> + <name>sample</name> + <uri>http://picasaweb.google.com/sample.user</uri> + </author> + <gphoto:id>100</gphoto:id> + <gphoto:name>Test</gphoto:name> + <gphoto:location/> + <gphoto:access>public</gphoto:access> + <gphoto:timestamp>1188975600000</gphoto:timestamp> + <gphoto:numphotos>2</gphoto:numphotos> + <gphoto:user>sample.user</gphoto:user> + <gphoto:nickname>sample</gphoto:nickname> + <gphoto:commentingEnabled>true</gphoto:commentingEnabled> + <gphoto:commentCount>0</gphoto:commentCount> + <media:group> + <media:title type="plain">Test</media:title> + <media:description type="plain"/> + <media:keywords/> + <media:content url="http://lh6.google.com/sample.user/Rt8WNoDZEJE/AAAAAAAAABk/HQGlDhpIgWo/Test.jpg" type="image/jpeg" medium="image"/> + <media:thumbnail url="http://lh6.google.com/sample.user/Rt8WNoDZEJE/AAAAAAAAABk/HQGlDhpIgWo/s160-c/Test.jpg" height="160" width="160"/> + <media:credit>sample</media:credit> + </media:group> + </entry> + <entry> + <id>http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/100/photoid/2</id> + <published>2007-09-05T20:49:24.000Z</published> + <updated>2007-09-05T20:49:23.000Z</updated> + <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/photos/2007#photo"/> + <title type="text">Second.jpg</title> + <summary type="text"/> + <content type="image/jpeg" src="http://lh5.google.com/sample.user/Rt8WVIDZELI/AAAAAAAAABg/d7e0i7gvhNU/Aqua%20Graphite.jpg"/> + <link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/100/photoid/2"/> + <link rel="alternate" type="text/html" href="http://picasaweb.google.com/sample.user/Test/photo#2"/> + <link rel="self" type="application/atom+xml" href="http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/100/photoid/2"/> + <gphoto:id>2</gphoto:id> + <gphoto:version>1189025363424891</gphoto:version> + <gphoto:albumid>100</gphoto:albumid> + <gphoto:width>2560</gphoto:width> + <gphoto:height>1600</gphoto:height> + <gphoto:size>798334</gphoto:size> + <gphoto:client/> + <gphoto:checksum/> + <gphoto:timestamp>1189025363000</gphoto:timestamp> + <exif:tags xmlns:exif="http://schemas.google.com/photos/exif/2007"> + <exif:flash>true</exif:flash> + <exif:imageUniqueID>a5ce2e36b9df7d3cb081511c72e73926</exif:imageUniqueID> + </exif:tags> + <gphoto:commentingEnabled>true</gphoto:commentingEnabled> + <gphoto:commentCount>0</gphoto:commentCount> + <media:group> + <media:title type="plain">Second.jpg</media:title> + <media:description type="plain"/> + <media:keywords/> + <media:content url="http://lh5.google.com/sample.user/Rt8WVIDZELI/AAAAAAAAABg/d7e0i7gvhNU/Aqua%20Graphite.jpg" height="1600" width="2560" type="image/jpeg" medium="image"/> + <media:thumbnail url="http://lh5.google.com/sample.user/Rt8WVIDZELI/AAAAAAAAABg/d7e0i7gvhNU/s72/Aqua%20Graphite.jpg" height="45" width="72"/> + <media:thumbnail url="http://lh5.google.com/sample.user/Rt8WVIDZELI/AAAAAAAAABg/d7e0i7gvhNU/s144/Aqua%20Graphite.jpg" height="90" width="144"/> + <media:thumbnail url="http://lh5.google.com/sample.user/Rt8WVIDZELI/AAAAAAAAABg/d7e0i7gvhNU/s288/Aqua%20Graphite.jpg" height="180" width="288"/> + <media:credit>sample</media:credit> + </media:group> + </entry> + <entry> + <id>http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/100/photoid/1</id> + <published>2007-09-05T20:49:23.000Z</published> + <updated>2007-09-05T20:49:22.000Z</updated> + <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/photos/2007#photo"/> + <title type="text">First.jpg</title> + <summary type="text"/> + <content type="image/jpeg" src="http://lh4.google.com/sample.user/Rt8WU4DZEKI/AAAAAAAAABY/IVgLqmnzJII/Aqua%20Blue.jpg"/> + <link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/100/photoid/1"/> + <link rel="alternate" type="text/html" href="http://picasaweb.google.com/sample.user/Test/photo#1"/> + <link rel="self" type="application/atom+xml" href="http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/100/photoid/1"/> + <gphoto:id>1</gphoto:id> + <gphoto:version>1189025362423722</gphoto:version> + <gphoto:albumid>100</gphoto:albumid> + <gphoto:width>2560</gphoto:width> + <gphoto:height>1600</gphoto:height> + <gphoto:size>883405</gphoto:size> + <gphoto:client/> + <gphoto:checksum/> + <gphoto:timestamp>1189025362000</gphoto:timestamp> + <exif:tags xmlns:exif="http://schemas.google.com/photos/exif/2007"> + <exif:flash>true</exif:flash> + <exif:imageUniqueID>c041ce17aaa637eb656c81d9cf526c24</exif:imageUniqueID> + </exif:tags> + <gphoto:commentingEnabled>true</gphoto:commentingEnabled> + <gphoto:commentCount>0</gphoto:commentCount> + <media:group> + <media:title type="plain">First.jpg</media:title> + <media:description type="plain"/> + <media:keywords/> + <media:content url="http://lh4.google.com/sample.user/Rt8WU4DZEKI/AAAAAAAAABY/IVgLqmnzJII/Aqua%20Blue.jpg" height="1600" width="2560" type="image/jpeg" medium="image"/> + <media:thumbnail url="http://lh4.google.com/sample.user/Rt8WU4DZEKI/AAAAAAAAABY/IVgLqmnzJII/s72/Aqua%20Blue.jpg" height="45" width="72"/> + <media:thumbnail url="http://lh4.google.com/sample.user/Rt8WU4DZEKI/AAAAAAAAABY/IVgLqmnzJII/s144/Aqua%20Blue.jpg" height="90" width="144"/> + <media:thumbnail url="http://lh4.google.com/sample.user/Rt8WU4DZEKI/AAAAAAAAABY/IVgLqmnzJII/s288/Aqua%20Blue.jpg" height="180" width="288"/> + <media:credit>sample</media:credit> + </media:group> + </entry> +</feed> diff --git a/zend/tests/Zend/Gdata/Photos/_files/test.jpg b/zend/tests/Zend/Gdata/Photos/_files/test.jpg Binary files differnew file mode 100755 index 0000000..d4a5a10 --- /dev/null +++ b/zend/tests/Zend/Gdata/Photos/_files/test.jpg 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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Photos + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Photos.php'; +require_once 'Zend/Http/Client.php'; +require_once 'Zend/Http/Client/Adapter/Test.php'; +require_once 'Zend/Gdata/ClientLogin.php'; +require_once 'Zend/Gdata/App/InvalidArgumentException.php'; + +/** + * @category Zend + * @package Zend_Gdata_Photos + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Photos + */ +class Zend_Gdata_PhotosOnlineTest extends PHPUnit_Framework_TestCase +{ + + protected $photos = null; + + public function setUp() + { + $user = constant('TESTS_ZEND_GDATA_CLIENTLOGIN_EMAIL'); + $pass = constant('TESTS_ZEND_GDATA_CLIENTLOGIN_PASSWORD'); + $service = 'lh2'; + $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service); + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Http/Client.php'; +require_once 'Zend/Gdata/Query.php'; + +/** + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + */ +class Zend_Gdata_QueryTest extends PHPUnit_Framework_TestCase +{ + public function setUp() + { + } + + public function testSetAndGetAlt() + { + $query = new Zend_Gdata_Query(); + $query->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Extension/RecurrenceException.php'; +require_once 'Zend/Gdata.php'; + +/** + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + */ +class Zend_Gdata_RecurrenceExceptionTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Extension/Recurrence.php'; +require_once 'Zend/Gdata.php'; + +/** + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + */ +class Zend_Gdata_RecurrenceTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Extension/Reminder.php'; +require_once 'Zend/Gdata.php'; + +/** + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + */ +class Zend_Gdata_ReminderTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +/** + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + */ +class Zend_Gdata_SkipOnlineTest extends PHPUnit_Framework_TestCase +{ + public function setUp() + { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Spreadsheets + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Spreadsheets.php'; +require_once 'Zend/Http/Client.php'; + +/** + * @category Zend + * @package Zend_Gdata_Spreadsheets + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Spreadsheets + */ +class Zend_Gdata_Spreadsheets_CellEntryTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() + { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Spreadsheets + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Spreadsheets.php'; +require_once 'Zend/Http/Client.php'; + +/** + * @category Zend + * @package Zend_Gdata_Spreadsheets + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Spreadsheets + */ +class Zend_Gdata_Spreadsheets_CellFeedTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() + { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Spreadsheets + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Spreadsheets.php'; +require_once 'Zend/Http/Client.php'; + +/** + * @category Zend + * @package Zend_Gdata_Spreadsheets + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Spreadsheets + */ +class Zend_Gdata_Spreadsheets_CellQueryTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() + { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Spreadsheets + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Spreadsheets.php'; +require_once 'Zend/Http/Client.php'; + +/** + * @category Zend + * @package Zend_Gdata_Spreadsheets + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Spreadsheets + */ +class Zend_Gdata_Spreadsheets_CellTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() + { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Spreadsheets + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Spreadsheets.php'; +require_once 'Zend/Http/Client.php'; + +/** + * @category Zend + * @package Zend_Gdata_Spreadsheets + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Spreadsheets + */ +class Zend_Gdata_Spreadsheets_ColCountTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() + { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Spreadsheets + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Spreadsheets.php'; +require_once 'Zend/Http/Client.php'; + +/** + * @category Zend + * @package Zend_Gdata_Spreadsheets + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Spreadsheets + */ +class Zend_Gdata_Spreadsheets_CustomTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() + { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Spreadsheets + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Spreadsheets.php'; +require_once 'Zend/Http/Client.php'; + +/** + * @category Zend + * @package Zend_Gdata_Spreadsheets + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Spreadsheets + */ +class Zend_Gdata_Spreadsheets_DocumentQueryTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() + { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Spreadsheets + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Spreadsheets.php'; +require_once 'Zend/Http/Client.php'; + +/** + * @category Zend + * @package Zend_Gdata_Spreadsheets + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Spreadsheets + */ +class Zend_Gdata_Spreadsheets_ListEntryTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() + { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Spreadsheets + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Spreadsheets.php'; +require_once 'Zend/Http/Client.php'; + +/** + * @category Zend + * @package Zend_Gdata_Spreadsheets + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Spreadsheets + */ +class Zend_Gdata_Spreadsheets_ListFeedTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() + { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Spreadsheets + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Spreadsheets.php'; +require_once 'Zend/Http/Client.php'; + +/** + * @category Zend + * @package Zend_Gdata_Spreadsheets + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Spreadsheets + */ +class Zend_Gdata_Spreadsheets_ListQueryTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() + { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Spreadsheets + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Spreadsheets.php'; +require_once 'Zend/Http/Client.php'; + +/** + * @category Zend + * @package Zend_Gdata_Spreadsheets + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Spreadsheets + */ +class Zend_Gdata_Spreadsheets_RowCountTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() + { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Spreadsheets + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Spreadsheets.php'; +require_once 'Zend/Http/Client.php'; + +/** + * @category Zend + * @package Zend_Gdata_Spreadsheets + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Spreadsheets + */ +class Zend_Gdata_Spreadsheets_SpreadsheetFeedTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() + { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Spreadsheets + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Spreadsheets.php'; +require_once 'Zend/Http/Client.php'; + +/** + * @category Zend + * @package Zend_Gdata_Spreadsheets + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Spreadsheets + */ +class Zend_Gdata_Spreadsheets_WorksheetEntryTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() + { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Spreadsheets + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Spreadsheets.php'; +require_once 'Zend/Http/Client.php'; + +/** + * @category Zend + * @package Zend_Gdata_Spreadsheets + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Spreadsheets + */ +class Zend_Gdata_Spreadsheets_WorksheetFeedTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() + { + $this->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 @@ +<feed xmlns="http://www.w3.org/2005/Atom"
+ xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/"
+ xmlns:gs="http://schemas.google.com/spreadsheets/2006">
+ <id>http://spreadsheets.google.com/feeds/cells/key/od6/private/full</id>
+ <updated>2006-11-17T18:27:32.543Z</updated>
+ <title type="text">Sheet1</title>
+ <link rel="alternate" type="text/html"
+ href="http://spreadsheets.google.com/ccc?key=key"/>
+ <link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml"
+ href="http://spreadsheets.google.com/feeds/cells/key/od6/private/full"/>
+ <link rel="http://schemas.google.com/g/2005#post" type="application/atom+xml"
+ href="http://spreadsheets.google.com/feeds/cells/key/od6/private/full"/>
+ <link rel="self" type="application/atom+xml"
+ href="http://spreadsheets.google.com/feeds/cells/key/od6/private/full"/>
+ <author>
+ <name>Fitzwilliam Darcy</name>
+ <email>fitz@gmail.com</email>
+ </author>
+ <openSearch:startIndex>1</openSearch:startIndex>
+ <openSearch:itemsPerPage>1</openSearch:itemsPerPage>
+ <gs:rowCount>100</gs:rowCount>
+ <gs:colCount>20</gs:colCount>
+ <entry>
+ <id>http://spreadsheets.google.com/feeds/cells/key/od6/private/full/R1C1</id>
+ <updated>2006-11-17T18:27:32.543Z</updated>
+ <category scheme="http://schemas.google.com/spreadsheets/2006"
+ term="http://schemas.google.com/spreadsheets/2006#cell"/>
+ <title type="text">A1</title>
+ <content type="text">Name</content>
+ <link rel="self" type="application/atom+xml"
+ href="http://spreadsheets.google.com/feeds/cells/key/od6/private/full/R1C1"/>
+ <link rel="edit" type="application/atom+xml"
+ href="http://spreadsheets.google.com/feeds/cells/key/od6/private/full/R1C1/bgvjf"/>
+ <gs:cell row="1" col="1" inputValue="Name">Name</gs:cell>
+ </entry>
+ <entry>
+ <id>http://spreadsheets.google.com/feeds/cells/key/od6/private/full/R1C2</id>
+ <updated>2006-11-17T18:27:32.543Z</updated>
+ <category scheme="http://schemas.google.com/spreadsheets/2006"
+ term="http://schemas.google.com/spreadsheets/2006#cell"/>
+ <title type="text">B1</title>
+ <content type="text">Hours</content>
+ <link rel="self" type="application/atom+xml"
+ href="http://spreadsheets.google.com/feeds/cells/key/od6/private/full/R1C2"/>
+ <link rel="edit" type="application/atom+xml"
+ href="http://spreadsheets.google.com/feeds/cells/key/od6/private/full/R1C2/1pn567"/>
+ <gs:cell row="1" col="2" inputValue="Hours">Hours</gs:cell>
+ </entry>
+</feed>
\ 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 @@ +<feed xmlns="http://www.w3.org/2005/Atom"
+ xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/"
+ xmlns:gsx="http://schemas.google.com/spreadsheets/2006/extended">
+ <id>http://spreadsheets.google.com/feeds/list/key/od6/private/full</id>
+ <updated>2006-11-17T18:23:45.173Z</updated>
+ <title type="text">Sheet1</title>
+ <link rel="alternate" type="text/html"
+ href="http://spreadsheets.google.com/ccc?key=key"/>
+ <link rel="http://schemas.google.com/g/2005#feed"
+ type="application/atom+xml"
+ href="http://spreadsheets.google.com/feeds/list/key/od6/private/full"/>
+ <link rel="http://schemas.google.com/g/2005#post"
+ type="application/atom+xml"
+ href="http://spreadsheets.google.com/feeds/list/key/od6/private/full"/>
+ <link rel="self" type="application/atom+xml"
+ href="http://spreadsheets.google.com/feeds/list/key/od6/private/full"/>
+ <author>
+ <name>Fitzwilliam Darcy</name>
+ <email>fitz@gmail.com</email>
+ </author>
+ <openSearch:totalResults>2</openSearch:totalResults>
+ <openSearch:startIndex>1</openSearch:startIndex>
+ <openSearch:itemsPerPage>2</openSearch:itemsPerPage>
+ <entry>
+ <id>http://spreadsheets.google.com/feeds/list/key/od6/private/full/cokwr</id>
+ <updated>2006-11-17T18:23:45.173Z</updated>
+ <category scheme="http://schemas.google.com/spreadsheets/2006"
+ term="http://schemas.google.com/spreadsheets/2006#list"/>
+ <title type="text">Bingley</title>
+ <content type="text">Hours: 10, Items: 2, IPM: 0.0033</content>
+ <link rel="self" type="application/atom+xml"
+ href="http://spreadsheets.google.com/feeds/list/key/od6/private/full/cokwr"/>
+ <link rel="edit" type="application/atom+xml"
+ href="http://spreadsheets.google.com/feeds/list/key/od6/private/full/cokwr/2ehkc2oh7d"/>
+ <gsx:name>Bingley</gsx:name>
+ <gsx:hours>10</gsx:hours>
+ <gsx:items>2</gsx:items>
+ <gsx:ipm>0.0033</gsx:ipm>
+ </entry>
+ <entry>
+ <id>http://spreadsheets.google.com/feeds/list/key/od6/private/full/cyevm</id>
+ <updated>2006-11-17T18:23:45.173Z</updated>
+ <category scheme="http://schemas.google.com/spreadsheets/2006"
+ term="http://schemas.google.com/spreadsheets/2006#list"/>
+ <title type="text">Charlotte</title>
+ <content type="text">Hours: 60, Items: 18000, IPM: 5</content>
+ <link rel="self" type="application/atom+xml"
+ href="http://spreadsheets.google.com/feeds/list/key/od6/private/full/cyevm"/>
+ <link rel="edit" type="application/atom+xml"
+ href="http://spreadsheets.google.com/feeds/list/key/od6/private/full/cyevm/64rl27px3zyn"/>
+ <gsx:name>Charlotte</gsx:name>
+ <gsx:hours>60</gsx:hours>
+ <gsx:items>18000</gsx:items>
+ <gsx:ipm>5</gsx:ipm>
+ </entry>
+</feed>
\ 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 @@ +<feed xmlns="http://www.w3.org/2005/Atom"
+ xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/"
+ xmlns:gs="http://schemas.google.com/spreadsheets/2006">
+ <id>http://spreadsheets.google.com/feeds/spreadsheets/private/full</id>
+ <updated>2006-11-17T18:23:45.173Z</updated>
+ <title type="text">Available Spreadsheets</title>
+ <link rel="alternate" type="text/html"
+ href="http://spreadsheets.google.com/ccc?key=key"/>
+ <link rel="http://schemas.google.com/g/2005#feed"
+ type="application/atom+xml"
+ href="http://spreadsheets.google.com/feeds/worksheets/key/private/full"/>
+ <link rel="self" type="application/atom+xml"
+ href="http://spreadsheets.google.com/feeds/worksheets/key/private/full"/>
+ <author>
+ <name>Fitzwilliam Darcy</name>
+ <email>fitz@gmail.com</email>
+ </author>
+ <openSearch:totalResults>1</openSearch:totalResults>
+ <openSearch:startIndex>1</openSearch:startIndex>
+ <openSearch:itemsPerPage>1</openSearch:itemsPerPage>
+ <entry>
+ <id>http://spreadsheets.google.com/feeds/spreadsheets/private/full/key</id>
+ <updated>2006-11-17T18:24:18.231Z</updated>
+ <title type="text">Groceries R Us</title>
+ <content type="text">Groceries R Us</content>
+ <link rel="http://schemas.google.com/spreadsheets/2006#worksheetsfeed"
+ type="application/atom+xml"
+ href="http://spreadsheets.google.com/feeds/worksheets/key/private/full"/>
+ <link rel="alternate" type="text/html"
+ href="http://spreadsheets.google.com/ccc?key=key"/>
+ <link rel="self" type="application/atom+xml"
+ href="http://spreadsheets.google.com/feeds/spreadsheets/private/full/key"/>
+ <author>
+ <name>Fitzwilliam Darcy</name>
+ <email>fitz@gmail.com</email>
+ </author>
+ </entry>
+</feed>
\ 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 @@ +<feed xmlns="http://www.w3.org/2005/Atom"
+ xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/"
+ xmlns:gs="http://schemas.google.com/spreadsheets/2006">
+ <id>http://spreadsheets.google.com/feeds/worksheets/key/private/full</id>
+ <updated>2006-11-17T18:23:45.173Z</updated>
+ <title type="text">Groceries R Us</title>
+ <link rel="alternate" type="text/html"
+ href="http://spreadsheets.google.com/ccc?key=key"/>
+ <link rel="http://schemas.google.com/g/2005#feed"
+ type="application/atom+xml"
+ href="http://spreadsheets.google.com/feeds/worksheets/key/private/full"/>
+ <link rel="self" type="application/atom+xml"
+ href="http://spreadsheets.google.com/feeds/worksheets/key/private/full"/>
+ <author>
+ <name>Fitzwilliam Darcy</name>
+ <email>fitz@gmail.com</email>
+ </author>
+ <openSearch:totalResults>1</openSearch:totalResults>
+ <openSearch:startIndex>1</openSearch:startIndex>
+ <openSearch:itemsPerPage>1</openSearch:itemsPerPage>
+ <entry>
+ <id>http://spreadsheets.google.com/feeds/worksheets/key/private/full/od6</id>
+ <updated>2006-11-17T18:23:45.173Z</updated>
+ <title type="text">Sheet1</title>
+ <content type="text">Sheet1</content>
+ <link rel="http://schemas.google.com/spreadsheets/2006#listfeed"
+ type="application/atom+xml"
+ href="http://spreadsheets.google.com/feeds/list/key/od6/private/full"/>
+ <link rel="http://schemas.google.com/spreadsheets/2006#cellsfeed"
+ type="application/atom+xml"
+ href="http://spreadsheets.google.com/feeds/cells/key/od6/private/full"/>
+ <link rel="self" type="application/atom+xml"
+ href="http://spreadsheets.google.com/feeds/worksheets/key/private/full/od6"/>
+ <gs:rowCount>100</gs:rowCount>
+ <gs:colCount>20</gs:colCount>
+ </entry>
+</feed>
\ 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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Spreadsheets + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Spreadsheets.php'; +require_once 'Zend/Http/Client.php'; +require_once 'Zend/Gdata/ClientLogin.php'; + +/** + * @category Zend + * @package Zend_Gdata_Spreadsheets + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Spreadsheets + */ +class Zend_Gdata_SpreadsheetsOnlineTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() + { + $user = constant('TESTS_ZEND_GDATA_CLIENTLOGIN_EMAIL'); + $pass = constant('TESTS_ZEND_GDATA_CLIENTLOGIN_PASSWORD'); + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_Spreadsheets + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Spreadsheets.php'; +require_once 'Zend/Http/Client.php'; + +/** + * @category Zend + * @package Zend_Gdata_Spreadsheets + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_Spreadsheets + */ +class Zend_Gdata_SpreadsheetsTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() + { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id: MockHttpClient.php 24593 2012-01-05 20:35:02Z matthew $ + */ + +require_once 'Zend/Http/Client/Adapter/Test.php'; + +/** + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + */ +class Test_Zend_Gdata_MockHttpClient_Request +{ + public $methd; + public $uri; + public $http_ver; + public $headers; + public $body; +} + +/** + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + */ +class Test_Zend_Gdata_MockHttpClient extends Zend_Http_Client_Adapter_Test +{ + protected $_requests; + + public function __construct() + { + parent::__construct(); + $this->_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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Extension/Transparency.php'; +require_once 'Zend/Gdata.php'; + +/** + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + */ +class Zend_Gdata_TransparencyTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Extension/Visibility.php'; +require_once 'Zend/Gdata.php'; + +/** + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + */ +class Zend_Gdata_VisibilityTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Extension/When.php'; +require_once 'Zend/Gdata.php'; + +/** + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + */ +class Zend_Gdata_WhenTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Extension/Where.php'; +require_once 'Zend/Gdata.php'; + +/** + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + */ +class Zend_Gdata_WhereTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/Extension/Who.php'; +require_once 'Zend/Gdata.php'; + +/** + * @category Zend + * @package Zend_Gdata + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + */ +class Zend_Gdata_WhoTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_YouTube + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/YouTube/ActivityEntry.php'; +require_once 'Zend/Gdata/YouTube.php'; + +/** + * @category Zend + * @package Zend_Gdata_YouTube + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_YouTube + */ +class Zend_Gdata_YouTube_ActivityEntryTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_YouTube + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/YouTube/ActivityFeed.php'; +require_once 'Zend/Gdata/YouTube.php'; + +/** + * @category Zend + * @package Zend_Gdata_YouTube + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_YouTube + */ +class Zend_Gdata_YouTube_ActivityFeedTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_YouTube + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/YouTube/CommentEntry.php'; +require_once 'Zend/Gdata/YouTube.php'; + +/** + * @category Zend + * @package Zend_Gdata_YouTube + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_YouTube + */ +class Zend_Gdata_YouTube_CommentEntryTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_YouTube + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/YouTube/CommentFeed.php'; +require_once 'Zend/Gdata/YouTube.php'; + +/** + * @category Zend + * @package Zend_Gdata_YouTube + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_YouTube + */ +class Zend_Gdata_YouTube_CommentFeedTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_YouTube + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/YouTube/ContactEntry.php'; +require_once 'Zend/Gdata/YouTube.php'; + +/** + * @category Zend + * @package Zend_Gdata_YouTube + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_YouTube + */ +class Zend_Gdata_YouTube_ContactEntryTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_YouTube + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/YouTube/ContactFeed.php'; +require_once 'Zend/Gdata/YouTube.php'; + +/** + * @category Zend + * @package Zend_Gdata_YouTube + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_YouTube + */ +class Zend_Gdata_YouTube_ContactFeedTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_YouTube + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/YouTube/InboxEntry.php'; +require_once 'Zend/Gdata/YouTube.php'; + +/** + * @category Zend + * @package Zend_Gdata_YouTube + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_YouTube + */ +class Zend_Gdata_YouTube_InboxEntryTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_YouTube + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/YouTube/InboxFeed.php'; +require_once 'Zend/Gdata/YouTube.php'; + +/** + * @category Zend + * @package Zend_Gdata_YouTube + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_YouTube + */ +class Zend_Gdata_YouTube_InboxFeedTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_YouTube + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/YouTube/PlaylistListEntry.php'; +require_once 'Zend/Gdata/YouTube.php'; + +/** + * @category Zend + * @package Zend_Gdata_YouTube + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_YouTube + */ +class Zend_Gdata_YouTube_PlaylistListEntryTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_YouTube + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/YouTube/PlaylistListFeed.php'; +require_once 'Zend/Gdata/YouTube.php'; + +/** + * @category Zend + * @package Zend_Gdata_YouTube + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_YouTube + */ +class Zend_Gdata_YouTube_PlaylistListFeedTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_YouTube + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/YouTube/PlaylistVideoEntry.php'; +require_once 'Zend/Gdata/YouTube.php'; + +/** + * @category Zend + * @package Zend_Gdata_YouTube + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_YouTube + */ +class Zend_Gdata_YouTube_PlaylistVideoEntryTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_YouTube + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/YouTube/PlaylistVideoFeed.php'; +require_once 'Zend/Gdata/YouTube.php'; + +/** + * @category Zend + * @package Zend_Gdata_YouTube + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_YouTube + */ +class Zend_Gdata_YouTube_PlaylistVideoFeedTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_YouTube + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/YouTube/SubscriptionEntry.php'; +require_once 'Zend/Gdata/YouTube.php'; + +/** + * @category Zend + * @package Zend_Gdata_YouTube + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_YouTube + */ +class Zend_Gdata_YouTube_SubscriptionEntryTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_YouTube + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/YouTube/SubscriptionFeed.php'; +require_once 'Zend/Gdata/YouTube.php'; + +/** + * @category Zend + * @package Zend_Gdata_YouTube + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_YouTube + */ +class Zend_Gdata_YouTube_SubscriptionFeedTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_YouTube + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/YouTube/UserProfileEntry.php'; +require_once 'Zend/Gdata/YouTube.php'; + +/** + * @category Zend + * @package Zend_Gdata_YouTube + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_YouTube + */ +class Zend_Gdata_YouTube_UserProfileEntryTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_YouTube + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id: VideoEntryTest.php 24593 2012-01-05 20:35:02Z matthew $ + */ + +require_once 'Zend/Gdata/YouTube/VideoEntry.php'; +require_once 'Zend/Gdata/YouTube/Extension/State.php'; +require_once 'Zend/Gdata/YouTube.php'; + +/** + * @category Zend + * @package Zend_Gdata_YouTube + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_YouTube + */ +class Zend_Gdata_YouTube_VideoEntryTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_YouTube + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/YouTube/VideoFeed.php'; +require_once 'Zend/Gdata/YouTube.php'; + +/** + * @category Zend + * @package Zend_Gdata_YouTube + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_YouTube + */ +class Zend_Gdata_YouTube_VideoFeedTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_YouTube + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/YouTube/VideoQuery.php'; +require_once 'Zend/Gdata/YouTube.php'; + +/** + * @category Zend + * @package Zend_Gdata_YouTube + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_YouTube + */ +class Zend_Gdata_YouTube_VideoQueryTest extends PHPUnit_Framework_TestCase +{ + + public function testQueryStringConstruction() + { + $yt = new Zend_Gdata_YouTube(); + $query = $yt->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 @@ +<?xml version='1.0' encoding='UTF-8'?> +<entry xmlns='http://www.w3.org/2005/Atom' xmlns:yt='http://gdata.youtube.com/schemas/2007' xmlns:gd='http://schemas.google.com/g/2005' gd:etag='W/"D0EGSH47eCp7ImA9WxRQQEg."'> + <id>tag:youtube.com,2008:event:Z2RweXRob24xMTIzNDMwMDAyMzI5NTQ2Nzg2MA%3D%3D</id> + <updated>2009-01-16T09:13:49.000-08:00</updated> + <category scheme='http://gdata.youtube.com/schemas/2007/userevents.cat' + term='video_favorited'/> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#userEvent'/> + <title>tayzonzay has favorited a video</title> + <link rel='alternate' type='text/html' href='http://www.youtube.com'/> + <link rel='http://gdata.youtube.com/schemas/2007#video' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/api/videos/z3U0kuLH974?v=2'/> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/api/events/VGF5Wm9uZGF5MzEyaIl2MTMxOTcxMDk3NzQ5MzM%3D?v=2'/> + <author> + <name>tayzonzay</name> + <uri>http://gdata.youtube.com/feeds/api/users/tayzonzay</uri> + </author> + <yt:videoid>z3U0kuLH974</yt:videoid> + <yt:username>foo</yt:username> + <gd:rating min='1' max='5' value='2' /> +</entry>
\ 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 @@ +<?xml version='1.0' encoding='UTF-8'?> +<feed xmlns='http://www.w3.org/2005/Atom' + xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/' + xmlns:gml='http://www.opengis.net/gml' + xmlns:georss='http://www.georss.org/georss' + xmlns:media='http://search.yahoo.com/mrss/' + xmlns:batch='http://schemas.google.com/gdata/batch' + xmlns:yt='http://gdata.youtube.com/schemas/2007' + xmlns:gd='http://schemas.google.com/g/2005' + gd:etag='W/"D0EGSH47eCp7ImA9WxRVGEg."'> + <updated>2009-01-28T09:13:49.000-08:00</updated> +<link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/events?v=2'/><link rel='http://schemas.google.com/g/2005#batch' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/events/batch?v=2'/><link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/events?author=gdpython&start-index=1&max-results=25&v=2'/><link rel='service' type='application/atomsvc+xml' href='http://gdata.youtube.com/feeds/api/events?alt=atom-service&v=2'/> + + + + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#userEvent'/> + <title>Activity of tayzonzay</title> + <logo>http://www.youtube.com/img/pic_youtubelogo_123x63.gif</logo> + <author> + <name>YouTube</name> + <uri>http://www.youtube.com/</uri> + </author> + <generator version='2.0' uri='http://gdata.youtube.com/'>YouTube data API</generator> + <openSearch:totalResults>12</openSearch:totalResults> + <openSearch:startIndex>1</openSearch:startIndex> + <openSearch:itemsPerPage>25</openSearch:itemsPerPage> + <entry gd:etag='W/"D0EGSH47eCp7ImA9WxRQQEg."'> + <updated>2009-01-16T09:13:49.000-08:00</updated> + <category scheme='http://gdata.youtube.com/schemas/2007/userevents.cat' + term='video_favorited'/> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#userEvent'/> + <title>tayzonzay has favorited a video</title> + <link rel='alternate' type='text/html' href='http://www.youtube.com'/> + <link rel='http://gdata.youtube.com/schemas/2007#video' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/api/videos/z3U0kuLH974?v=2'/> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/api/events/VGF5Wm9uZGF5MzEyaIl2MTMxOTcxMDk3NzQ5MzM%3D?v=2'/> + <author> + <name>tayzonzay</name> + <uri>http://gdata.youtube.com/feeds/api/users/tayzonzay</uri> + </author> + <yt:videoid>z3U0kuLH974</yt:videoid> + </entry> +</feed>
\ 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 @@ +<?xml version='1.0' encoding='utf-8'?> +<entry xmlns='http://www.w3.org/2005/Atom'> + <id>http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments/CE0314DEBFFC9052</id> + <published>2007-09-02T18:00:04.000-07:00</published> + <updated>2007-09-02T18:00:04.000-07:00</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#comment' /> + <title type='text'>how to turn ...</title> + <content type='text'>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?</content> + <link rel='related' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg' /> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/watch?v=Lnio-pqLPgg' /> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments/CE0314DEBFFC9052' /> + <author> + <name>reneemathome</name> + <uri>http://gdata.youtube.com/feeds/users/reneemathome</uri> + </author> +</entry> 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 @@ +<?xml version='1.0' encoding='utf-8'?> +<feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'> + <id>http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments</id> + <updated>2007-09-21T02:32:55.032Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#comment' /> + <title type='text'>Comments on '"That Girl" - Original Song - Acoustic Version'</title> + <logo> http://www.youtube.com/img/pic_youtubelogo_123x63.gif</logo> + <link rel='related' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg' /> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/watch?v=Lnio-pqLPgg' /> + <link rel='http://schemas.google.com/g/2005#feed' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments' /> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments?start-index=1&max-results=4' /> + <link rel='next' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments?start-index=6&max-results=4' /> + <author> + <name>YouTube</name> + <uri>http://www.youtube.com/</uri> + </author> + <generator version='beta' uri='http://gdata.youtube.com/'>YouTube data API</generator> + <openSearch:totalResults>100</openSearch:totalResults> + <openSearch:startIndex>1</openSearch:startIndex> + <openSearch:itemsPerPage>4</openSearch:itemsPerPage> + <entry> + <id> + http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments/CE0314DEBFFC9052</id> + <published>2007-09-02T18:00:04.000-07:00</published> + <updated>2007-09-02T18:00:04.000-07:00</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#comment' /> + <title type='text'>how to turn ...</title> + <content type='text'>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?</content> + <link rel='related' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg' /> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/watch?v=Lnio-pqLPgg' /> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments/CE0314DEBFFC9052' /> + <author> + <name>reneemathome</name> + <uri>http://gdata.youtube.com/feeds/users/reneemathome</uri> + </author> + </entry> + <entry> + <id> + http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments/405F5D8E73538763</id> + <published>2007-09-02T20:51:52.000-07:00</published> + <updated>2007-09-02T20:51:52.000-07:00</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#comment' /> + <title type='text'>The stars are ...</title> + <content type='text'>The stars are flying... Make something + with this!!!:)</content> + <link rel='related' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg' /> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/watch?v=Lnio-pqLPgg' /> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments/405F5D8E73538763' /> + <author> + <name>minoujill</name> + <uri>http://gdata.youtube.com/feeds/users/minoujill</uri> + </author> + </entry> + <entry> + <id> + http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments/DA7550644FFCF2EC</id> + <published>2007-09-02T22:22:27.000-07:00</published> + <updated>2007-09-02T22:22:27.000-07:00</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#comment' /> + <title type='text'>awesome song!</title> + <content type='text'>awesome song!</content> + <link rel='related' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg' /> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/watch?v=Lnio-pqLPgg' /> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments/DA7550644FFCF2EC' /> + <author> + <name>beeGoaTee</name> + <uri>http://gdata.youtube.com/feeds/users/beeGoaTee</uri> + </author> + </entry> + <entry> + <id> + http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments/B99ACB2520430E90</id> + <published>2007-09-03T10:46:45.000-07:00</published> + <updated>2007-09-03T10:46:45.000-07:00</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#comment' /> + <title type='text'>This is GOOD!!</title> + <content type='text'>This is GOOD!!</content> + <link rel='related' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg' /> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/watch?v=Lnio-pqLPgg' /> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments/B99ACB2520430E90' /> + <author> + <name>Grosh62</name> + <uri>http://gdata.youtube.com/feeds/users/Grosh62</uri> + </author> + </entry> +</feed> 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 @@ +<?xml version='1.0' encoding='utf-8'?> +<entry xmlns='http://www.w3.org/2005/Atom' +xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' +xmlns:yt='http://gdata.youtube.com/schemas/2007'> + <id>http://gdata.youtube.com/feeds/users/davidchoimusic/contacts/testuser</id> + <published>1970-01-14T04:17:17.804-08:00</published> + <updated>2007-09-21T02:44:41.134Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#friend' /> + <category scheme='http://gdata.youtube.com/schemas/2007/contact.cat' + term='Friends' /> + <title type='text'>testuser</title> + <link rel='related' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/users/testuser' /> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/profile?user=testuser' /> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/users/davidchoimusic/contacts/testuser' /> + <author> + <name>davidchoimusic</name> + <uri> + http://gdata.youtube.com/feeds/users/davidchoimusic</uri> + </author> + <yt:username>testuser</yt:username> + <yt:status>accepted</yt:status> +</entry> 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 @@ +<?xml version='1.0' encoding='utf-8'?> +<feed xmlns='http://www.w3.org/2005/Atom' +xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' +xmlns:yt='http://gdata.youtube.com/schemas/2007'> + <id>http://gdata.youtube.com/feeds/users/davidchoimusic/contacts</id> + <updated>2007-09-21T02:44:41.135Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#friend' /> + <title type='text'>davidchoimusic's Contacts</title> + <logo>http://www.youtube.com/img/pic_youtubelogo_123x63.gif</logo> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/profile_friends?user=davidchoimusic' /> + <link rel='http://schemas.google.com/g/2005#feed' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/users/davidchoimusic/contacts' /> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/users/davidchoimusic/contacts?start-index=1&max-results=5' /> + <link rel='next' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/users/davidchoimusic/contacts?start-index=6&max-results=5' /> + <author> + <name>davidchoimusic</name> + <uri>http://gdata.youtube.com/feeds/users/davidchoimusic</uri> + </author> + <generator version='beta' uri='http://gdata.youtube.com/'>YouTube data API</generator> + <openSearch:totalResults>1558</openSearch:totalResults> + <openSearch:startIndex>1</openSearch:startIndex> + <openSearch:itemsPerPage>5</openSearch:itemsPerPage> + <entry> + <id>http://gdata.youtube.com/feeds/users/davidchoimusic/contacts/testuser</id> + <published>1970-01-14T04:17:17.804-08:00</published> + <updated>2007-09-21T02:44:41.134Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#friend' /> + <category scheme='http://gdata.youtube.com/schemas/2007/contact.cat' + term='Friends' /> + <title type='text'>testuser</title> + <link rel='related' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/users/testuser' /> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/profile?user=testuser' /> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/users/davidchoimusic/contacts/testuser' /> + <author> + <name>davidchoimusic</name> + <uri> + http://gdata.youtube.com/feeds/users/davidchoimusic</uri> + </author> + <yt:username>testuser</yt:username> + <yt:status>accepted</yt:status> + </entry> +</feed> 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 @@ +<response><url>http://uploads.gdata.youtube.com/action/FormDataUpload/AIwbF1_JjEQ9cGTjEAd5FKwV42SeNWJexmc5y7XR-eFj24uqbqU6NRcxKJW_4R-sYISLxQ</url><token>AIwbFAQ21fImpR2iYPaFnfuCvfbCB3qBxl5qXiZlpH3lfkungiSPoyw1iOM1gFB6Nx-wmY-kjprNT3qtdp7LJCLfngn11Ne_X9Jd44Vz8AzygtEtaDGyib5tnri0O0-V5pwcAPCHIJurOMsOpA2zInW8V8qHk2S2LheXfTXVbqc0Li9iCBpsoBGbykYU0moNoyGAaKRbSBD0oPnCv6v9Rll5Zjvivi2hQt-Br2JDb9wVeLv3qyAFaeyN6X6k32RyaAHs_n8d8d_oSriQmvS8g1HxSCS4dnoGL7tafQ4SBqnrQEb-hxFeu1ZrAwCLv</token></response> 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 @@ +<?xml version='1.0' encoding='UTF-8'?> +<entry xmlns='http://www.w3.org/2005/Atom' + xmlns:gml='http://www.opengis.net/gml' + xmlns:georss='http://www.georss.org/georss' + xmlns:media='http://search.yahoo.com/mrss/' + xmlns:yt='http://gdata.youtube.com/schemas/2007' + xmlns:gd='http://schemas.google.com/g/2005'> + <id> + http://gdata.youtube.com/feeds/api/users/andyland74/inbox/ffb9a5f32cd5f55 + </id> + <published>2008-06-10T13:55:32.000-07:00</published> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#videoMessage'/> + <title type='text'>andyland74sFriend sent you a video!</title> + <content type='text'>Check out this video!</content> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/watch?v=jXE6G9CYcJs'/> + <link + rel='http://gdata.youtube.com/schemas/2007#video.responses' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/api/videos/jXE6G9CYcJs/responses'/> + <link rel='http://gdata.youtube.com/schemas/2007#video.ratings' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/api/videos/jXE6G9CYcJs/ratings'/> + <link rel='http://gdata.youtube.com/schemas/2007#video.complaints' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/api/videos/jXE6G9CYcJs/complaints'/> + <link rel='http://gdata.youtube.com/schemas/2007#video.related' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/api/videos/jXE6G9CYcJs/related'/> + <link rel='related' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/api/videos/jXE6G9CYcJs'/> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/api/users/andyland74/inbox/ffb9a5f32cd5f55'/> + <link rel='edit' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/api/users/andyland74/inbox/ffb9a5f32cd5f55'/> + <author> + <name>andyland74sFriend</name> + <uri> + http://gdata.youtube.com/feeds/api/users/andyland74sFriend + </uri> + </author> + <media:group> + <media:title type='plain'>Learning the ABCs</media:title> + <media:description type='plain'> + A great method for teaching kids the alphabet. + </media:description> + <media:keywords>alphabet, teaching, children</media:keywords> + <yt:duration seconds='202'/> + <media:category label='Education' + scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> + Education</media:category> + <media:content url='http://www.youtube.com/v/jXE6G9CYcJs' + type='application/x-shockwave-flash' medium='video' + isDefault='true' expression='full' duration='202' yt:format='5'/> + <media:content + url='rtsp://rtsp2.youtube.com/ChoLENyDSANFEgGDA==/0/0/0/video.3gp' + type='video/3gpp' medium='video' expression='full' + duration='202' yt:format='1'/> + <media:content + url='rtsp://rtsp2.youtube.com/ChoLENyESARFEgGDA==/0/0/0/video.3gp' + type='video/3gpp' medium='video' expression='full' + duration='202' yt:format='6'/> + <media:player url='http://www.youtube.com/watch?v=jXE6G9CYcJs'/> + <media:thumbnail url='http://img.youtube.com/vi/jXE6G9CYcJs/2.jpg' + height='97' width='130' time='00:01:41'/> + <media:thumbnail url='http://img.youtube.com/vi/jXE6G9CYcJs/1.jpg' + height='97' width='130' time='00:00:50.500'/> + <media:thumbnail url='http://img.youtube.com/vi/jXE6G9CYcJs/3.jpg' + height='97' width='130' time='00:02:31.500'/> + <media:thumbnail url='http://img.youtube.com/vi/jXE6G9CYcJs/0.jpg' + height='240' width='320' time='00:01:41'/> + </media:group> + <yt:statistics viewCount='56620' favoriteCount='67'/> + <gd:rating min='1' max='5' numRaters='372' average='3.93'/> + <gd:comments> + <gd:feedLink + href='http://gdata.youtube.com/feeds/api/videos/jXE6G9CYcJs/comments' + countHint='481'/> + </gd:comments> + <yt:description>Check out this video!</yt:description> + </entry>
\ 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 @@ +<?xml version='1.0' encoding='UTF-8'?> +<entry xmlns='http://www.w3.org/2005/Atom' + xmlns:gml='http://www.opengis.net/gml' + xmlns:georss='http://www.georss.org/georss' + xmlns:media='http://search.yahoo.com/mrss/' + xmlns:yt='http://gdata.youtube.com/schemas/2007' + xmlns:gd='http://schemas.google.com/g/2005' + gd:etag='W/"C0QHQ347eCp7ImA9WxdQEU4."'> + <id>tag:youtube,2008:user:andyland74:inbox:D_uaXzLRX1U</id> + <published>2008-06-10T13:55:32.000-07:00</published> + <updated>2008-06-10T13:55:32.000-07:00</updated> + <app:edited + xmlns:app='http://www.w3.org/2007/app'>2008-06-10T20:55:32.000Z</app:edited> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#videoMessage'/> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='surfing'/> + <category scheme='http://gdata.youtube.com/schemas/2007/categories.cat' + term='People' label='People & Blogs'/> + <title>andyland74sFriend sent you a video!</title> + <summary>Check out this video!</summary> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/watch?v=jXE6G9CYcJs'/> + <link rel='http://gdata.youtube.com/schemas/2007#video.responses' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/api/videos/jXE6G9CYcJs/responses?v=2'/> + <link rel='http://gdata.youtube.com/schemas/2007#video.ratings' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/api/videos/jXE6G9CYcJs/ratings?v=2'/> + <link rel='http://gdata.youtube.com/schemas/2007#video.complaints' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/api/videos/jXE6G9CYcJs/complaints?v=2'/> + <link rel='http://gdata.youtube.com/schemas/2007#mobile' + type='text/html' href='http://m.youtube.com/details?v=jXE6G9CYcJs'/> + <link rel='http://gdata.youtube.com/schemas/2007#video.related' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/api/videos/jXE6G9CYcJs/related?v=2'/> + <link rel='related' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/api/videos/jXE6G9CYcJs?v=2'/> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/api/users/andyland74/inbox/ffb9a5f32cd5f55?v=2'/> + <link rel='edit' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/api/users/andyland74/inbox/ffb9a5f32cd5f55?v=2'/> + <author> + <name>andyland74sFriend</name> + <uri>http://gdata.youtube.com/feeds/api/users/andyland74sFriend</uri> + </author> + <media:group> + <media:title type='plain'>Learning the ABCs</media:title> + <media:description type='plain'> + A great method for teaching kids the alphabet. + </media:description> + <media:keywords>alphabet, teaching, children</media:keywords> + <yt:duration seconds='202'/> + <yt:videoid>jXE6G9CYcJs</yt:videoid> + <media:credit role='uploader' scheme='urn:youtube'>andyland74sFriend</media:credit> + <media:category label='Education' + scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> + Education</media:category> + <media:content url='http://www.youtube.com/v/jXE6G9CYcJs' + type='application/x-shockwave-flash' medium='video' isDefault='true' + expression='full' duration='202' yt:format='5'/> + <media:content + url='rtsp://rtsp2.youtube.com/ChoLENySANFEgGDA==/0/0/0/video.3gp' + type='video/3gpp' medium='video' expression='full' + duration='202' yt:format='1'/> + <media:content + url='rtsp://rtsp2.youtube.com/ChoLENySARFEgGDA==/0/0/0/video.3gp' + type='video/3gpp' medium='video' expression='full' + duration='202' yt:format='6'/> + <media:player url='http://www.youtube.com/watch?v=jXE6G9CYcJs'/> + <media:thumbnail url='http://img.youtube.com/vi/jXE6G9CYcJs/2.jpg' + height='97' width='130' time='00:01:41'/> + <media:thumbnail url='http://img.youtube.com/vi/jXE6G9CYcJs/1.jpg' + height='97' width='130' time='00:00:50.500'/> + <media:thumbnail url='http://img.youtube.com/vi/jXE6G9CYcJs/3.jpg' + height='97' width='130' time='00:02:31.500'/> + <media:thumbnail url='http://img.youtube.com/vi/jXE6G9CYcJs/0.jpg' + height='240' width='320' time='00:01:41'/> + </media:group> + <yt:statistics viewCount='286355' favoriteCount='201'/> + <gd:rating min='1' max='5' numRaters='877' average='3.88'/> + <gd:comments> + <gd:feedLink + href='http://gdata.youtube.com/feeds/api/videos/jXE6G9CYcJs/comments' + countHint='1088'/> + </gd:comments> +</entry>
\ 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 @@ +<?xml version='1.0' encoding='UTF-8'?> +<feed xmlns='http://www.w3.org/2005/Atom' + xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' + xmlns:gml='http://www.opengis.net/gml' + xmlns:georss='http://www.georss.org/georss' + xmlns:media='http://search.yahoo.com/mrss/' + xmlns:yt='http://gdata.youtube.com/schemas/2007' + xmlns:gd='http://schemas.google.com/g/2005'> + <id>http://gdata.youtube.com/feeds/api/users/default/inbox</id> + <updated>2008-06-10T20:55:40.271Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#videoMessage'/> + <title type='text'>Inbox of andyland74</title> + <logo>http://www.youtube.com/img/pic_youtubelogo_123x63.gif</logo> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/my_messages?folder=inbox&filter=videos'/> + <link rel='http://schemas.google.com/g/2005#feed' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/api/users/andyland74/inbox'/> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/api/users/andyland74/inbox?...'/> + <author> + <name>andyland74</name> + <uri>http://gdata.youtube.com/feeds/api/users/andyland74</uri> + </author> + <generator version='beta' + uri='http://gdata.youtube.com/'>YouTube data API</generator> + <openSearch:totalResults>1</openSearch:totalResults> + <openSearch:startIndex>1</openSearch:startIndex> + <openSearch:itemsPerPage>25</openSearch:itemsPerPage> + <entry> + <id> + http://gdata.youtube.com/feeds/api/users/andyland74/inbox/ffb9a5f32cd5f55 + </id> + <published>2008-06-10T13:55:32.000-07:00</published> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#videoMessage'/> + <title type='text'>andyland74sFriend sent you a video!</title> + <content type='text'>Check out this video!</content> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/watch?v=jXE6G9CYcJs'/> + <link + rel='http://gdata.youtube.com/schemas/2007#video.responses' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/api/videos/jXE6G9CYcJs/responses'/> + <link rel='http://gdata.youtube.com/schemas/2007#video.ratings' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/api/videos/jXE6G9CYcJs/ratings'/> + <link rel='http://gdata.youtube.com/schemas/2007#video.complaints' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/api/videos/jXE6G9CYcJs/complaints'/> + <link rel='http://gdata.youtube.com/schemas/2007#video.related' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/api/videos/jXE6G9CYcJs/related'/> + <link rel='related' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/api/videos/jXE6G9CYcJs'/> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/api/users/andyland74/inbox/ffb9a5f32cd5f55'/> + <link rel='edit' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/api/users/andyland74/inbox/ffb9a5f32cd5f55'/> + <author> + <name>andyland74sFriend</name> + <uri> + http://gdata.youtube.com/feeds/api/users/andyland74sFriend + </uri> + </author> + <media:group> + <media:title type='plain'>Learning the ABCs</media:title> + <media:description type='plain'> + A great method for teaching kids the alphabet. + </media:description> + <media:keywords>alphabet, teaching, children</media:keywords> + <yt:duration seconds='202'/> + <media:category label='Education' + scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> + Education</media:category> + <media:content url='http://www.youtube.com/v/jXE6G9CYcJs' + type='application/x-shockwave-flash' medium='video' + isDefault='true' expression='full' duration='202' yt:format='5'/> + <media:content + url='rtsp://rtsp2.youtube.com/ChoLENyDSANFEgGDA==/0/0/0/video.3gp' + type='video/3gpp' medium='video' expression='full' + duration='202' yt:format='1'/> + <media:content + url='rtsp://rtsp2.youtube.com/ChoLENyESARFEgGDA==/0/0/0/video.3gp' + type='video/3gpp' medium='video' expression='full' + duration='202' yt:format='6'/> + <media:player url='http://www.youtube.com/watch?v=jXE6G9CYcJs'/> + <media:thumbnail url='http://img.youtube.com/vi/jXE6G9CYcJs/2.jpg' + height='97' width='130' time='00:01:41'/> + <media:thumbnail url='http://img.youtube.com/vi/jXE6G9CYcJs/1.jpg' + height='97' width='130' time='00:00:50.500'/> + <media:thumbnail url='http://img.youtube.com/vi/jXE6G9CYcJs/3.jpg' + height='97' width='130' time='00:02:31.500'/> + <media:thumbnail url='http://img.youtube.com/vi/jXE6G9CYcJs/0.jpg' + height='240' width='320' time='00:01:41'/> + </media:group> + <yt:statistics viewCount='56620' favoriteCount='67'/> + <gd:rating min='1' max='5' numRaters='372' average='3.93'/> + <gd:comments> + <gd:feedLink + href='http://gdata.youtube.com/feeds/api/videos/jXE6G9CYcJs/comments' + countHint='481'/> + </gd:comments> + <yt:description>Check out this video!</yt:description> + </entry> +</feed>
\ 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 @@ +<?xml version='1.0' encoding='UTF-8'?> +<feed xmlns='http://www.w3.org/2005/Atom' + xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/' + xmlns:gml='http://www.opengis.net/gml' + xmlns:georss='http://www.georss.org/georss' + xmlns:media='http://search.yahoo.com/mrss/' + xmlns:batch='http://schemas.google.com/gdata/batch' + xmlns:yt='http://gdata.youtube.com/schemas/2007' + xmlns:gd='http://schemas.google.com/g/2005' + gd:etag='W/"C0QHQ347eCp7ImA9WxdQEU4."'> + <id>tag:youtube,2008:user:andyland74:inbox</id> + <updated>2008-07-21T17:54:30.236Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#videoMessage'/> + <title>Inbox of andyland74</title> + <logo>http://www.youtube.com/img/pic_youtubelogo_123x63.gif</logo> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/my_messages?folder=inbox&filter=videos'/> + <link rel='http://schemas.google.com/g/2005#feed' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/api/users/andyland74/inbox?v=2'/> + <link rel='http://schemas.google.com/g/2005#batch' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/api/users/andyland74/inbox/batch?v=2'/> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/api/users/andyland74/inbox?...'/> + <link rel='service' type='application/atomsvc+xml' + href='http://gdata.youtube.com/feeds/api/users/andyland74/inbox?alt=...'/> + <author> + <name>andyland74</name> + <uri>http://gdata.youtube.com/feeds/api/users/andyland74</uri> + </author> + <generator version='2.0' + uri='http://gdata.youtube.com/'>YouTube data API</generator> + <openSearch:totalResults>1</openSearch:totalResults> + <openSearch:startIndex>1</openSearch:startIndex> + <openSearch:itemsPerPage>25</openSearch:itemsPerPage> + <entry gd:etag='W/"C0QHQ347eCp7ImA9WxdQEU4."'> + <id>tag:youtube,2008:user:andyland74:inbox:D_uaXzLRX1U</id> + <published>2008-06-10T13:55:32.000-07:00</published> + <updated>2008-06-10T13:55:32.000-07:00</updated> + <app:edited + xmlns:app='http://www.w3.org/2007/app'>2008-06-10T20:55:32.000Z</app:edited> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#videoMessage'/> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='surfing'/> + <category scheme='http://gdata.youtube.com/schemas/2007/categories.cat' + term='People' label='People & Blogs'/> + <title>andyland74sFriend sent you a video!</title> + <summary>Check out this video!</summary> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/watch?v=jXE6G9CYcJs'/> + <link rel='http://gdata.youtube.com/schemas/2007#video.responses' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/api/videos/jXE6G9CYcJs/responses?v=2'/> + <link rel='http://gdata.youtube.com/schemas/2007#video.ratings' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/api/videos/jXE6G9CYcJs/ratings?v=2'/> + <link rel='http://gdata.youtube.com/schemas/2007#video.complaints' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/api/videos/jXE6G9CYcJs/complaints?v=2'/> + <link rel='http://gdata.youtube.com/schemas/2007#mobile' + type='text/html' href='http://m.youtube.com/details?v=jXE6G9CYcJs'/> + <link rel='http://gdata.youtube.com/schemas/2007#video.related' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/api/videos/jXE6G9CYcJs/related?v=2'/> + <link rel='related' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/api/videos/jXE6G9CYcJs?v=2'/> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/api/users/andyland74/inbox/ffb9a5f32cd5f55?v=2'/> + <link rel='edit' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/api/users/andyland74/inbox/ffb9a5f32cd5f55?v=2'/> + <author> + <name>andyland74sFriend</name> + <uri>http://gdata.youtube.com/feeds/api/users/andyland74sFriend</uri> + </author> + <media:group> + <media:title type='plain'>Learning the ABCs</media:title> + <media:description type='plain'> + A great method for teaching kids the alphabet. + </media:description> + <media:keywords>alphabet, teaching, children</media:keywords> + <yt:duration seconds='202'/> + <yt:videoid>jXE6G9CYcJs</yt:videoid> + <media:credit role='uploader' scheme='urn:youtube'>andyland74sFriend</media:credit> + <media:category label='Education' + scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> + Education</media:category> + <media:content url='http://www.youtube.com/v/jXE6G9CYcJs' + type='application/x-shockwave-flash' medium='video' isDefault='true' + expression='full' duration='202' yt:format='5'/> + <media:content + url='rtsp://rtsp2.youtube.com/ChoLENySANFEgGDA==/0/0/0/video.3gp' + type='video/3gpp' medium='video' expression='full' + duration='202' yt:format='1'/> + <media:content + url='rtsp://rtsp2.youtube.com/ChoLENySARFEgGDA==/0/0/0/video.3gp' + type='video/3gpp' medium='video' expression='full' + duration='202' yt:format='6'/> + <media:player url='http://www.youtube.com/watch?v=jXE6G9CYcJs'/> + <media:thumbnail url='http://img.youtube.com/vi/jXE6G9CYcJs/2.jpg' + height='97' width='130' time='00:01:41'/> + <media:thumbnail url='http://img.youtube.com/vi/jXE6G9CYcJs/1.jpg' + height='97' width='130' time='00:00:50.500'/> + <media:thumbnail url='http://img.youtube.com/vi/jXE6G9CYcJs/3.jpg' + height='97' width='130' time='00:02:31.500'/> + <media:thumbnail url='http://img.youtube.com/vi/jXE6G9CYcJs/0.jpg' + height='240' width='320' time='00:01:41'/> + </media:group> + <yt:statistics viewCount='286355' favoriteCount='201'/> + <gd:rating min='1' max='5' numRaters='877' average='3.88'/> + <gd:comments> + <gd:feedLink + href='http://gdata.youtube.com/feeds/api/videos/jXE6G9CYcJs/comments' + countHint='1088'/> + </gd:comments> + </entry> +</feed> 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 @@ +<?xml version='1.0' encoding='utf-8'?> +<entry xmlns='http://www.w3.org/2005/Atom' +xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' +xmlns:media='http://search.yahoo.com/mrss/' +xmlns:gd='http://schemas.google.com/g/2005' +xmlns:yt='http://gdata.youtube.com/schemas/2007'> + <id> + http://gdata.youtube.com/feeds/users/testuser/playlists/46A2F8C9B36B6FE7</id> + <published>2007-01-29T22:42:12.000-08:00</published> + <updated>2007-09-20T13:42:19.000-07:00</updated> + <category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' + term='music' /> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#playlistLink' /> + <title type='text'>YouTube Musicians</title> + <content type='text'>Music from talented people on YouTube.</content> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/view_play_list?p=46A2F8C9B36B6FE7' /> + <link rel='related' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/users/testuser' /> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/users/testuser/playlists/46A2F8C9B36B6FE7' /> + <author> + <name>testuser</name> + <uri>http://gdata.youtube.com/feeds/users/testuser</uri> + </author> + <yt:description>Music from talented people on YouTube.</yt:description> + <gd:feedLink rel='http://gdata.youtube.com/schemas/2007#playlist' + href='http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7' /> +</entry> 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 @@ +<?xml version='1.0' encoding='UTF-8'?> +<entry xmlns='http://www.w3.org/2005/Atom' xmlns:media='http://search.yahoo.com/mrss/' xmlns:yt='http://gdata.youtube.com/schemas/2007' xmlns:gd='http://schemas.google.com/g/2005' gd:etag='W/"CE4CQn47eCp7ImA9WxRbGU0."'> +<id>tag:youtube.com,2008:user:googledevelopers:playlist:8E2186857EE27746</id> +<published>2007-08-23T21:48:43.000Z</published> +<updated>2008-12-10T09:56:03.000Z</updated> +<category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#playlistLink'/> +<title>Non-google Interviews</title> +<summary>This playlist contains interviews with people outside of Google.</summary> +<content type='application/atom+xml;type=feed' src='http://gdata.youtube.com/feeds/api/playlists/8E2186857EE27746?v=2'/> +<link rel='related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/googledevelopers?v=2'/> +<link rel='alternate' type='text/html' href='http://www.youtube.com/view_play_list?p=8E2186857EE27746'/> +<link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/googledevelopers/playlists/8E2186857EE27746?v=2'/> +<author><name>googledevelopers</name><uri>http://gdata.youtube.com/feeds/api/users/googledevelopers</uri></author> +<yt:playlistId>8E2186857EE27746</yt:playlistId> +<yt:countHint>1</yt:countHint> +</entry>
\ 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 @@ +<?xml version='1.0' encoding='utf-8'?> +<feed xmlns='http://www.w3.org/2005/Atom' +xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' +xmlns:media='http://search.yahoo.com/mrss/' +xmlns:gd='http://schemas.google.com/g/2005' +xmlns:yt='http://gdata.youtube.com/schemas/2007'> + <id>http://gdata.youtube.com/feeds/users/testuser/playlists</id> + <updated>2007-09-20T20:59:47.530Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#playlistLink' /> + <title type='text'>testuser's Playlists</title> + <logo>http://www.youtube.com/img/pic_youtubelogo_123x63.gif</logo> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/profile_play_list?user=testuser' /> + <link rel='related' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/users/testuser' /> + <link rel='http://schemas.google.com/g/2005#feed' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/users/testuser/playlists' /> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/users/testuser/playlists?start-index=1&max-results=25' /> + <author> + <name>testuser</name> + <uri>http://gdata.youtube.com/feeds/users/testuser</uri> + </author> + <generator version='beta' uri='http://gdata.youtube.com/'>YouTube + data API</generator> + <openSearch:totalResults>2</openSearch:totalResults> + <openSearch:startIndex>1</openSearch:startIndex> + <openSearch:itemsPerPage>25</openSearch:itemsPerPage> + <entry> + <id> + http://gdata.youtube.com/feeds/users/testuser/playlists/A0F668D93B388F99</id> + <published>2007-01-17T14:13:22.000-08:00</published> + <updated>2007-02-04T21:56:42.000-08:00</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#playlistLink' /> + <title type='text'>Korean/Chinese Playlist</title> + <content type='text'>Testing characters</content> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/view_play_list?p=A0F668D93B388F99' /> + <link rel='related' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/users/testuser' /> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/users/testuser/playlists/A0F668D93B388F99' /> + <author> + <name>testuser</name> + <uri>http://gdata.youtube.com/feeds/users/testuser</uri> + </author> + <yt:description>Testing characters</yt:description> + <gd:feedLink rel='http://gdata.youtube.com/schemas/2007#playlist' + href='http://gdata.youtube.com/feeds/playlists/A0F668D93B388F99' /> + </entry> + <entry> + <id> + http://gdata.youtube.com/feeds/users/testuser/playlists/46A2F8C9B36B6FE7</id> + <published>2007-01-29T22:42:12.000-08:00</published> + <updated>2007-09-20T13:42:19.000-07:00</updated> + <category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' + term='music' /> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#playlistLink' /> + <title type='text'>YouTube Musicians</title> + <content type='text'>Music from talented people on YouTube.</content> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/view_play_list?p=46A2F8C9B36B6FE7' /> + <link rel='related' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/users/testuser' /> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/users/testuser/playlists/46A2F8C9B36B6FE7' /> + <author> + <name>testuser</name> + <uri>http://gdata.youtube.com/feeds/users/testuser</uri> + </author> + <yt:description>Music from talented people on YouTube.</yt:description> + <gd:feedLink rel='http://gdata.youtube.com/schemas/2007#playlist' + href='http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7' /> + </entry> +</feed> 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 @@ +<?xml version='1.0' encoding='UTF-8'?> +<feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/' xmlns:media='http://search.yahoo.com/mrss/' xmlns:batch='http://schemas.google.com/gdata/batch' xmlns:yt='http://gdata.youtube.com/schemas/2007' xmlns:gd='http://schemas.google.com/g/2005' gd:etag='W/"CE4CQn47eCp7ImA9WxRbGU0."'> + <id>tag:youtube.com,2008:user:GoogleDevelopers:playlists</id> + <updated>2008-12-10T09:56:03.000Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#playlistLink'/> + <title>Playlists of GoogleDevelopers</title> + <logo>http://www.youtube.com/img/pic_youtubelogo_123x63.gif</logo> + <link rel='related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/googledevelopers?v=2'/> + <link rel='alternate' type='text/html' href='http://www.youtube.com/profile_play_list?user=GoogleDevelopers'/> + <link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/GoogleDevelopers/playlists?v=2'/> + <link rel='http://schemas.google.com/g/2005#batch' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/GoogleDevelopers/playlists/batch?v=2'/> + <link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/GoogleDevelopers/playlists?start-index=1&max-results=25&v=2'/> + <link rel='service' type='application/atomsvc+xml' href='http://gdata.youtube.com/feeds/api/users/GoogleDevelopers/playlists?alt=atom-service&v=2'/> + <link rel='next' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/GoogleDevelopers/playlists?start-index=26&max-results=25&v=2'/> + <author> + <name>GoogleDevelopers</name> + <uri>http://gdata.youtube.com/feeds/api/users/googledevelopers</uri> + </author> + <generator version='2.0' uri='http://gdata.youtube.com/'>YouTube data API</generator> + <openSearch:totalResults>70</openSearch:totalResults> +<openSearch:startIndex>1</openSearch:startIndex> + <openSearch:itemsPerPage>25</openSearch:itemsPerPage> + <entry gd:etag='W/"CE4CQn47eCp7ImA9WxRbGU0."'> + <id>tag:youtube.com,2008:user:GoogleDevelopers:playlist:8E2186857EE27746</id> + <published>2007-08-23T21:48:43.000Z</published> + <updated>2008-12-10T09:56:03.000Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#playlistLink'/> + <title>Non-google Interviews</title> + <summary>This playlist contains interviews with people outside of Google.</summary> + <content type='application/atom+xml;type=feed' src='http://gdata.youtube.com/feeds/api/playlists/8E2186857EE27746?v=2'/> + <link rel='related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/googledevelopers?v=2'/> + <link rel='alternate' type='text/html' href='http://www.youtube.com/view_play_list?p=8E2186857EE27746'/> + <link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/GoogleDevelopers/playlists/8E2186857EE27746?v=2'/> + <author> +<name>GoogleDevelopers</name> +<uri>http://gdata.youtube.com/feeds/api/users/googledevelopers</uri> +</author> + <yt:playlistId>8E2186857EE27746</yt:playlistId> + <yt:countHint>1</yt:countHint> + </entry> + <entry gd:etag='W/"DkUDQn47eCp7ImA9WxRaEE0."'> + <id>tag:youtube.com,2008:user:GoogleDevelopers:playlist:4AE5C0D23C2EB82D</id> + <published>2007-08-23T21:50:19.000Z</published> + <updated>2008-12-11T14:04:33.000Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#playlistLink'/> + <category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='engineers'/> + <category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='google'/> + <title>From Google Engineers</title> + <summary>These videos are interviews straight from the horses mouth... the Google teams themselves.</summary> + <content type='application/atom+xml;type=feed' src='http://gdata.youtube.com/feeds/api/playlists/4AE5C0D23C2EB82D?v=2'/> + <link rel='related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/googledevelopers?v=2'/> + <link rel='alternate' type='text/html' href='http://www.youtube.com/view_play_list?p=4AE5C0D23C2EB82D'/> + <link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/GoogleDevelopers/playlists/4AE5C0D23C2EB82D?v=2'/> + <author> +<name>GoogleDevelopers</name> +<uri>http://gdata.youtube.com/feeds/api/users/googledevelopers</uri> +</author> + <yt:playlistId>4AE5C0D23C2EB82D</yt:playlistId> + <yt:countHint>5</yt:countHint> + </entry> + <entry gd:etag='W/"DUEDQn47eCp7ImA9WxRaEU0."'> + <id>tag:youtube.com,2008:user:GoogleDevelopers:playlist:2C63610CE65A92B9</id> + <published>2007-08-28T16:11:35.000Z</published> + <updated>2008-12-12T18:47:53.000Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#playlistLink'/> + <category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='googlecodeforeducators'/> + <category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='googlecode'/> + <category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='google'/> + <title>Google Code For Educators</title> + <summary>Videos from Google Code For Educators</summary> + <content type='application/atom+xml;type=feed' src='http://gdata.youtube.com/feeds/api/playlists/2C63610CE65A92B9?v=2'/> + <link rel='related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/googledevelopers?v=2'/> + <link rel='alternate' type='text/html' href='http://www.youtube.com/view_play_list?p=2C63610CE65A92B9'/> + <link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/GoogleDevelopers/playlists/2C63610CE65A92B9?v=2'/> + <author> +<name>GoogleDevelopers</name> +<uri>http://gdata.youtube.com/feeds/api/users/googledevelopers</uri> +</author> + <yt:playlistId>2C63610CE65A92B9</yt:playlistId> + <yt:countHint>5</yt:countHint> + </entry> + <entry gd:etag='W/"CE4CRH47eCp7ImA9WxRbF0o."'> + <id>tag:youtube.com,2008:user:GoogleDevelopers:playlist:D9740C0183D07BE6</id> + <published>2007-08-30T00:03:01.000Z</published> + <updated>2008-12-08T21:49:25.000Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#playlistLink'/> + <category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='offline'/> + <category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='gears'/> + <category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='google'/> + <title>Gears</title> + <summary>All videos related to Gears</summary> + <content type='application/atom+xml;type=feed' src='http://gdata.youtube.com/feeds/api/playlists/D9740C0183D07BE6?v=2'/> + <link rel='related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/googledevelopers?v=2'/> + <link rel='alternate' type='text/html' href='http://www.youtube.com/view_play_list?p=D9740C0183D07BE6'/> + <link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/GoogleDevelopers/playlists/D9740C0183D07BE6?v=2'/> + <author> +<name>GoogleDevelopers</name> +<uri>http://gdata.youtube.com/feeds/api/users/googledevelopers</uri> +</author> + <yt:playlistId>D9740C0183D07BE6</yt:playlistId> + <yt:countHint>10</yt:countHint> + </entry> + <entry gd:etag='W/"DUAFQn47eCp7ImA9WxRaEU0."'> + <id>tag:youtube.com,2008:user:GoogleDevelopers:playlist:3A74996A44A8FA83</id> + <published>2007-10-12T22:26:05.000Z</published> + <updated>2008-12-12T18:48:33.000Z</updated> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='googlesummerofcode'/> +<category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#playlistLink'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='summerofcode'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='google'/> +<title>Google Summer of Code</title> +<summary>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.</summary> +<content type='application/atom+xml;type=feed' src='http://gdata.youtube.com/feeds/api/playlists/3A74996A44A8FA83?v=2'/> +<link rel='related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/googledevelopers?v=2'/> +<link rel='alternate' type='text/html' href='http://www.youtube.com/view_play_list?p=3A74996A44A8FA83'/> +<link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/GoogleDevelopers/playlists/3A74996A44A8FA83?v=2'/> +<author> +<name>GoogleDevelopers</name> +<uri>http://gdata.youtube.com/feeds/api/users/googledevelopers</uri> +</author> +<yt:playlistId>3A74996A44A8FA83</yt:playlistId> +<yt:countHint>2</yt:countHint> +</entry> +<entry gd:etag='W/"A0AMRX47eCp7ImA9WxRbGU0."'> +<id>tag:youtube.com,2008:user:GoogleDevelopers:playlist:0559F3902CC876AE</id> +<published>2007-10-15T22:04:22.000Z</published> +<updated>2008-12-10T11:49:44.000Z</updated> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='mashup'/> +<category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#playlistLink'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='editor'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='gme'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='google'/> +<title>Google Mashup Editor</title> +<summary>Videos related to the Google Mashup Editor</summary> +<content type='application/atom+xml;type=feed' src='http://gdata.youtube.com/feeds/api/playlists/0559F3902CC876AE?v=2'/> +<link rel='related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/googledevelopers?v=2'/> +<link rel='alternate' type='text/html' href='http://www.youtube.com/view_play_list?p=0559F3902CC876AE'/> +<link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/GoogleDevelopers/playlists/0559F3902CC876AE?v=2'/> +<author> +<name>GoogleDevelopers</name> +<uri>http://gdata.youtube.com/feeds/api/users/googledevelopers</uri> +</author> +<yt:playlistId>0559F3902CC876AE</yt:playlistId> +<yt:countHint>2</yt:countHint> +</entry> +<entry gd:etag='W/"A0IMQH47eCp7ImA9WxRbFkg."'> +<id>tag:youtube.com,2008:user:GoogleDevelopers:playlist:327240CFB48BEC5D</id> +<published>2007-10-15T22:16:04.000Z</published> +<updated>2008-12-07T14:19:41.000Z</updated> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='widgets'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='components'/> +<category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#playlistLink'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='google'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='gadgets'/> +<title>Google Gadgets</title> +<summary>Content on all types of gadgets (desktop, igoogle, and embedable!)</summary> +<content type='application/atom+xml;type=feed' src='http://gdata.youtube.com/feeds/api/playlists/327240CFB48BEC5D?v=2'/> +<link rel='related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/googledevelopers?v=2'/> +<link rel='alternate' type='text/html' href='http://www.youtube.com/view_play_list?p=327240CFB48BEC5D'/> +<link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/GoogleDevelopers/playlists/327240CFB48BEC5D?v=2'/> +<author> +<name>GoogleDevelopers</name> +<uri>http://gdata.youtube.com/feeds/api/users/googledevelopers</uri> +</author> +<yt:playlistId>327240CFB48BEC5D</yt:playlistId> +<yt:countHint>4</yt:countHint> +</entry> +<entry gd:etag='W/"AkENRn47eCp7ImA9WxRbGUw."'> +<id>tag:youtube.com,2008:user:GoogleDevelopers:playlist:EC7C82F4E9ACC351</id> +<published>2007-10-15T22:17:03.000Z</published> +<updated>2008-12-10T14:18:17.000Z</updated> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='earth'/> +<category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#playlistLink'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='maps'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='kml'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='geo'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='google'/> +<title>Google Maps and Earth</title> +<summary>All things Geo</summary> +<content type='application/atom+xml;type=feed' src='http://gdata.youtube.com/feeds/api/playlists/EC7C82F4E9ACC351?v=2'/> +<link rel='related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/googledevelopers?v=2'/> +<link rel='alternate' type='text/html' href='http://www.youtube.com/view_play_list?p=EC7C82F4E9ACC351'/> +<link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/GoogleDevelopers/playlists/EC7C82F4E9ACC351?v=2'/> +<author> +<name>GoogleDevelopers</name> +<uri>http://gdata.youtube.com/feeds/api/users/googledevelopers</uri> +</author> +<yt:playlistId>EC7C82F4E9ACC351</yt:playlistId> +<yt:countHint>16</yt:countHint> +</entry> +<entry gd:etag='W/"DE8GQ347eCp7ImA9WxRbFE8."'> +<id>tag:youtube.com,2008:user:GoogleDevelopers:playlist:968FABA11F2EDEA1</id> +<published>2007-10-15T22:18:00.000Z</published> +<updated>2008-12-04T21:40:22.000Z</updated> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='toolkit'/> +<category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#playlistLink'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='ajax'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='gwt'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='web'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='google'/> +<title>Google Web Toolkit</title> +<summary>Content on the Google Web Toolkit</summary> +<content type='application/atom+xml;type=feed' src='http://gdata.youtube.com/feeds/api/playlists/968FABA11F2EDEA1?v=2'/> +<link rel='related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/googledevelopers?v=2'/> +<link rel='alternate' type='text/html' href='http://www.youtube.com/view_play_list?p=968FABA11F2EDEA1'/> +<link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/GoogleDevelopers/playlists/968FABA11F2EDEA1?v=2'/> +<author> +<name>GoogleDevelopers</name> +<uri>http://gdata.youtube.com/feeds/api/users/googledevelopers</uri> +</author> +<yt:playlistId>968FABA11F2EDEA1</yt:playlistId> +<yt:countHint>34</yt:countHint> +</entry> +<entry gd:etag='W/"Ck8EQX47eCp7ImA9WxRaEU0."'> +<id>tag:youtube.com,2008:user:GoogleDevelopers:playlist:E6DE6EC9A373AF57</id> +<published>2007-10-15T22:20:18.000Z</published> +<updated>2008-12-12T16:53:20.000Z</updated> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='gdata'/> +<category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#playlistLink'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='apis'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='data'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='youtubeapis'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='google'/> +<title>Google Data APIs</title> +<summary>All things related to Google Data APIs</summary> +<content type='application/atom+xml;type=feed' src='http://gdata.youtube.com/feeds/api/playlists/E6DE6EC9A373AF57?v=2'/> +<link rel='related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/googledevelopers?v=2'/> +<link rel='alternate' type='text/html' href='http://www.youtube.com/view_play_list?p=E6DE6EC9A373AF57'/> +<link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/GoogleDevelopers/playlists/E6DE6EC9A373AF57?v=2'/> +<author> +<name>GoogleDevelopers</name> +<uri>http://gdata.youtube.com/feeds/api/users/googledevelopers</uri> +</author> +<yt:playlistId>E6DE6EC9A373AF57</yt:playlistId> +<yt:countHint>24</yt:countHint> +</entry> +<entry gd:etag='W/"C0AERX47eCp7ImA9WxRaEUw."'> +<id>tag:youtube.com,2008:user:GoogleDevelopers:playlist:CCAE880913CAFE9B</id> +<published>2007-10-15T22:24:17.000Z</published> +<updated>2008-12-12T19:55:04.000Z</updated> +<category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#playlistLink'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='adsense'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='advertising'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='ads'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='google'/> +<title>AdSense APIs</title> +<summary>Content related to our ad APIs</summary> +<content type='application/atom+xml;type=feed' src='http://gdata.youtube.com/feeds/api/playlists/CCAE880913CAFE9B?v=2'/> +<link rel='related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/googledevelopers?v=2'/> +<link rel='alternate' type='text/html' href='http://www.youtube.com/view_play_list?p=CCAE880913CAFE9B'/> +<link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/GoogleDevelopers/playlists/CCAE880913CAFE9B?v=2'/> +<author> +<name>GoogleDevelopers</name> +<uri>http://gdata.youtube.com/feeds/api/users/googledevelopers</uri> +</author> +<yt:playlistId>CCAE880913CAFE9B</yt:playlistId> +<yt:countHint>1</yt:countHint> +</entry> +<entry gd:etag='W/"C0IBQ347eCp7ImA9WxRbF0Q."'> +<id>tag:youtube.com,2008:user:GoogleDevelopers:playlist:72CF07D200AA2AFA</id> +<published>2007-10-17T18:36:51.000Z</published> +<updated>2008-12-09T02:59:12.000Z</updated> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='youtube'/> +<category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#playlistLink'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='apis'/> +<title>YouTube</title> +<summary>Content related to YouTube APIs</summary> +<content type='application/atom+xml;type=feed' src='http://gdata.youtube.com/feeds/api/playlists/72CF07D200AA2AFA?v=2'/> +<link rel='related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/googledevelopers?v=2'/> +<link rel='alternate' type='text/html' href='http://www.youtube.com/view_play_list?p=72CF07D200AA2AFA'/> +<link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/GoogleDevelopers/playlists/72CF07D200AA2AFA?v=2'/> +<author> +<name>GoogleDevelopers</name> +<uri>http://gdata.youtube.com/feeds/api/users/googledevelopers</uri> +</author> +<yt:playlistId>72CF07D200AA2AFA</yt:playlistId> +<yt:countHint>18</yt:countHint> +</entry> +<entry gd:etag='W/"CE4DQ347eCp7ImA9WxRbGU0."'> +<id>tag:youtube.com,2008:user:GoogleDevelopers:playlist:BC2ECF70FE499266</id> +<published>2007-10-17T18:38:13.000Z</published> +<updated>2008-12-10T09:56:12.000Z</updated> +<category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#playlistLink'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='opensource'/> +<title>Open Source at Google</title> +<summary>Content related to open source.</summary> +<content type='application/atom+xml;type=feed' src='http://gdata.youtube.com/feeds/api/playlists/BC2ECF70FE499266?v=2'/> +<link rel='related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/googledevelopers?v=2'/> +<link rel='alternate' type='text/html' href='http://www.youtube.com/view_play_list?p=BC2ECF70FE499266'/> +<link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/GoogleDevelopers/playlists/BC2ECF70FE499266?v=2'/> +<author> +<name>GoogleDevelopers</name> +<uri>http://gdata.youtube.com/feeds/api/users/googledevelopers</uri> +</author> +<yt:playlistId>BC2ECF70FE499266</yt:playlistId> +<yt:countHint>8</yt:countHint> +</entry> +<entry gd:etag='W/"CkYEQX47eCp7ImA9WxRbEEs."'> +<id>tag:youtube.com,2008:user:GoogleDevelopers:playlist:79B6967AC7A09B42</id> +<published>2007-10-17T18:40:07.000Z</published> +<updated>2008-11-30T15:48:20.000Z</updated> +<category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#playlistLink'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='search'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='apis'/> +<title>Google Search</title> +<summary>Content released to Search APIs</summary> +<content type='application/atom+xml;type=feed' src='http://gdata.youtube.com/feeds/api/playlists/79B6967AC7A09B42?v=2'/> +<link rel='related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/googledevelopers?v=2'/> +<link rel='alternate' type='text/html' href='http://www.youtube.com/view_play_list?p=79B6967AC7A09B42'/> +<link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/GoogleDevelopers/playlists/79B6967AC7A09B42?v=2'/> +<author> +<name>GoogleDevelopers</name> +<uri>http://gdata.youtube.com/feeds/api/users/googledevelopers</uri> +</author> +<yt:playlistId>79B6967AC7A09B42</yt:playlistId> +<yt:countHint>2</yt:countHint> +</entry> +<entry gd:etag='W/"DEUGQX47eCp7ImA9WxRaEE0."'> +<id>tag:youtube.com,2008:user:GoogleDevelopers:playlist:DA15B72EA2633F26</id> +<published>2007-10-17T18:41:25.000Z</published> +<updated>2008-12-11T14:37:00.000Z</updated> +<category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#playlistLink'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='ajax'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='apis'/> +<title>Google AJAX APIs</title> +<summary>Content related to the various Ajax APIs</summary> +<content type='application/atom+xml;type=feed' src='http://gdata.youtube.com/feeds/api/playlists/DA15B72EA2633F26?v=2'/> +<link rel='related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/googledevelopers?v=2'/> +<link rel='alternate' type='text/html' href='http://www.youtube.com/view_play_list?p=DA15B72EA2633F26'/> +<link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/GoogleDevelopers/playlists/DA15B72EA2633F26?v=2'/> +<author> +<name>GoogleDevelopers</name> +<uri>http://gdata.youtube.com/feeds/api/users/googledevelopers</uri> +</author> +<yt:playlistId>DA15B72EA2633F26</yt:playlistId> +<yt:countHint>5</yt:countHint> +</entry> +<entry gd:etag='W/"DUEDRH47eCp7ImA9WxRaEU0."'> +<id>tag:youtube.com,2008:user:GoogleDevelopers:playlist:18E9C145F20ED640</id> +<published>2007-10-17T18:42:21.000Z</published> +<updated>2008-12-12T18:47:55.000Z</updated> +<category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#playlistLink'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='mobile'/> +<title>Google Mobile</title> +<summary>Content related to mobile development and Google</summary> +<content type='application/atom+xml;type=feed' src='http://gdata.youtube.com/feeds/api/playlists/18E9C145F20ED640?v=2'/> +<link rel='related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/googledevelopers?v=2'/> +<link rel='alternate' type='text/html' href='http://www.youtube.com/view_play_list?p=18E9C145F20ED640'/> +<link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/GoogleDevelopers/playlists/18E9C145F20ED640?v=2'/> +<author> +<name>GoogleDevelopers</name> +<uri>http://gdata.youtube.com/feeds/api/users/googledevelopers</uri> +</author> +<yt:playlistId>18E9C145F20ED640</yt:playlistId> +<yt:countHint>1</yt:countHint> +</entry> +<entry gd:etag='W/"DUAFR347eCp7ImA9WxRaEU0."'> +<id>tag:youtube.com,2008:user:GoogleDevelopers:playlist:74D78B3235613DCB</id> +<published>2007-10-17T18:44:32.000Z</published> +<updated>2008-12-12T18:48:36.000Z</updated> +<category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#playlistLink'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='gmail'/> +<title>Gmail</title> +<summary>Content related to the Gmail product.</summary> +<content type='application/atom+xml;type=feed' src='http://gdata.youtube.com/feeds/api/playlists/74D78B3235613DCB?v=2'/> +<link rel='related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/googledevelopers?v=2'/> +<link rel='alternate' type='text/html' href='http://www.youtube.com/view_play_list?p=74D78B3235613DCB'/> +<link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/GoogleDevelopers/playlists/74D78B3235613DCB?v=2'/> +<author> +<name>GoogleDevelopers</name> +<uri>http://gdata.youtube.com/feeds/api/users/googledevelopers</uri> +</author> +<yt:playlistId>74D78B3235613DCB</yt:playlistId> +<yt:countHint>1</yt:countHint> +</entry> +<entry gd:etag='W/"DUAGQX47eCp7ImA9WxRaEU0."'> +<id>tag:youtube.com,2008:user:GoogleDevelopers:playlist:7F19205748B0A698</id> +<published>2007-10-19T18:45:08.000Z</published> +<updated>2008-12-12T18:48:40.000Z</updated> +<category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#playlistLink'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='api'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='base'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='googlebase'/> +<title>Google Base</title> +<summary>Content related to the Google Base product</summary> +<content type='application/atom+xml;type=feed' src='http://gdata.youtube.com/feeds/api/playlists/7F19205748B0A698?v=2'/> +<link rel='related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/googledevelopers?v=2'/> +<link rel='alternate' type='text/html' href='http://www.youtube.com/view_play_list?p=7F19205748B0A698'/> +<link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/GoogleDevelopers/playlists/7F19205748B0A698?v=2'/> +<author> +<name>GoogleDevelopers</name> +<uri>http://gdata.youtube.com/feeds/api/users/googledevelopers</uri> +</author> +<yt:playlistId>7F19205748B0A698</yt:playlistId> +<yt:countHint>2</yt:countHint> +</entry> +<entry gd:etag='W/"D0MHR347eCp7ImA9WxRbE08."'> +<id>tag:youtube.com,2008:user:GoogleDevelopers:playlist:59127FA00275EB77</id> +<published>2007-10-29T19:26:57.000Z</published> +<updated>2008-12-03T17:30:36.000Z</updated> +<category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#playlistLink'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='feedburner'/> +<title>FeedBurner</title> +<summary>FeedBurner API videos</summary> +<content type='application/atom+xml;type=feed' src='http://gdata.youtube.com/feeds/api/playlists/59127FA00275EB77?v=2'/> +<link rel='related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/googledevelopers?v=2'/> +<link rel='alternate' type='text/html' href='http://www.youtube.com/view_play_list?p=59127FA00275EB77'/> +<link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/GoogleDevelopers/playlists/59127FA00275EB77?v=2'/> +<author> +<name>GoogleDevelopers</name> +<uri>http://gdata.youtube.com/feeds/api/users/googledevelopers</uri> +</author> +<yt:playlistId>59127FA00275EB77</yt:playlistId> +<yt:countHint>1</yt:countHint> +</entry> +<entry gd:etag='W/"A0QGSX47eCp7ImA9WxRbGUU."'> +<id>tag:youtube.com,2008:user:GoogleDevelopers:playlist:A31A1098FDE85663</id> +<published>2007-10-29T23:52:25.000Z</published> +<updated>2008-12-11T09:55:28.000Z</updated> +<category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#playlistLink'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='apps'/> +<title>Google Apps</title> +<summary>Google Apps User Videos</summary> +<content type='application/atom+xml;type=feed' src='http://gdata.youtube.com/feeds/api/playlists/A31A1098FDE85663?v=2'/> +<link rel='related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/googledevelopers?v=2'/> +<link rel='alternate' type='text/html' href='http://www.youtube.com/view_play_list?p=A31A1098FDE85663'/> +<link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/GoogleDevelopers/playlists/A31A1098FDE85663?v=2'/> +<author> +<name>GoogleDevelopers</name> +<uri>http://gdata.youtube.com/feeds/api/users/googledevelopers</uri> +</author> +<yt:playlistId>A31A1098FDE85663</yt:playlistId> +<yt:countHint>3</yt:countHint> +</entry> +<entry gd:etag='W/"DEACQ347eCp7ImA9WxRbFE8."'> +<id>tag:youtube.com,2008:user:GoogleDevelopers:playlist:CF46C525B4C90C17</id> +<published>2007-10-30T01:19:18.000Z</published> +<updated>2008-12-04T21:39:22.000Z</updated> +<category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#playlistLink'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='ajax'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='feed'/> +<title>Google AJAX Feed API</title> +<summary>AJAX Feed API</summary> +<content type='application/atom+xml;type=feed' src='http://gdata.youtube.com/feeds/api/playlists/CF46C525B4C90C17?v=2'/> +<link rel='related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/googledevelopers?v=2'/> +<link rel='alternate' type='text/html' href='http://www.youtube.com/view_play_list?p=CF46C525B4C90C17'/> +<link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/GoogleDevelopers/playlists/CF46C525B4C90C17?v=2'/> +<author> +<name>GoogleDevelopers</name> +<uri>http://gdata.youtube.com/feeds/api/users/googledevelopers</uri> +</author> +<yt:playlistId>CF46C525B4C90C17</yt:playlistId> +<yt:countHint>2</yt:countHint> +</entry> +<entry gd:etag='W/"DEEMR347eCp7ImA9WxRaEEU."'> +<id>tag:youtube.com,2008:user:GoogleDevelopers:playlist:5F0F046F77B7B62A</id> +<published>2007-11-02T15:29:38.000Z</published> +<updated>2008-12-12T12:58:06.000Z</updated> +<category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#playlistLink'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='opensocial'/> +<title>OpenSocial</title> +<summary>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.</summary> +<content type='application/atom+xml;type=feed' src='http://gdata.youtube.com/feeds/api/playlists/5F0F046F77B7B62A?v=2'/> +<link rel='related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/googledevelopers?v=2'/> +<link rel='alternate' type='text/html' href='http://www.youtube.com/view_play_list?p=5F0F046F77B7B62A'/> +<link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/GoogleDevelopers/playlists/5F0F046F77B7B62A?v=2'/> +<author> +<name>GoogleDevelopers</name> +<uri>http://gdata.youtube.com/feeds/api/users/googledevelopers</uri> +</author> +<yt:playlistId>5F0F046F77B7B62A</yt:playlistId> +<yt:countHint>48</yt:countHint> +</entry> +<entry gd:etag='W/"AkUAQH47eCp7ImA9WxRaEU0."'> +<id>tag:youtube.com,2008:user:GoogleDevelopers:playlist:586D322B5E2764CF</id> +<published>2007-11-13T19:41:21.000Z</published> +<updated>2008-12-12T18:57:21.000Z</updated> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='phone'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='alliance'/> +<category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#playlistLink'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='handset'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='android'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='developers'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='mobile'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='google'/> +<title>Android</title> +<summary>Demos and tutorials about the new Android platform.</summary> +<content type='application/atom+xml;type=feed' src='http://gdata.youtube.com/feeds/api/playlists/586D322B5E2764CF?v=2'/> +<link rel='related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/googledevelopers?v=2'/> +<link rel='alternate' type='text/html' href='http://www.youtube.com/view_play_list?p=586D322B5E2764CF'/> +<link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/GoogleDevelopers/playlists/586D322B5E2764CF?v=2'/> +<author> +<name>GoogleDevelopers</name> +<uri>http://gdata.youtube.com/feeds/api/users/googledevelopers</uri> +</author> +<yt:playlistId>586D322B5E2764CF</yt:playlistId> +<yt:countHint>32</yt:countHint> +</entry> +<entry gd:etag='W/"DUEDQ347eCp7ImA9WxRaEU0."'> +<id>tag:youtube.com,2008:user:GoogleDevelopers:playlist:8B1C566EDD2DCB77</id> +<published>2007-11-28T21:45:37.000Z</published> +<updated>2008-12-12T18:47:52.000Z</updated> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='Repor'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='Ning'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='E-junkie'/> +<category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#playlistLink'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='Flixster'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='Plaxo'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='Bleacher'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='iLike'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='Qloud'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='FotoFlexer'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='interviews'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='LinkedIn'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='Hi5'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='opensocial'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='Shelfari'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='Chronus'/> +<title>OpenSocial Interviews</title> +<summary>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!</summary> +<content type='application/atom+xml;type=feed' src='http://gdata.youtube.com/feeds/api/playlists/8B1C566EDD2DCB77?v=2'/> +<link rel='related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/googledevelopers?v=2'/> +<link rel='alternate' type='text/html' href='http://www.youtube.com/view_play_list?p=8B1C566EDD2DCB77'/> +<link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/GoogleDevelopers/playlists/8B1C566EDD2DCB77?v=2'/> +<author> +<name>GoogleDevelopers</name> +<uri>http://gdata.youtube.com/feeds/api/users/googledevelopers</uri> +</author> +<yt:playlistId>8B1C566EDD2DCB77</yt:playlistId> +<yt:countHint>16</yt:countHint> +</entry> +<entry gd:etag='W/"DUAFR347eCp7ImA9WxRaEU0."'> +<id>tag:youtube.com,2008:user:GoogleDevelopers:playlist:8F1A9670BA923DF3</id> +<published>2007-12-04T18:07:07.000Z</published> +<updated>2008-12-12T18:48:36.000Z</updated> +<category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#playlistLink'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='googlemac'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='opensource'/> +<category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='google'/> +<title>Google Mac</title> +<summary>Content related to Google Mac development, including the Google Mac Playground.</summary> +<content type='application/atom+xml;type=feed' src='http://gdata.youtube.com/feeds/api/playlists/8F1A9670BA923DF3?v=2'/> +<link rel='related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/googledevelopers?v=2'/> +<link rel='alternate' type='text/html' href='http://www.youtube.com/view_play_list?p=8F1A9670BA923DF3'/> +<link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/GoogleDevelopers/playlists/8F1A9670BA923DF3?v=2'/> +<author> +<name>GoogleDevelopers</name> +<uri>http://gdata.youtube.com/feeds/api/users/googledevelopers</uri> +</author> +<yt:playlistId>8F1A9670BA923DF3</yt:playlistId> +<yt:countHint>3</yt:countHint> +</entry> +</feed>
\ 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 @@ +<?xml version='1.0' encoding='UTF-8'?> +<feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/' xmlns:gml='http://www.opengis.net/gml' xmlns:georss='http://www.georss.org/georss' xmlns:media='http://search.yahoo.com/mrss/' xmlns:batch='http://schemas.google.com/gdata/batch' xmlns:yt='http://gdata.youtube.com/schemas/2007' xmlns:gd='http://schemas.google.com/g/2005' gd:etag='W/"C0AERX47eCp7ImA9WxRaEUw."'> + <id>tag:youtube.com,2008:playlist:CCAE880913CAFE9B</id> + <updated>2008-12-12T19:55:04.000Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#playlist'/> + <category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='adsense'/> + <category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='advertising'/> + <category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='ads'/> + <category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' term='google'/> + <title>AdSense APIs</title> + <subtitle>Content related to our ad APIs</subtitle> + <logo>http://www.youtube.com/img/pic_youtubelogo_123x63.gif</logo> + <link rel='alternate' type='text/html' href='http://www.youtube.com/view_play_list?p=CCAE880913CAFE9B'/> + <link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/playlists/CCAE880913CAFE9B?v=2'/> + <link rel='http://schemas.google.com/g/2005#batch' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/playlists/CCAE880913CAFE9B/batch?v=2'/><link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/playlists/CCAE880913CAFE9B?start-index=1&max-results=25&v=2'/> + <link rel='service' type='application/atomsvc+xml' href='http://gdata.youtube.com/feeds/api/playlists/CCAE880913CAFE9B?alt=atom-service&v=2'/> + <author><name>GoogleDevelopers</name><uri>http://gdata.youtube.com/feeds/api/users/googledevelopers</uri></author> + <generator version='2.0' uri='http://gdata.youtube.com/'>YouTube data API</generator> + <openSearch:totalResults>1</openSearch:totalResults> + <openSearch:startIndex>1</openSearch:startIndex> + <openSearch:itemsPerPage>25</openSearch:itemsPerPage> + <yt:playlistId>CCAE880913CAFE9B</yt:playlistId> + <media:group> + <media:title type='plain'>AdSense APIs</media:title> + <media:description type='plain'>Content related to our ad APIs</media:description> + <media:content url='http://www.youtube.com/ep.swf?id=CCAE880913CAFE9B' type='application/x-shockwave-flash' yt:format='5'/> + </media:group> + <entry gd:etag='W/"C0ADSHg4fSp7ImA9WxRaEUw."'> + <id>tag:youtube.com,2008:playlist:CCAE880913CAFE9B:C63BCCC84EBE64BD</id> + <updated>2008-12-12T19:56:19.635Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#playlist'/> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='adsense'/> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='google'/> + <category scheme='http://gdata.youtube.com/schemas/2007/categories.cat' term='Howto' label='Howto & Style'/> + <title>Google Developer Day - Brazil - AdSense</title> + <link rel='alternate' type='text/html' href='http://www.youtube.com/watch?v=RTQDqPtErB0'/> + <link rel='http://gdata.youtube.com/schemas/2007#video.responses' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos/RTQDqPtErB0/responses?v=2'/> + <link rel='http://gdata.youtube.com/schemas/2007#video.related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos/RTQDqPtErB0/related?v=2'/> + <link rel='related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos/RTQDqPtErB0?v=2'/> + <link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/playlists/CCAE880913CAFE9B/C63BCCC84EBE64BD?v=2'/> + <author><name>GoogleDevelopers</name><uri>http://gdata.youtube.com/feeds/api/users/googledevelopers</uri></author> + <media:group> + <media:title type='plain'>Google Developer Day - Brazil - AdSense</media:title> + <media:description type='plain'>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.</media:description> + <media:keywords>adsense, google</media:keywords> + <yt:duration seconds='1491'/> + <yt:videoid>RTQDqPtErB0</yt:videoid> + <yt:uploaded>2007-06-01T14:33:00.000Z</yt:uploaded> + <media:player url='http://www.youtube.com/watch?v=RTQDqPtErB0'/> + <media:credit role='uploader' scheme='urn:youtube'>GoogleDeveloperDay</media:credit> + <media:category label='Howto & Style' scheme='http://gdata.youtube.com/schemas/2007/categories.cat'>Howto</media:category> + <media:content url='http://www.youtube.com/v/RTQDqPtErB0&f=gdata_playlists' type='application/x-shockwave-flash' medium='video' isDefault='true' expression='full' duration='1491' yt:format='5'/> + <media:content url='rtsp://rtsp2.youtube.com/CisLENy73wIaIgkdrET7qAM0RRMYDSANFEgGUg9nZGF0YV9wbGF5bGlzdHMM/0/0/0/video.3gp' type='video/3gpp' medium='video' expression='full' duration='1491' yt:format='1'/> + <media:thumbnail url='http://i.ytimg.com/vi/RTQDqPtErB0/2.jpg' height='97' width='130' time='00:12:25.500'/> + <media:thumbnail url='http://i.ytimg.com/vi/RTQDqPtErB0/1.jpg' height='97' width='130' time='00:06:12.750'/> + <media:thumbnail url='http://i.ytimg.com/vi/RTQDqPtErB0/3.jpg' height='97' width='130' time='00:18:38.250'/> + <media:thumbnail url='http://i.ytimg.com/vi/RTQDqPtErB0/hqdefault.jpg' height='360' width='480'/> + </media:group> + <yt:statistics viewCount='7390' favoriteCount='63'/> + <gd:rating min='1' max='5' numRaters='23' average='4.30'/> + <gd:comments> + <gd:feedLink href='http://gdata.youtube.com/feeds/api/videos/RTQDqPtErB0/comments?v=2' countHint='10'/> + </gd:comments> + <yt:position>1</yt:position> + </entry> +</feed>
\ 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 @@ +<?xml version='1.0' encoding='utf-8'?> +<entry xmlns='http://www.w3.org/2005/Atom' +xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' +xmlns:media='http://search.yahoo.com/mrss/' +xmlns:gd='http://schemas.google.com/g/2005' +xmlns:yt='http://gdata.youtube.com/schemas/2007'> + <id> + http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/efb9b9a8dd4c2b21</id> + <updated>2007-09-20T22:56:57.061Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#playlist' /> + <title type='text'>"Crazy (Gnarles Barkley)" - Acoustic Cover</title> + <content type='html'><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></content> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/watch?v=UMFI1hdm96E' /> + <link rel='http://gdata.youtube.com/schemas/2007#video.responses' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/UMFI1hdm96E/responses' /> + <link rel='http://gdata.youtube.com/schemas/2007#video.related' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/UMFI1hdm96E/related' /> + <link rel='related' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/UMFI1hdm96E' /> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/efb9b9a8dd4c2b21' /> + <author> + <name>davidchoimusic</name> + <uri> + http://gdata.youtube.com/feeds/users/davidchoimusic</uri> + </author> + <media:group> + <media:title type='plain'>"Crazy (Gnarles Barkley)" - Acoustic Cover</media:title> + <media:description type='plain'>Gnarles Barkley acoustic cover http://www.myspace.com/davidchoimusic</media:description> + <media:keywords>music, singing, gnarls, barkley, acoustic, cover</media:keywords> + <yt:duration seconds='255' /> + <media:category label='Music' + scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> + Music</media:category> + <media:content url='http://www.youtube.com/v/UMFI1hdm96E' + type='application/x-shockwave-flash' medium='video' + isDefault='true' expression='full' duration='255' + yt:format='5' /> + <media:player url='http://www.youtube.com/watch?v=UMFI1hdm96E' /> + <media:thumbnail url='http://img.youtube.com/vi/UMFI1hdm96E/2.jpg' + height='97' width='130' time='00:02:07.500' /> + <media:thumbnail url='http://img.youtube.com/vi/UMFI1hdm96E/1.jpg' + height='97' width='130' time='00:01:03.750' /> + <media:thumbnail url='http://img.youtube.com/vi/UMFI1hdm96E/3.jpg' + height='97' width='130' time='00:03:11.250' /> + <media:thumbnail url='http://img.youtube.com/vi/UMFI1hdm96E/0.jpg' + height='240' width='320' time='00:02:07.500' /> + </media:group> + <yt:statistics viewCount='113321' /> + <gd:rating min='1' max='5' numRaters='1005' average='4.77' /> + <gd:comments> + <gd:feedLink href='http://gdata.youtube.com/feeds/videos/UMFI1hdm96E/comments' /> + </gd:comments> + <yt:position>1</yt:position> +</entry> 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 @@ +<?xml version='1.0' encoding='utf-8'?> +<entry xmlns='http://www.w3.org/2005/Atom' +xmlns:gml='http://www.opengis.net/gml' +xmlns:georss='http://www.georss.org/georss' +xmlns:media='http://search.yahoo.com/mrss/' +xmlns:batch='http://schemas.google.com/gdata/batch' +xmlns:yt='http://gdata.youtube.com/schemas/2007' +xmlns:gd='http://schemas.google.com/g/2005' +gd:etag='W/"CEQGQno4fCp7ImA9WxRaFEg."'> +<id> +tag:youtube.com,2008:playlist:4E6265CEF8BAA793:579617126485907C</id> +<updated>2008-12-16T18:32:03.434Z</updated> +<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' +term='dynamite' /> +<category scheme='http://gdata.youtube.com/schemas/2007/categories.cat' +term='News' label='News & Politics' /> +<category scheme='http://schemas.google.com/g/2005#kind' +term='http://gdata.youtube.com/schemas/2007#playlist' /> +<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' +term='police' /> +<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' +term='paris' /> +<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' +term='explosives' /> +<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' +term='find' /> +<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' +term='france' /> +<title>Paris Police Find Dynamite in Department Store</title> +<link rel='alternate' type='text/html' +href='http://www.youtube.com/watch?v=Lur391T5ApY' /> +<link rel='http://gdata.youtube.com/schemas/2007#video.responses' +type='application/atom+xml' +href='http://gdata.youtube.com/feeds/api/videos/Lur391T5ApY/responses?v=2' /> +<link rel='http://gdata.youtube.com/schemas/2007#video.related' +type='application/atom+xml' +href='http://gdata.youtube.com/feeds/api/videos/Lur391T5ApY/related?v=2' /> +<link rel='http://gdata.youtube.com/schemas/2007#mobile' +type='text/html' +href='http://m.youtube.com/details?v=Lur391T5ApY' /> +<link rel='related' type='application/atom+xml' +href='http://gdata.youtube.com/feeds/api/videos/Lur391T5ApY?v=2' /> +<link rel='self' type='application/atom+xml' +href='http://gdata.youtube.com/feeds/api/playlists/4E6265CEF8BAA793/579617126485907C?v=2' /> +<author> +<name>zfgdata</name> +<uri>http://gdata.youtube.com/feeds/api/users/zfgdata</uri> +</author> +<media:group> +<media:title type='plain'>Paris Police Find</media:title> +<media:description type='plain'>French police found.</media:description> +<media:keywords>department, dynamite, explosives, find</media:keywords> +<yt:duration seconds='67' /> +<yt:videoid>Lur391T5ApY</yt:videoid> +<yt:uploaded>2008-12-16T17:01:42.000Z</yt:uploaded> +<media:player url='http://www.youtube.com/watch?v=Lur391T5ApY' /> +<media:credit role='uploader' scheme='urn:youtube' +yt:type='partner'>AssociatedPress</media:credit> +<media:category label='News & Politics' +scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> +News</media:category> +<media:content url='http://www.youtube.com/v/Lur391T5ApY&f=gdata_playlists' +type='application/x-shockwave-flash' medium='video' +isDefault='true' expression='full' duration='67' yt:format='5' /> +<media:content url='rtsp://rtsp2.youtube.com/CisLENy73wIaIgmWAvlU9_fqLhMYDSANFEgGUg9nZGF0YV9wbGF5bGlzdHMM/0/0/0/video.3gp' +type='video/3gpp' medium='video' expression='full' duration='67' +yt:format='1' /> +<media:content url='rtsp://rtsp2.youtube.com/CisLENy73wIaIgmWAvlU9_fqLhMYESARFEgGUg9nZGF0YV9wbGF5bGlzdHMM/0/0/0/video.3gp' +type='video/3gpp' medium='video' expression='full' duration='67' +yt:format='6' /> +<media:thumbnail url='http://i.ytimg.com/vi/Lur391T5ApY/2.jpg' +height='97' width='130' time='00:00:33.500' /> +<media:thumbnail url='http://i.ytimg.com/vi/Lur391T5ApY/1.jpg' +height='97' width='130' time='00:00:16.750' /> +<media:thumbnail url='http://i.ytimg.com/vi/Lur391T5ApY/3.jpg' +height='97' width='130' time='00:00:50.250' /> +<media:thumbnail url='http://i.ytimg.com/vi/Lur391T5ApY/hqdefault.jpg' +height='360' width='480' /> +</media:group> +<yt:statistics viewCount='271' favoriteCount='1' /> +<gd:rating min='1' max='5' numRaters='5' average='4.20' /> +<yt:location>New York, NY</yt:location> +<yt:recorded>2008-12-16</yt:recorded> +<gd:comments> +<gd:feedLink href='http://gdata.youtube.com/feeds/api/videos/Lur391T5ApY/comments?v=2' +countHint='4' /> +</gd:comments> +<yt:position>1</yt:position> +</entry>
\ 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 @@ +<?xml version='1.0' encoding='utf-8'?> +<feed xmlns='http://www.w3.org/2005/Atom' +xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' +xmlns:media='http://search.yahoo.com/mrss/' +xmlns:gd='http://schemas.google.com/g/2005' +xmlns:yt='http://gdata.youtube.com/schemas/2007'> + <id> + http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7</id> + <updated>2007-09-20T13:42:19.000-07:00</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#playlist' /> + <category scheme='http://gdata.youtube.com/schemas/2007/tags.cat' + term='music' /> + <title type='text'>YouTube Musicians</title> + <subtitle type='text'>Music from talented people on YouTube.</subtitle> + <logo> + http://www.youtube.com/img/pic_youtubelogo_123x63.gif</logo> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/view_play_list?p=46A2F8C9B36B6FE7' /> + <link rel='http://schemas.google.com/g/2005#feed' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7' /> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7?start-index=1&max-results=25' /> + <author> + <name>testuser</name> + <uri>http://gdata.youtube.com/feeds/users/testuser</uri> + </author> + <generator version='beta' uri='http://gdata.youtube.com/'>YouTube + data API</generator> + <openSearch:totalResults>13</openSearch:totalResults> + <openSearch:startIndex>1</openSearch:startIndex> + <openSearch:itemsPerPage>25</openSearch:itemsPerPage> + <entry> + <id> + http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/efb9b9a8dd4c2b21</id> + <updated>2007-09-20T22:56:57.061Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#playlist' /> + <title type='text'>"Crazy (Gnarles Barkley)" - Acoustic + Cover</title> + <content type='html'><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></content> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/watch?v=UMFI1hdm96E' /> + <link rel='http://gdata.youtube.com/schemas/2007#video.responses' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/UMFI1hdm96E/responses' /> + <link rel='http://gdata.youtube.com/schemas/2007#video.related' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/UMFI1hdm96E/related' /> + <link rel='related' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/UMFI1hdm96E' /> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/efb9b9a8dd4c2b21' /> + <author> + <name>davidchoimusic</name> + <uri> + http://gdata.youtube.com/feeds/users/davidchoimusic</uri> + </author> + <media:group> + <media:title type='plain'>"Crazy (Gnarles Barkley)" - + Acoustic Cover</media:title> + <media:description type='plain'>Gnarles Barkley acoustic + cover + http://www.myspace.com/davidchoimusic</media:description> + <media:keywords>music, singing, gnarls, barkley, acoustic, + cover</media:keywords> + <yt:duration seconds='255' /> + <media:category label='Music' + scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> + Music</media:category> + <media:content url='http://www.youtube.com/v/UMFI1hdm96E' + type='application/x-shockwave-flash' medium='video' + isDefault='true' expression='full' duration='255' + yt:format='5' /> + <media:player url='http://www.youtube.com/watch?v=UMFI1hdm96E' /> + <media:thumbnail url='http://img.youtube.com/vi/UMFI1hdm96E/2.jpg' + height='97' width='130' time='00:02:07.500' /> + <media:thumbnail url='http://img.youtube.com/vi/UMFI1hdm96E/1.jpg' + height='97' width='130' time='00:01:03.750' /> + <media:thumbnail url='http://img.youtube.com/vi/UMFI1hdm96E/3.jpg' + height='97' width='130' time='00:03:11.250' /> + <media:thumbnail url='http://img.youtube.com/vi/UMFI1hdm96E/0.jpg' + height='240' width='320' time='00:02:07.500' /> + </media:group> + <yt:statistics viewCount='113321' /> + <gd:rating min='1' max='5' numRaters='1005' average='4.77' /> + <gd:comments> + <gd:feedLink href='http://gdata.youtube.com/feeds/videos/UMFI1hdm96E/comments' /> + </gd:comments> + <yt:position>1</yt:position> + </entry> + <entry> + <id> + http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/c9d8e923d586c337</id> + <updated>2007-09-20T22:56:57.061Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#playlist' /> + <title type='text'>gnals barkley</title> + <content type='html'><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></content> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/watch?v=waQuw1P7VU8' /> + <link rel='http://gdata.youtube.com/schemas/2007#video.responses' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/waQuw1P7VU8/responses' /> + <link rel='http://gdata.youtube.com/schemas/2007#video.related' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/waQuw1P7VU8/related' /> + <link rel='related' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/waQuw1P7VU8' /> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/c9d8e923d586c337' /> + <author> + <name>esmeedenters</name> + <uri>http://gdata.youtube.com/feeds/users/esmeedenters</uri> + </author> + <media:group> + <media:title type='plain'>gnals barkley</media:title> + <media:description type='plain'>Me singing Crazy by gnarls + barkley</media:description> + <media:keywords>music, singing, gnarls, + barkley</media:keywords> + <yt:duration seconds='179' /> + <media:category label='Music' + scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> + Music</media:category> + <media:content url='http://www.youtube.com/v/waQuw1P7VU8' + type='application/x-shockwave-flash' medium='video' + isDefault='true' expression='full' duration='179' + yt:format='5' /> + <media:player url='http://www.youtube.com/watch?v=waQuw1P7VU8' /> + <media:thumbnail url='http://img.youtube.com/vi/waQuw1P7VU8/2.jpg' + height='97' width='130' time='00:01:29.500' /> + <media:thumbnail url='http://img.youtube.com/vi/waQuw1P7VU8/1.jpg' + height='97' width='130' time='00:00:44.750' /> + <media:thumbnail url='http://img.youtube.com/vi/waQuw1P7VU8/3.jpg' + height='97' width='130' time='00:02:14.250' /> + <media:thumbnail url='http://img.youtube.com/vi/waQuw1P7VU8/0.jpg' + height='240' width='320' time='00:01:29.500' /> + </media:group> + <yt:statistics viewCount='219224' /> + <gd:rating min='1' max='5' numRaters='1753' average='4.73' /> + <gd:comments> + <gd:feedLink href='http://gdata.youtube.com/feeds/videos/waQuw1P7VU8/comments' /> + </gd:comments> + <yt:position>2</yt:position> + </entry> + <entry> + <id> + http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/8574b0cf3b5045b9</id> + <updated>2007-09-20T22:56:57.061Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#playlist' /> + <title type='text'>Can't take my eyes off of you</title> + <content type='html'><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></content> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/watch?v=xjidkN6kleU' /> + <link rel='http://gdata.youtube.com/schemas/2007#video.responses' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/xjidkN6kleU/responses' /> + <link rel='http://gdata.youtube.com/schemas/2007#video.related' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/xjidkN6kleU/related' /> + <link rel='related' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/xjidkN6kleU' /> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/8574b0cf3b5045b9' /> + <author> + <name>munilicious</name> + <uri>http://gdata.youtube.com/feeds/users/munilicious</uri> + </author> + <media:group> + <media:title type='plain'>Can't take my eyes off of + you</media:title> + <media:description type='plain'>Lauryn Hill Cover - Can't + take my eyes off of you. my way--- a good + way?</media:description> + <media:keywords>Lauryn, Hill, Can't, take, my, eyes, off, of, + you</media:keywords> + <yt:duration seconds='138' /> + <media:category label='Music' + scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> + Music</media:category> + <media:player url='http://www.youtube.com/watch?v=xjidkN6kleU' /> + <media:thumbnail url='http://img.youtube.com/vi/xjidkN6kleU/2.jpg' + height='97' width='130' time='00:01:09' /> + <media:thumbnail url='http://img.youtube.com/vi/xjidkN6kleU/1.jpg' + height='97' width='130' time='00:00:34.500' /> + <media:thumbnail url='http://img.youtube.com/vi/xjidkN6kleU/3.jpg' + height='97' width='130' time='00:01:43.500' /> + <media:thumbnail url='http://img.youtube.com/vi/xjidkN6kleU/0.jpg' + height='240' width='320' time='00:01:09' /> + </media:group> + <yt:statistics viewCount='12968' /> + <yt:noembed /> + <gd:rating min='1' max='5' numRaters='34' average='3.85' /> + <gd:comments> + <gd:feedLink href='http://gdata.youtube.com/feeds/videos/xjidkN6kleU/comments' /> + </gd:comments> + <yt:position>3</yt:position> + </entry> + <entry> + <id> + http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/6d42a26a97a53c78</id> + <updated>2007-09-20T22:56:57.062Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#playlist' /> + <title type='text'>hanging by a moment (cover)</title> + <content type='html'><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></content> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/watch?v=MOxExzhhW0c' /> + <link rel='http://gdata.youtube.com/schemas/2007#video.responses' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/MOxExzhhW0c/responses' /> + <link rel='http://gdata.youtube.com/schemas/2007#video.related' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/MOxExzhhW0c/related' /> + <link rel='related' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/MOxExzhhW0c' /> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/6d42a26a97a53c78' /> + <author> + <name>lauwarm</name> + <uri>http://gdata.youtube.com/feeds/users/lauwarm</uri> + </author> + <media:group> + <media:title type='plain'>hanging by a moment + (cover)</media:title> + <media:description type='plain'>my sister(guitar) and me + jamming lifehouse</media:description> + <media:keywords>lifehouse, hanging, by, moment, cover, + acoustic</media:keywords> + <yt:duration seconds='30' /> + <media:category label='Music' + scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> + Music</media:category> + <media:content url='http://www.youtube.com/v/MOxExzhhW0c' + type='application/x-shockwave-flash' medium='video' + isDefault='true' expression='full' duration='30' + yt:format='5' /> + <media:player url='http://www.youtube.com/watch?v=MOxExzhhW0c' /> + <media:thumbnail url='http://img.youtube.com/vi/MOxExzhhW0c/2.jpg' + height='97' width='130' time='00:00:15' /> + <media:thumbnail url='http://img.youtube.com/vi/MOxExzhhW0c/1.jpg' + height='97' width='130' time='00:00:07.500' /> + <media:thumbnail url='http://img.youtube.com/vi/MOxExzhhW0c/3.jpg' + height='97' width='130' time='00:00:22.500' /> + <media:thumbnail url='http://img.youtube.com/vi/MOxExzhhW0c/0.jpg' + height='240' width='320' time='00:00:15' /> + </media:group> + <yt:statistics viewCount='7186' /> + <gd:rating min='1' max='5' numRaters='24' average='4.21' /> + <gd:comments> + <gd:feedLink href='http://gdata.youtube.com/feeds/videos/MOxExzhhW0c/comments' /> + </gd:comments> + <yt:position>4</yt:position> + </entry> + <entry> + <id> + http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/f78779d50b24db79</id> + <updated>2007-09-20T22:56:57.062Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#playlist' /> + <title type='text'>I'LL BE-MEN'S OCTET (ACAPELLA)</title> + <content type='html'><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></content> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/watch?v=_KHqQc1nn_0' /> + <link rel='http://gdata.youtube.com/schemas/2007#video.responses' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/_KHqQc1nn_0/responses' /> + <link rel='http://gdata.youtube.com/schemas/2007#video.related' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/_KHqQc1nn_0/related' /> + <link rel='related' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/_KHqQc1nn_0' /> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/f78779d50b24db79' /> + <author> + <name>boredom</name> + <uri>http://gdata.youtube.com/feeds/users/boredom</uri> + </author> + <media:group> + <media:title type='plain'>I'LL BE-MEN'S OCTET + (ACAPELLA)</media:title> + <media:description type='plain'>UC BERKELEY'S MEN'S OCTET + (ACAPELLA)</media:description> + <media:keywords>ACAPELLA, berkeley, octet</media:keywords> + <yt:duration seconds='246' /> + <media:category label='Music' + scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> + Music</media:category> + <media:content url='http://www.youtube.com/v/_KHqQc1nn_0' + type='application/x-shockwave-flash' medium='video' + isDefault='true' expression='full' duration='246' + yt:format='5' /> + <media:player url='http://www.youtube.com/watch?v=_KHqQc1nn_0' /> + <media:thumbnail url='http://img.youtube.com/vi/_KHqQc1nn_0/2.jpg' + height='97' width='130' time='00:02:03' /> + <media:thumbnail url='http://img.youtube.com/vi/_KHqQc1nn_0/1.jpg' + height='97' width='130' time='00:01:01.500' /> + <media:thumbnail url='http://img.youtube.com/vi/_KHqQc1nn_0/3.jpg' + height='97' width='130' time='00:03:04.500' /> + <media:thumbnail url='http://img.youtube.com/vi/_KHqQc1nn_0/0.jpg' + height='240' width='320' time='00:02:03' /> + </media:group> + <yt:statistics viewCount='46416' /> + <gd:rating min='1' max='5' numRaters='116' average='4.65' /> + <gd:comments> + <gd:feedLink href='http://gdata.youtube.com/feeds/videos/_KHqQc1nn_0/comments' /> + </gd:comments> + <yt:position>5</yt:position> + </entry> + <entry> + <id> + http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/d5fead6a034eb51c</id> + <updated>2007-09-20T22:56:57.062Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#playlist' /> + <title type='text'>Kiss the Girl</title> + <content type='html'><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></content> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/watch?v=EV1_qPBuDt8' /> + <link rel='http://gdata.youtube.com/schemas/2007#video.responses' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/EV1_qPBuDt8/responses' /> + <link rel='http://gdata.youtube.com/schemas/2007#video.related' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/EV1_qPBuDt8/related' /> + <link rel='related' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/EV1_qPBuDt8' /> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/d5fead6a034eb51c' /> + <author> + <name>cmorris</name> + <uri>http://gdata.youtube.com/feeds/users/cmorris</uri> + </author> + <media:group> + <media:title type='plain'>Kiss the Girl</media:title> + <media:description type='plain'>Alma College's Scots on the + Rocks sing their acapella rendition of Kiss the Girl from the + Little Mermaid</media:description> + <media:keywords>acapella</media:keywords> + <yt:duration seconds='196' /> + <media:category label='Music' + scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> + Music</media:category> + <media:content url='http://www.youtube.com/v/EV1_qPBuDt8' + type='application/x-shockwave-flash' medium='video' + isDefault='true' expression='full' duration='196' + yt:format='5' /> + <media:player url='http://www.youtube.com/watch?v=EV1_qPBuDt8' /> + <media:thumbnail url='http://img.youtube.com/vi/EV1_qPBuDt8/2.jpg' + height='97' width='130' time='00:01:38' /> + <media:thumbnail url='http://img.youtube.com/vi/EV1_qPBuDt8/1.jpg' + height='97' width='130' time='00:00:49' /> + <media:thumbnail url='http://img.youtube.com/vi/EV1_qPBuDt8/3.jpg' + height='97' width='130' time='00:02:27' /> + <media:thumbnail url='http://img.youtube.com/vi/EV1_qPBuDt8/0.jpg' + height='240' width='320' time='00:01:38' /> + </media:group> + <yt:statistics viewCount='37218' /> + <gd:rating min='1' max='5' numRaters='312' average='4.77' /> + <gd:comments> + <gd:feedLink href='http://gdata.youtube.com/feeds/videos/EV1_qPBuDt8/comments' /> + </gd:comments> + <yt:position>6</yt:position> + </entry> + <entry> + <id> + http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/618d7dba982c0d7e</id> + <updated>2007-09-20T22:56:57.063Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#playlist' /> + <title type='text'>Oasis "Wonderwall" Acoustic Cover by + ortoPilot</title> + <content type='html'><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></content> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/watch?v=t4EaHIpjTTY' /> + <link rel='http://gdata.youtube.com/schemas/2007#video.responses' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/t4EaHIpjTTY/responses' /> + <link rel='http://gdata.youtube.com/schemas/2007#video.related' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/t4EaHIpjTTY/related' /> + <link rel='related' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/t4EaHIpjTTY' /> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/618d7dba982c0d7e' /> + <author> + <name>ortoPilot</name> + <uri>http://gdata.youtube.com/feeds/users/ortoPilot</uri> + </author> + <media:group> + <media:title type='plain'>Oasis "Wonderwall" Acoustic Cover + by ortoPilot</media:title> + <media:description type='plain'>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!</media:description> + <media:keywords>acoustic, guitar, cover, oasis, wonderwall, + ortopilot, matt, hutchison, live, tab, tabs, + tutorial</media:keywords> + <yt:duration seconds='241' /> + <media:category label='Music' + scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> + Music</media:category> + <media:content url='http://www.youtube.com/v/t4EaHIpjTTY' + type='application/x-shockwave-flash' medium='video' + isDefault='true' expression='full' duration='241' + yt:format='5' /> + <media:player url='http://www.youtube.com/watch?v=t4EaHIpjTTY' /> + <media:thumbnail url='http://img.youtube.com/vi/t4EaHIpjTTY/2.jpg' + height='97' width='130' time='00:02:00.500' /> + <media:thumbnail url='http://img.youtube.com/vi/t4EaHIpjTTY/1.jpg' + height='97' width='130' time='00:01:00.250' /> + <media:thumbnail url='http://img.youtube.com/vi/t4EaHIpjTTY/3.jpg' + height='97' width='130' time='00:03:00.750' /> + <media:thumbnail url='http://img.youtube.com/vi/t4EaHIpjTTY/0.jpg' + height='240' width='320' time='00:02:00.500' /> + </media:group> + <yt:statistics viewCount='92395' /> + <gd:rating min='1' max='5' numRaters='521' average='4.66' /> + <gd:comments> + <gd:feedLink href='http://gdata.youtube.com/feeds/videos/t4EaHIpjTTY/comments' /> + </gd:comments> + <yt:position>7</yt:position> + </entry> + <entry> + <id> + http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/4bfaab0ffb00dfdd</id> + <updated>2007-09-20T22:56:57.063Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#playlist' /> + <title type='text'>Pancakes!</title> + <content type='html'><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></content> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/watch?v=PnCVZozHTG8' /> + <link rel='http://gdata.youtube.com/schemas/2007#video.responses' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/PnCVZozHTG8/responses' /> + <link rel='http://gdata.youtube.com/schemas/2007#video.related' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/PnCVZozHTG8/related' /> + <link rel='related' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/PnCVZozHTG8' /> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/4bfaab0ffb00dfdd' /> + <author> + <name>GiR2007</name> + <uri>http://gdata.youtube.com/feeds/users/GiR2007</uri> + </author> + <media:group> + <media:title type='plain'>Pancakes!</media:title> + <media:description type='plain'>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.</media:description> + <media:keywords>stop, motion, pancakes, GiR2007, food, tasty, + nutella, jam, maple, syrup, animation, GMA, good, morning, + america, goodmorning</media:keywords> + <yt:duration seconds='142' /> + <media:category label='Film & Animation' + scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> + Film</media:category> + <media:content url='http://www.youtube.com/v/PnCVZozHTG8' + type='application/x-shockwave-flash' medium='video' + isDefault='true' expression='full' duration='142' + yt:format='5' /> + <media:content url='rtsp://rtsp.youtube.com/youtube/videos/PnCVZozHTG8/video.3gp' + type='video/3gpp' medium='video' expression='full' + duration='142' yt:format='1' /> + <media:player url='http://www.youtube.com/watch?v=PnCVZozHTG8' /> + <media:thumbnail url='http://img.youtube.com/vi/PnCVZozHTG8/2.jpg' + height='97' width='130' time='00:01:11' /> + <media:thumbnail url='http://img.youtube.com/vi/PnCVZozHTG8/1.jpg' + height='97' width='130' time='00:00:35.500' /> + <media:thumbnail url='http://img.youtube.com/vi/PnCVZozHTG8/3.jpg' + height='97' width='130' time='00:01:46.500' /> + <media:thumbnail url='http://img.youtube.com/vi/PnCVZozHTG8/0.jpg' + height='240' width='320' time='00:01:11' /> + </media:group> + <yt:statistics viewCount='2249048' /> + <gd:rating min='1' max='5' numRaters='17754' average='4.59' /> + <gd:comments> + <gd:feedLink href='http://gdata.youtube.com/feeds/videos/PnCVZozHTG8/comments' /> + </gd:comments> + <yt:position>8</yt:position> + </entry> + <entry> + <id> + http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/46632a732cae0cbc</id> + <updated>2007-09-20T22:56:57.063Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#playlist' /> + <title type='text'>Ana Free - Chained</title> + <content type='html'><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></content> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/watch?v=_6ceUy9lVdM' /> + <link rel='http://gdata.youtube.com/schemas/2007#video.responses' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/_6ceUy9lVdM/responses' /> + <link rel='http://gdata.youtube.com/schemas/2007#video.related' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/_6ceUy9lVdM/related' /> + <link rel='related' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/_6ceUy9lVdM' /> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/46632a732cae0cbc' /> + <author> + <name>anafree</name> + <uri>http://gdata.youtube.com/feeds/users/anafree</uri> + </author> + <media:group> + <media:title type='plain'>Ana Free - Chained</media:title> + <media:description type='plain'>The second upload of the + day.. :) All is explained in the video, no point in writing + it here! Take care *** Ana</media:description> + <media:keywords>anafree, ana, free, chained, original, + acoustic, love</media:keywords> + <yt:duration seconds='191' /> + <media:category label='Music' + scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> + Music</media:category> + <media:content url='http://www.youtube.com/v/_6ceUy9lVdM' + type='application/x-shockwave-flash' medium='video' + isDefault='true' expression='full' duration='191' + yt:format='5' /> + <media:player url='http://www.youtube.com/watch?v=_6ceUy9lVdM' /> + <media:thumbnail url='http://img.youtube.com/vi/_6ceUy9lVdM/2.jpg' + height='97' width='130' time='00:01:35.500' /> + <media:thumbnail url='http://img.youtube.com/vi/_6ceUy9lVdM/1.jpg' + height='97' width='130' time='00:00:47.750' /> + <media:thumbnail url='http://img.youtube.com/vi/_6ceUy9lVdM/3.jpg' + height='97' width='130' time='00:02:23.250' /> + <media:thumbnail url='http://img.youtube.com/vi/_6ceUy9lVdM/0.jpg' + height='240' width='320' time='00:01:35.500' /> + </media:group> + <yt:statistics viewCount='688963' /> + <gd:rating min='1' max='5' numRaters='4530' average='4.48' /> + <gd:comments> + <gd:feedLink href='http://gdata.youtube.com/feeds/videos/_6ceUy9lVdM/comments' /> + </gd:comments> + <yt:position>9</yt:position> + </entry> + <entry> + <id> + http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/e67d5bf916676e20</id> + <updated>2007-09-20T22:56:57.064Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#playlist' /> + <title type='text'>Ana Free (Bic Runga - Sway</title> + <content type='html'><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></content> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/watch?v=ihQW-pWlkJw' /> + <link rel='http://gdata.youtube.com/schemas/2007#video.responses' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/ihQW-pWlkJw/responses' /> + <link rel='http://gdata.youtube.com/schemas/2007#video.related' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/ihQW-pWlkJw/related' /> + <link rel='related' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/ihQW-pWlkJw' /> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/e67d5bf916676e20' /> + <author> + <name>anafree</name> + <uri>http://gdata.youtube.com/feeds/users/anafree</uri> + </author> + <media:group> + <media:title type='plain'>Ana Free (Bic Runga - + Sway</media:title> + <media:description type='plain'>This is Sway by Bic Runga, + difficult to sing and I guess to play aswell..:) Hope you + enjoy it!</media:description> + <media:keywords>bic, runga, sway, ana, free, anafree, + acoustic, singing</media:keywords> + <yt:duration seconds='204' /> + <media:category label='Music' + scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> + Music</media:category> + <media:content url='http://www.youtube.com/v/ihQW-pWlkJw' + type='application/x-shockwave-flash' medium='video' + isDefault='true' expression='full' duration='204' + yt:format='5' /> + <media:player url='http://www.youtube.com/watch?v=ihQW-pWlkJw' /> + <media:thumbnail url='http://img.youtube.com/vi/ihQW-pWlkJw/2.jpg' + height='97' width='130' time='00:01:42' /> + <media:thumbnail url='http://img.youtube.com/vi/ihQW-pWlkJw/1.jpg' + height='97' width='130' time='00:00:51' /> + <media:thumbnail url='http://img.youtube.com/vi/ihQW-pWlkJw/3.jpg' + height='97' width='130' time='00:02:33' /> + <media:thumbnail url='http://img.youtube.com/vi/ihQW-pWlkJw/0.jpg' + height='240' width='320' time='00:01:42' /> + </media:group> + <yt:statistics viewCount='282936' /> + <gd:rating min='1' max='5' numRaters='2224' average='4.74' /> + <gd:comments> + <gd:feedLink href='http://gdata.youtube.com/feeds/videos/ihQW-pWlkJw/comments' /> + </gd:comments> + <yt:position>10</yt:position> + </entry> + <entry> + <id> + http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/a3011180d79eff53</id> + <updated>2007-09-20T22:56:57.064Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#playlist' /> + <title type='text'>I'm falling in love (u can buy the mp3 at + justinsteere.com)</title> + <content type='html'><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></content> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/watch?v=oXjInYHk2j0' /> + <link rel='http://gdata.youtube.com/schemas/2007#video.responses' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/oXjInYHk2j0/responses' /> + <link rel='http://gdata.youtube.com/schemas/2007#video.related' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/oXjInYHk2j0/related' /> + <link rel='related' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/oXjInYHk2j0' /> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/a3011180d79eff53' /> + <author> + <name>bunetaybaz</name> + <uri>http://gdata.youtube.com/feeds/users/bunetaybaz</uri> + </author> + <media:group> + <media:title type='plain'>I'm falling in love (u can buy the + mp3 at justinsteere.com)</media:title> + <media:description type='plain'>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 :)</media:description> + <media:keywords>justin, steere, jason, mraz, im, yours, dax, + flame, brookers, david, gray, josh, groban, you, and, I, + both, right, kind, of, phrase, better</media:keywords> + <yt:duration seconds='197' /> + <media:category label='Music' + scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> + Music</media:category> + <media:content url='http://www.youtube.com/v/oXjInYHk2j0' + type='application/x-shockwave-flash' medium='video' + isDefault='true' expression='full' duration='197' + yt:format='5' /> + <media:content url='rtsp://rtsp.youtube.com/youtube/videos/oXjInYHk2j0/video.3gp' + type='video/3gpp' medium='video' expression='full' + duration='197' yt:format='1' /> + <media:player url='http://www.youtube.com/watch?v=oXjInYHk2j0' /> + <media:thumbnail url='http://img.youtube.com/vi/oXjInYHk2j0/2.jpg' + height='97' width='130' time='00:01:38.500' /> + <media:thumbnail url='http://img.youtube.com/vi/oXjInYHk2j0/1.jpg' + height='97' width='130' time='00:00:49.250' /> + <media:thumbnail url='http://img.youtube.com/vi/oXjInYHk2j0/3.jpg' + height='97' width='130' time='00:02:27.750' /> + <media:thumbnail url='http://img.youtube.com/vi/oXjInYHk2j0/0.jpg' + height='240' width='320' time='00:01:38.500' /> + </media:group> + <yt:statistics viewCount='653489' /> + <gd:rating min='1' max='5' numRaters='4654' average='4.59' /> + <gd:comments> + <gd:feedLink href='http://gdata.youtube.com/feeds/videos/oXjInYHk2j0/comments' /> + </gd:comments> + <yt:position>11</yt:position> + </entry> + <entry> + <id> + http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/798565c7d1c75453</id> + <updated>2007-09-20T22:56:57.064Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#playlist' /> + <title type='text'>When I Loved You</title> + <content type='html'><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></content> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/watch?v=KjMRf4egAyA' /> + <link rel='http://gdata.youtube.com/schemas/2007#video.responses' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/KjMRf4egAyA/responses' /> + <link rel='http://gdata.youtube.com/schemas/2007#video.related' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/KjMRf4egAyA/related' /> + <link rel='related' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/KjMRf4egAyA' /> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/798565c7d1c75453' /> + <author> + <name>mishalmooremusic</name> + <uri> + http://gdata.youtube.com/feeds/users/mishalmooremusic</uri> + </author> + <media:group> + <media:title type='plain'>When I Loved You</media:title> + <media:description type='plain'>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</media:description> + <media:keywords>mishal, moore, when, i, loved, + you</media:keywords> + <yt:duration seconds='158' /> + <media:category label='Music' + scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> + Music</media:category> + <media:content url='http://www.youtube.com/v/KjMRf4egAyA' + type='application/x-shockwave-flash' medium='video' + isDefault='true' expression='full' duration='158' + yt:format='5' /> + <media:content url='rtsp://rtsp.youtube.com/youtube/videos/KjMRf4egAyA/video.3gp' + type='video/3gpp' medium='video' expression='full' + duration='158' yt:format='1' /> + <media:player url='http://www.youtube.com/watch?v=KjMRf4egAyA' /> + <media:thumbnail url='http://img.youtube.com/vi/KjMRf4egAyA/2.jpg' + height='97' width='130' time='00:01:19' /> + <media:thumbnail url='http://img.youtube.com/vi/KjMRf4egAyA/1.jpg' + height='97' width='130' time='00:00:39.500' /> + <media:thumbnail url='http://img.youtube.com/vi/KjMRf4egAyA/3.jpg' + height='97' width='130' time='00:01:58.500' /> + <media:thumbnail url='http://img.youtube.com/vi/KjMRf4egAyA/0.jpg' + height='240' width='320' time='00:01:19' /> + </media:group> + <yt:statistics viewCount='715030' /> + <gd:rating min='1' max='5' numRaters='2988' average='4.48' /> + <gd:comments> + <gd:feedLink href='http://gdata.youtube.com/feeds/videos/KjMRf4egAyA/comments' /> + </gd:comments> + <yt:position>12</yt:position> + </entry> + <entry> + <id> + http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/2c0c020593e15124</id> + <updated>2007-09-20T22:56:57.065Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#playlist' /> + <title type='text'>CONCEIT- Scissors & Glue ON THE RISE + CONTEST WINNER</title> + <content type='html'><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></content> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/watch?v=R_ruSmFFdAY' /> + <link rel='http://gdata.youtube.com/schemas/2007#video.responses' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/R_ruSmFFdAY/responses' /> + <link rel='http://gdata.youtube.com/schemas/2007#video.related' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/R_ruSmFFdAY/related' /> + <link rel='related' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/R_ruSmFFdAY' /> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/playlists/46A2F8C9B36B6FE7/2c0c020593e15124' /> + <author> + <name>conceit</name> + <uri>http://gdata.youtube.com/feeds/users/conceit</uri> + </author> + <media:group> + <media:title type='plain'>CONCEIT- Scissors & Glue ON THE + RISE CONTEST WINNER</media:title> + <media:description type='plain'>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</media:description> + <media:keywords>rap, music, contest, 50, cent, conceit, sf, + bay, area, ontherise, wasted, talent, gurp, city, machete, + vox</media:keywords> + <yt:duration seconds='142' /> + <media:category label='Music' + scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> + Music</media:category> + <media:content url='http://www.youtube.com/v/R_ruSmFFdAY' + type='application/x-shockwave-flash' medium='video' + isDefault='true' expression='full' duration='142' + yt:format='5' /> + <media:player url='http://www.youtube.com/watch?v=R_ruSmFFdAY' /> + <media:thumbnail url='http://img.youtube.com/vi/R_ruSmFFdAY/2.jpg' + height='97' width='130' time='00:01:11' /> + <media:thumbnail url='http://img.youtube.com/vi/R_ruSmFFdAY/1.jpg' + height='97' width='130' time='00:00:35.500' /> + <media:thumbnail url='http://img.youtube.com/vi/R_ruSmFFdAY/3.jpg' + height='97' width='130' time='00:01:46.500' /> + <media:thumbnail url='http://img.youtube.com/vi/R_ruSmFFdAY/0.jpg' + height='240' width='320' time='00:01:11' /> + </media:group> + <yt:statistics viewCount='188729' /> + <gd:rating min='1' max='5' numRaters='680' average='3.84' /> + <gd:comments> + <gd:feedLink href='http://gdata.youtube.com/feeds/videos/R_ruSmFFdAY/comments' /> + </gd:comments> + <yt:position>13</yt:position> + </entry> +</feed> 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 @@ +<?xml version='1.0' encoding='utf-8'?> +<entry xmlns='http://www.w3.org/2005/Atom' +xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' +xmlns:media='http://search.yahoo.com/mrss/' +xmlns:gd='http://schemas.google.com/g/2005' +xmlns:yt='http://gdata.youtube.com/schemas/2007'> + <id> + http://gdata.youtube.com/feeds/users/testuser/subscriptions/35bbde297dba88db</id> + <published>2007-03-02T11:58:22.000-08:00</published> + <updated>2007-03-02T11:58:22.000-08:00</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#subscription' /> + <category scheme='http://gdata.youtube.com/schemas/2007/subscriptiontypes.cat' + term='publisher' /> + <title type='text'>Videos published by : BBC</title> + <link rel='related' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/users/testuser' /> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/profile_videos?user=BBC' /> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/users/testuser/subscriptions/35bbde297dba88db' /> + <author> + <name>testuser</name> + <uri>http://gdata.youtube.com/feeds/users/testuser</uri> + </author> + <gd:feedLink rel='http://gdata.youtube.com/schemas/2007#user.uploads' + href='http://gdata.youtube.com/feeds/users/BBC/uploads' + countHint='697' /> +</entry> 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 @@ +<?xml version='1.0' encoding='utf-8'?> +<entry xmlns='http://www.w3.org/2005/Atom' +xmlns:media='http://search.yahoo.com/mrss/' +xmlns:batch='http://schemas.google.com/gdata/batch' +xmlns:yt='http://gdata.youtube.com/schemas/2007' +xmlns:gd='http://schemas.google.com/g/2005' +gd:etag='W/"Dk4FRn47eCp7ImA9WB9WEkg."'> +<id> +tag:youtube.com,2008:user:googledevelopers:subscription:Z1Lm-S9gkRQ</id> +<published>2007-11-16T15:15:17.000-08:00</published> +<updated>2007-11-16T15:15:17.000-08:00</updated> +<category scheme='http://gdata.youtube.com/schemas/2007/subscriptiontypes.cat' +term='channel' /> +<category scheme='http://schemas.google.com/g/2005#kind' +term='http://gdata.youtube.com/schemas/2007#subscription' /> +<title>Videos published by : androiddevelopers</title> +<content type='application/atom+xml;type=feed' +src='http://gdata.youtube.com/feeds/api/users/androiddevelopers/uploads?v=2' /> +<link rel='related' type='application/atom+xml' +href='http://gdata.youtube.com/feeds/api/users/googledevelopers?v=2' /> +<link rel='alternate' type='text/html' +href='http://www.youtube.com/profile_videos?user=androiddevelopers' /> +<link rel='self' type='application/atom+xml' +href='http://gdata.youtube.com/feeds/api/users/googledevelopers/subscriptions/Z1Lm-S9gkRQ?v=2' /> +<author> +<name>GoogleDevelopers</name> +<uri> +http://gdata.youtube.com/feeds/api/users/googledevelopers</uri> +</author> +<yt:username>androiddevelopers</yt:username> +<yt:countHint>50</yt:countHint> +<media:thumbnail url='http://i2.ytimg.com/vi/1FJHYqE0RDg/default.jpg' /> +</entry> 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 @@ +<?xml version='1.0' encoding='utf-8'?> +<entry xmlns='http://www.w3.org/2005/Atom' +xmlns:media='http://search.yahoo.com/mrss/' +xmlns:batch='http://schemas.google.com/gdata/batch' +xmlns:yt='http://gdata.youtube.com/schemas/2007' +xmlns:gd='http://schemas.google.com/g/2005' +gd:etag='W/"Dk4FRn47eCp7ImA9WB9WEkg."'> +<id> +tag:youtube.com,2008:user:googledevelopers:subscription:Z1Lm-S9gkRQ</id> +<published>2007-11-16T15:15:17.000-08:00</published> +<updated>2007-11-16T15:15:17.000-08:00</updated> +<category scheme='http://gdata.youtube.com/schemas/2007/subscriptiontypes.cat' +term='channel' /> +<category scheme='http://schemas.google.com/g/2005#kind' +term='http://gdata.youtube.com/schemas/2007#subscription' /> +<title>Videos published by : androiddevelopers</title> +<content type='application/atom+xml;type=feed' +src='http://gdata.youtube.com/feeds/api/users/androiddevelopers/uploads?v=2' /> +<link rel='related' type='application/atom+xml' +href='http://gdata.youtube.com/feeds/api/users/googledevelopers?v=2' /> +<link rel='alternate' type='text/html' +href='http://www.youtube.com/profile_videos?user=androiddevelopers' /> +<link rel='self' type='application/atom+xml' +href='http://gdata.youtube.com/feeds/api/users/googledevelopers/subscriptions/Z1Lm-S9gkRQ?v=2' /> +<author> +<name>GoogleDevelopers</name> +<uri> +http://gdata.youtube.com/feeds/api/users/googledevelopers</uri> +</author> +<yt:username>androiddevelopers</yt:username> +<yt:countHint>50</yt:countHint> +<media:thumbnail url='http://i2.ytimg.com/vi/1FJHYqE0RDg/default.jpg' /> +</entry> 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 @@ +<?xml version='1.0' encoding='utf-8'?> +<entry xmlns='http://www.w3.org/2005/Atom' +xmlns:media='http://search.yahoo.com/mrss/' +xmlns:batch='http://schemas.google.com/gdata/batch' +xmlns:yt='http://gdata.youtube.com/schemas/2007' +xmlns:gd='http://schemas.google.com/g/2005' +gd:etag='W/"C04CR347eCp7ImA9WxRaE0U."'> +<id>tag:youtube.com,2008:user:zfgdata:subscription:S_KBJ3ylYwc</id> +<published>2008-12-15T14:59:26.000-08:00</published> +<updated>2008-12-15T14:59:26.000-08:00</updated> +<category scheme='http://gdata.youtube.com/schemas/2007/subscriptiontypes.cat' +term='favorites' /> +<category scheme='http://schemas.google.com/g/2005#kind' +term='http://gdata.youtube.com/schemas/2007#subscription' /> +<title>Favorites of : NBA</title> +<content type='application/atom+xml;type=feed' +src='http://gdata.youtube.com/feeds/api/users/nba/favorites?v=2' /> +<link rel='related' type='application/atom+xml' +href='http://gdata.youtube.com/feeds/api/users/zfgdata?v=2' /> +<link rel='alternate' type='text/html' +href='http://www.youtube.com/profile_favorites?user=NBA' /> +<link rel='self' type='application/atom+xml' +href='http://gdata.youtube.com/feeds/api/users/zfgdata/subscriptions/S_KBJ3ylYwc?v=2' /> +<author> +<name>zfgdata</name> +<uri>http://gdata.youtube.com/feeds/api/users/zfgdata</uri> +</author> +<yt:username>NBA</yt:username> +<media:thumbnail url='http://i4.ytimg.com/i/WJ2lWNubArHWmf3FIHbfcQ/1.jpg' /> +</entry>
\ 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 @@ +<?xml version='1.0' encoding='utf-8'?> +<entry xmlns='http://www.w3.org/2005/Atom' +xmlns:media='http://search.yahoo.com/mrss/' +xmlns:batch='http://schemas.google.com/gdata/batch' +xmlns:yt='http://gdata.youtube.com/schemas/2007' +xmlns:gd='http://schemas.google.com/g/2005' +gd:etag='W/"DUMHQ347eCp7ImA9WB9TE0k."'> +<id>tag:youtube.com,2008:user:zfgdata:subscription:i_2YXxZb9Zg</id> +<published>2007-09-20T21:03:52.000-07:00</published> +<updated>2007-09-20T21:03:52.000-07:00</updated> +<category scheme='http://gdata.youtube.com/schemas/2007/subscriptiontypes.cat' +term='playlist' /> +<category scheme='http://schemas.google.com/g/2005#kind' +term='http://gdata.youtube.com/schemas/2007#subscription' /> +<title>From Google Engineers</title> +<content type='application/atom+xml;type=feed' +src='http://gdata.youtube.com/feeds/api/playlists/4AE5C0D23C2EB82D?v=2' /> +<link rel='related' type='application/atom+xml' +href='http://gdata.youtube.com/feeds/api/users/zfgdata?v=2' /> +<link rel='alternate' type='text/html' +href='http://www.youtube.com/view_play_list?p=4AE5C0D23C2EB82D' /> +<link rel='self' type='application/atom+xml' +href='http://gdata.youtube.com/feeds/api/users/zfgdata/subscriptions/i_2YXxZb9Zg?v=2' /> +<author> +<name>zfgdata</name> +<uri>http://gdata.youtube.com/feeds/api/users/zfgdata</uri> +</author> +<yt:playlistTitle>From Google Engineers</yt:playlistTitle> +<yt:username>GoogleDevelopers</yt:username> +<yt:playlistId>4AE5C0D23C2EB82D</yt:playlistId> +<media:thumbnail url='http://i3.ytimg.com/vi/zI38Tc9GjSk/default.jpg' /> +</entry>
\ 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 @@ +<?xml version='1.0' encoding='utf-8'?> +<entry xmlns='http://www.w3.org/2005/Atom' +xmlns:media='http://search.yahoo.com/mrss/' +xmlns:batch='http://schemas.google.com/gdata/batch' +xmlns:yt='http://gdata.youtube.com/schemas/2007' +xmlns:gd='http://schemas.google.com/g/2005' +gd:etag='W/"C0QFSH47eCp7ImA9WxRaE0U."'> +<id> +tag:youtube.com,2008:user:zfgdata:subscription:59NG0lkr7r4</id> +<published>2008-12-15T14:48:39.000-08:00</published> +<updated>2008-12-15T14:48:39.000-08:00</updated> +<category scheme='http://gdata.youtube.com/schemas/2007/subscriptiontypes.cat' +term='query' /> +<category scheme='http://schemas.google.com/g/2005#kind' +term='http://gdata.youtube.com/schemas/2007#subscription' /> +<title>Videos matching : google</title> +<content type='application/atom+xml;type=feed' +src='http://gdata.youtube.com/feeds/api/videos?q=google&v=2' /> +<link rel='related' type='application/atom+xml' +href='http://gdata.youtube.com/feeds/api/users/zfgdata?v=2' /> +<link rel='alternate' type='text/html' +href='http://www.youtube.com/results?search_query=google' /> +<link rel='self' type='application/atom+xml' +href='http://gdata.youtube.com/feeds/api/users/zfgdata/subscriptions/59NG0lkr7r4?v=2' /> +<author> +<name>zfgdata</name> +<uri> +http://gdata.youtube.com/feeds/api/users/zfgdata</uri> +</author> +<yt:queryString>google</yt:queryString> +</entry>
\ 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 @@ +<?xml version='1.0' encoding='utf-8'?> +<feed xmlns='http://www.w3.org/2005/Atom' +xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' +xmlns:media='http://search.yahoo.com/mrss/' +xmlns:gd='http://schemas.google.com/g/2005' +xmlns:yt='http://gdata.youtube.com/schemas/2007'> + <id> + http://gdata.youtube.com/feeds/users/testuser/subscriptions</id> + <updated>2007-09-20T22:12:45.193Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#subscription' /> + <title type='text'>testuser's Subscriptions</title> + <logo> + http://www.youtube.com/img/pic_youtubelogo_123x63.gif</logo> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/profile_subscriptions?user=testuser' /> + <link rel='related' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/users/testuser' /> + <link rel='http://schemas.google.com/g/2005#feed' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/users/testuser/subscriptions' /> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/users/testuser/subscriptions?start-index=1&max-results=25' /> + <author> + <name>testuser</name> + <uri>http://gdata.youtube.com/feeds/users/testuser</uri> + </author> + <generator version='beta' uri='http://gdata.youtube.com/'>YouTube + data API</generator> + <openSearch:totalResults>3</openSearch:totalResults> + <openSearch:startIndex>1</openSearch:startIndex> + <openSearch:itemsPerPage>25</openSearch:itemsPerPage> + <entry> + <id> + http://gdata.youtube.com/feeds/users/testuser/subscriptions/35bbde297dba88db</id> + <published>2007-03-02T11:58:22.000-08:00</published> + <updated>2007-03-02T11:58:22.000-08:00</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#subscription' /> + <category scheme='http://gdata.youtube.com/schemas/2007/subscriptiontypes.cat' + term='publisher' /> + <title type='text'>Videos published by : BBC</title> + <link rel='related' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/users/testuser' /> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/profile_videos?user=BBC' /> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/users/testuser/subscriptions/35bbde297dba88db' /> + <author> + <name>testuser</name> + <uri>http://gdata.youtube.com/feeds/users/testuser</uri> + </author> + <gd:feedLink rel='http://gdata.youtube.com/schemas/2007#user.uploads' + href='http://gdata.youtube.com/feeds/users/BBC/uploads' + countHint='697' /> + </entry> + <entry> + <id> + http://gdata.youtube.com/feeds/users/testuser/subscriptions/742853a3468b2418</id> + <published>2007-09-18T21:39:36.000-07:00</published> + <updated>2007-09-18T21:39:36.000-07:00</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#subscription' /> + <category scheme='http://gdata.youtube.com/schemas/2007/subscriptiontypes.cat' + term='publisher' /> + <title type='text'>Videos published by : communitychannel</title> + <link rel='related' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/users/testuser' /> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/profile_videos?user=communitychannel' /> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/users/testuser/subscriptions/742853a3468b2418' /> + <author> + <name>testuser</name> + <uri>http://gdata.youtube.com/feeds/users/testuser</uri> + </author> + <gd:feedLink rel='http://gdata.youtube.com/schemas/2007#user.uploads' + href='http://gdata.youtube.com/feeds/users/communitychannel/uploads' + countHint='49' /> + </entry> + <entry> + <id> + http://gdata.youtube.com/feeds/users/testuser/subscriptions/98263c1ed3e31828</id> + <published>2007-09-20T13:45:29.000-07:00</published> + <updated>2007-09-20T13:45:29.000-07:00</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#subscription' /> + <category scheme='http://gdata.youtube.com/schemas/2007/subscriptiontypes.cat' + term='publisher' /> + <title type='text'>Videos published by : ucberkeley</title> + <link rel='related' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/users/testuser' /> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/profile_videos?user=ucberkeley' /> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/users/testuser/subscriptions/98263c1ed3e31828' /> + <author> + <name>testuser</name> + <uri>http://gdata.youtube.com/feeds/users/testuser</uri> + </author> + <gd:feedLink rel='http://gdata.youtube.com/schemas/2007#user.uploads' + href='http://gdata.youtube.com/feeds/users/ucberkeley/uploads' + countHint='201' /> + </entry> +</feed> 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 @@ +<?xml version='1.0' encoding='utf-8'?> +<feed xmlns='http://www.w3.org/2005/Atom' +xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/' +xmlns:media='http://search.yahoo.com/mrss/' +xmlns:batch='http://schemas.google.com/gdata/batch' +xmlns:yt='http://gdata.youtube.com/schemas/2007' +xmlns:gd='http://schemas.google.com/g/2005' +gd:etag='W/"DUUDQn47eCp7ImA9WB9TE0k."'> +<id>tag:youtube.com,2008:user:zfgdata:subscriptions</id> +<updated>2007-09-20T21:01:13.000-07:00</updated> +<category scheme='http://schemas.google.com/g/2005#kind' +term='http://gdata.youtube.com/schemas/2007#subscription' /> +<title>Subscriptions of zfgdata</title> +<logo>http://www.youtube.com/img/pic_youtubelogo_123x63.gif</logo> +<link rel='related' type='application/atom+xml' +href='http://gdata.youtube.com/feeds/api/users/zfgdata?v=2' /> +<link rel='alternate' type='text/html' +href='http://www.youtube.com/profile_subscriptions?user=zfgdata' /> +<link rel='http://schemas.google.com/g/2005#feed' +type='application/atom+xml' +href='http://gdata.youtube.com/feeds/api/users/zfgdata/subscriptions?v=2' /> +<link rel='http://schemas.google.com/g/2005#batch' +type='application/atom+xml' +href='http://gdata.youtube.com/feeds/api/users/zfgdata/subscriptions/batch?v=2' /> +<link rel='self' type='application/atom+xml' +href='http://gdata.youtube.com/feeds/api/users/zfgdata/subscriptions?start-index=1&max-results=25&v=2' /> +<link rel='service' type='application/atomsvc+xml' +href='http://gdata.youtube.com/feeds/api/users/zfgdata/subscriptions?alt=atom-service&v=2' /> +<author> +<name>zfgdata</name> +<uri>http://gdata.youtube.com/feeds/api/users/zfgdata</uri> +</author> +<generator version='2.0' uri='http://gdata.youtube.com/'>YouTube +data API</generator> +<openSearch:totalResults>8</openSearch:totalResults> +<openSearch:startIndex>1</openSearch:startIndex> +<openSearch:itemsPerPage>25</openSearch:itemsPerPage> +<entry gd:etag='W/"DUUDQn47eCp7ImA9WB9TE0k."'> +<id>tag:youtube.com,2008:user:zfgdata:subscription:_Jkf5no0ZW0</id> +<published>2007-09-20T21:01:13.000-07:00</published> +<updated>2007-09-20T21:01:13.000-07:00</updated> +<category scheme='http://gdata.youtube.com/schemas/2007/subscriptiontypes.cat' +term='channel' /> +<category scheme='http://schemas.google.com/g/2005#kind' +term='http://gdata.youtube.com/schemas/2007#subscription' /> +<title>Videos published by : tonyrain</title> +<content type='application/atom+xml;type=feed' +src='http://gdata.youtube.com/feeds/api/users/tonyrain/uploads?v=2' /> +<link rel='related' type='application/atom+xml' +href='http://gdata.youtube.com/feeds/api/users/zfgdata?v=2' /> +<link rel='alternate' type='text/html' +href='http://www.youtube.com/profile_videos?user=tonyrain' /> +<link rel='self' type='application/atom+xml' +href='http://gdata.youtube.com/feeds/api/users/zfgdata/subscriptions/_Jkf5no0ZW0?v=2' /> +<author> +<name>zfgdata</name> +<uri>http://gdata.youtube.com/feeds/api/users/zfgdata</uri> +</author> +<yt:username>tonyrain</yt:username> +<yt:countHint>13</yt:countHint> +<media:thumbnail url='http://i2.ytimg.com/vi/10-yctITMjk/default.jpg' /> +</entry> +<entry gd:etag='W/"C04CR347eCp7ImA9WxRaE0U."'> +<id>tag:youtube.com,2008:user:zfgdata:subscription:S_KBJ3ylYwc</id> +<published>2008-12-15T14:59:26.000-08:00</published> +<updated>2008-12-15T14:59:26.000-08:00</updated> +<category scheme='http://gdata.youtube.com/schemas/2007/subscriptiontypes.cat' +term='favorites' /> +<category scheme='http://schemas.google.com/g/2005#kind' +term='http://gdata.youtube.com/schemas/2007#subscription' /> +<title>Favorites of : NBA</title> +<content type='application/atom+xml;type=feed' +src='http://gdata.youtube.com/feeds/api/users/nba/favorites?v=2' /> +<link rel='related' type='application/atom+xml' +href='http://gdata.youtube.com/feeds/api/users/zfgdata?v=2' /> +<link rel='alternate' type='text/html' +href='http://www.youtube.com/profile_favorites?user=NBA' /> +<link rel='self' type='application/atom+xml' +href='http://gdata.youtube.com/feeds/api/users/zfgdata/subscriptions/S_KBJ3ylYwc?v=2' /> +<author> +<name>zfgdata</name> +<uri>http://gdata.youtube.com/feeds/api/users/zfgdata</uri> +</author> +<yt:username>NBA</yt:username> +<media:thumbnail url='http://i4.ytimg.com/i/WJ2lWNubArHWmf3FIHbfcQ/1.jpg' /> +</entry> +<entry gd:etag='W/"DUMHQ347eCp7ImA9WB9TE0k."'> +<id>tag:youtube.com,2008:user:zfgdata:subscription:i_2YXxZb9Zg</id> +<published>2007-09-20T21:03:52.000-07:00</published> +<updated>2007-09-20T21:03:52.000-07:00</updated> +<category scheme='http://gdata.youtube.com/schemas/2007/subscriptiontypes.cat' +term='playlist' /> +<category scheme='http://schemas.google.com/g/2005#kind' +term='http://gdata.youtube.com/schemas/2007#subscription' /> +<title>From Google Engineers</title> +<content type='application/atom+xml;type=feed' +src='http://gdata.youtube.com/feeds/api/playlists/4AE5C0D23C2EB82D?v=2' /> +<link rel='related' type='application/atom+xml' +href='http://gdata.youtube.com/feeds/api/users/zfgdata?v=2' /> +<link rel='alternate' type='text/html' +href='http://www.youtube.com/view_play_list?p=4AE5C0D23C2EB82D' /> +<link rel='self' type='application/atom+xml' +href='http://gdata.youtube.com/feeds/api/users/zfgdata/subscriptions/i_2YXxZb9Zg?v=2' /> +<author> +<name>zfgdata</name> +<uri>http://gdata.youtube.com/feeds/api/users/zfgdata</uri> +</author> +<yt:playlistTitle>From Google Engineers</yt:playlistTitle> +<yt:username>GoogleDevelopers</yt:username> +<yt:playlistId>4AE5C0D23C2EB82D</yt:playlistId> +<media:thumbnail url='http://i3.ytimg.com/vi/zI38Tc9GjSk/default.jpg' /> +</entry> +<entry gd:etag='W/"C0QFSH47eCp7ImA9WxRaE0U."'> +<id> +tag:youtube.com,2008:user:zfgdata:subscription:59NG0lkr7r4</id> +<published>2008-12-15T14:48:39.000-08:00</published> +<updated>2008-12-15T14:48:39.000-08:00</updated> +<category scheme='http://gdata.youtube.com/schemas/2007/subscriptiontypes.cat' +term='query' /> +<category scheme='http://schemas.google.com/g/2005#kind' +term='http://gdata.youtube.com/schemas/2007#subscription' /> +<title>Videos matching : google</title> +<content type='application/atom+xml;type=feed' +src='http://gdata.youtube.com/feeds/api/videos?q=google&v=2' /> +<link rel='related' type='application/atom+xml' +href='http://gdata.youtube.com/feeds/api/users/zfgdata?v=2' /> +<link rel='alternate' type='text/html' +href='http://www.youtube.com/results?search_query=google' /> +<link rel='self' type='application/atom+xml' +href='http://gdata.youtube.com/feeds/api/users/zfgdata/subscriptions/59NG0lkr7r4?v=2' /> +<author> +<name>zfgdata</name> +<uri> +http://gdata.youtube.com/feeds/api/users/zfgdata</uri> +</author> +<yt:queryString>google</yt:queryString> +</entry> +</feed>
\ 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 @@ +<?xml version='1.0' encoding='utf-8'?> +<entry xmlns="http://www.w3.org/2005/Atom" + xmlns:gd="http://schemas.google.com/g/2005" + xmlns:yt="http://gdata.youtube.com/schemas/2007"> + <id>http://gdata.youtube.com/feeds/users/darcy</id> + <published>2006-03-19T11:35:56.000-08:00</published> + <updated>2007-08-13T12:37:03.000-07:00</updated> + <category scheme="http://schemas.google.com/g/2005#kind" + term="http://gdata.youtube.com/schemas/2007#userProfile"/> + <title type="text">Darcy</title> + <link rel="alternate" type="text/html" + href="http://www.youtube.com/profile?user=darcy"/> + <link rel="self" type="application/atom+xml" + href="http://gdata.youtube.com/feeds/users/darcy"/> + <author> + <name>Fitzwilliam Darcy</name> + <uri>http://gdata.youtube.com/feeds/users/darcy</uri> + </author> + + <yt:age>32</yt:age> + <yt:description>A person of great interest</yt:description> + <yt:username>darcy</yt:username> + <yt:books>Pride and Prejudice</yt:books> + <yt:company>Self employed</yt:company> + <yt:hobbies>Reading, arguing with Liz</yt:hobbies> + <yt:hometown>Steventon</yt:hometown> + <yt:location>Longbourn in Hertfordshire, Pemberley in Derbyshire</yt:location> + <yt:movies>Pride and Prejudice, 2005</yt:movies> + <yt:music>Air Con Varizzioni, The Pleasure of the Town</yt:music> + <yt:occupation>Gentleman</yt:occupation> + <yt:school>Home schooling</yt:school> + <yt:gender>m</yt:gender> + <yt:relationship>taken</yt:relationship> + + <gd:feedLink rel="http://gdata.youtube.com/schemas/2007#user.favorites" + href="http://gdata.youtube.com/feeds/users/darcy/favorites"/> + <gd:feedLink rel="http://gdata.youtube.com/schemas/2007#user.contacts" + href="http://gdata.youtube.com/feeds/users/darcy/contacts"/> + <gd:feedLink rel="http://gdata.youtube.com/schemas/2007#user.inbox" + href="http://gdata.youtube.com/feeds/users/darcy/inbox"/> + <gd:feedLink rel="http://gdata.youtube.com/schemas/2007#user.playlists" + href="http://gdata.youtube.com/feeds/users/darcy/playlists"/> + <gd:feedLink rel="http://gdata.youtube.com/schemas/2007#user.subscriptions" + href="http://gdata.youtube.com/feeds/users/darcy/subscriptions"/> + <gd:feedLink rel="http://gdata.youtube.com/schemas/2007#user.uploads" + href="http://gdata.youtube.com/feeds/users/darcy/uploads"/> +</entry> 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 @@ +<?xml version='1.0' encoding='utf-8'?> +<entry xmlns='http://www.w3.org/2005/Atom' +xmlns:media='http://search.yahoo.com/mrss/' +xmlns:batch='http://schemas.google.com/gdata/batch' +xmlns:yt='http://gdata.youtube.com/schemas/2007' +xmlns:gd='http://schemas.google.com/g/2005' +gd:etag='W/"DEEBR347eCp7ImA9WxRaE0o."'> +<id>tag:youtube.com,2008:user:zfgdata</id> +<published>2007-09-20T21:00:09.000-07:00</published> +<updated>2008-12-15T13:30:56.000-08:00</updated> +<category scheme='http://gdata.youtube.com/schemas/2007/channeltypes.cat' +term='Standard' /> +<category scheme='http://schemas.google.com/g/2005#kind' +term='http://gdata.youtube.com/schemas/2007#userProfile' /> +<title>zfgdata Channel</title> +<link rel='http://gdata.youtube.com/schemas/2007#featured-video' +type='application/atom+xml' +href='http://gdata.youtube.com/feeds/api/videos/66wj2g5yz0M?v=2' /> +<link rel='related' type='text/html' +href='http://code.google.com/apis/gdata/' /> +<link rel='alternate' type='text/html' +href='http://www.youtube.com/profile?user=zfgdata' /> +<link rel='self' type='application/atom+xml' +href='http://gdata.youtube.com/feeds/api/users/zfgdata?v=2' /> +<author> +<name>zfgdata</name> +<uri>http://gdata.youtube.com/feeds/api/users/zfgdata</uri> +</author> +<yt:firstName>Lonely</yt:firstName> +<yt:lastName>TestAccount</yt:lastName> +<yt:aboutMe>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.</yt:aboutMe> +<yt:age>32</yt:age> +<yt:username>zfgdata</yt:username> +<yt:books>crime and punishment, ps i love you, the stand</yt:books> +<yt:gender>f</yt:gender> +<yt:company>Google</yt:company> +<yt:hobbies>software engineering, information architecture, +photography, travel</yt:hobbies> +<yt:hometown>Mountain View, CA</yt:hometown> +<yt:location>San Francisco, CA 94114, US</yt:location> +<yt:movies>monk, heroes, law and order, top gun</yt:movies> +<yt:music>imogen heap, frou frou, thievory corp, morcheeba, +barenaked ladies</yt:music> +<yt:occupation>Developer Programs</yt:occupation> +<yt:relationship>taken</yt:relationship> +<yt:school>University of the World</yt:school> +<media:thumbnail url='http://i3.ytimg.com/vi/66wj2g5yz0M/default.jpg' /> +<yt:statistics viewCount='88' videoWatchCount='14' lastWebAccess='2008-12-15T14:56:57.000-08:00' subscriberCount='12' /> +<gd:feedLink rel='http://gdata.youtube.com/schemas/2007#user.favorites' +href='http://gdata.youtube.com/feeds/api/users/zfgdata/favorites?v=2' +countHint='1' /> +<gd:feedLink rel='http://gdata.youtube.com/schemas/2007#user.contacts' +href='http://gdata.youtube.com/feeds/api/users/zfgdata/contacts?v=2' +countHint='1' /> +<gd:feedLink rel='http://gdata.youtube.com/schemas/2007#user.inbox' +href='http://gdata.youtube.com/feeds/api/users/zfgdata/inbox?v=2' /> +<gd:feedLink rel='http://gdata.youtube.com/schemas/2007#user.playlists' +href='http://gdata.youtube.com/feeds/api/users/zfgdata/playlists?v=2' /> +<gd:feedLink rel='http://gdata.youtube.com/schemas/2007#user.subscriptions' +href='http://gdata.youtube.com/feeds/api/users/zfgdata/subscriptions?v=2' +countHint='8' /> +<gd:feedLink rel='http://gdata.youtube.com/schemas/2007#user.uploads' +href='http://gdata.youtube.com/feeds/api/users/zfgdata/uploads?v=2' +countHint='1' /> +<gd:feedLink rel='http://gdata.youtube.com/schemas/2007#user.newsubscriptionvideos' +href='http://gdata.youtube.com/feeds/api/users/zfgdata/newsubscriptionvideos?v=2' /> +</entry>
\ 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 @@ +<?xml version='1.0' encoding='utf-8'?> +<entry xmlns='http://www.w3.org/2005/Atom' +xmlns:media='http://search.yahoo.com/mrss/' +xmlns:gd='http://schemas.google.com/g/2005' +xmlns:yt='http://gdata.youtube.com/schemas/2007' +xmlns:gml='http://www.opengis.net/gml' +xmlns:georss='http://www.georss.org/georss' +xmlns:app='http://purl.org/atom/app#'> + <id>http://gdata.youtube.com/feeds/videos/UMFI1hdm96E</id> + <published>2007-01-07T01:50:15.000Z</published> + <updated>2007-01-07T01:50:15.000Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#video' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='barkley' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='singing' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='acoustic' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='cover' /> + <category scheme='http://gdata.youtube.com/schemas/2007/categories.cat' + term='Music' label='Music' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='gnarls' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='music' /> + <title type='text'>"Crazy (Gnarles Barkley)" - Acoustic Cover</title> + <content type='html'><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></content> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/UMFI1hdm96E' /> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/watch?v=UMFI1hdm96E' /> + <link rel='http://gdata.youtube.com/schemas/2007#video.responses' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/UMFI1hdm96E/responses' /> + <link rel='http://gdata.youtube.com/schemas/2007#video.related' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/UMFI1hdm96E/related' /> + <author> + <name>davidchoimusic</name> + <uri>http://gdata.youtube.com/feeds/users/davidchoimusic</uri> + </author> + <media:group> + <media:title type='plain'>"Crazy (Gnarles Barkley)" - Acoustic Cover</media:title> + <media:description type='plain'>Gnarles Barkley acoustic cover http://www.myspace.com/davidchoimusic</media:description> + <media:keywords>music, singing, gnarls, barkley, acoustic, cover</media:keywords> + <yt:duration seconds='255' /> + <media:category label='Music' + scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> + Music</media:category> + <media:category + scheme='http://gdata.youtube.com/schemas/2007/developertags.cat'> + DeveloperTag1</media:category> + <media:content url='http://www.youtube.com/v/UMFI1hdm96E' + type='application/x-shockwave-flash' medium='video' + isDefault='true' expression='full' duration='255' + yt:format='5' /> + <media:player url='http://www.youtube.com/watch?v=UMFI1hdm96E' /> + <media:thumbnail url='http://img.youtube.com/vi/UMFI1hdm96E/2.jpg' + height='97' width='130' time='00:02:07.500' /> + <media:thumbnail url='http://img.youtube.com/vi/UMFI1hdm96E/1.jpg' + height='97' width='130' time='00:01:03.750' /> + <media:thumbnail url='http://img.youtube.com/vi/UMFI1hdm96E/3.jpg' + height='97' width='130' time='00:03:11.250' /> + <media:thumbnail url='http://img.youtube.com/vi/UMFI1hdm96E/0.jpg' + height='240' width='320' time='00:02:07.500' /> + </media:group> + <yt:statistics viewCount='113321' /> + <gd:rating min='1' max='5' numRaters='1005' average='4.77' /> + <georss:where> + <gml:Point> + <gml:pos>37.398529052734375 -122.0635986328125</gml:pos> + </gml:Point> + </georss:where> + <yt:recorded>2008-09-25</yt:recorded> + <gd:comments> + <gd:feedLink href='http://gdata.youtube.com/feeds/videos/UMFI1hdm96E/comments' /> + </gd:comments> + <yt:noembed /> + <app:control> + <app:draft>yes</app:draft> + <yt:state + name="rejected" + reasonCode="inappropriate" + helpUrl="http://www.youtube.com/t/community_guidelines"> + The content of this video may violate the terms of use.</yt:state> + </app:control> +</entry> 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 @@ +<?xml version='1.0' encoding='utf-8'?> +<entry xmlns='http://www.w3.org/2005/Atom' +xmlns:media='http://search.yahoo.com/mrss/' +xmlns:gd='http://schemas.google.com/g/2005' +xmlns:yt='http://gdata.youtube.com/schemas/2007' +xmlns:gml='http://www.opengis.net/gml' +xmlns:georss='http://www.georss.org/georss' +xmlns:app='http://purl.org/atom/app#'> + <id>http://gdata.youtube.com/feeds/videos/UMFI1hdm96E</id> + <published>2007-01-07T01:50:15.000Z</published> + <updated>2007-01-07T01:50:15.000Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#video' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='barkley' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='singing' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='acoustic' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='cover' /> + <category scheme='http://gdata.youtube.com/schemas/2007/categories.cat' + term='Music' label='Music' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='gnarls' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='music' /> + <title type='text'>"Crazy (Gnarles Barkley)" - Acoustic Cover</title> + <content type='html'><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></content> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/UMFI1hdm96E' /> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/watch?v=UMFI1hdm96E' /> + <link rel='http://gdata.youtube.com/schemas/2007#video.responses' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/UMFI1hdm96E/responses' /> + <link rel='http://gdata.youtube.com/schemas/2007#video.related' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/UMFI1hdm96E/related' /> + <author> + <name>davidchoimusic</name> + <uri>http://gdata.youtube.com/feeds/users/davidchoimusic</uri> + </author> + <media:group> + <media:title type='plain'>"Crazy (Gnarles Barkley)" - Acoustic Cover</media:title> + <media:description type='plain'>Gnarles Barkley acoustic cover http://www.myspace.com/davidchoimusic</media:description> + <media:keywords>music, singing, gnarls, barkley, acoustic, cover</media:keywords> + <yt:duration seconds='255' /> + <media:category label='Music' + scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> + Music</media:category> + <media:category + scheme='http://gdata.youtube.com/schemas/2007/developertags.cat'> + DeveloperTag1</media:category> + <media:content url='http://www.youtube.com/v/UMFI1hdm96E' + type='application/x-shockwave-flash' medium='video' + isDefault='true' expression='full' duration='255' + yt:format='5' /> + <media:player url='http://www.youtube.com/watch?v=UMFI1hdm96E' /> + <media:thumbnail url='http://img.youtube.com/vi/UMFI1hdm96E/2.jpg' + height='97' width='130' time='00:02:07.500' /> + <media:thumbnail url='http://img.youtube.com/vi/UMFI1hdm96E/1.jpg' + height='97' width='130' time='00:01:03.750' /> + <media:thumbnail url='http://img.youtube.com/vi/UMFI1hdm96E/3.jpg' + height='97' width='130' time='00:03:11.250' /> + <media:thumbnail url='http://img.youtube.com/vi/UMFI1hdm96E/0.jpg' + height='240' width='320' time='00:02:07.500' /> + <yt:private /> + </media:group> + <yt:statistics viewCount='113321' /> + <gd:rating min='1' max='5' numRaters='1005' average='4.77' /> + <georss:where> + <gml:Point> + <gml:pos>37.398529052734375 -122.0635986328125</gml:pos> + </gml:Point> + </georss:where> + <yt:recorded>2008-09-25</yt:recorded> + <gd:comments> + <gd:feedLink href='http://gdata.youtube.com/feeds/videos/UMFI1hdm96E/comments' /> + </gd:comments> + <yt:noembed /> + <app:control> + <app:draft>yes</app:draft> + <yt:state + name="rejected" + reasonCode="inappropriate" + helpUrl="http://www.youtube.com/t/community_guidelines"> + The content of this video may violate the terms of use.</yt:state> + </app:control> +</entry> 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 @@ +<?xml version='1.0' encoding='UTF-8'?> +<entry xmlns='http://www.w3.org/2005/Atom' +xmlns:gml='http://www.opengis.net/gml' +xmlns:georss='http://www.georss.org/georss' +xmlns:media='http://search.yahoo.com/mrss/' +xmlns:batch='http://schemas.google.com/gdata/batch' +xmlns:yt='http://gdata.youtube.com/schemas/2007' +xmlns:gd='http://schemas.google.com/g/2005' +gd:etag='W/"A0cDQn47eCp7ImA9WxRbF00."'> +<id>tag:youtube.com,2008:video:UMFI1hdm96E</id> +<published>2007-01-07T01:50:15.000Z</published> +<updated>2008-12-08T04:04:33.000Z</updated> +<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='cover'/> +<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='acoustic'/> +<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='gnarls'/> +<category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#video'/> +<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='barkley'/> +<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='music'/> +<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='singing'/> +<category scheme='http://gdata.youtube.com/schemas/2007/categories.cat' term='Music' label='Music'/> +<title>"Crazy (Gnarles Barkley)" - Acoustic Cover</title> +<content type='application/x-shockwave-flash' src='http://www.youtube.com/v/UMFI1hdm96E&f=gdata_videos'/> +<link rel='alternate' type='text/html' href='http://www.youtube.com/watch?v=UMFI1hdm96E'/> +<link rel='http://gdata.youtube.com/schemas/2007#video.responses' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos/UMFI1hdm96E/responses?v=2'/> +<link rel='http://gdata.youtube.com/schemas/2007#video.related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos/UMFI1hdm96E/related?v=2'/> +<link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos/UMFI1hdm96E?v=2'/> +<author> + <name>davidchoimusic</name><uri>http://gdata.youtube.com/feeds/api/users/davidchoimusic</uri> +</author> +<media:group> + <media:title type='plain'>"Crazy (Gnarles Barkley)" - Acoustic Cover</media:title> + <media:description type='plain'>Gnarles Barkley acoustic cover http://www.myspace.com/davidchoimusic</media:description> + <media:rating scheme="http://gdata.youtube.com/schemas/2007#mediarating" country="HK,TW">1</media:rating> + <media:category + scheme='http://gdata.youtube.com/schemas/2007/developertags.cat'> + DeveloperTag1</media:category> + <media:keywords>acoustic, barkley, cover, gnarls, music, singing</media:keywords> + <yt:duration seconds='255'/> + <yt:videoid>UMFI1hdm96E</yt:videoid> + <yt:uploaded>2007-01-07T01:50:15.000Z</yt:uploaded> + <media:player url='http://www.youtube.com/watch?v=UMFI1hdm96E'/> + <media:credit role='uploader' scheme='urn:youtube' yt:type='partner'>davidchoimusic</media:credit> + <media:category label='Music' scheme='http://gdata.youtube.com/schemas/2007/categories.cat'>Music</media:category> + <media:content url='http://www.youtube.com/v/UMFI1hdm96E&f=gdata_videos' type='application/x-shockwave-flash' medium='video' isDefault='true' expression='full' duration='255' yt:format='5'/> + <media:content url='rtsp://rtsp2.youtube.com/CigLENy73wIaHwmh92YX1kjBUBMYESARFEgGUgxnZGF0YV92aWRlb3MM/0/0/0/video.3gp' type='video/3gpp' medium='video' expression='full' duration='255' yt:format='6'/> + <media:thumbnail url='http://i.ytimg.com/vi/UMFI1hdm96E/2.jpg' height='97' width='130' time='00:02:07.500'/> + <media:thumbnail url='http://i.ytimg.com/vi/UMFI1hdm96E/1.jpg' height='97' width='130' time='00:01:03.750'/> + <media:thumbnail url='http://i.ytimg.com/vi/UMFI1hdm96E/3.jpg' height='97' width='130' time='00:03:11.250'/> + <media:thumbnail url='http://i.ytimg.com/vi/UMFI1hdm96E/0.jpg' height='240' width='320' time='00:02:07.500'/> + <media:thumbnail url='http://i.ytimg.com/vi/UMFI1hdm96E/hqdefault.jpg' height='360' width='480'/> +</media:group> +<yt:statistics viewCount='267971' favoriteCount='1822'/> +<gd:rating min='1' max='5' numRaters='2062' average='4.74'/> + <georss:where> + <gml:Point> + <gml:pos>37.398529052734375 -122.0635986328125</gml:pos> + </gml:Point> + </georss:where> + <yt:recorded>2008-09-25</yt:recorded> +<gd:comments> + <gd:feedLink href='http://gdata.youtube.com/feeds/api/videos/UMFI1hdm96E/comments?v=2' countHint='1074'/> + </gd:comments> +</entry>
\ 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 @@ +<?xml version='1.0' encoding='utf-8'?> +<feed xmlns='http://www.w3.org/2005/Atom' +xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' +xmlns:media='http://search.yahoo.com/mrss/' +xmlns:gd='http://schemas.google.com/g/2005' +xmlns:yt='http://gdata.youtube.com/schemas/2007'> + <id>http://gdata.youtube.com/feeds/users/davidchoimusic/uploads</id> + <updated>2007-09-21T02:27:22.638Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#video' /> + <title type='text'>Davidchoimusic's Videos</title> + <logo> http://www.youtube.com/img/pic_youtubelogo_123x63.gif</logo> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/profile_videos?user=davidchoimusic' /> + <link rel='related' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/users/davidchoimusic' /> + <link rel='http://schemas.google.com/g/2005#feed' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/users/davidchoimusic/uploads' /> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/users/davidchoimusic/uploads?start-index=1&max-results=5' /> + <link rel='next' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/users/davidchoimusic/uploads?start-index=6&max-results=5' /> + <author> + <name>davidchoimusic</name> + <uri>http://gdata.youtube.com/feeds/users/davidchoimusic</uri> + </author> + <generator version='beta' uri='http://gdata.youtube.com/'>YouTube data API</generator> + <openSearch:totalResults>54</openSearch:totalResults> + <openSearch:startIndex>1</openSearch:startIndex> + <openSearch:itemsPerPage>5</openSearch:itemsPerPage> + <entry> + <id>http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg</id> + <published>2007-01-11T00:17:31.000Z</published> + <updated>2007-01-11T00:17:31.000Z</updated> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='Song' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='Version' /> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#video' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='Original' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='Girl' /> + <category scheme='http://gdata.youtube.com/schemas/2007/categories.cat' + term='Music' label='Music' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='That' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='Acoustic' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='davidchoimusic' /> + <title type='text'>"That Girl" - Original Song - Acoustic + Version</title> + <content type='html'><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></content> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg' /> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/watch?v=Lnio-pqLPgg' /> + <link rel='http://gdata.youtube.com/schemas/2007#video.responses' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/responses' /> + <link rel='http://gdata.youtube.com/schemas/2007#video.related' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/related' /> + <author> + <name>davidchoimusic</name> + <uri> + http://gdata.youtube.com/feeds/users/davidchoimusic</uri> + </author> + <media:group> + <media:title type='plain'>"That Girl" - Original Song - + Acoustic Version</media:title> + <media:description type='plain'>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</media:description> + <media:keywords>That, Girl, Original, Song, Acoustic, + Version, davidchoimusic</media:keywords> + <yt:duration seconds='220' /> + <media:category label='Music' + scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> + Music</media:category> + <media:content url='http://www.youtube.com/v/Lnio-pqLPgg' + type='application/x-shockwave-flash' medium='video' + isDefault='true' expression='full' duration='220' + yt:format='5' /> + <media:player url='http://www.youtube.com/watch?v=Lnio-pqLPgg' /> + <media:thumbnail url='http://img.youtube.com/vi/Lnio-pqLPgg/2.jpg' + height='97' width='130' time='00:01:50' /> + <media:thumbnail url='http://img.youtube.com/vi/Lnio-pqLPgg/1.jpg' + height='97' width='130' time='00:00:55' /> + <media:thumbnail url='http://img.youtube.com/vi/Lnio-pqLPgg/3.jpg' + height='97' width='130' time='00:02:45' /> + <media:thumbnail url='http://img.youtube.com/vi/Lnio-pqLPgg/0.jpg' + height='240' width='320' time='00:01:50' /> + </media:group> + <yt:statistics viewCount='437209' /> + <gd:rating min='1' max='5' numRaters='2981' average='4.89' /> + <gd:comments> + <gd:feedLink href='http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments' /> + </gd:comments> + </entry> + <entry> + <id>http://gdata.youtube.com/feeds/videos/FWPzxVMQU8g</id> + <published>2006-12-30T23:20:14.000Z</published> + <updated>2006-12-30T23:20:14.000Z</updated> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='Song' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='Song)' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='Version' /> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#video' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='Love' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='Tube' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='Original' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='You' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='(A' /> + <category scheme='http://gdata.youtube.com/schemas/2007/categories.cat' + term='Music' label='Music' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='Acoustic' /> + <title type='text'>"You Tube" (A Love Song) - Original Song - + Acoustic Version</title> + <content type='html'><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></content> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/FWPzxVMQU8g' /> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/watch?v=FWPzxVMQU8g' /> + <link rel='http://gdata.youtube.com/schemas/2007#video.responses' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/FWPzxVMQU8g/responses' /> + <link rel='http://gdata.youtube.com/schemas/2007#video.related' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/FWPzxVMQU8g/related' /> + <author> + <name>davidchoimusic</name> + <uri> + http://gdata.youtube.com/feeds/users/davidchoimusic</uri> + </author> + <media:group> + <media:title type='plain'>"You Tube" (A Love Song) - Original + Song - Acoustic Version</media:title> + <media:description type='plain'> + 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</media:description> + <media:keywords>You, Tube, (A, Love, Song), Original, Song, + Acoustic, Version</media:keywords> + <yt:duration seconds='177' /> + <media:category label='Music' + scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> + Music</media:category> + <media:content url='http://www.youtube.com/v/FWPzxVMQU8g' + type='application/x-shockwave-flash' medium='video' + isDefault='true' expression='full' duration='177' + yt:format='5' /> + <media:player url='http://www.youtube.com/watch?v=FWPzxVMQU8g' /> + <media:thumbnail url='http://img.youtube.com/vi/FWPzxVMQU8g/2.jpg' + height='97' width='130' time='00:01:28.500' /> + <media:thumbnail url='http://img.youtube.com/vi/FWPzxVMQU8g/1.jpg' + height='97' width='130' time='00:00:44.250' /> + <media:thumbnail url='http://img.youtube.com/vi/FWPzxVMQU8g/3.jpg' + height='97' width='130' time='00:02:12.750' /> + <media:thumbnail url='http://img.youtube.com/vi/FWPzxVMQU8g/0.jpg' + height='240' width='320' time='00:01:28.500' /> + </media:group> + <yt:statistics viewCount='1495035' /> + <gd:rating min='1' max='5' numRaters='10995' average='4.64' /> + <gd:comments> + <gd:feedLink href='http://gdata.youtube.com/feeds/videos/FWPzxVMQU8g/comments' /> + </gd:comments> + </entry> + <entry> + <id>http://gdata.youtube.com/feeds/videos/uWVuAl_aFRo</id> + <published>2007-07-13T06:28:11.000Z</published> + <updated>2007-07-13T06:28:11.000Z</updated> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='kingston' /> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#video' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='video' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='beautiful' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='acoustic' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='cover' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='sean' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='girls' /> + <category scheme='http://gdata.youtube.com/schemas/2007/categories.cat' + term='Music' label='Music' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='suicidal' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='davidchoimusic' /> + <title type='text'>"Beautiful Girls" - Sean Kingston - Acoustic + Cover</title> + <content type='html'><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></content> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/uWVuAl_aFRo' /> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/watch?v=uWVuAl_aFRo' /> + <link rel='http://gdata.youtube.com/schemas/2007#video.responses' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/uWVuAl_aFRo/responses' /> + <link rel='http://gdata.youtube.com/schemas/2007#video.related' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/uWVuAl_aFRo/related' /> + <author> + <name>davidchoimusic</name> + <uri> + http://gdata.youtube.com/feeds/users/davidchoimusic</uri> + </author> + <media:group> + <media:title type='plain'>"Beautiful Girls" - Sean Kingston - + Acoustic Cover</media:title> + <media:description type='plain'>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 + :)</media:description> + <media:keywords>davidchoimusic, beautiful, girls, sean, + kingston, acoustic, cover, video, suicidal</media:keywords> + <yt:duration seconds='263' /> + <media:category label='Music' + scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> + Music</media:category> + <media:content url='http://www.youtube.com/v/uWVuAl_aFRo' + type='application/x-shockwave-flash' medium='video' + isDefault='true' expression='full' duration='263' + yt:format='5' /> + <media:player url='http://www.youtube.com/watch?v=uWVuAl_aFRo' /> + <media:thumbnail url='http://img.youtube.com/vi/uWVuAl_aFRo/2.jpg' + height='97' width='130' time='00:02:11.500' /> + <media:thumbnail url='http://img.youtube.com/vi/uWVuAl_aFRo/1.jpg' + height='97' width='130' time='00:01:05.750' /> + <media:thumbnail url='http://img.youtube.com/vi/uWVuAl_aFRo/3.jpg' + height='97' width='130' time='00:03:17.250' /> + <media:thumbnail url='http://img.youtube.com/vi/uWVuAl_aFRo/0.jpg' + height='240' width='320' time='00:02:11.500' /> + </media:group> + <yt:statistics viewCount='124571' /> + <gd:rating min='1' max='5' numRaters='1201' average='4.71' /> + <gd:comments> + <gd:feedLink href='http://gdata.youtube.com/feeds/videos/uWVuAl_aFRo/comments' /> + </gd:comments> + </entry> + <entry> + <id>http://gdata.youtube.com/feeds/videos/_PCgDBIgPbo</id> + <published>2007-02-15T20:40:24.000Z</published> + <updated>2007-02-15T20:40:24.000Z</updated> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#video' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='Chords' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='Girl' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='Vlog' /> + <category scheme='http://gdata.youtube.com/schemas/2007/categories.cat' + term='Music' label='Music' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='That' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='Guitar' /> + <title type='text'>Vlog - "That Girl" - Guitar Chords</title> + <content type='html'><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></content> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/_PCgDBIgPbo' /> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/watch?v=_PCgDBIgPbo' /> + <link rel='http://gdata.youtube.com/schemas/2007#video.responses' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/_PCgDBIgPbo/responses' /> + <link rel='http://gdata.youtube.com/schemas/2007#video.related' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/_PCgDBIgPbo/related' /> + <author> + <name>davidchoimusic</name> + <uri> + http://gdata.youtube.com/feeds/users/davidchoimusic</uri> + </author> + <media:group> + <media:title type='plain'>Vlog - "That Girl" - Guitar + Chords</media:title> + <media:description type='plain'>Vlog - "That Girl" - Guitar + Chords Finally here! Enjoy! + http://www.myspace.com/davidchoimusic + http://www.broadjam.com/davidchoi</media:description> + <media:keywords>Vlog, That, Girl, Guitar, + Chords</media:keywords> + <yt:duration seconds='338' /> + <media:category label='Music' + scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> + Music</media:category> + <media:content url='http://www.youtube.com/v/_PCgDBIgPbo' + type='application/x-shockwave-flash' medium='video' + isDefault='true' expression='full' duration='338' + yt:format='5' /> + <media:player url='http://www.youtube.com/watch?v=_PCgDBIgPbo' /> + <media:thumbnail url='http://img.youtube.com/vi/_PCgDBIgPbo/2.jpg' + height='97' width='130' time='00:02:49' /> + <media:thumbnail url='http://img.youtube.com/vi/_PCgDBIgPbo/1.jpg' + height='97' width='130' time='00:01:24.500' /> + <media:thumbnail url='http://img.youtube.com/vi/_PCgDBIgPbo/3.jpg' + height='97' width='130' time='00:04:13.500' /> + <media:thumbnail url='http://img.youtube.com/vi/_PCgDBIgPbo/0.jpg' + height='240' width='320' time='00:02:49' /> + </media:group> + <yt:statistics viewCount='76681' /> + <gd:rating min='1' max='5' numRaters='384' average='4.79' /> + <gd:comments> + <gd:feedLink href='http://gdata.youtube.com/feeds/videos/_PCgDBIgPbo/comments' /> + </gd:comments> + </entry> + <entry> + <id>http://gdata.youtube.com/feeds/videos/DdGyPZ0v7Ng</id> + <published>2007-08-12T00:59:18.000Z</published> + <updated>2007-08-12T00:59:18.000Z</updated> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='Choi' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='David' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='Making' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='with' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='to' /> + <category scheme='http://schemas.google.com/g/2005#kind' + term='http://gdata.youtube.com/schemas/2007#video' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='how' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='Beat' /> + <category scheme='http://gdata.youtube.com/schemas/2007/categories.cat' + term='Music' label='Music' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='tools' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='pro' /> + <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' + term='davidchoimusic' /> + <title type='text'>Beat Making with David Choi</title> + <content type='html'><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></content> + <link rel='self' type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/DdGyPZ0v7Ng' /> + <link rel='alternate' type='text/html' + href='http://www.youtube.com/watch?v=DdGyPZ0v7Ng' /> + <link rel='http://gdata.youtube.com/schemas/2007#video.responses' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/DdGyPZ0v7Ng/responses' /> + <link rel='http://gdata.youtube.com/schemas/2007#video.related' + type='application/atom+xml' + href='http://gdata.youtube.com/feeds/videos/DdGyPZ0v7Ng/related' /> + <author> + <name>davidchoimusic</name> + <uri> + http://gdata.youtube.com/feeds/users/davidchoimusic</uri> + </author> + <media:group> + <media:title type='plain'>Beat Making with David + Choi</media:title> + <media:description type='plain'>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 :)</media:description> + <media:keywords>how, to, Beat, Making, with, David, Choi, + davidchoimusic, pro, tools</media:keywords> + <yt:duration seconds='591' /> + <media:category label='Music' + scheme='http://gdata.youtube.com/schemas/2007/categories.cat'> + Music</media:category> + <media:content url='http://www.youtube.com/v/DdGyPZ0v7Ng' + type='application/x-shockwave-flash' medium='video' + isDefault='true' expression='full' duration='591' + yt:format='5' /> + <media:player url='http://www.youtube.com/watch?v=DdGyPZ0v7Ng' /> + <media:thumbnail url='http://img.youtube.com/vi/DdGyPZ0v7Ng/2.jpg' + height='97' width='130' time='00:04:55.500' /> + <media:thumbnail url='http://img.youtube.com/vi/DdGyPZ0v7Ng/1.jpg' + height='97' width='130' time='00:02:27.750' /> + <media:thumbnail url='http://img.youtube.com/vi/DdGyPZ0v7Ng/3.jpg' + height='97' width='130' time='00:07:23.250' /> + <media:thumbnail url='http://img.youtube.com/vi/DdGyPZ0v7Ng/0.jpg' + height='240' width='320' time='00:04:55.500' /> + </media:group> + <yt:statistics viewCount='22559' /> + <gd:rating min='1' max='5' numRaters='371' average='4.74' /> + <gd:comments> + <gd:feedLink href='http://gdata.youtube.com/feeds/videos/DdGyPZ0v7Ng/comments' /> + </gd:comments> + </entry> +</feed> 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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_YouTube + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'Zend/Gdata/YouTube.php'; +require_once 'Zend/Gdata/YouTube/VideoQuery.php'; +require_once 'Zend/Gdata/ClientLogin.php'; + +/** + * @category Zend + * @package Zend_Gdata_YouTube + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_YouTube + */ +class Zend_Gdata_YouTubeOnlineTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() + { + $this->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 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Gdata_YouTube + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id $ + */ + +require_once 'TestHelper.php'; +require_once 'Zend/Gdata/YouTube.php'; +require_once 'Zend/Http/Client.php'; + +/** + * @category Zend + * @package Zend_Gdata_YouTube + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Gdata + * @group Zend_Gdata_YouTube + */ +class Zend_Gdata_YouTubeTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() + { + // These tests shouldn't be doing anything online, so we can use + // bogus authentication credentials. + $this->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 + +<?xml version="1.0" encoding="UTF-8"?> +<?xml-stylesheet href="http://www.google.com/url?sa=D&q=http://www.blogger.com/styles/atom.css" type="text/css"?> +<entry xmlns="http://www.w3.org/2005/Atom"> + <id>12345678901234567890</id> + <published>2008-09-07T10:53:00.001-07:00</published> + <updated>2008-09-07T10:53:51.144-07:00</updated> + <app:edited xmlns:app="http://www.w3.org/2007/app">2008-09-07T10:53:51.144-07:00</app:edited> + <title>Hello world</title> + <content type="html"><p>Hello world!</p></content> + <link rel="alternate" type="text/html" href="http://www.google.com/url?sa=D&q=http://example.blogspot.com/2008/09/hello-world.html" title="Hello world"/> + <link rel="replies" type="text/html" href="http://www.google.com/url?sa=D&q=http://www.blogger.com/comment.g%3FblogID%3D12345678901234567890%26amp%3BpostID%3D09876543210987654321" title="0 Comments"/> + <link rel="replies" type="application/atom+xml" href="http://www.google.com/url?sa=D&q=http://example.blogspot.com/feeds/12345678901234567890/comments/default" title="Post Comments"/> + <link rel="self" type="application/atom+xml" href="http://www.google.com/url?sa=D&q=http://example.blogspot.com/feeds/posts/default/12345678901234567890"/> + <link rel="edit" type="application/atom+xml" href="http://www.google.com/url?sa=D&q=http://www.blogger.com/feeds/12345678901234567890/posts/default/09876543210987654321%3Fv%3D2"/> + <author> + <name>John Doe</name> + <uri>http://www.blogger.com/profile/5555555555555555</uri> + <email>jdoe@example.com</email> + </author> +</entry> 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 + +<?xml version="1.0" encoding="UTF-8"?> +<?xml-stylesheet href="http://www.google.com/url?sa=D&q=http://www.blogger.com/styles/atom.css" type="text/css"?> +<entry xmlns="http://www.w3.org/2005/Atom"> + <id>12345678901234567890</id> + <published>2008-09-07T10:53:00.001-07:00</published> + <updated>2008-09-07T10:53:51.144-07:00</updated> + <app:edited xmlns:app="http://www.w3.org/2007/app">2008-09-07T10:53:51.144-07:00</app:edited> + <title>Hello world</title> + <content type="html"><p>Hello world!</p></content> + <link rel="alternate" type="text/html" href="http://www.google.com/url?sa=D&q=http://example.blogspot.com/2008/09/hello-world.html" title="Hello world"/> + <link rel="replies" type="text/html" href="http://www.google.com/url?sa=D&q=http://www.blogger.com/comment.g%3FblogID%3D12345678901234567890%26amp%3BpostID%3D09876543210987654321" title="0 Comments"/> + <link rel="replies" type="application/atom+xml" href="http://www.google.com/url?sa=D&q=http://example.blogspot.com/feeds/12345678901234567890/comments/default" title="Post Comments"/> + <link rel="self" type="application/atom+xml" href="http://www.google.com/url?sa=D&q=http://example.blogspot.com/feeds/posts/default/12345678901234567890"/> + <link rel="edit" type="application/atom+xml" href="http://www.google.com/url?sa=D&q=http://www.blogger.com/feeds/12345678901234567890/posts/default/09876543210987654321%3Fv%3D2"/> + <author> + <name>John Doe</name> + <uri>http://www.blogger.com/profile/5555555555555555</uri> + <email>jdoe@example.com</email> + </author> +</entry> 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 + +<?xml version='1.0' encoding='UTF-8'?> +<?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?> +<feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/' xmlns:gd='http://schemas.google.com/g/2005' gd:etag='W/"CE4BRXw4cCp7ImA9WxRVFEs."'> + <id>tag:blogger.com,1999:blog-8273578352962669317</id> + <updated>2008-11-11T20:09:14.238-08:00</updated> + <title>Test Blog</title> + <subtitle type='html'>This is my description.</subtitle> + <link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://tmjdev-test.blogspot.com/feeds/posts/default'/> + <link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8273578352962669317/posts/default?v=2'/> + <link rel='alternate' type='text/html' href='http://tmjdev-test.blogspot.com/'/> + <link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/8273578352962669317/posts/default?start-index=26&max-results=25&v=2'/> + <author> + <name>John Doe</name> + <uri>http://www.blogger.com/profile/05925487542352262450</uri> + <email>tmjdev@gmail.com</email> + </author> + <generator version='7.00' uri='http://www.blogger.com'>Blogger</generator> + <openSearch:totalResults>30</openSearch:totalResults> + <openSearch:startIndex>1</openSearch:startIndex> + <openSearch:itemsPerPage>25</openSearch:itemsPerPage> + <entry gd:etag='W/"CE4BRXw-eSp7ImA9WxRVFEs."'> + <id>tag:blogger.com,1999:blog-8273578352962669317.post-4858063079003295518</id> + <published>2008-11-11T20:09:00.001-08:00</published> + <updated>2008-11-11T20:09:14.251-08:00</updated> + <app:edited xmlns:app='http://www.w3.org/2007/app'>2008-11-11T20:09:14.251-08:00</app:edited> + <title>Test Image</title> + <content type='html'>FOO</content> + <link + rel='replies' + type='application/atom+xml' + href='http://tmjdev-test.blogspot.com/feeds/4858063079003295518/comments/default' + title='Post Comments'/> + <link + rel='replies' + type='text/html' + href='https://www.blogger.com/comment.g?blogID=8273578352962669317&postID=4858063079003295518' + title='0 Comments'/> + <link + rel='edit' + type='application/atom+xml' + href='http://www.blogger.com/feeds/8273578352962669317/posts/default/4858063079003295518?v=2'/> + <link + rel='self' + type='application/atom+xml' + href='http://www.blogger.com/feeds/8273578352962669317/posts/default/4858063079003295518?v=2'/> + <link + rel='alternate' + type='text/html' + href='http://tmjdev-test.blogspot.com/2008/11/test-image_11.html' + title='Test Image'/> + <author> + <name>John Doe</name> + <uri>http://www.blogger.com/profile/05925487542352262450</uri> + <email>tmjdev@gmail.com</email> + </author> + <thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total> + </entry> +</feed>
\ 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 + +<?xml version='1.0' encoding='UTF-8'?> +<?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?> +<feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/' xmlns:gd='http://schemas.google.com/g/2005' gd:etag='W/"CE4BRXw4cCp7ImA9WxRVFEs."'> + <id>tag:blogger.com,1999:blog-8273578352962669317</id> + <updated>2008-11-11T20:09:14.238-08:00</updated> + <title>Test Blog</title> + <subtitle type='html'>This is my description.</subtitle> + <link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://tmjdev-test.blogspot.com/feeds/posts/default'/> + <link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8273578352962669317/posts/default?v=2'/> + <link rel='alternate' type='text/html' href='http://tmjdev-test.blogspot.com/'/> + <link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/8273578352962669317/posts/default?start-index=26&max-results=25&v=2'/> + <author> + <name>John Doe</name> + <uri>http://www.blogger.com/profile/05925487542352262450</uri> + <email>tmjdev@gmail.com</email> + </author> + <generator version='7.00' uri='http://www.blogger.com'>Blogger</generator> + <openSearch:totalResults>30</openSearch:totalResults> + <openSearch:startIndex>1</openSearch:startIndex> + <openSearch:itemsPerPage>25</openSearch:itemsPerPage> + <entry gd:etag='W/"CE4BRXw-eSp7ImA9WxRVFEs."'> + <id>tag:blogger.com,1999:blog-8273578352962669317.post-4858063079003295518</id> + <published>2008-11-11T20:09:00.001-08:00</published> + <updated>2008-11-11T20:09:14.251-08:00</updated> + <app:edited xmlns:app='http://www.w3.org/2007/app'>2008-11-11T20:09:14.251-08:00</app:edited> + <title>Test Image</title> + <content type='html'>FOO</content> + <link + rel='replies' + type='application/atom+xml' + href='http://tmjdev-test.blogspot.com/feeds/4858063079003295518/comments/default' + title='Post Comments'/> + <link + rel='replies' + type='text/html' + href='https://www.blogger.com/comment.g?blogID=8273578352962669317&postID=4858063079003295518' + title='0 Comments'/> + <link + rel='edit' + type='application/atom+xml' + href='http://www.blogger.com/feeds/8273578352962669317/posts/default/4858063079003295518?v=2'/> + <link + rel='self' + type='application/atom+xml' + href='http://www.blogger.com/feeds/8273578352962669317/posts/default/4858063079003295518?v=2'/> + <link + rel='alternate' + type='text/html' + href='http://tmjdev-test.blogspot.com/2008/11/test-image_11.html' + title='Test Image'/> + <author> + <name>John Doe</name> + <uri>http://www.blogger.com/profile/05925487542352262450</uri> + <email>tmjdev@gmail.com</email> + </author> + <thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total> + </entry> +</feed>
\ 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 @@ +<?xml version="1.0" encoding="utf-8" ?> +<attendeeStatus xmlns="http://schemas.google.com/g/2005" value="http://schemas.google.com/g/2005#event.invited"/> 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 @@ +<?xml version="1.0" encoding="utf-8" ?> +<attendeeType xmlns="http://schemas.google.com/g/2005" value="http://schemas.google.com/g/2005#event.required"/> 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 @@ +<?xml version="1.0" encoding="utf-8" ?> +<comments xmlns="http://schemas.google.com/g/2005" rel="http://schemas.google.com/g/2005#reviews"> + <feedLink href="http://example.com/restaurants/SanFrancisco/432432/reviews"> + </feedLink> +</comments> 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 @@ +<?xml version="1.0" encoding="utf-8" ?> +<gd:entryLink xmlns="http://www.w3.org/2005/Atom" xmlns:gd="http://schemas.google.com/g/2005" href="http://gmail.com/jo/contacts/Jo" readOnly="true" rel="via"> + <entry> + <category scheme="http://schemas.google.com/g/2005#kind" + term="http://schemas.google.com/g/2005#contact"/> + <id>http://gmail.com/jo/contacts/Jo</id> + <category term="user-tag" label="Google"/> + <title>Jo March</title> + </entry> +</gd:entryLink> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?xml-stylesheet href="http://www.google.com/url?sa=D&q=http://www.blogger.com/styles/atom.css" type="text/css"?> +<entry xmlns="http://www.w3.org/2005/Atom" xmlns:gd="http://schemas.google.com/g/2005" gd:etag="W/"CkcHQH8_fCp7ImA9WxRTGEw.""> + <id>tag:blogger.com,1999:blog-8273578352962669317.post-6938730899689776686</id> + <published>2008-09-07T10:53:00.001-07:00</published> + <updated>2008-09-07T10:53:51.144-07:00</updated> + <app:edited xmlns:app="http://www.w3.org/2007/app">2008-09-07T10:53:51.144-07:00</app:edited> + <title>Hello world</title> + <content type="html"><p>Hello world!</p></content> + <link rel="alternate" type="text/html" href="http://www.google.com/url?sa=D&q=http://example.blogspot.com/2008/09/hello-world.html" title="Hello world"/> + <link rel="replies" type="text/html" href="http://www.google.com/url?sa=D&q=http://www.blogger.com/comment.g%3FblogID%3D12345678901234567890%26amp%3BpostID%3D09876543210987654321" title="0 Comments"/> + <link rel="replies" type="application/atom+xml" href="http://www.google.com/url?sa=D&q=http://example.blogspot.com/feeds/12345678901234567890/comments/default" title="Post Comments"/> + <link rel="self" type="application/atom+xml" href="http://www.google.com/url?sa=D&q=http://example.blogspot.com/feeds/posts/default/12345678901234567890"/> + <link rel="edit" type="application/atom+xml" href="http://www.google.com/url?sa=D&q=http://www.blogger.com/feeds/12345678901234567890/posts/default/09876543210987654321%3Fv%3D2"/> + <author> + <name>John Doe</name> + <uri>http://www.blogger.com/profile/12345678901234567890</uri> + <email>jdoe@example.com</email> + </author> +</entry> 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 @@ +<?xml version="1.0" encoding="utf-8" ?> +<eventStatus xmlns="http://schemas.google.com/g/2005" value="http://schemas.google.com/g/2005#event.confirmed"/> 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 @@ +<?xml version="1.0" encoding="utf-8" ?> +<extendedProperty xmlns="http://schemas.google.com/g/2005" name="http://www.example.com/schemas/2007#mycal.id" + value="1234" />
\ 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 @@ +<?xml version="1.0" encoding="utf-8" ?> +<gd:feedLink xmlns="http://www.w3.org/2005/Atom" xmlns:gd="http://schemas.google.com/g/2005" href="http://www.google.com/calendar/feeds/default/private/full/3tsi3ag1q40bnsik88k25sgpss/comments" countHint="0" readOnly="true" rel="http://schemas.google.com/g/2005#feed"> + <feed> + <updated>2007-06-19T00:48:41.230Z</updated> + <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/g/2005#message"/> + <title type="text">Comments for: Sample Event</title> + <link rel="alternate" type="text/html" href="http://www.google.com/calendar/feeds/default/private/full/3tsi3ag1q40bnsik88k25sgpss/comments" title="alternate"/> + </feed> +</gd:feedLink> 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 @@ +<?xml version='1.0' encoding='UTF-8'?> +<?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?> +<feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:gd='http://schemas.google.com/g/2005'> + <id>tag:blogger.com,1999:blog-8273578352962669317</id> + <updated>2008-11-11T20:09:14.238-08:00</updated> + <title>Test Blog</title> + <subtitle type='html'>This is my description.</subtitle> + <link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://tmjdev-test.blogspot.com/feeds/posts/default'/> + <link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8273578352962669317/posts/default'/> + <link rel='alternate' type='text/html' href='http://tmjdev-test.blogspot.com/'/> + <link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/8273578352962669317/posts/default?start-index=26&max-results=25'/> + <author> + <name>John Doe</name> + <uri>http://www.blogger.com/profile/05925487542352262450</uri> + <email>tmjdev@gmail.com</email> + </author> + <generator version='7.00' uri='http://www.blogger.com'>Blogger</generator> + <openSearch:totalResults>30</openSearch:totalResults> + <openSearch:startIndex>1</openSearch:startIndex> + <openSearch:itemsPerPage>25</openSearch:itemsPerPage> + <entry> + <id>tag:blogger.com,1999:blog-8273578352962669317.post-4858063079003295518</id> + <published>2008-11-11T20:09:00.001-08:00</published> + <updated>2008-11-11T20:09:14.251-08:00</updated> + <app:edited xmlns:app='http://www.w3.org/2007/app'>2008-11-11T20:09:14.251-08:00</app:edited> + <title>Test Image</title> + <content type='html'>FOO</content> + <link + rel='replies' + type='application/atom+xml' + href='http://tmjdev-test.blogspot.com/feeds/4858063079003295518/comments/default' + title='Post Comments'/> + <link + rel='replies' + type='text/html' + href='https://www.blogger.com/comment.g?blogID=8273578352962669317&postID=4858063079003295518' + title='0 Comments'/> + <link + rel='edit' + type='application/atom+xml' + href='http://www.blogger.com/feeds/8273578352962669317/posts/default/4858063079003295518/1234567890'/> + <link + rel='self' + type='application/atom+xml' + href='http://www.blogger.com/feeds/8273578352962669317/posts/default/4858063079003295518'/> + <link + rel='alternate' + type='text/html' + href='http://tmjdev-test.blogspot.com/2008/11/test-image_11.html' + title='Test Image'/> + <author> + <name>John Doe</name> + <uri>http://www.blogger.com/profile/05925487542352262450</uri> + <email>tmjdev@gmail.com</email> + </author> + <thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total> + </entry> +</feed>
\ 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 @@ +<?xml version='1.0' encoding='UTF-8'?> +<?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?> +<feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/' xmlns:gd='http://schemas.google.com/g/2005' gd:etag='W/"CE4BRXw4cCp7ImA9WxRVFEs."'> + <id>tag:blogger.com,1999:blog-8273578352962669317</id> + <updated>2008-11-11T20:09:14.238-08:00</updated> + <title>Test Blog</title> + <subtitle type='html'>This is my description.</subtitle> + <link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://tmjdev-test.blogspot.com/feeds/posts/default'/> + <link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8273578352962669317/posts/default?v=2'/> + <link rel='alternate' type='text/html' href='http://tmjdev-test.blogspot.com/'/> + <link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/8273578352962669317/posts/default?start-index=26&max-results=25&v=2'/> + <author> + <name>John Doe</name> + <uri>http://www.blogger.com/profile/05925487542352262450</uri> + <email>tmjdev@gmail.com</email> + </author> + <generator version='7.00' uri='http://www.blogger.com'>Blogger</generator> + <openSearch:totalResults>30</openSearch:totalResults> + <openSearch:startIndex>1</openSearch:startIndex> + <openSearch:itemsPerPage>25</openSearch:itemsPerPage> + <entry gd:etag='W/"CE4BRXw-eSp7ImA9WxRVFEs."'> + <id>tag:blogger.com,1999:blog-8273578352962669317.post-4858063079003295518</id> + <published>2008-11-11T20:09:00.001-08:00</published> + <updated>2008-11-11T20:09:14.251-08:00</updated> + <app:edited xmlns:app='http://www.w3.org/2007/app'>2008-11-11T20:09:14.251-08:00</app:edited> + <title>Test Image</title> + <content type='html'>FOO</content> + <link + rel='replies' + type='application/atom+xml' + href='http://tmjdev-test.blogspot.com/feeds/4858063079003295518/comments/default' + title='Post Comments'/> + <link + rel='replies' + type='text/html' + href='https://www.blogger.com/comment.g?blogID=8273578352962669317&postID=4858063079003295518' + title='0 Comments'/> + <link + rel='edit' + type='application/atom+xml' + href='http://www.blogger.com/feeds/8273578352962669317/posts/default/4858063079003295518?v=2'/> + <link + rel='self' + type='application/atom+xml' + href='http://www.blogger.com/feeds/8273578352962669317/posts/default/4858063079003295518?v=2'/> + <link + rel='alternate' + type='text/html' + href='http://tmjdev-test.blogspot.com/2008/11/test-image_11.html' + title='Test Image'/> + <author> + <name>John Doe</name> + <uri>http://www.blogger.com/profile/05925487542352262450</uri> + <email>tmjdev@gmail.com</email> + </author> + <thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total> + </entry> +</feed>
\ 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 @@ +<?xml version="1.0" encoding="utf-8" ?> +<itemsPerPage xmlns="http://a9.com/-/spec/opensearchrss/1.0/">25</itemsPerPage> 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 @@ +<?xml version="1.0" encoding="utf-8" ?> +<startIndex xmlns="http://a9.com/-/spec/opensearchrss/1.0/">5</startIndex> 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 @@ +<?xml version="1.0" encoding="utf-8" ?> +<totalResults xmlns="http://a9.com/-/spec/opensearchrss/1.0/">12</totalResults> 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 @@ +<?xml version="1.0" encoding="utf-8" ?> +<originalEvent xmlns="http://schemas.google.com/g/2005" id="i8fl1nrv2bl57c1qgr3f0onmgg" href="http://www.google.com/calendar/feeds/userID/private/full/123456789"> + <when startTime="2006-03-17T22:00:00.000Z"/> +</originalEvent> 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 @@ +<?xml version="1.0" encoding="utf-8" ?> +<recurrence xmlns="http://schemas.google.com/g/2005"> +DTSTART;VALUE=DATE:20070501 +DTEND;VALUE=DATE:20070502 +RRULE:FREQ=WEEKLY;BYDAY=Tu;UNTIL=20070904 +</recurrence> 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 @@ +<?xml version="1.0" encoding="utf-8" ?> +<recurrenceException xmlns="http://schemas.google.com/g/2005" specialized="true"> + <entryLink href="http://www.google.com/calendar/feeds/default/private/full/hj4geu9lpkh3ebk6rvm4k8mhik"> + </entryLink> + <originalEvent id="hj4geu9lpkh3ebk6rvm4k8mhik" href="http://www.google.com/calendar/feeds/default/private/composite/hj4geu9lpkh3ebk6rvm4k8mhik" /> +</recurrenceException> 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 @@ +<?xml version="1.0" encoding="utf-8" ?> +<reminder xmlns="http://schemas.google.com/g/2005" absoluteTime="2005-06-06T16:55:00-08:00" days="42" hours="20" minutes="50" method="sms"/> 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 @@ +<?xml version="1.0" encoding="utf-8" ?> +<transparency xmlns="http://schemas.google.com/g/2005" value="http://schemas.google.com/g/2005#event.transparent"/> 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 @@ +<?xml version="1.0" encoding="utf-8" ?> +<visibility xmlns="http://schemas.google.com/g/2005" value="http://schemas.google.com/g/2005#event.confidential"/> 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 @@ +<?xml version="1.0" encoding="utf-8" ?> +<when xmlns="http://schemas.google.com/g/2005" startTime="2005-06-06T17:00:00-08:00" endTime="2005-06-06T18:00:00-08:00" valueString="Tomorrow @ 5 PM"/> 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 @@ +<?xml version="1.0" encoding="utf-8" ?> +<where xmlns="http://schemas.google.com/g/2005" rel="http://schemas.google.com/g/2005#event" valueString="Joe's Pub" label="1234 Anywhere Ln., New York, NY"> + <entryLink href="http://local.example.com/10018/JoesPub"> + </entryLink> +</where> 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 @@ +<?xml version="1.0" encoding="utf-8" ?> +<who xmlns="http://schemas.google.com/g/2005" rel="http://schemas.google.com/g/2005#event.attendee" valueString="Jo" email="jo@nowhere.invalid"> + <attendeeType value="http://schemas.google.com/g/2005#event.required"/> + <attendeeStatus value="http://schemas.google.com/g/2005#event.tentative"/> + <entryLink href="http://gmail.com/jo/contacts/Jo"> + </entryLink> +</who> diff --git a/zend/tests/Zend/Gdata/_files/testImage.jpg b/zend/tests/Zend/Gdata/_files/testImage.jpg Binary files differnew file mode 100644 index 0000000..b378f7a --- /dev/null +++ b/zend/tests/Zend/Gdata/_files/testImage.jpg |
