From 469ba46bd520050191e424027618be1455fceb00 Mon Sep 17 00:00:00 2001 From: prolic Date: Sat, 23 Jun 2012 15:03:06 +0200 Subject: [PATCH 1/2] fixed use statements in Zend\Feed --- src/PubSubHubbub/PubSubHubbub.php | 4 ++-- src/PubSubHubbub/Subscriber/Callback.php | 4 ++-- src/Reader/AbstractEntry.php | 6 +++--- src/Reader/AbstractFeed.php | 6 +++--- src/Reader/Entry/AbstractEntry.php | 10 +++++----- src/Reader/Entry/Atom.php | 6 +++--- src/Reader/Entry/Rss.php | 10 +++++----- src/Reader/Extension/AbstractEntry.php | 8 ++++---- src/Reader/Extension/AbstractFeed.php | 6 +++--- src/Reader/Extension/Atom/Entry.php | 16 ++++++++-------- src/Reader/Extension/Atom/Feed.php | 12 ++++++------ src/Reader/Extension/Content/Entry.php | 4 ++-- src/Reader/Extension/CreativeCommons/Feed.php | 4 ++-- src/Reader/Extension/DublinCore/Entry.php | 10 +++++----- src/Reader/Extension/DublinCore/Feed.php | 8 ++++---- src/Reader/Extension/Podcast/Feed.php | 4 ++-- src/Reader/Extension/Syndication/Feed.php | 6 +++--- src/Reader/Feed/AbstractFeed.php | 8 ++++---- src/Reader/Feed/Atom.php | 6 +++--- src/Reader/Feed/Atom/Source.php | 10 +++++----- src/Reader/Feed/FeedInterface.php | 4 ++-- src/Reader/Feed/Rss.php | 10 +++++----- src/Reader/FeedSet.php | 6 +++--- src/Reader/Reader.php | 12 ++++++------ src/Writer/AbstractFeed.php | 6 +++--- src/Writer/Deleted.php | 4 ++-- src/Writer/Entry.php | 6 +++--- src/Writer/Extension/AbstractRenderer.php | 4 ++-- src/Writer/Extension/Atom/Renderer/Feed.php | 6 +++--- src/Writer/Extension/Content/Renderer/Entry.php | 6 +++--- .../Extension/DublinCore/Renderer/Entry.php | 6 +++--- .../Extension/DublinCore/Renderer/Feed.php | 6 +++--- src/Writer/Extension/ITunes/Feed.php | 4 ++-- src/Writer/Extension/ITunes/Renderer/Entry.php | 6 +++--- src/Writer/Extension/ITunes/Renderer/Feed.php | 6 +++--- src/Writer/Extension/Renderer.php | 4 ++-- src/Writer/Extension/Slash/Renderer/Entry.php | 6 +++--- .../Extension/Threading/Renderer/Entry.php | 6 +++--- .../Extension/WellFormedWeb/Renderer/Entry.php | 6 +++--- src/Writer/Feed.php | 8 ++++---- src/Writer/Renderer/Entry/Atom.php | 14 +++++++------- src/Writer/Renderer/Entry/Atom/Deleted.php | 4 ++-- src/Writer/Renderer/Entry/Rss.php | 12 ++++++------ src/Writer/Renderer/Feed/AbstractAtom.php | 10 +++++----- src/Writer/Renderer/Feed/Atom.php | 6 +++--- src/Writer/Renderer/Feed/Atom/AbstractAtom.php | 6 +++--- src/Writer/Renderer/Feed/Atom/Source.php | 4 ++-- src/Writer/Renderer/Feed/AtomSource.php | 8 ++++---- src/Writer/Renderer/Feed/Rss.php | 12 ++++++------ src/Writer/Renderer/RendererInterface.php | 4 ++-- src/Writer/Writer.php | 8 ++++---- 51 files changed, 179 insertions(+), 179 deletions(-) diff --git a/src/PubSubHubbub/PubSubHubbub.php b/src/PubSubHubbub/PubSubHubbub.php index cc40e61a..90c2f723 100644 --- a/src/PubSubHubbub/PubSubHubbub.php +++ b/src/PubSubHubbub/PubSubHubbub.php @@ -20,8 +20,8 @@ namespace Zend\Feed\PubSubHubbub; -use Zend\Feed\Reader, - Zend\Http; +use Zend\Feed\Reader; +use Zend\Http; /** * @category Zend diff --git a/src/PubSubHubbub/Subscriber/Callback.php b/src/PubSubHubbub/Subscriber/Callback.php index f39e97d3..63337920 100644 --- a/src/PubSubHubbub/Subscriber/Callback.php +++ b/src/PubSubHubbub/Subscriber/Callback.php @@ -20,8 +20,8 @@ namespace Zend\Feed\PubSubHubbub\Subscriber; -use Zend\Feed\PubSubHubbub, - Zend\Uri; +use Zend\Feed\PubSubHubbub; +use Zend\Uri; /** * @category Zend diff --git a/src/Reader/AbstractEntry.php b/src/Reader/AbstractEntry.php index d95755cb..09b1a36b 100644 --- a/src/Reader/AbstractEntry.php +++ b/src/Reader/AbstractEntry.php @@ -20,9 +20,9 @@ namespace Zend\Feed\Reader; -use DOMElement, - DOMDocument, - DOMXPath; +use DOMElement; +use DOMDocument; +use DOMXPath; /** * @category Zend diff --git a/src/Reader/AbstractFeed.php b/src/Reader/AbstractFeed.php index 6623ee58..b14d83bb 100644 --- a/src/Reader/AbstractFeed.php +++ b/src/Reader/AbstractFeed.php @@ -20,9 +20,9 @@ namespace Zend\Feed\Reader; -use DOMDocument, - DOMElement, - DOMXPath; +use DOMDocument; +use DOMElement; +use DOMXPath; /** * @category Zend diff --git a/src/Reader/Entry/AbstractEntry.php b/src/Reader/Entry/AbstractEntry.php index bf27e6c6..d10774f3 100644 --- a/src/Reader/Entry/AbstractEntry.php +++ b/src/Reader/Entry/AbstractEntry.php @@ -20,11 +20,11 @@ namespace Zend\Feed\Reader\Entry; -use Zend\Feed\Reader, - Zend\Feed\Reader\Exception, - DOMElement, - DOMDocument, - DOMXPath; +use Zend\Feed\Reader; +use Zend\Feed\Reader\Exception; +use DOMElement; +use DOMDocument; +use DOMXPath; /** * @category Zend diff --git a/src/Reader/Entry/Atom.php b/src/Reader/Entry/Atom.php index fe46ff1f..9e09d0d9 100644 --- a/src/Reader/Entry/Atom.php +++ b/src/Reader/Entry/Atom.php @@ -20,9 +20,9 @@ namespace Zend\Feed\Reader\Entry; -use Zend\Feed\Reader, - DOMElement, - DOMXPath; +use Zend\Feed\Reader; +use DOMElement; +use DOMXPath; /** * @category Zend diff --git a/src/Reader/Entry/Rss.php b/src/Reader/Entry/Rss.php index c266d4fb..a5e90da1 100644 --- a/src/Reader/Entry/Rss.php +++ b/src/Reader/Entry/Rss.php @@ -20,11 +20,11 @@ namespace Zend\Feed\Reader\Entry; -use Zend\Feed\Reader, - Zend\Date, - Zend\Feed\Reader\Exception, - DOMElement, - DOMXPath; +use Zend\Feed\Reader; +use Zend\Date; +use Zend\Feed\Reader\Exception; +use DOMElement; +use DOMXPath; /** * @category Zend diff --git a/src/Reader/Extension/AbstractEntry.php b/src/Reader/Extension/AbstractEntry.php index 7b08ffd6..95f43f7c 100644 --- a/src/Reader/Extension/AbstractEntry.php +++ b/src/Reader/Extension/AbstractEntry.php @@ -20,10 +20,10 @@ namespace Zend\Feed\Reader\Extension; -use Zend\Feed\Reader, - DOMXPath, - DOMDocument, - DOMElement; +use Zend\Feed\Reader; +use DOMXPath; +use DOMDocument; +use DOMElement; /** * @category Zend diff --git a/src/Reader/Extension/AbstractFeed.php b/src/Reader/Extension/AbstractFeed.php index c44a5669..934e856d 100644 --- a/src/Reader/Extension/AbstractFeed.php +++ b/src/Reader/Extension/AbstractFeed.php @@ -20,9 +20,9 @@ namespace Zend\Feed\Reader\Extension; -use Zend\Feed\Reader, - DOMDocument, - DOMXPath; +use Zend\Feed\Reader; +use DOMDocument; +use DOMXPath; /** * @category Zend diff --git a/src/Reader/Extension/Atom/Entry.php b/src/Reader/Extension/Atom/Entry.php index 42667b86..1e0872ad 100644 --- a/src/Reader/Extension/Atom/Entry.php +++ b/src/Reader/Extension/Atom/Entry.php @@ -20,14 +20,14 @@ namespace Zend\Feed\Reader\Extension\Atom; -use DOMDocument, - DOMElement, - stdClass, - Zend\Date, - Zend\Feed\Reader, - Zend\Feed\Reader\Collection, - Zend\Feed\Reader\Extension, - Zend\Uri; +use DOMDocument; +use DOMElement; +use stdClass; +use Zend\Date; +use Zend\Feed\Reader; +use Zend\Feed\Reader\Collection; +use Zend\Feed\Reader\Extension; +use Zend\Uri; /** * @category Zend diff --git a/src/Reader/Extension/Atom/Feed.php b/src/Reader/Extension/Atom/Feed.php index 10f2b860..f3d4101e 100644 --- a/src/Reader/Extension/Atom/Feed.php +++ b/src/Reader/Extension/Atom/Feed.php @@ -20,12 +20,12 @@ namespace Zend\Feed\Reader\Extension\Atom; -use Zend\Date, - Zend\Feed\Reader, - Zend\Feed\Reader\Collection, - Zend\Feed\Reader\Extension, - Zend\Uri, - DOMElement; +use Zend\Date; +use Zend\Feed\Reader; +use Zend\Feed\Reader\Collection; +use Zend\Feed\Reader\Extension; +use Zend\Uri; +use DOMElement; /** * @category Zend diff --git a/src/Reader/Extension/Content/Entry.php b/src/Reader/Extension/Content/Entry.php index f83d5ff9..80e58737 100644 --- a/src/Reader/Extension/Content/Entry.php +++ b/src/Reader/Extension/Content/Entry.php @@ -20,8 +20,8 @@ namespace Zend\Feed\Reader\Extension\Content; -use Zend\Feed\Reader, - Zend\Feed\Reader\Extension; +use Zend\Feed\Reader; +use Zend\Feed\Reader\Extension; /** * @category Zend diff --git a/src/Reader/Extension/CreativeCommons/Feed.php b/src/Reader/Extension/CreativeCommons/Feed.php index b6634145..84afa1fc 100644 --- a/src/Reader/Extension/CreativeCommons/Feed.php +++ b/src/Reader/Extension/CreativeCommons/Feed.php @@ -20,8 +20,8 @@ namespace Zend\Feed\Reader\Extension\CreativeCommons; -use Zend\Feed\Reader, - Zend\Feed\Reader\Extension; +use Zend\Feed\Reader; +use Zend\Feed\Reader\Extension; /** * @category Zend diff --git a/src/Reader/Extension/DublinCore/Entry.php b/src/Reader/Extension/DublinCore/Entry.php index 452f55a1..e2e6db13 100644 --- a/src/Reader/Extension/DublinCore/Entry.php +++ b/src/Reader/Extension/DublinCore/Entry.php @@ -20,11 +20,11 @@ namespace Zend\Feed\Reader\Extension\DublinCore; -use Zend\Feed\Reader, - Zend\Feed\Reader\Collection, - Zend\Feed\Reader\Extension, - Zend\Date, - DOMElement; +use Zend\Feed\Reader; +use Zend\Feed\Reader\Collection; +use Zend\Feed\Reader\Extension; +use Zend\Date; +use DOMElement; /** * @category Zend diff --git a/src/Reader/Extension/DublinCore/Feed.php b/src/Reader/Extension/DublinCore/Feed.php index 57f9bf61..d0542350 100644 --- a/src/Reader/Extension/DublinCore/Feed.php +++ b/src/Reader/Extension/DublinCore/Feed.php @@ -20,10 +20,10 @@ namespace Zend\Feed\Reader\Extension\DublinCore; -use Zend\Feed\Reader, - Zend\Feed\Reader\Collection, - Zend\Feed\Reader\Extension, - Zend\Date; +use Zend\Feed\Reader; +use Zend\Feed\Reader\Collection; +use Zend\Feed\Reader\Extension; +use Zend\Date; /** * @category Zend diff --git a/src/Reader/Extension/Podcast/Feed.php b/src/Reader/Extension/Podcast/Feed.php index c5b81f36..59fdfb0b 100644 --- a/src/Reader/Extension/Podcast/Feed.php +++ b/src/Reader/Extension/Podcast/Feed.php @@ -20,8 +20,8 @@ namespace Zend\Feed\Reader\Extension\Podcast; -use Zend\Feed\Reader\Extension, - DOMText; +use Zend\Feed\Reader\Extension; +use DOMText; /** * @category Zend diff --git a/src/Reader/Extension/Syndication/Feed.php b/src/Reader/Extension/Syndication/Feed.php index 7f2b7ae1..c0b65b1e 100644 --- a/src/Reader/Extension/Syndication/Feed.php +++ b/src/Reader/Extension/Syndication/Feed.php @@ -20,9 +20,9 @@ namespace Zend\Feed\Reader\Extension\Syndication; -use Zend\Feed\Reader, - Zend\Feed\Reader\Extension, - Zend\Date; +use Zend\Feed\Reader; +use Zend\Feed\Reader\Extension; +use Zend\Date; /** * @category Zend diff --git a/src/Reader/Feed/AbstractFeed.php b/src/Reader/Feed/AbstractFeed.php index 500800b2..7f948241 100644 --- a/src/Reader/Feed/AbstractFeed.php +++ b/src/Reader/Feed/AbstractFeed.php @@ -20,10 +20,10 @@ namespace Zend\Feed\Reader\Feed; -use Zend\Feed\Reader, - Zend\Feed\Reader\Exception, - DOMXPath, - DOMDocument; +use Zend\Feed\Reader; +use Zend\Feed\Reader\Exception; +use DOMXPath; +use DOMDocument; /** * @category Zend diff --git a/src/Reader/Feed/Atom.php b/src/Reader/Feed/Atom.php index b1336381..4c5c0833 100644 --- a/src/Reader/Feed/Atom.php +++ b/src/Reader/Feed/Atom.php @@ -20,9 +20,9 @@ namespace Zend\Feed\Reader\Feed; -use Zend\Feed\Reader, - Zend\Date, - DOMDocument; +use Zend\Feed\Reader; +use Zend\Date; +use DOMDocument; /** * @category Zend diff --git a/src/Reader/Feed/Atom/Source.php b/src/Reader/Feed/Atom/Source.php index 3731f031..d8153867 100644 --- a/src/Reader/Feed/Atom/Source.php +++ b/src/Reader/Feed/Atom/Source.php @@ -20,11 +20,11 @@ namespace Zend\Feed\Reader\Feed\Atom; -use Zend\Feed\Reader, - Zend\Feed\Reader\Feed, - Zend\Date, - DOMElement, - DOMXPath; +use Zend\Feed\Reader; +use Zend\Feed\Reader\Feed; +use Zend\Date; +use DOMElement; +use DOMXPath; /** * @category Zend diff --git a/src/Reader/Feed/FeedInterface.php b/src/Reader/Feed/FeedInterface.php index 93e38f22..dbc70c7d 100644 --- a/src/Reader/Feed/FeedInterface.php +++ b/src/Reader/Feed/FeedInterface.php @@ -20,8 +20,8 @@ namespace Zend\Feed\Reader\Feed; -use Iterator, - Countable; +use Iterator; +use Countable; /** * @category Zend diff --git a/src/Reader/Feed/Rss.php b/src/Reader/Feed/Rss.php index f4b77b9e..2667cea4 100644 --- a/src/Reader/Feed/Rss.php +++ b/src/Reader/Feed/Rss.php @@ -20,11 +20,11 @@ namespace Zend\Feed\Reader\Feed; -use Zend\Feed\Reader, - Zend\Feed\Reader\Collection, - Zend\Feed\Reader\Exception, - Zend\Date, - DOMDocument; +use Zend\Feed\Reader; +use Zend\Feed\Reader\Collection; +use Zend\Feed\Reader\Exception; +use Zend\Date; +use DOMDocument; /** * @category Zend diff --git a/src/Reader/FeedSet.php b/src/Reader/FeedSet.php index cdc51bb8..d0776d8b 100644 --- a/src/Reader/FeedSet.php +++ b/src/Reader/FeedSet.php @@ -20,9 +20,9 @@ namespace Zend\Feed\Reader; -use ArrayObject, - DOMNodeList, - Zend\Uri; +use ArrayObject; +use DOMNodeList; +use Zend\Uri; /** * @category Zend diff --git a/src/Reader/Reader.php b/src/Reader/Reader.php index ee42b652..e9521c1f 100644 --- a/src/Reader/Reader.php +++ b/src/Reader/Reader.php @@ -20,12 +20,12 @@ namespace Zend\Feed\Reader; -use Zend\Cache\Storage\StorageInterface as CacheStorage, - Zend\Http, - Zend\Loader, - Zend\Stdlib\ErrorHandler, - DOMDocument, - DOMXPath; +use Zend\Cache\Storage\StorageInterface as CacheStorage; +use Zend\Http; +use Zend\Loader; +use Zend\Stdlib\ErrorHandler; +use DOMDocument; +use DOMXPath; /** * @category Zend diff --git a/src/Writer/AbstractFeed.php b/src/Writer/AbstractFeed.php index 48c43351..e2f42523 100644 --- a/src/Writer/AbstractFeed.php +++ b/src/Writer/AbstractFeed.php @@ -20,9 +20,9 @@ namespace Zend\Feed\Writer; -use Zend\Uri, - Zend\Date, - Zend\Validator; +use Zend\Uri; +use Zend\Date; +use Zend\Validator; /** * @category Zend diff --git a/src/Writer/Deleted.php b/src/Writer/Deleted.php index 4dc82be6..83e81b69 100644 --- a/src/Writer/Deleted.php +++ b/src/Writer/Deleted.php @@ -20,8 +20,8 @@ namespace Zend\Feed\Writer; -use Zend\Date, - Zend\Uri; +use Zend\Date; +use Zend\Uri; /** * @category Zend diff --git a/src/Writer/Entry.php b/src/Writer/Entry.php index a3cb0c6a..97343769 100644 --- a/src/Writer/Entry.php +++ b/src/Writer/Entry.php @@ -20,9 +20,9 @@ namespace Zend\Feed\Writer; -use Zend\Feed\Writer\Exception, - Zend\Uri, - Zend\Date; +use Zend\Feed\Writer\Exception; +use Zend\Uri; +use Zend\Date; /** * @category Zend diff --git a/src/Writer/Extension/AbstractRenderer.php b/src/Writer/Extension/AbstractRenderer.php index baa56639..88907a85 100644 --- a/src/Writer/Extension/AbstractRenderer.php +++ b/src/Writer/Extension/AbstractRenderer.php @@ -20,8 +20,8 @@ namespace Zend\Feed\Writer\Extension; -use DOMDocument, - DOMElement; +use DOMDocument; +use DOMElement; /** * @category Zend diff --git a/src/Writer/Extension/Atom/Renderer/Feed.php b/src/Writer/Extension/Atom/Renderer/Feed.php index 5a9b5b9e..86e910b2 100644 --- a/src/Writer/Extension/Atom/Renderer/Feed.php +++ b/src/Writer/Extension/Atom/Renderer/Feed.php @@ -20,9 +20,9 @@ namespace Zend\Feed\Writer\Extension\Atom\Renderer; -use Zend\Feed\Writer\Extension, - DOMDocument, - DOMElement; +use Zend\Feed\Writer\Extension; +use DOMDocument; +use DOMElement; /** * @category Zend diff --git a/src/Writer/Extension/Content/Renderer/Entry.php b/src/Writer/Extension/Content/Renderer/Entry.php index a7669f97..5dd5ccbc 100644 --- a/src/Writer/Extension/Content/Renderer/Entry.php +++ b/src/Writer/Extension/Content/Renderer/Entry.php @@ -20,9 +20,9 @@ namespace Zend\Feed\Writer\Extension\Content\Renderer; -use Zend\Feed\Writer\Extension, - DOMDocument, - DOMElement; +use Zend\Feed\Writer\Extension; +use DOMDocument; +use DOMElement; /** * @category Zend diff --git a/src/Writer/Extension/DublinCore/Renderer/Entry.php b/src/Writer/Extension/DublinCore/Renderer/Entry.php index 8a2be91c..fcb03000 100644 --- a/src/Writer/Extension/DublinCore/Renderer/Entry.php +++ b/src/Writer/Extension/DublinCore/Renderer/Entry.php @@ -20,9 +20,9 @@ namespace Zend\Feed\Writer\Extension\DublinCore\Renderer; -use Zend\Feed\Writer\Extension, - DOMDocument, - DOMElement; +use Zend\Feed\Writer\Extension; +use DOMDocument; +use DOMElement; /** * @category Zend diff --git a/src/Writer/Extension/DublinCore/Renderer/Feed.php b/src/Writer/Extension/DublinCore/Renderer/Feed.php index 05edddc0..4c02f81b 100644 --- a/src/Writer/Extension/DublinCore/Renderer/Feed.php +++ b/src/Writer/Extension/DublinCore/Renderer/Feed.php @@ -20,9 +20,9 @@ namespace Zend\Feed\Writer\Extension\DublinCore\Renderer; -use Zend\Feed\Writer\Extension, - DOMDocument, - DOMElement; +use Zend\Feed\Writer\Extension; +use DOMDocument; +use DOMElement; /** * @category Zend diff --git a/src/Writer/Extension/ITunes/Feed.php b/src/Writer/Extension/ITunes/Feed.php index 4f33f123..c57c9319 100644 --- a/src/Writer/Extension/ITunes/Feed.php +++ b/src/Writer/Extension/ITunes/Feed.php @@ -20,8 +20,8 @@ namespace Zend\Feed\Writer\Extension\ITunes; -use Zend\Feed\Writer, - Zend\Uri; +use Zend\Feed\Writer; +use Zend\Uri; /** * @category Zend diff --git a/src/Writer/Extension/ITunes/Renderer/Entry.php b/src/Writer/Extension/ITunes/Renderer/Entry.php index dab3105a..4c2b860a 100644 --- a/src/Writer/Extension/ITunes/Renderer/Entry.php +++ b/src/Writer/Extension/ITunes/Renderer/Entry.php @@ -20,9 +20,9 @@ namespace Zend\Feed\Writer\Extension\ITunes\Renderer; -use Zend\Feed\Writer\Extension, - DOMDocument, - DOMElement; +use Zend\Feed\Writer\Extension; +use DOMDocument; +use DOMElement; /** * @category Zend diff --git a/src/Writer/Extension/ITunes/Renderer/Feed.php b/src/Writer/Extension/ITunes/Renderer/Feed.php index 77cabdbf..63c2d643 100644 --- a/src/Writer/Extension/ITunes/Renderer/Feed.php +++ b/src/Writer/Extension/ITunes/Renderer/Feed.php @@ -20,9 +20,9 @@ namespace Zend\Feed\Writer\Extension\ITunes\Renderer; -use Zend\Feed\Writer\Extension, - DOMDocument, - DOMElement; +use Zend\Feed\Writer\Extension; +use DOMDocument; +use DOMElement; /** * @category Zend diff --git a/src/Writer/Extension/Renderer.php b/src/Writer/Extension/Renderer.php index 297664c4..5de01266 100644 --- a/src/Writer/Extension/Renderer.php +++ b/src/Writer/Extension/Renderer.php @@ -20,8 +20,8 @@ namespace Zend\Feed\Writer\Extension; -use DOMDocument, - DOMElement; +use DOMDocument; +use DOMElement; /** * @category Zend diff --git a/src/Writer/Extension/Slash/Renderer/Entry.php b/src/Writer/Extension/Slash/Renderer/Entry.php index d0b27c0e..51594837 100644 --- a/src/Writer/Extension/Slash/Renderer/Entry.php +++ b/src/Writer/Extension/Slash/Renderer/Entry.php @@ -20,9 +20,9 @@ namespace Zend\Feed\Writer\Extension\Slash\Renderer; -use Zend\Feed\Writer\Extension, - DOMDocument, - DOMElement; +use Zend\Feed\Writer\Extension; +use DOMDocument; +use DOMElement; /** * @category Zend diff --git a/src/Writer/Extension/Threading/Renderer/Entry.php b/src/Writer/Extension/Threading/Renderer/Entry.php index 24f90471..36db2d9f 100644 --- a/src/Writer/Extension/Threading/Renderer/Entry.php +++ b/src/Writer/Extension/Threading/Renderer/Entry.php @@ -20,9 +20,9 @@ namespace Zend\Feed\Writer\Extension\Threading\Renderer; -use Zend\Feed\Writer\Extension, - DOMDocument, - DOMElement; +use Zend\Feed\Writer\Extension; +use DOMDocument; +use DOMElement; /** * @category Zend diff --git a/src/Writer/Extension/WellFormedWeb/Renderer/Entry.php b/src/Writer/Extension/WellFormedWeb/Renderer/Entry.php index 38ac7ad9..25e99504 100644 --- a/src/Writer/Extension/WellFormedWeb/Renderer/Entry.php +++ b/src/Writer/Extension/WellFormedWeb/Renderer/Entry.php @@ -20,9 +20,9 @@ namespace Zend\Feed\Writer\Extension\WellFormedWeb\Renderer; -use Zend\Feed\Writer\Extension, - DOMDocument, - DOMElement; +use Zend\Feed\Writer\Extension; +use DOMDocument; +use DOMElement; /** * @category Zend diff --git a/src/Writer/Feed.php b/src/Writer/Feed.php index 8fd2bb85..9900abee 100644 --- a/src/Writer/Feed.php +++ b/src/Writer/Feed.php @@ -20,10 +20,10 @@ namespace Zend\Feed\Writer; -use Countable, - Iterator, - Zend\Date, - Zend\Feed\Writer\Renderer; +use Countable; +use Iterator; +use Zend\Date; +use Zend\Feed\Writer\Renderer; /** * @category Zend diff --git a/src/Writer/Renderer/Entry/Atom.php b/src/Writer/Renderer/Entry/Atom.php index eeb1cbe1..d6fc1f9c 100644 --- a/src/Writer/Renderer/Entry/Atom.php +++ b/src/Writer/Renderer/Entry/Atom.php @@ -20,13 +20,13 @@ namespace Zend\Feed\Writer\Renderer\Entry; -use DOMDocument, - DOMElement, - Zend\Date, - Zend\Feed\Writer, - Zend\Feed\Writer\Renderer, - Zend\Uri, - Zend\Validator; +use DOMDocument; +use DOMElement; +use Zend\Date; +use Zend\Feed\Writer; +use Zend\Feed\Writer\Renderer; +use Zend\Uri; +use Zend\Validator; /** * @category Zend diff --git a/src/Writer/Renderer/Entry/Atom/Deleted.php b/src/Writer/Renderer/Entry/Atom/Deleted.php index 1b702091..0a151abb 100644 --- a/src/Writer/Renderer/Entry/Atom/Deleted.php +++ b/src/Writer/Renderer/Entry/Atom/Deleted.php @@ -20,8 +20,8 @@ namespace Zend\Feed\Writer\Renderer\Entry\Atom; -use DOMDocument, - DOMElement; +use DOMDocument; +use DOMElement; /** * @category Zend diff --git a/src/Writer/Renderer/Entry/Rss.php b/src/Writer/Renderer/Entry/Rss.php index 32ce4953..6744e874 100644 --- a/src/Writer/Renderer/Entry/Rss.php +++ b/src/Writer/Renderer/Entry/Rss.php @@ -20,12 +20,12 @@ namespace Zend\Feed\Writer\Renderer\Entry; -use Zend\Date, - Zend\Feed\Writer, - Zend\Feed\Writer\Renderer, - Zend\Uri, - DOMDocument, - DOMElement; +use Zend\Date; +use Zend\Feed\Writer; +use Zend\Feed\Writer\Renderer; +use Zend\Uri; +use DOMDocument; +use DOMElement; /** * @category Zend diff --git a/src/Writer/Renderer/Feed/AbstractAtom.php b/src/Writer/Renderer/Feed/AbstractAtom.php index fde2e6eb..1a26d30f 100644 --- a/src/Writer/Renderer/Feed/AbstractAtom.php +++ b/src/Writer/Renderer/Feed/AbstractAtom.php @@ -20,11 +20,11 @@ namespace Zend\Feed\Writer\Renderer\Feed; -use Zend\Feed\Writer\Renderer, - Zend\Date, - Zend\Feed\Writer, - DOMDocument, - DOMElement; +use Zend\Feed\Writer\Renderer; +use Zend\Date; +use Zend\Feed\Writer; +use DOMDocument; +use DOMElement; /** * @category Zend diff --git a/src/Writer/Renderer/Feed/Atom.php b/src/Writer/Renderer/Feed/Atom.php index ef113b0f..981b85cb 100644 --- a/src/Writer/Renderer/Feed/Atom.php +++ b/src/Writer/Renderer/Feed/Atom.php @@ -20,9 +20,9 @@ namespace Zend\Feed\Writer\Renderer\Feed; -use Zend\Feed\Writer\Renderer, - Zend\Feed\Writer, - DOMDocument; +use Zend\Feed\Writer\Renderer; +use Zend\Feed\Writer; +use DOMDocument; /** * @category Zend diff --git a/src/Writer/Renderer/Feed/Atom/AbstractAtom.php b/src/Writer/Renderer/Feed/Atom/AbstractAtom.php index 3a9f0963..eb817664 100644 --- a/src/Writer/Renderer/Feed/Atom/AbstractAtom.php +++ b/src/Writer/Renderer/Feed/Atom/AbstractAtom.php @@ -20,9 +20,9 @@ namespace Zend\Feed\Writer\Renderer\Feed\Atom; -use Zend\Feed, - DOMDocument, - DOMElement; +use Zend\Feed; +use DOMDocument; +use DOMElement; /** * @category Zend diff --git a/src/Writer/Renderer/Feed/Atom/Source.php b/src/Writer/Renderer/Feed/Atom/Source.php index 5e34e05b..8958cd38 100644 --- a/src/Writer/Renderer/Feed/Atom/Source.php +++ b/src/Writer/Renderer/Feed/Atom/Source.php @@ -20,8 +20,8 @@ namespace Zend\Feed\Writer\Renderer\Feed\Atom; -use DOMDocument, - DOMElement; +use DOMDocument; +use DOMElement; /** * @category Zend diff --git a/src/Writer/Renderer/Feed/AtomSource.php b/src/Writer/Renderer/Feed/AtomSource.php index 005d000c..cff02b45 100644 --- a/src/Writer/Renderer/Feed/AtomSource.php +++ b/src/Writer/Renderer/Feed/AtomSource.php @@ -20,10 +20,10 @@ namespace Zend\Feed\Writer\Renderer\Feed; -use Zend\Feed\Writer\Renderer, - Zend\Feed\Writer, - DOMElement, - DOMDocument; +use Zend\Feed\Writer\Renderer; +use Zend\Feed\Writer; +use DOMElement; +use DOMDocument; /** * @category Zend diff --git a/src/Writer/Renderer/Feed/Rss.php b/src/Writer/Renderer/Feed/Rss.php index a129cb7f..56420c96 100644 --- a/src/Writer/Renderer/Feed/Rss.php +++ b/src/Writer/Renderer/Feed/Rss.php @@ -20,12 +20,12 @@ namespace Zend\Feed\Writer\Renderer\Feed; -use DOMDocument, - DOMElement, - Zend\Date, - Zend\Feed\Writer, - Zend\Feed\Writer\Renderer, - Zend\Uri; +use DOMDocument; +use DOMElement; +use Zend\Date; +use Zend\Feed\Writer; +use Zend\Feed\Writer\Renderer; +use Zend\Uri; /** * @category Zend diff --git a/src/Writer/Renderer/RendererInterface.php b/src/Writer/Renderer/RendererInterface.php index c2468aec..1d0f76c8 100644 --- a/src/Writer/Renderer/RendererInterface.php +++ b/src/Writer/Renderer/RendererInterface.php @@ -20,8 +20,8 @@ namespace Zend\Feed\Writer\Renderer; -use DOMDocument, - DOMElement; +use DOMDocument; +use DOMElement; /** * @category Zend diff --git a/src/Writer/Writer.php b/src/Writer/Writer.php index fbb472ef..c6b8b0ba 100644 --- a/src/Writer/Writer.php +++ b/src/Writer/Writer.php @@ -20,10 +20,10 @@ namespace Zend\Feed\Writer; -use Zend\Loader\ShortNameLocator, - Zend\Loader\PrefixPathLoader, - Zend\Loader\PrefixPathMapper, - Zend\Loader\Exception\PluginLoaderException; +use Zend\Loader\ShortNameLocator; +use Zend\Loader\PrefixPathLoader; +use Zend\Loader\PrefixPathMapper; +use Zend\Loader\Exception\PluginLoaderException; /** * @category Zend From 545292f695969f6753cc405e7475e0d280c2c05c Mon Sep 17 00:00:00 2001 From: Maks3w Date: Wed, 27 Jun 2012 14:09:14 +0200 Subject: [PATCH 2/2] [Feed] Remove Zend\Date in favor of DateTime --- src/PubSubHubbub/Model/Subscription.php | 23 +- src/PubSubHubbub/Subscriber.php | 11 +- src/Reader/Entry/Rss.php | 15 +- src/Reader/Extension/Atom/Entry.php | 8 +- src/Reader/Extension/Atom/Feed.php | 14 +- src/Reader/Extension/DublinCore/Entry.php | 7 +- src/Reader/Extension/DublinCore/Feed.php | 9 +- src/Reader/Extension/Syndication/Feed.php | 9 +- src/Reader/Feed/Atom.php | 1 - src/Reader/Feed/Atom/Source.php | 1 - src/Reader/Feed/Rss.php | 32 +- src/Writer/AbstractFeed.php | 58 ++- src/Writer/Deleted.php | 26 +- src/Writer/Entry.php | 40 +- src/Writer/Feed.php | 6 +- src/Writer/Renderer/Entry/Atom.php | 6 +- src/Writer/Renderer/Entry/Atom/Deleted.php | 3 +- src/Writer/Renderer/Entry/AtomDeleted.php | 3 +- src/Writer/Renderer/Entry/Rss.php | 4 +- src/Writer/Renderer/Feed/AbstractAtom.php | 4 +- .../Renderer/Feed/Atom/AbstractAtom.php | 3 +- src/Writer/Renderer/Feed/Rss.php | 6 +- test/PubSubHubbub/Model/SubscriptionTest.php | 4 +- test/PubSubHubbub/Subscriber/CallbackTest.php | 23 +- test/Reader/Entry/AtomStandaloneEntryTest.php | 28 +- test/Reader/Entry/AtomTest.php | 35 +- test/Reader/Entry/RssTest.php | 320 +++------------ test/Reader/Feed/AtomSourceTest.php | 27 +- test/Reader/Feed/AtomTest.php | 39 +- test/Reader/Feed/RssTest.php | 365 +++--------------- .../Integration/H-OnlineComAtom10Test.php | 14 +- test/Reader/Integration/LautDeRdfTest.php | 14 +- test/Reader/Integration/PodcastRss2Test.php | 14 +- .../Integration/WordpressAtom10Test.php | 14 +- test/Writer/DeletedTest.php | 27 +- test/Writer/EntryTest.php | 50 +-- test/Writer/FeedTest.php | 82 ++-- test/Writer/Renderer/Entry/AtomTest.php | 6 +- test/Writer/Renderer/Entry/RssTest.php | 6 +- test/Writer/Renderer/Feed/AtomTest.php | 4 +- test/Writer/Renderer/Feed/RssTest.php | 5 +- 41 files changed, 375 insertions(+), 991 deletions(-) diff --git a/src/PubSubHubbub/Model/Subscription.php b/src/PubSubHubbub/Model/Subscription.php index 2ca2fa7b..fcdd3bc5 100644 --- a/src/PubSubHubbub/Model/Subscription.php +++ b/src/PubSubHubbub/Model/Subscription.php @@ -21,7 +21,8 @@ namespace Zend\Feed\PubSubHubbub\Model; -use Zend\Date; +use DateInterval; +use DateTime; use Zend\Feed\PubSubHubbub; /** @@ -34,9 +35,9 @@ class Subscription extends AbstractModel implements SubscriptionPersistenceInterface { /** - * Common Date\Date object to assist with unit testing + * Common DateTime object to assist with unit testing * - * @var Date\Date + * @var DateTime */ protected $now; @@ -61,8 +62,8 @@ public function setSubscription(array $data) if (array_key_exists('lease_seconds', $data) && $data['lease_seconds'] ) { - $data['expiration_time'] = $now->add($data['lease_seconds'], Date\Date::SECOND) - ->get('yyyy-MM-dd HH:mm:ss'); + $data['expiration_time'] = $now->add(new DateInterval('PT' . $data['lease_seconds'] . 'S')) + ->format('Y-m-d H:i:s'); } $this->_db->update( $data, @@ -134,25 +135,25 @@ public function deleteSubscription($key) } /** - * Get a new Date\Date or the one injected for testing + * Get a new DateTime or the one injected for testing * - * @return Date\Date + * @return DateTime */ public function getNow() { if (null === $this->now) { - return new Date\Date; + return new DateTime(); } return $this->now; } /** - * Set a Date\Date instance for assisting with unit testing + * Set a DateTime instance for assisting with unit testing * - * @param Date\Date $now + * @param DateTime $now * @return Subscription */ - public function setNow(Date\Date $now) + public function setNow(DateTime $now) { $this->now = $now; return $this; diff --git a/src/PubSubHubbub/Subscriber.php b/src/PubSubHubbub/Subscriber.php index 9bbfef7b..75fdfcdb 100644 --- a/src/PubSubHubbub/Subscriber.php +++ b/src/PubSubHubbub/Subscriber.php @@ -20,9 +20,10 @@ namespace Zend\Feed\PubSubHubbub; +use DateInterval; +use DateTime; use Traversable; use Zend\Stdlib\ArrayUtils; -use Zend\Date; use Zend\Http\Request as HttpRequest; use Zend\Uri; use Zend\Version; @@ -740,17 +741,17 @@ protected function _getRequestParameters($hubUrl, $mode) } // store subscription to storage - $now = new Date\Date; + $now = new DateTime(); $expires = null; if (isset($params['hub.lease_seconds'])) { - $expires = $now->add($params['hub.lease_seconds'], Date\Date::SECOND) - ->get('yyyy-MM-dd HH:mm:ss'); + $expires = $now->add(new DateInterval('PT' . $params['hub.lease_seconds'] . 'S')) + ->format('Y-m-d H:i:s'); } $data = array( 'id' => $key, 'topic_url' => $params['hub.topic'], 'hub_url' => $hubUrl, - 'created_time' => $now->get('yyyy-MM-dd HH:mm:ss'), + 'created_time' => $now->format('Y-m-d H:i:s'), 'lease_seconds' => $expires, 'verify_token' => hash('sha256', $params['hub.verify_token']), 'secret' => null, diff --git a/src/Reader/Entry/Rss.php b/src/Reader/Entry/Rss.php index beedac08..ed01b237 100644 --- a/src/Reader/Entry/Rss.php +++ b/src/Reader/Entry/Rss.php @@ -20,8 +20,8 @@ namespace Zend\Feed\Reader\Entry; +use DateTime; use Zend\Feed\Reader, - Zend\Date, Zend\Feed\Reader\Exception, DOMElement, DOMXPath; @@ -219,17 +219,16 @@ public function getDateModified() if ($dateModified) { $dateModifiedParsed = strtotime($dateModified); if ($dateModifiedParsed) { - $date = new Date\Date($dateModifiedParsed); + $date = new DateTime('@' . $dateModifiedParsed); } else { - $dateStandards = array(Date\Date::RSS, Date\Date::RFC_822, - Date\Date::RFC_2822, Date\Date::DATES); - $date = new Date\Date; + $dateStandards = array(DateTime::RSS, DateTime::RFC822, + DateTime::RFC2822, null); foreach ($dateStandards as $standard) { try { - $date->set($dateModified, $standard); + $date = date_create_from_format($standard, $dateModified); break; - } catch (Date\Exception $e) { - if ($standard == Date\Date::DATES) { + } catch (\Exception $e) { + if ($standard == null) { throw new Exception\RuntimeException( 'Could not load date due to unrecognised' .' format (should follow RFC 822 or 2822):' diff --git a/src/Reader/Extension/Atom/Entry.php b/src/Reader/Extension/Atom/Entry.php index 42667b86..31b9fb78 100644 --- a/src/Reader/Extension/Atom/Entry.php +++ b/src/Reader/Extension/Atom/Entry.php @@ -20,10 +20,10 @@ namespace Zend\Feed\Reader\Extension\Atom; +use DateTime; use DOMDocument, DOMElement, stdClass, - Zend\Date, Zend\Feed\Reader, Zend\Feed\Reader\Collection, Zend\Feed\Reader\Extension, @@ -187,8 +187,7 @@ public function getDateCreated() } if ($dateCreated) { - $date = new Date\Date; - $date->set($dateCreated, Date\Date::ISO_8601); + $date = DateTime::createFromFormat(DateTime::ISO8601, $dateCreated); } $this->_data['datecreated'] = $date; @@ -216,8 +215,7 @@ public function getDateModified() } if ($dateModified) { - $date = new Date\Date; - $date->set($dateModified, Date\Date::ISO_8601); + $date = DateTime::createFromFormat(DateTime::ISO8601, $dateModified); } $this->_data['datemodified'] = $date; diff --git a/src/Reader/Extension/Atom/Feed.php b/src/Reader/Extension/Atom/Feed.php index 10f2b860..92a440b1 100644 --- a/src/Reader/Extension/Atom/Feed.php +++ b/src/Reader/Extension/Atom/Feed.php @@ -20,8 +20,8 @@ namespace Zend\Feed\Reader\Extension\Atom; -use Zend\Date, - Zend\Feed\Reader, +use DateTime; +use Zend\Feed\Reader, Zend\Feed\Reader\Collection, Zend\Feed\Reader\Extension, Zend\Uri, @@ -120,7 +120,7 @@ public function getCopyright() /** * Get the feed creation date * - * @return Date\Date|null + * @return DateTime|null */ public function getDateCreated() { @@ -137,8 +137,7 @@ public function getDateCreated() } if ($dateCreated) { - $date = new Date\Date; - $date->set($dateCreated, Date\Date::ISO_8601); + $date = DateTime::createFromFormat(DateTime::ISO8601, $dateCreated); } $this->_data['datecreated'] = $date; @@ -149,7 +148,7 @@ public function getDateCreated() /** * Get the feed modification date * - * @return Date\Date|null + * @return DateTime|null */ public function getDateModified() { @@ -166,8 +165,7 @@ public function getDateModified() } if ($dateModified) { - $date = new Date\Date; - $date->set($dateModified, Date\Date::ISO_8601); + $date = DateTime::createFromFormat(DateTime::ISO8601, $dateModified); } $this->_data['datemodified'] = $date; diff --git a/src/Reader/Extension/DublinCore/Entry.php b/src/Reader/Extension/DublinCore/Entry.php index 452f55a1..0bfde674 100644 --- a/src/Reader/Extension/DublinCore/Entry.php +++ b/src/Reader/Extension/DublinCore/Entry.php @@ -20,10 +20,10 @@ namespace Zend\Feed\Reader\Extension\DublinCore; +use DateTime; use Zend\Feed\Reader, Zend\Feed\Reader\Collection, Zend\Feed\Reader\Extension, - Zend\Date, DOMElement; /** @@ -219,7 +219,7 @@ public function getTitle() /** * * - * @return Date\Date|null + * @return DateTime|null */ public function getDate() { @@ -235,8 +235,7 @@ public function getDate() } if ($date) { - $d = new Date\Date; - $d->set($date, Date\Date::ISO_8601); + $d = DateTime::createFromFormat(DateTime::ISO8601, $date); } $this->_data['date'] = $d; diff --git a/src/Reader/Extension/DublinCore/Feed.php b/src/Reader/Extension/DublinCore/Feed.php index 57f9bf61..1917d7da 100644 --- a/src/Reader/Extension/DublinCore/Feed.php +++ b/src/Reader/Extension/DublinCore/Feed.php @@ -20,10 +20,10 @@ namespace Zend\Feed\Reader\Extension\DublinCore; +use DateTime; use Zend\Feed\Reader, Zend\Feed\Reader\Collection, - Zend\Feed\Reader\Extension, - Zend\Date; + Zend\Feed\Reader\Extension; /** * @category Zend @@ -227,7 +227,7 @@ public function getTitle() /** * * - * @return Date\Date|null + * @return DateTime|null */ public function getDate() { @@ -243,8 +243,7 @@ public function getDate() } if ($date) { - $d = new Date\Date; - $d->set($date, Date\Date::ISO_8601); + $d = DateTime::createFromFormat(DateTime::ISO8601, $date); } $this->_data['date'] = $d; diff --git a/src/Reader/Extension/Syndication/Feed.php b/src/Reader/Extension/Syndication/Feed.php index 7f2b7ae1..b7e623a2 100644 --- a/src/Reader/Extension/Syndication/Feed.php +++ b/src/Reader/Extension/Syndication/Feed.php @@ -20,9 +20,9 @@ namespace Zend\Feed\Reader\Extension\Syndication; +use DateTime; use Zend\Feed\Reader, - Zend\Feed\Reader\Extension, - Zend\Date; + Zend\Feed\Reader\Extension; /** * @category Zend @@ -118,15 +118,14 @@ public function getUpdateFrequencyAsTicks() /** * Get update base * - * @return Date\Date|null + * @return DateTime|null */ public function getUpdateBase() { $updateBase = $this->_getData('updateBase'); $date = null; if ($updateBase) { - $date = new Date\Date; - $date->set($updateBase, Date\Date::W3C); + $date = DateTime::createFromFormat(DateTime::W3C, $updateBase); } return $date; } diff --git a/src/Reader/Feed/Atom.php b/src/Reader/Feed/Atom.php index b1336381..2b035c3e 100644 --- a/src/Reader/Feed/Atom.php +++ b/src/Reader/Feed/Atom.php @@ -21,7 +21,6 @@ namespace Zend\Feed\Reader\Feed; use Zend\Feed\Reader, - Zend\Date, DOMDocument; /** diff --git a/src/Reader/Feed/Atom/Source.php b/src/Reader/Feed/Atom/Source.php index 3731f031..2b26d093 100644 --- a/src/Reader/Feed/Atom/Source.php +++ b/src/Reader/Feed/Atom/Source.php @@ -22,7 +22,6 @@ use Zend\Feed\Reader, Zend\Feed\Reader\Feed, - Zend\Date, DOMElement, DOMXPath; diff --git a/src/Reader/Feed/Rss.php b/src/Reader/Feed/Rss.php index 03c36cd3..2ccaa970 100644 --- a/src/Reader/Feed/Rss.php +++ b/src/Reader/Feed/Rss.php @@ -20,10 +20,10 @@ namespace Zend\Feed\Reader\Feed; +use DateTime; use Zend\Feed\Reader, Zend\Feed\Reader\Collection, Zend\Feed\Reader\Exception, - Zend\Date, DOMDocument; /** @@ -190,7 +190,7 @@ public function getDateCreated() /** * Get the feed modification date * - * @return Date\Date + * @return DateTime * @throws Exception\RuntimeException */ public function getDateModified() @@ -211,17 +211,16 @@ public function getDateModified() if ($dateModified) { $dateModifiedParsed = strtotime($dateModified); if ($dateModifiedParsed) { - $date = new Date\Date($dateModifiedParsed); + $date = new DateTime('@' . $dateModifiedParsed); } else { - $dateStandards = array(Date\Date::RSS, Date\Date::RFC_822, - Date\Date::RFC_2822, Date\Date::DATES); - $date = new Date\Date; + $dateStandards = array(DateTime::RSS, DateTime::RFC822, + DateTime::RFC2822, null); foreach ($dateStandards as $standard) { try { - $date->set($dateModified, $standard); + $date = DateTime::createFromFormat($standard, $dateModified); break; - } catch (Date\Exception $e) { - if ($standard == Date\Date::DATES) { + } catch (\Exception $e) { + if ($standard == null) { throw new Exception\RuntimeException( 'Could not load date due to unrecognised' .' format (should follow RFC 822 or 2822):' @@ -255,7 +254,7 @@ public function getDateModified() /** * Get the feed lastBuild date * - * @return Date\Date + * @return DateTime */ public function getLastBuildDate() { @@ -272,17 +271,16 @@ public function getLastBuildDate() if ($lastBuildDate) { $lastBuildDateParsed = strtotime($lastBuildDate); if ($lastBuildDateParsed) { - $date = new Date\Date($lastBuildDateParsed); + $date = new DateTime('@' . $lastBuildDateParsed); } else { - $dateStandards = array(Date\Date::RSS, Date\Date::RFC_822, - Date\Date::RFC_2822, Date\Date::DATES); - $date = new Date\Date; + $dateStandards = array(DateTime::RSS, DateTime::RFC822, + DateTime::RFC2822, null); foreach ($dateStandards as $standard) { try { - $date->set($lastBuildDate, $standard); + $date = DateTime::createFromFormat($standard, $lastBuildDateParsed); break; - } catch (Date\Exception $e) { - if ($standard == Date\Date::DATES) { + } catch (\Exception $e) { + if ($standard == null) { throw new Exception\RuntimeException( 'Could not load date due to unrecognised' .' format (should follow RFC 822 or 2822):' diff --git a/src/Writer/AbstractFeed.php b/src/Writer/AbstractFeed.php index 48c43351..787df879 100644 --- a/src/Writer/AbstractFeed.php +++ b/src/Writer/AbstractFeed.php @@ -20,8 +20,8 @@ namespace Zend\Feed\Writer; +use DateTime; use Zend\Uri, - Zend\Date, Zend\Validator; /** @@ -131,64 +131,58 @@ public function setCopyright($copyright) /** * Set the feed creation date * - * @param null|integer|Date\Date + * @param null|integer|DateTime * @throws Exception\InvalidArgumentException */ public function setDateCreated($date = null) { - $zdate = null; if ($date === null) { - $zdate = new Date\Date; - } elseif (ctype_digit((string)$date)) { - $zdate = new Date\Date($date, Date\Date::TIMESTAMP); - } elseif ($date instanceof Date\Date) { - $zdate = $date; - } else { - throw new Exception\InvalidArgumentException('Invalid Date\Date object or UNIX Timestamp passed as parameter'); + $date = new DateTime(); + } elseif (is_int($date)) { + $date = new DateTime('@' . $date); + } elseif (!$date instanceof DateTime) { + throw new Exception\InvalidArgumentException('Invalid DateTime object or UNIX Timestamp' + . ' passed as parameter'); } - $this->_data['dateCreated'] = $zdate; + $this->_data['dateCreated'] = $date; } /** * Set the feed modification date * - * @param null|integer|Date\Date + * @param null|integer|DateTime * @throws Exception\InvalidArgumentException */ public function setDateModified($date = null) { - $zdate = null; if ($date === null) { - $zdate = new Date\Date; - } elseif (ctype_digit((string)$date)) { - $zdate = new Date\Date($date, Date\Date::TIMESTAMP); - } elseif ($date instanceof Date\Date) { - $zdate = $date; - } else { - throw new Exception\InvalidArgumentException('Invalid Date\Date object or UNIX Timestamp passed as parameter'); + $date = new DateTime(); + } elseif (is_int($date)) { + $date = new DateTime('@' . $date); + } elseif (!$date instanceof DateTime) { + throw new Exception\InvalidArgumentException('Invalid DateTime object or UNIX Timestamp' + . ' passed as parameter'); } - $this->_data['dateModified'] = $zdate; + $this->_data['dateModified'] = $date; } /** * Set the feed last-build date. Ignored for Atom 1.0. * - * @param null|integer|Date\Date + * @param null|integer|DateTime * @throws Exception\InvalidArgumentException */ public function setLastBuildDate($date = null) { - $zdate = null; if ($date === null) { - $zdate = new Date\Date; - } elseif (ctype_digit((string)$date)) { - $zdate = new Date\Date($date, Date\Date::TIMESTAMP); - } elseif ($date instanceof Date\Date) { - $zdate = $date; - } else { - throw new Exception\InvalidArgumentException('Invalid Date\Date object or UNIX Timestamp passed as parameter'); - } - $this->_data['lastBuildDate'] = $zdate; + $date = new DateTime(); + } elseif (is_int($date)) { + $date = new DateTime('@' . $date); + } elseif (!$date instanceof DateTime) { + throw new Exception\InvalidArgumentException('Invalid DateTime object or UNIX Timestamp' + . ' passed as parameter'); + } + $this->_data['lastBuildDate'] = $date; } /** diff --git a/src/Writer/Deleted.php b/src/Writer/Deleted.php index 4dc82be6..c16ea393 100644 --- a/src/Writer/Deleted.php +++ b/src/Writer/Deleted.php @@ -20,8 +20,8 @@ namespace Zend\Feed\Writer; -use Zend\Date, - Zend\Uri; +use DateTime; +use Zend\Uri; /** * @category Zend @@ -133,25 +133,25 @@ public function getReference() /** * Set when * - * @param null|string|Date\Date $date + * @param null|string|DateTime $date * @throws Exception\InvalidArgumentException */ public function setWhen($date = null) { - $zdate = null; if ($date === null) { - $zdate = new Date\Date; - } elseif (ctype_digit((string)$date)) { - $zdate = new Date\Date($date, Date\Date::TIMESTAMP); - } elseif ($date instanceof Date\Date) { - $zdate = $date; - } else { - throw new Exception\InvalidArgumentException('Invalid Date\Date object or UNIX Timestamp' + $date = new DateTime(); + } elseif (is_int($date)) { + $date = new DateTime('@' . $date); + } elseif (!$date instanceof DateTime) { + throw new Exception\InvalidArgumentException('Invalid DateTime object or UNIX Timestamp' . ' passed as parameter'); } - $this->_data['when'] = $zdate; + $this->_data['when'] = $date; } - + + /** + * @return \DateTime + */ public function getWhen() { if (!array_key_exists('when', $this->_data)) { diff --git a/src/Writer/Entry.php b/src/Writer/Entry.php index a07b76d4..51767907 100644 --- a/src/Writer/Entry.php +++ b/src/Writer/Entry.php @@ -20,9 +20,9 @@ namespace Zend\Feed\Writer; +use DateTime; use Zend\Feed\Writer\Exception, - Zend\Uri, - Zend\Date; + Zend\Uri; /** * @category Zend @@ -179,43 +179,37 @@ public function setContent($content) /** * Set the feed creation date * - * @return string|null|Date\Date + * @return string|null|DateTime * @throws Exception\InvalidArgumentException */ public function setDateCreated($date = null) { - $zdate = null; if ($date === null) { - $zdate = new Date\Date; - } elseif (ctype_digit((string)$date)) { - $zdate = new Date\Date($date, Date\Date::TIMESTAMP); - } elseif ($date instanceof Date\Date) { - $zdate = $date; - } else { - throw new Exception\InvalidArgumentException('Invalid Zend\Date\Date object or UNIX Timestamp passed as parameter'); + $date = new DateTime(); + } elseif (is_int($date)) { + $date = new DateTime('@' . $date); + } elseif (!$date instanceof DateTime) { + throw new Exception\InvalidArgumentException('Invalid DateTime object or UNIX Timestamp passed as parameter'); } - $this->_data['dateCreated'] = $zdate; + $this->_data['dateCreated'] = $date; } /** * Set the feed modification date * - * @return string|null + * @return string|null|DateTime * @throws Exception\InvalidArgumentException */ public function setDateModified($date = null) { - $zdate = null; if ($date === null) { - $zdate = new Date\Date; - } elseif (ctype_digit((string)$date)) { - $zdate = new Date\Date($date, Date\Date::TIMESTAMP); - } elseif ($date instanceof Date\Date) { - $zdate = $date; - } else { - throw new Exception\InvalidArgumentException('Invalid Date\Date object or UNIX Timestamp passed as parameter'); - } - $this->_data['dateModified'] = $zdate; + $date = new DateTime(); + } elseif (is_int($date)) { + $date = new DateTime('@' . $date); + } elseif (!$date instanceof DateTime) { + throw new Exception\InvalidArgumentException('Invalid DateTime object or UNIX Timestamp passed as parameter'); + } + $this->_data['dateModified'] = $date; } /** diff --git a/src/Writer/Feed.php b/src/Writer/Feed.php index 8fd2bb85..e7ee4e20 100644 --- a/src/Writer/Feed.php +++ b/src/Writer/Feed.php @@ -21,8 +21,8 @@ namespace Zend\Feed\Writer; use Countable, + DateTime, Iterator, - Zend\Date, Zend\Feed\Writer\Renderer; /** @@ -152,9 +152,9 @@ public function orderByDate() $entries = array(); foreach ($this->_entries as $entry) { if ($entry->getDateModified()) { - $timestamp = (int) $entry->getDateModified()->get(Date\Date::TIMESTAMP); + $timestamp = (int) $entry->getDateModified()->getTimestamp(); } elseif ($entry->getDateCreated()) { - $timestamp = (int) $entry->getDateCreated()->get(Date\Date::TIMESTAMP); + $timestamp = (int) $entry->getDateCreated()->getTimestamp(); } $entries[$timestamp] = $entry; } diff --git a/src/Writer/Renderer/Entry/Atom.php b/src/Writer/Renderer/Entry/Atom.php index 5e4b5d47..0491b42b 100644 --- a/src/Writer/Renderer/Entry/Atom.php +++ b/src/Writer/Renderer/Entry/Atom.php @@ -20,9 +20,9 @@ namespace Zend\Feed\Writer\Renderer\Entry; +use DateTime; use DOMDocument, DOMElement, - Zend\Date, Zend\Feed\Writer, Zend\Feed\Writer\Renderer, Zend\Uri, @@ -152,7 +152,7 @@ protected function _setDateModified(DOMDocument $dom, DOMElement $root) $updated = $dom->createElement('updated'); $root->appendChild($updated); $text = $dom->createTextNode( - $this->getDataContainer()->getDateModified()->get(Date\Date::ISO_8601) + $this->getDataContainer()->getDateModified()->format(DateTime::ISO8601) ); $updated->appendChild($text); } @@ -172,7 +172,7 @@ protected function _setDateCreated(DOMDocument $dom, DOMElement $root) $el = $dom->createElement('published'); $root->appendChild($el); $text = $dom->createTextNode( - $this->getDataContainer()->getDateCreated()->get(Date\Date::ISO_8601) + $this->getDataContainer()->getDateCreated()->format(DateTime::ISO8601) ); $el->appendChild($text); } diff --git a/src/Writer/Renderer/Entry/Atom/Deleted.php b/src/Writer/Renderer/Entry/Atom/Deleted.php index 1b702091..f1307a63 100644 --- a/src/Writer/Renderer/Entry/Atom/Deleted.php +++ b/src/Writer/Renderer/Entry/Atom/Deleted.php @@ -20,6 +20,7 @@ namespace Zend\Feed\Writer\Renderer\Entry\Atom; +use DateTime; use DOMDocument, DOMElement; @@ -57,7 +58,7 @@ public function render() $this->_dom->appendChild($entry); $entry->setAttribute('ref', $this->_container->getReference()); - $entry->setAttribute('when', $this->_container->getWhen()->get(\Zend\Date\Date::ISO_8601)); + $entry->setAttribute('when', $this->_container->getWhen()->format(DateTime::ISO8601)); $this->_setBy($this->_dom, $entry); $this->_setComment($this->_dom, $entry); diff --git a/src/Writer/Renderer/Entry/AtomDeleted.php b/src/Writer/Renderer/Entry/AtomDeleted.php index f6912697..a796e728 100644 --- a/src/Writer/Renderer/Entry/AtomDeleted.php +++ b/src/Writer/Renderer/Entry/AtomDeleted.php @@ -20,6 +20,7 @@ namespace Zend\Feed\Writer\Renderer\Entry; +use DateTime; use Zend\Feed\Writer\Renderer, Zend\Feed\Writer, DOMDocument, @@ -57,7 +58,7 @@ public function render() $this->_dom->appendChild($entry); $entry->setAttribute('ref', $this->_container->getReference()); - $entry->setAttribute('when', $this->_container->getWhen()->get(Date\Date::ISO_8601)); + $entry->setAttribute('when', $this->_container->getWhen()->format(DateTime::ISO8601)); $this->_setBy($this->_dom, $entry); $this->_setComment($this->_dom, $entry); diff --git a/src/Writer/Renderer/Entry/Rss.php b/src/Writer/Renderer/Entry/Rss.php index 5d4b1d0b..8ee41a34 100644 --- a/src/Writer/Renderer/Entry/Rss.php +++ b/src/Writer/Renderer/Entry/Rss.php @@ -20,7 +20,7 @@ namespace Zend\Feed\Writer\Renderer\Entry; -use Zend\Date, +use DateTime, Zend\Feed\Writer, Zend\Feed\Writer\Renderer, Zend\Uri, @@ -155,7 +155,7 @@ protected function _setDateModified(DOMDocument $dom, DOMElement $root) $updated = $dom->createElement('pubDate'); $root->appendChild($updated); $text = $dom->createTextNode( - $this->getDataContainer()->getDateModified()->get(Date\Date::RSS) + $this->getDataContainer()->getDateModified()->format(DateTime::RSS) ); $updated->appendChild($text); } diff --git a/src/Writer/Renderer/Feed/AbstractAtom.php b/src/Writer/Renderer/Feed/AbstractAtom.php index e6b82659..d18100ff 100644 --- a/src/Writer/Renderer/Feed/AbstractAtom.php +++ b/src/Writer/Renderer/Feed/AbstractAtom.php @@ -20,8 +20,8 @@ namespace Zend\Feed\Writer\Renderer\Feed; +use DateTime; use Zend\Feed\Writer\Renderer, - Zend\Date, Zend\Feed\Writer, DOMDocument, DOMElement; @@ -131,7 +131,7 @@ protected function _setDateModified(DOMDocument $dom, DOMElement $root) $updated = $dom->createElement('updated'); $root->appendChild($updated); $text = $dom->createTextNode( - $this->getDataContainer()->getDateModified()->get(Date\Date::ISO_8601) + $this->getDataContainer()->getDateModified()->format(DateTime::ISO8601) ); $updated->appendChild($text); } diff --git a/src/Writer/Renderer/Feed/Atom/AbstractAtom.php b/src/Writer/Renderer/Feed/Atom/AbstractAtom.php index 032d8390..d20eda31 100644 --- a/src/Writer/Renderer/Feed/Atom/AbstractAtom.php +++ b/src/Writer/Renderer/Feed/Atom/AbstractAtom.php @@ -20,6 +20,7 @@ namespace Zend\Feed\Writer\Renderer\Feed\Atom; +use Datetime; use Zend\Feed, DOMDocument, DOMElement; @@ -130,7 +131,7 @@ protected function _setDateModified(DOMDocument $dom, DOMElement $root) $updated = $dom->createElement('updated'); $root->appendChild($updated); $text = $dom->createTextNode( - $this->getDataContainer()->getDateModified()->get(\Zend\Date\Date::ISO_8601) + $this->getDataContainer()->getDateModified()->format(DateTime::ISO8601) ); $updated->appendChild($text); } diff --git a/src/Writer/Renderer/Feed/Rss.php b/src/Writer/Renderer/Feed/Rss.php index 94c94c2e..e27bbf12 100644 --- a/src/Writer/Renderer/Feed/Rss.php +++ b/src/Writer/Renderer/Feed/Rss.php @@ -20,9 +20,9 @@ namespace Zend\Feed\Writer\Renderer\Feed; +use DateTime; use DOMDocument, DOMElement, - Zend\Date, Zend\Feed\Writer, Zend\Feed\Writer\Renderer, Zend\Uri; @@ -196,7 +196,7 @@ protected function _setDateModified(DOMDocument $dom, DOMElement $root) $updated = $dom->createElement('pubDate'); $root->appendChild($updated); $text = $dom->createTextNode( - $this->getDataContainer()->getDateModified()->get(Date\Date::RSS) + $this->getDataContainer()->getDateModified()->format(DateTime::RSS) ); $updated->appendChild($text); } @@ -451,7 +451,7 @@ protected function _setLastBuildDate(DOMDocument $dom, DOMElement $root) $lastBuildDate = $dom->createElement('lastBuildDate'); $root->appendChild($lastBuildDate); $text = $dom->createTextNode( - $this->getDataContainer()->getLastBuildDate()->get(Date\Date::RSS) + $this->getDataContainer()->getLastBuildDate()->format(DateTime::RSS) ); $lastBuildDate->appendChild($text); } diff --git a/test/PubSubHubbub/Model/SubscriptionTest.php b/test/PubSubHubbub/Model/SubscriptionTest.php index 2d486584..fcd5ca5b 100644 --- a/test/PubSubHubbub/Model/SubscriptionTest.php +++ b/test/PubSubHubbub/Model/SubscriptionTest.php @@ -20,8 +20,8 @@ namespace ZendTest\Feed\PubSubHubbub\Model; +use DateTime; use PDO; -use Zend\Date\Date; use Zend\Db\Adapter\Adapter as DbAdapter; use Zend\Db\TableGateway\TableGateway; use Zend\Feed\PubSubHubbub\Model\Subscription; @@ -75,7 +75,7 @@ public function testImpemetsSubscriptionInterface() public function testCurrentTimeSetterAndGetter() { - $now = new Date; + $now = new DateTime(); $subscription = new Subscription(new TableGateway('subscription', $this->initDb())); $subscription->setNow($now); $this->assertSame($subscription->getNow(), $now); diff --git a/test/PubSubHubbub/Subscriber/CallbackTest.php b/test/PubSubHubbub/Subscriber/CallbackTest.php index abe24bdc..0a2d9319 100644 --- a/test/PubSubHubbub/Subscriber/CallbackTest.php +++ b/test/PubSubHubbub/Subscriber/CallbackTest.php @@ -20,7 +20,8 @@ namespace ZendTest\Feed\PubSubHubbub\Subscriber; -use Zend\Date\Date; +use DateInterval; +use DateTime; use Zend\Feed\PubSubHubbub\HttpResponse; use Zend\Feed\PubSubHubbub\Model; use Zend\Feed\PubSubHubbub\Subscriber\Callback as CallbackSubscriber; @@ -47,7 +48,7 @@ class CallbackTest extends \PHPUnit_Framework_TestCase public $_rowset; /** @var array */ public $_get; - /** @var Date */ + /** @var DateTime */ public $now; public function setUp() @@ -69,7 +70,7 @@ public function setUp() ->will($this->returnValue($this->_adapter)); $storage = new Model\Subscription($this->_tableGateway); - $this->now = new Date; + $this->now = new DateTime(); $storage->setNow(clone $this->now); $this->_callback->setStorage($storage); @@ -276,7 +277,7 @@ public function testRespondsToValidConfirmationWith200Response() $rowdata = array( 'id' => 'verifytokenkey', 'verify_token' => hash('sha256', 'cba'), - 'created_time' => $t->get(Date::TIMESTAMP), + 'created_time' => $t->getTimestamp(), 'lease_seconds' => 10000 ); @@ -295,11 +296,11 @@ public function testRespondsToValidConfirmationWith200Response() ->with( $this->equalTo(array('id' => 'verifytokenkey', 'verify_token' => hash('sha256', 'cba'), - 'created_time' => $t->get(Date::TIMESTAMP), + 'created_time' => $t->getTimestamp(), 'lease_seconds' => 1234567, 'subscription_state'=> 'verified', - 'expiration_time' => $t->add(1234567, Date::SECOND) - ->get('yyyy-MM-dd HH:mm:ss'))), + 'expiration_time' => $t->add(new DateInterval('PT1234567S')) + ->format('Y-m-d H:i:s'))), $this->equalTo(array('id' => 'verifytokenkey')) ); @@ -318,7 +319,7 @@ public function testRespondsToValidConfirmationWithBodyContainingHubChallenge() $rowdata = array( 'id' => 'verifytokenkey', 'verify_token' => hash('sha256', 'cba'), - 'created_time' => $t->get(Date::TIMESTAMP), + 'created_time' => $t->getTimestamp(), 'lease_seconds' => 10000 ); @@ -337,11 +338,11 @@ public function testRespondsToValidConfirmationWithBodyContainingHubChallenge() ->with( $this->equalTo(array('id' => 'verifytokenkey', 'verify_token' => hash('sha256', 'cba'), - 'created_time' => $t->get(Date::TIMESTAMP), + 'created_time' => $t->getTimestamp(), 'lease_seconds' => 1234567, 'subscription_state'=> 'verified', - 'expiration_time' => $t->add(1234567, Date::SECOND) - ->get('yyyy-MM-dd HH:mm:ss'))), + 'expiration_time' => $t->add(new DateInterval('PT1234567S')) + ->format('Y-m-d H:i:s'))), $this->equalTo(array('id' => 'verifytokenkey')) ); diff --git a/test/Reader/Entry/AtomStandaloneEntryTest.php b/test/Reader/Entry/AtomStandaloneEntryTest.php index a05e95d3..712db051 100644 --- a/test/Reader/Entry/AtomStandaloneEntryTest.php +++ b/test/Reader/Entry/AtomStandaloneEntryTest.php @@ -20,8 +20,9 @@ */ namespace ZendTest\Feed\Reader\Entry; + +use DateTime; use Zend\Feed\Reader; -use Zend\Date; /** * @category Zend @@ -45,13 +46,7 @@ public function setup() { Reader\Reader::reset(); $this->_feedSamplePath = dirname(__FILE__) . '/_files/AtomStandaloneEntry'; - $this->_options = Date\Date::setOptions(); - foreach($this->_options as $k=>$v) { - if (is_null($v)) { - unset($this->_options[$k]); - } - } - Date\Date::setOptions(array('format_type'=>'iso')); + $this->_expectedCats = array( array( 'term' => 'topic1', @@ -82,12 +77,7 @@ public function setup() ) ); } - - public function teardown() - { - Date\Date::setOptions($this->_options); - } - + public function testReaderImportOfAtomEntryDocumentReturnsEntryClass() { $object = Reader\Reader::importString( @@ -117,9 +107,8 @@ public function testGetsDateCreatedFromAtom10() $entry = Reader\Reader::importString( file_get_contents($this->_feedSamplePath . '/datecreated/atom10.xml') ); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($entry->getDateCreated())); + $edate = DateTime::createFromFormat(DateTime::ISO8601, '2009-03-07T08:03:50Z'); + $this->assertEquals($edate, $entry->getDateCreated()); } /** @@ -131,9 +120,8 @@ public function testGetsDateModifiedFromAtom10() $entry = Reader\Reader::importString( file_get_contents($this->_feedSamplePath . '/datemodified/atom10.xml') ); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($entry->getDateModified())); + $edate = DateTime::createFromFormat(DateTime::ISO8601, '2009-03-07T08:03:50Z'); + $this->assertEquals($edate, $entry->getDateModified()); } /** diff --git a/test/Reader/Entry/AtomTest.php b/test/Reader/Entry/AtomTest.php index f7af17c6..aa07667e 100644 --- a/test/Reader/Entry/AtomTest.php +++ b/test/Reader/Entry/AtomTest.php @@ -20,8 +20,9 @@ */ namespace ZendTest\Feed\Reader\Entry; + +use DateTime; use Zend\Feed\Reader; -use Zend\Date; /** * @category Zend @@ -45,13 +46,6 @@ public function setup() { Reader\Reader::reset(); $this->_feedSamplePath = dirname(__FILE__) . '/_files/Atom'; - $this->_options = Date\Date::setOptions(); - foreach($this->_options as $k=>$v) { - if (is_null($v)) { - unset($this->_options[$k]); - } - } - Date\Date::setOptions(array('format_type'=>'iso')); $this->_expectedCats = array( array( 'term' => 'topic1', @@ -82,11 +76,6 @@ public function setup() ) ); } - - public function teardown() - { - Date\Date::setOptions($this->_options); - } /** * Get Id (Unencoded Text) @@ -119,9 +108,8 @@ public function testGetsDateCreatedFromAtom03() file_get_contents($this->_feedSamplePath . '/datecreated/plain/atom03.xml') ); $entry = $feed->current(); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($entry->getDateCreated())); + $edate = DateTime::createFromFormat(DateTime::ISO8601, '2009-03-07T08:03:50Z'); + $this->assertEquals($edate, $entry->getDateCreated()); } public function testGetsDateCreatedFromAtom10() @@ -130,9 +118,8 @@ public function testGetsDateCreatedFromAtom10() file_get_contents($this->_feedSamplePath . '/datecreated/plain/atom10.xml') ); $entry = $feed->current(); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($entry->getDateCreated())); + $edate = DateTime::createFromFormat(DateTime::ISO8601, '2009-03-07T08:03:50Z'); + $this->assertEquals($edate, $entry->getDateCreated()); } /** @@ -144,9 +131,8 @@ public function testGetsDateModifiedFromAtom03() file_get_contents($this->_feedSamplePath . '/datemodified/plain/atom03.xml') ); $entry = $feed->current(); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($entry->getDateModified())); + $edate = DateTime::createFromFormat(DateTime::ISO8601, '2009-03-07T08:03:50Z'); + $this->assertEquals($edate, $entry->getDateModified()); } public function testGetsDateModifiedFromAtom10() @@ -155,9 +141,8 @@ public function testGetsDateModifiedFromAtom10() file_get_contents($this->_feedSamplePath . '/datemodified/plain/atom10.xml') ); $entry = $feed->current(); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($entry->getDateModified())); + $edate = DateTime::createFromFormat(DateTime::ISO8601, '2009-03-07T08:03:50Z'); + $this->assertEquals($edate, $entry->getDateModified()); } /** diff --git a/test/Reader/Entry/RssTest.php b/test/Reader/Entry/RssTest.php index 3457b686..f17d31a8 100644 --- a/test/Reader/Entry/RssTest.php +++ b/test/Reader/Entry/RssTest.php @@ -20,8 +20,9 @@ */ namespace ZendTest\Feed\Reader\Entry; + +use DateTime; use Zend\Feed\Reader; -use Zend\Date; /** * @category Zend @@ -47,13 +48,7 @@ public function setup() { Reader\Reader::reset(); $this->_feedSamplePath = dirname(__FILE__) . '/_files/Rss'; - $this->_options = Date\Date::setOptions(); - foreach($this->_options as $k=>$v) { - if (is_null($v)) { - unset($this->_options[$k]); - } - } - Date\Date::setOptions(array('format_type'=>'iso')); + $this->_expectedCats = array( array( 'term' => 'topic1', @@ -101,11 +96,6 @@ public function setup() ) ); } - - public function teardown() - { - Date\Date::setOptions($this->_options); - } /** * Get Id (Unencoded Text) @@ -1880,270 +1870,50 @@ public function testGetsLinkFromRss090_None() /** * Get DateModified (Unencoded Text) + * @dataProvider dateModifiedProvider */ - public function testGetsDateModifiedFromRss20() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/rss20.xml') - ); - $entry = $feed->current(); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($entry->getDateModified())); - } - - /** - * @group ZF-8702 - */ - public function testParsesCorrectDateIfMissingOffsetWhenSystemUsesUSLocale() - { - $locale = new \Zend\Locale\Locale('en_US'); - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/rss20_en_US.xml') - ); - $entry = $feed->current(); - $fdate = $entry->getDateModified(); - $edate = new Date\Date; - $edate->set('2010-01-04T02:14:00-0600', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($fdate)); - } - - // DC 1.0 - - public function testGetsDateModifiedFromRss20_Dc10() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/dc10/rss20.xml') - ); - $entry = $feed->current(); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($entry->getDateModified())); - } - - public function testGetsDateModifiedFromRss094_Dc10() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/dc10/rss094.xml') - ); - $entry = $feed->current(); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($entry->getDateModified())); - } - - public function testGetsDateModifiedFromRss093_Dc10() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/dc10/rss093.xml') - ); - $entry = $feed->current(); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($entry->getDateModified())); - } - - public function testGetsDateModifiedFromRss092_Dc10() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/dc10/rss092.xml') - ); - $entry = $feed->current(); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($entry->getDateModified())); - } - - public function testGetsDateModifiedFromRss091_Dc10() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/dc10/rss091.xml') - ); - $entry = $feed->current(); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($entry->getDateModified())); - } - - public function testGetsDateModifiedFromRss10_Dc10() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/dc10/rss10.xml') - ); - $entry = $feed->current(); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($entry->getDateModified())); - } - - public function testGetsDateModifiedFromRss090_Dc10() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/dc10/rss090.xml') + public function testGetsDateModified($path, $edate) + { + $feed = Reader\Reader::importString( + file_get_contents($this->_feedSamplePath . $path) + ); + $entry = $feed->current(); + + $this->assertTrue($edate == $entry->getDateModified()); + } + + public function dateModifiedProvider() { + $iso = DateTime::createFromFormat(DateTime::ISO8601, '2009-03-07T08:03:50Z'); + $us = DateTime::createFromFormat(DateTime::ISO8601, '2010-01-04T02:14:00-0600'); + $rss = DateTime::createFromFormat(DateTime::RSS, 'Sun, 11 Jan 2009 09:55:59 GMT'); + return array( + array('/datemodified/plain/rss20.xml', $iso), + array('/datemodified/plain/rss20_en_US.xml', $us), + array('/datemodified/plain/dc10/rss20.xml', $iso), + array('/datemodified/plain/dc10/rss094.xml', $iso), + array('/datemodified/plain/dc10/rss093.xml', $iso), + array('/datemodified/plain/dc10/rss092.xml', $iso), + array('/datemodified/plain/dc10/rss091.xml', $iso), + array('/datemodified/plain/dc10/rss10.xml', $iso), + array('/datemodified/plain/dc10/rss090.xml', $iso), + array('/datemodified/plain/dc11/rss20.xml', $iso), + array('/datemodified/plain/dc11/rss094.xml', $iso), + array('/datemodified/plain/dc11/rss093.xml', $iso), + array('/datemodified/plain/dc11/rss092.xml', $iso), + array('/datemodified/plain/dc11/rss091.xml', $iso), + array('/datemodified/plain/dc11/rss10.xml', $iso), + array('/datemodified/plain/dc11/rss090.xml', $iso), + + array('/datemodified/plain/none/rss20.xml', null), + array('/datemodified/plain/none/rss094.xml', null), + array('/datemodified/plain/none/rss093.xml', null), + array('/datemodified/plain/none/rss092.xml', null), + array('/datemodified/plain/none/rss091.xml', null), + array('/datemodified/plain/none/rss10.xml', null), + array('/datemodified/plain/none/rss090.xml', null), + + array('/datemodified/plain/rss20-zf-7908.xml', $rss), ); - $entry = $feed->current(); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($entry->getDateModified())); - } - - // DC 1.1 - - public function testGetsDateModifiedFromRss20_Dc11() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/dc11/rss20.xml') - ); - $entry = $feed->current(); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($entry->getDateModified())); - } - - public function testGetsDateModifiedFromRss094_Dc11() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/dc11/rss094.xml') - ); - $entry = $feed->current(); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($entry->getDateModified())); - } - - public function testGetsDateModifiedFromRss093_Dc11() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/dc11/rss093.xml') - ); - $entry = $feed->current(); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($entry->getDateModified())); - } - - public function testGetsDateModifiedFromRss092_Dc11() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/dc11/rss092.xml') - ); - $entry = $feed->current(); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($entry->getDateModified())); - } - - public function testGetsDateModifiedFromRss091_Dc11() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/dc11/rss091.xml') - ); - $entry = $feed->current(); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($entry->getDateModified())); - } - - public function testGetsDateModifiedFromRss10_Dc11() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/dc11/rss10.xml') - ); - $entry = $feed->current(); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($entry->getDateModified())); - } - - public function testGetsDateModifiedFromRss090_Dc11() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/dc11/rss090.xml') - ); - $entry = $feed->current(); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($entry->getDateModified())); - } - - // Missing DateModified - - public function testGetsDateModifiedFromRss20_None() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/none/rss20.xml') - ); - $entry = $feed->current(); - $this->assertEquals(null, $entry->getDateModified()); - } - - public function testGetsDateModifiedFromRss094_None() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/none/rss094.xml') - ); - $entry = $feed->current(); - $this->assertEquals(null, $entry->getDateModified()); - } - - public function testGetsDateModifiedFromRss093_None() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/none/rss093.xml') - ); - $entry = $feed->current(); - $this->assertEquals(null, $entry->getDateModified()); - } - - public function testGetsDateModifiedFromRss092_None() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/none/rss092.xml') - ); - $entry = $feed->current(); - $this->assertEquals(null, $entry->getDateModified()); - } - - public function testGetsDateModifiedFromRss091_None() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/none/rss091.xml') - ); - $entry = $feed->current(); - $this->assertEquals(null, $entry->getDateModified()); - } - - public function testGetsDateModifiedFromRss10_None() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/none/rss10.xml') - ); - $entry = $feed->current(); - $this->assertEquals(null, $entry->getDateModified()); - } - - public function testGetsDateModifiedFromRss090_None() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/none/rss090.xml') - ); - $entry = $feed->current(); - $this->assertEquals(null, $entry->getDateModified()); - } - - /** - * @issue ZF-7908 - */ - public function testGetsDateModifiedFromRss20_UnrecognisedGmtFormat() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/rss20-zf-7908.xml') - ); - $entry = $feed->current(); - //$this->assertEquals('Sunday 11 January 2009 09 55 59 +0000', $entry->getDateModified()->toString('EEEE dd MMMM YYYY HH mm ss ZZZ')); - $edate = new Date\Date; - $edate->set('Sun, 11 Jan 2009 09:55:59 GMT', Date\Date::RSS); - $this->assertTrue($edate->equals($entry->getDateModified())); } /** diff --git a/test/Reader/Feed/AtomSourceTest.php b/test/Reader/Feed/AtomSourceTest.php index 486fb30b..916f6248 100644 --- a/test/Reader/Feed/AtomSourceTest.php +++ b/test/Reader/Feed/AtomSourceTest.php @@ -20,8 +20,9 @@ */ namespace ZendTest\Feed\Reader\Feed; + +use DateTime; use Zend\Feed\Reader; -use Zend\Date; /** * @category Zend @@ -47,13 +48,6 @@ public function setup() { Reader\Reader::reset(); $this->_feedSamplePath = dirname(__FILE__) . '/_files/AtomSource'; - $this->_options = Date\Date::setOptions(); - foreach($this->_options as $k=>$v) { - if (is_null($v)) { - unset($this->_options[$k]); - } - } - Date\Date::setOptions(array('format_type'=>'iso')); $this->_expectedCats = array( array( 'term' => 'topic1', @@ -84,12 +78,7 @@ public function setup() ) ); } - - public function teardown() - { - Date\Date::setOptions($this->_options); - } - + public function testGetsSourceFromEntry() { $feed = Reader\Reader::importString( @@ -160,9 +149,8 @@ public function testGetsDateCreatedFromAtom10() ); $source = $feed->current()->getSource(); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($source->getDateCreated())); + $edate = DateTime::createFromFormat(DateTime::ISO8601, '2009-03-07T08:03:50Z'); + $this->assertEquals($edate, $source->getDateCreated()); } /** @@ -176,9 +164,8 @@ public function testGetsDateModifiedFromAtom10() ); $source = $feed->current()->getSource(); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($source->getDateModified())); + $edate = DateTime::createFromFormat(DateTime::ISO8601, '2009-03-07T08:03:50Z'); + $this->assertEquals($edate, $source->getDateModified()); } /** diff --git a/test/Reader/Feed/AtomTest.php b/test/Reader/Feed/AtomTest.php index 59247071..24d95646 100644 --- a/test/Reader/Feed/AtomTest.php +++ b/test/Reader/Feed/AtomTest.php @@ -20,8 +20,9 @@ */ namespace ZendTest\Feed\Reader\Feed; + +use DateTime; use Zend\Feed\Reader; -use Zend\Date; /** * @category Zend @@ -47,13 +48,7 @@ public function setup() { Reader\Reader::reset(); $this->_feedSamplePath = dirname(__FILE__) . '/_files/Atom'; - $this->_options = Date\Date::setOptions(); - foreach($this->_options as $k=>$v) { - if (is_null($v)) { - unset($this->_options[$k]); - } - } - Date\Date::setOptions(array('format_type'=>'iso')); + $this->_expectedCats = array( array( 'term' => 'topic1', @@ -84,11 +79,6 @@ public function setup() ) ); } - - public function teardown() - { - Date\Date::setOptions($this->_options); - } /** * Get Title (Unencoded Text) @@ -177,9 +167,8 @@ public function testGetsDateCreatedFromAtom03() $feed = Reader\Reader::importString( file_get_contents($this->_feedSamplePath . '/datecreated/plain/atom03.xml') ); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($feed->getDateCreated())); + $edate = DateTime::createFromFormat(DateTime::ISO8601, '2009-03-07T08:03:50Z'); + $this->assertEquals($edate, $feed->getDateCreated()); } public function testGetsDateCreatedFromAtom10() @@ -187,10 +176,8 @@ public function testGetsDateCreatedFromAtom10() $feed = Reader\Reader::importString( file_get_contents($this->_feedSamplePath . '/datecreated/plain/atom10.xml') ); - - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($feed->getDateCreated())); + $edate = DateTime::createFromFormat(DateTime::ISO8601, '2009-03-07T08:03:50Z'); + $this->assertEquals($edate, $feed->getDateCreated()); } /** @@ -201,10 +188,8 @@ public function testGetsDateModifiedFromAtom03() $feed = Reader\Reader::importString( file_get_contents($this->_feedSamplePath . '/datemodified/plain/atom03.xml') ); - - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($feed->getDateModified())); + $edate = DateTime::createFromFormat(DateTime::ISO8601, '2009-03-07T08:03:50Z'); + $this->assertEquals($edate, $feed->getDateModified()); } public function testGetsDateModifiedFromAtom10() @@ -212,10 +197,8 @@ public function testGetsDateModifiedFromAtom10() $feed = Reader\Reader::importString( file_get_contents($this->_feedSamplePath . '/datemodified/plain/atom10.xml') ); - - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($feed->getDateModified())); + $edate = DateTime::createFromFormat(DateTime::ISO8601, '2009-03-07T08:03:50Z'); + $this->assertEquals($edate, $feed->getDateModified()); } /** diff --git a/test/Reader/Feed/RssTest.php b/test/Reader/Feed/RssTest.php index 34735890..d683d65b 100644 --- a/test/Reader/Feed/RssTest.php +++ b/test/Reader/Feed/RssTest.php @@ -20,8 +20,9 @@ */ namespace ZendTest\Feed\Reader\Feed; + +use DateTime; use Zend\Feed\Reader; -use Zend\Date; /** * @category Zend @@ -47,13 +48,7 @@ public function setup() { Reader\Reader::reset(); $this->_feedSamplePath = dirname(__FILE__) . '/_files/Rss'; - $this->_options = Date\Date::setOptions(); - foreach($this->_options as $k=>$v) { - if (is_null($v)) { - unset($this->_options[$k]); - } - } - Date\Date::setOptions(array('format_type'=>'iso')); + $this->_expectedCats = array( array( 'term' => 'topic1', @@ -101,11 +96,6 @@ public function setup() ) ); } - - public function teardown() - { - Date\Date::setOptions($this->_options); - } /** * Get Title (Unencoded Text) @@ -2102,9 +2092,8 @@ public function testGetsLastBuildDateFromRss20() $feed = Reader\Reader::importString( file_get_contents($this->_feedSamplePath.'/lastbuilddate/plain/rss20.xml') ); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($feed->getLastBuildDate())); + $edate = DateTime::createFromFormat(DateTime::ISO8601, '2009-03-07T08:03:50Z'); + $this->assertTrue($edate == $feed->getLastBuildDate()); } public function testGetsLastBuildDateFromRss20_None() @@ -2116,305 +2105,55 @@ public function testGetsLastBuildDateFromRss20_None() } /** - * Get Date Modified (Unencoded Text) + * Get DateModified (Unencoded Text) + * @dataProvider dateModifiedProvider */ - public function testGetsDateModifiedFromRss20() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/rss20.xml') - ); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($feed->getDateModified())); - } - - /** - * @group ZF-8702 - */ - public function testParsesCorrectDateIfMissingOffsetWhenSystemUsesUSLocale() - { - $locale = new \Zend\Locale\Locale('en_US'); - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/rss20_en_US.xml') - ); - $fdate = $feed->getDateModified(); - $edate = new Date\Date; - $edate->set('2010-01-04T02:14:00-0600', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($fdate)); - } - - // DC 1.0 - - public function testGetsDateModifiedFromRss20_Dc10() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/dc10/rss20.xml') - ); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($feed->getDateModified())); - } - - public function testGetsDateModifiedFromRss094_Dc10() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/dc10/rss094.xml') - ); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($feed->getDateModified())); - } - - public function testGetsDateModifiedFromRss093_Dc10() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/dc10/rss093.xml') - ); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($feed->getDateModified())); - } - - public function testGetsDateModifiedFromRss092_Dc10() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/dc10/rss092.xml') - ); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($feed->getDateModified())); - } - - public function testGetsDateModifiedFromRss091_Dc10() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/dc10/rss091.xml') - ); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($feed->getDateModified())); - } - - public function testGetsDateModifiedFromRss10_Dc10() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/dc10/rss10.xml') - ); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($feed->getDateModified())); - } - - public function testGetsDateModifiedFromRss090_Dc10() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/dc10/rss090.xml') - ); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($feed->getDateModified())); - } - - // DC 1.1 - - public function testGetsDateModifiedFromRss20_Dc11() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/dc11/rss20.xml') - ); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($feed->getDateModified())); - } - - public function testGetsDateModifiedFromRss094_Dc11() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/dc11/rss094.xml') - ); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($feed->getDateModified())); - } - - public function testGetsDateModifiedFromRss093_Dc11() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/dc11/rss093.xml') - ); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($feed->getDateModified())); - } - - public function testGetsDateModifiedFromRss092_Dc11() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/dc11/rss092.xml') - ); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($feed->getDateModified())); - } - - public function testGetsDateModifiedFromRss091_Dc11() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/dc11/rss091.xml') - ); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($feed->getDateModified())); - } - - public function testGetsDateModifiedFromRss10_Dc11() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/dc11/rss10.xml') - ); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($feed->getDateModified())); - } - - public function testGetsDateModifiedFromRss090_Dc11() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/dc11/rss090.xml') - ); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($feed->getDateModified())); - } - - // Atom 1.0 - - public function testGetsDateModifiedFromRss20_atom10() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/atom10/rss20.xml') - ); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($feed->getDateModified())); - } - - public function testGetsDateModifiedFromRss094_atom10() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/atom10/rss094.xml') - ); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($feed->getDateModified())); - } - - public function testGetsDateModifiedFromRss093_atom10() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/atom10/rss093.xml') - ); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($feed->getDateModified())); - } - - public function testGetsDateModifiedFromRss092_atom10() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/atom10/rss092.xml') - ); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($feed->getDateModified())); - } - - public function testGetsDateModifiedFromRss091_atom10() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/atom10/rss091.xml') - ); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($feed->getDateModified())); - } - - public function testGetsDateModifiedFromRss10_atom10() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/atom10/rss10.xml') - ); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($feed->getDateModified())); - } - - public function testGetsDateModifiedFromRss090_atom10() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/atom10/rss090.xml') - ); - $edate = new Date\Date; - $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); - $this->assertTrue($edate->equals($feed->getDateModified())); - } - - // Missing DateModified - - public function testGetsDateModifiedFromRss20_None() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/none/rss20.xml') - ); - $this->assertEquals(null, $feed->getDateModified()); - } - - public function testGetsDateModifiedFromRss094_None() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/none/rss094.xml') - ); - $this->assertEquals(null, $feed->getDateModified()); - } - - public function testGetsDateModifiedFromRss093_None() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/none/rss093.xml') - ); - $this->assertEquals(null, $feed->getDateModified()); - } - - public function testGetsDateModifiedFromRss092_None() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/none/rss092.xml') - ); - $this->assertEquals(null, $feed->getDateModified()); - } - - public function testGetsDateModifiedFromRss091_None() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/none/rss091.xml') - ); - $this->assertEquals(null, $feed->getDateModified()); - } - - public function testGetsDateModifiedFromRss10_None() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/none/rss10.xml') - ); - $this->assertEquals(null, $feed->getDateModified()); - } - - public function testGetsDateModifiedFromRss090_None() - { - $feed = Reader\Reader::importString( - file_get_contents($this->_feedSamplePath.'/datemodified/plain/none/rss090.xml') + public function testGetsDateModified($path, $edate) + { + $feed = Reader\Reader::importString( + file_get_contents($this->_feedSamplePath . $path) + ); + + $this->assertTrue($edate == $feed->getDateModified()); + } + + public function dateModifiedProvider() { + $iso = DateTime::createFromFormat(DateTime::ISO8601, '2009-03-07T08:03:50Z'); + $us = DateTime::createFromFormat(DateTime::ISO8601, '2010-01-04T02:14:00-0600'); + return array( + array('/datemodified/plain/rss20.xml', $iso), + array('/datemodified/plain/rss20_en_US.xml', $us), + array('/datemodified/plain/dc10/rss20.xml', $iso), + array('/datemodified/plain/dc10/rss094.xml', $iso), + array('/datemodified/plain/dc10/rss093.xml', $iso), + array('/datemodified/plain/dc10/rss092.xml', $iso), + array('/datemodified/plain/dc10/rss091.xml', $iso), + array('/datemodified/plain/dc10/rss10.xml', $iso), + array('/datemodified/plain/dc10/rss090.xml', $iso), + array('/datemodified/plain/dc11/rss20.xml', $iso), + array('/datemodified/plain/dc11/rss094.xml', $iso), + array('/datemodified/plain/dc11/rss093.xml', $iso), + array('/datemodified/plain/dc11/rss092.xml', $iso), + array('/datemodified/plain/dc11/rss091.xml', $iso), + array('/datemodified/plain/dc11/rss10.xml', $iso), + array('/datemodified/plain/dc11/rss090.xml', $iso), + + array('/datemodified/plain/atom10/rss20.xml', $iso), + array('/datemodified/plain/atom10/rss094.xml', $iso), + array('/datemodified/plain/atom10/rss093.xml', $iso), + array('/datemodified/plain/atom10/rss092.xml', $iso), + array('/datemodified/plain/atom10/rss091.xml', $iso), + array('/datemodified/plain/atom10/rss10.xml', $iso), + array('/datemodified/plain/atom10/rss090.xml', $iso), + + array('/datemodified/plain/none/rss20.xml', null), + array('/datemodified/plain/none/rss094.xml', null), + array('/datemodified/plain/none/rss093.xml', null), + array('/datemodified/plain/none/rss092.xml', null), + array('/datemodified/plain/none/rss091.xml', null), + array('/datemodified/plain/none/rss10.xml', null), + array('/datemodified/plain/none/rss090.xml', null), ); - $this->assertEquals(null, $feed->getDateModified()); } /** diff --git a/test/Reader/Integration/H-OnlineComAtom10Test.php b/test/Reader/Integration/H-OnlineComAtom10Test.php index 96df4f0e..5d0efd50 100644 --- a/test/Reader/Integration/H-OnlineComAtom10Test.php +++ b/test/Reader/Integration/H-OnlineComAtom10Test.php @@ -20,8 +20,8 @@ */ namespace ZendTest\Feed\Reader\Integration; + use Zend\Feed\Reader; -use Zend\Date; /** * @category Zend @@ -41,18 +41,6 @@ public function setup() { Reader\Reader::reset(); $this->_feedSamplePath = dirname(__FILE__) . '/_files/h-online.com-atom10.xml'; - $this->_options = Date\Date::setOptions(); - foreach($this->_options as $k=>$v) { - if (is_null($v)) { - unset($this->_options[$k]); - } - } - Date\Date::setOptions(array('format_type'=>'iso')); - } - - public function teardown() - { - Date\Date::setOptions($this->_options); } public function testGetsTitle() diff --git a/test/Reader/Integration/LautDeRdfTest.php b/test/Reader/Integration/LautDeRdfTest.php index 635bc4b1..29cc7ea9 100644 --- a/test/Reader/Integration/LautDeRdfTest.php +++ b/test/Reader/Integration/LautDeRdfTest.php @@ -20,8 +20,8 @@ */ namespace ZendTest\Feed\Reader\Integration; + use Zend\Feed\Reader; -use Zend\Date; /** * @category Zend @@ -41,18 +41,6 @@ public function setup() { Reader\Reader::reset(); $this->_feedSamplePath = dirname(__FILE__) . '/_files/laut.de-rdf.xml'; - $this->_options = Date\Date::setOptions(); - foreach($this->_options as $k=>$v) { - if (is_null($v)) { - unset($this->_options[$k]); - } - } - Date\Date::setOptions(array('format_type'=>'iso')); - } - - public function teardown() - { - Date\Date::setOptions($this->_options); } /** diff --git a/test/Reader/Integration/PodcastRss2Test.php b/test/Reader/Integration/PodcastRss2Test.php index 70fae25c..66989bd3 100644 --- a/test/Reader/Integration/PodcastRss2Test.php +++ b/test/Reader/Integration/PodcastRss2Test.php @@ -20,8 +20,8 @@ */ namespace ZendTest\Feed\Reader\Integration; + use Zend\Feed\Reader; -use Zend\Date; /** * @category Zend @@ -41,18 +41,6 @@ public function setup() { Reader\Reader::reset(); $this->_feedSamplePath = dirname(__FILE__) . '/_files/podcast.xml'; - $this->_options = Date\Date::setOptions(); - foreach($this->_options as $k=>$v) { - if (is_null($v)) { - unset($this->_options[$k]); - } - } - Date\Date::setOptions(array('format_type'=>'iso')); - } - - public function teardown() - { - Date\Date::setOptions($this->_options); } /** diff --git a/test/Reader/Integration/WordpressAtom10Test.php b/test/Reader/Integration/WordpressAtom10Test.php index 33451c28..d3cb1499 100644 --- a/test/Reader/Integration/WordpressAtom10Test.php +++ b/test/Reader/Integration/WordpressAtom10Test.php @@ -20,8 +20,8 @@ */ namespace ZendTest\Feed\Reader\Integration; + use Zend\Feed\Reader; -use Zend\Date; /** * @category Zend @@ -41,18 +41,6 @@ public function setup() { Reader\Reader::reset(); $this->_feedSamplePath = dirname(__FILE__) . '/_files/wordpress-atom10.xml'; - $this->_options = Date\Date::setOptions(); - foreach($this->_options as $k=>$v) { - if (is_null($v)) { - unset($this->_options[$k]); - } - } - Date\Date::setOptions(array('format_type'=>'iso')); - } - - public function teardown() - { - Date\Date::setOptions($this->_options); } public function testGetsTitle() diff --git a/test/Writer/DeletedTest.php b/test/Writer/DeletedTest.php index 55b6ad8d..b2a52943 100644 --- a/test/Writer/DeletedTest.php +++ b/test/Writer/DeletedTest.php @@ -20,8 +20,9 @@ */ namespace ZendTest\Feed\Writer; + +use DateTime; use Zend\Feed\Writer; -use Zend\Date; /** * @category Zend @@ -62,16 +63,16 @@ public function testSetWhenDefaultsToCurrentTime() { $entry = new Writer\Deleted; $entry->setWhen(); - $dateNow = new Date\Date; - $this->assertTrue($dateNow->isLater($entry->getWhen()) || $dateNow->equals($entry->getWhen())); + $dateNow = new DateTime(); + $this->assertTrue($dateNow >= $entry->getWhen()); } public function testSetWhenUsesGivenUnixTimestamp() { $entry = new Writer\Deleted; $entry->setWhen(1234567890); - $myDate = new Date\Date('1234567890', Date\Date::TIMESTAMP); - $this->assertTrue($myDate->equals($entry->getWhen())); + $myDate = new DateTime('@' . 1234567890); + $this->assertEquals($myDate, $entry->getWhen()); } /** @@ -81,8 +82,8 @@ public function testSetWhenUsesGivenUnixTimestampWhenItIsLessThanTenDigits() { $entry = new Writer\Deleted; $entry->setWhen(123456789); - $myDate = new Date\Date('123456789', Date\Date::TIMESTAMP); - $this->assertTrue($myDate->equals($entry->getWhen())); + $myDate = new DateTime('@' . 123456789); + $this->assertEquals($myDate, $entry->getWhen()); } /** @@ -92,16 +93,16 @@ public function testSetWhenUsesGivenUnixTimestampWhenItIsAVerySmallInteger() { $entry = new Writer\Deleted; $entry->setWhen(123); - $myDate = new Date\Date('123', Date\Date::TIMESTAMP); - $this->assertTrue($myDate->equals($entry->getWhen())); + $myDate = new DateTime('@' . 123); + $this->assertEquals($myDate, $entry->getWhen()); } - public function testSetWhenUsesZendDateObject() + public function testSetWhenUsesDateTimeObject() { + $myDate = new DateTime('@' . 1234567890); $entry = new Writer\Deleted; - $entry->setWhen(new Date\Date('1234567890', Date\Date::TIMESTAMP)); - $myDate = new Date\Date('1234567890', Date\Date::TIMESTAMP); - $this->assertTrue($myDate->equals($entry->getWhen())); + $entry->setWhen($myDate); + $this->assertEquals($myDate, $entry->getWhen()); } public function testSetWhenThrowsExceptionOnInvalidParameter() diff --git a/test/Writer/EntryTest.php b/test/Writer/EntryTest.php index 382cabdb..ac00b9a9 100644 --- a/test/Writer/EntryTest.php +++ b/test/Writer/EntryTest.php @@ -21,8 +21,8 @@ namespace ZendTest\Feed\Writer; +use DateTime; use Zend\Feed\Writer; -use Zend\Date; /** * @category Zend @@ -210,16 +210,16 @@ public function testSetDateCreatedDefaultsToCurrentTime() { $entry = new Writer\Entry; $entry->setDateCreated(); - $dateNow = new Date\Date; - $this->assertTrue($dateNow->isLater($entry->getDateCreated()) || $dateNow->equals($entry->getDateCreated())); + $dateNow = new DateTime(); + $this->assertTrue($dateNow >= $entry->getDateCreated()); } public function testSetDateCreatedUsesGivenUnixTimestamp() { $entry = new Writer\Entry; $entry->setDateCreated(1234567890); - $myDate = new Date\Date('1234567890', Date\Date::TIMESTAMP); - $this->assertTrue($myDate->equals($entry->getDateCreated())); + $myDate = new DateTime('@' . 1234567890); + $this->assertEquals($myDate, $entry->getDateCreated()); } /** @@ -229,8 +229,8 @@ public function testSetDateCreatedUsesGivenUnixTimestampWhenItIsLessThanTenDigit { $entry = new Writer\Entry; $entry->setDateCreated(123456789); - $myDate = new Date\Date('123456789', Date\Date::TIMESTAMP); - $this->assertTrue($myDate->equals($entry->getDateCreated())); + $myDate = new DateTime('@' . 123456789); + $this->assertEquals($myDate, $entry->getDateCreated()); } /** @@ -240,32 +240,32 @@ public function testSetDateCreatedUsesGivenUnixTimestampWhenItIsAVerySmallIntege { $entry = new Writer\Entry; $entry->setDateCreated(123); - $myDate = new Date\Date('123', Date\Date::TIMESTAMP); - $this->assertTrue($myDate->equals($entry->getDateCreated())); + $myDate = new DateTime('@' . 123); + $this->assertEquals($myDate, $entry->getDateCreated()); } - public function testSetDateCreatedUsesZendDateObject() + public function testSetDateCreatedUsesDateTimeObject() { + $myDate = new DateTime('@' . 1234567890); $entry = new Writer\Entry; - $entry->setDateCreated(new Date\Date('1234567890', Date\Date::TIMESTAMP)); - $myDate = new Date\Date('1234567890', Date\Date::TIMESTAMP); - $this->assertTrue($myDate->equals($entry->getDateCreated())); + $entry->setDateCreated($myDate); + $this->assertEquals($myDate, $entry->getDateCreated()); } public function testSetDateModifiedDefaultsToCurrentTime() { $entry = new Writer\Entry; $entry->setDateModified(); - $dateNow = new Date\Date; - $this->assertTrue($dateNow->isLater($entry->getDateModified()) || $dateNow->equals($entry->getDateModified())); + $dateNow = new DateTime(); + $this->assertTrue($dateNow >= $entry->getDateModified()); } public function testSetDateModifiedUsesGivenUnixTimestamp() { $entry = new Writer\Entry; $entry->setDateModified(1234567890); - $myDate = new Date\Date('1234567890', Date\Date::TIMESTAMP); - $this->assertTrue($myDate->equals($entry->getDateModified())); + $myDate = new DateTime('@' . 1234567890); + $this->assertEquals($myDate, $entry->getDateModified()); } /** @@ -275,8 +275,8 @@ public function testSetDateModifiedUsesGivenUnixTimestampWhenItIsLessThanTenDigi { $entry = new Writer\Entry; $entry->setDateModified(123456789); - $myDate = new Date\Date('123456789', Date\Date::TIMESTAMP); - $this->assertTrue($myDate->equals($entry->getDateModified())); + $myDate = new DateTime('@' . 123456789); + $this->assertEquals($myDate, $entry->getDateModified()); } /** @@ -286,16 +286,16 @@ public function testSetDateModifiedUsesGivenUnixTimestampWhenItIsAVerySmallInteg { $entry = new Writer\Entry; $entry->setDateModified(123); - $myDate = new Date\Date('123', Date\Date::TIMESTAMP); - $this->assertTrue($myDate->equals($entry->getDateModified())); + $myDate = new DateTime('@' . 123); + $this->assertEquals($myDate, $entry->getDateModified()); } - public function testSetDateModifiedUsesZendDateObject() + public function testSetDateModifiedUsesDateTimeObject() { + $myDate = new DateTime('@' . 1234567890); $entry = new Writer\Entry; - $entry->setDateModified(new Date\Date('1234567890', Date\Date::TIMESTAMP)); - $myDate = new Date\Date('1234567890', Date\Date::TIMESTAMP); - $this->assertTrue($myDate->equals($entry->getDateModified())); + $entry->setDateModified($myDate); + $this->assertEquals($myDate, $entry->getDateModified()); } public function testSetDateCreatedThrowsExceptionOnInvalidParameter() diff --git a/test/Writer/FeedTest.php b/test/Writer/FeedTest.php index 28f93571..b886350f 100644 --- a/test/Writer/FeedTest.php +++ b/test/Writer/FeedTest.php @@ -21,9 +21,9 @@ namespace ZendTest\Feed\Writer; +use DateTime; use Zend\Feed\Writer; use Zend\Feed\Writer\Feed; -use Zend\Date; /** * @category Zend @@ -146,16 +146,16 @@ public function testSetDateCreatedDefaultsToCurrentTime() { $writer = new Writer\Feed; $writer->setDateCreated(); - $dateNow = new Date\Date; - $this->assertTrue($dateNow->isLater($writer->getDateCreated()) || $dateNow->equals($writer->getDateCreated())); + $dateNow = new DateTime(); + $this->assertTrue($dateNow >= $writer->getDateCreated()); } public function testSetDateCreatedUsesGivenUnixTimestamp() { $writer = new Writer\Feed; $writer->setDateCreated(1234567890); - $myDate = new Date\Date('1234567890', Date\Date::TIMESTAMP); - $this->assertTrue($myDate->equals($writer->getDateCreated())); + $myDate = new DateTime('@' . 1234567890); + $this->assertEquals($myDate, $writer->getDateCreated()); } /** @@ -165,8 +165,8 @@ public function testSetDateCreatedUsesGivenUnixTimestampThatIsLessThanTenDigits( { $writer = new Writer\Feed; $writer->setDateCreated(123456789); - $myDate = new Date\Date('123456789', Date\Date::TIMESTAMP); - $this->assertTrue($myDate->equals($writer->getDateCreated())); + $myDate = new DateTime('@' . 123456789); + $this->assertEquals($myDate, $writer->getDateCreated()); } /** @@ -176,33 +176,32 @@ public function testSetDateCreatedUsesGivenUnixTimestampThatIsAVerySmallInteger( { $writer = new Writer\Feed; $writer->setDateCreated(123); - $myDate = new Date\Date('123', Date\Date::TIMESTAMP); - $this->assertTrue($myDate->equals($writer->getDateCreated())); + $myDate = new DateTime('@' . 123); + $this->assertEquals($myDate, $writer->getDateCreated()); } - public function testSetDateCreatedUsesZendDateObject() + public function testSetDateCreatedUsesDateTimeObject() { + $myDate = new DateTime('@' . 1234567890); $writer = new Writer\Feed; - $writer->setDateCreated(new Date\Date('1234567890', Date\Date::TIMESTAMP)); - $myDate = new Date\Date('1234567890', Date\Date::TIMESTAMP); - $this->assertTrue($myDate->equals($writer->getDateCreated())); + $writer->setDateCreated($myDate); + $this->assertEquals($myDate, $writer->getDateCreated()); } public function testSetDateModifiedDefaultsToCurrentTime() { $writer = new Writer\Feed; $writer->setDateModified(); - $dateNow = new Date\Date; - $this->assertTrue( - $dateNow->isLater($writer->getDateModified()) || $dateNow->equals($writer->getDateModified())); + $dateNow = new DateTime(); + $this->assertTrue($dateNow >= $writer->getDateModified()); } public function testSetDateModifiedUsesGivenUnixTimestamp() { $writer = new Writer\Feed; $writer->setDateModified(1234567890); - $myDate = new Date\Date('1234567890', Date\Date::TIMESTAMP); - $this->assertTrue($myDate->equals($writer->getDateModified())); + $myDate = new DateTime('@' . 1234567890); + $this->assertEquals($myDate, $writer->getDateModified()); } /** @@ -212,8 +211,8 @@ public function testSetDateModifiedUsesGivenUnixTimestampThatIsLessThanTenDigits { $writer = new Writer\Feed; $writer->setDateModified(123456789); - $myDate = new Date\Date('123456789', Date\Date::TIMESTAMP); - $this->assertTrue($myDate->equals($writer->getDateModified())); + $myDate = new DateTime('@' . 123456789); + $this->assertEquals($myDate, $writer->getDateModified()); } /** @@ -221,18 +220,19 @@ public function testSetDateModifiedUsesGivenUnixTimestampThatIsLessThanTenDigits */ public function testSetDateModifiedUsesGivenUnixTimestampThatIsAVerySmallInteger() { + $writer = new Writer\Feed; $writer->setDateModified(123); - $myDate = new Date\Date('123', Date\Date::TIMESTAMP); - $this->assertTrue($myDate->equals($writer->getDateModified())); + $myDate = new DateTime('@' . 123); + $this->assertEquals($myDate, $writer->getDateModified()); } - public function testSetDateModifiedUsesZendDateObject() + public function testSetDateModifiedUsesDateTimeObject() { + $myDate = new DateTime('@' . 1234567890); $writer = new Writer\Feed; - $writer->setDateModified(new Date\Date('1234567890', Date\Date::TIMESTAMP)); - $myDate = new Date\Date('1234567890', Date\Date::TIMESTAMP); - $this->assertTrue($myDate->equals($writer->getDateModified())); + $writer->setDateModified($myDate); + $this->assertEquals($myDate, $writer->getDateModified()); } public function testSetDateCreatedThrowsExceptionOnInvalidParameter() @@ -271,17 +271,16 @@ public function testSetLastBuildDateDefaultsToCurrentTime() { $writer = new Writer\Feed; $writer->setLastBuildDate(); - $dateNow = new Date\Date; - $this->assertTrue( - $dateNow->isLater($writer->getLastBuildDate()) || $dateNow->equals($writer->getLastBuildDate())); + $dateNow = new DateTime(); + $this->assertTrue($dateNow >= $writer->getLastBuildDate()); } public function testSetLastBuildDateUsesGivenUnixTimestamp() { $writer = new Writer\Feed; $writer->setLastBuildDate(1234567890); - $myDate = new Date\Date('1234567890', Date\Date::TIMESTAMP); - $this->assertTrue($myDate->equals($writer->getLastBuildDate())); + $myDate = new DateTime('@' . 1234567890); + $this->assertEquals($myDate, $writer->getLastBuildDate()); } /** @@ -291,8 +290,8 @@ public function testSetLastBuildDateUsesGivenUnixTimestampThatIsLessThanTenDigit { $writer = new Writer\Feed; $writer->setLastBuildDate(123456789); - $myDate = new Date\Date('123456789', Date\Date::TIMESTAMP); - $this->assertTrue($myDate->equals($writer->getLastBuildDate())); + $myDate = new DateTime('@' . 123456789); + $this->assertEquals($myDate, $writer->getLastBuildDate()); } /** @@ -302,16 +301,16 @@ public function testSetLastBuildDateUsesGivenUnixTimestampThatIsAVerySmallIntege { $writer = new Writer\Feed; $writer->setLastBuildDate(123); - $myDate = new Date\Date('123', Date\Date::TIMESTAMP); - $this->assertTrue($myDate->equals($writer->getLastBuildDate())); + $myDate = new DateTime('@' . 123); + $this->assertEquals($myDate, $writer->getLastBuildDate()); } - public function testSetLastBuildDateUsesZendDateObject() + public function testSetLastBuildDateUsesDateTimeObject() { + $myDate = new DateTime('@' . 1234567890); $writer = new Writer\Feed; - $writer->setLastBuildDate(new Date\Date('1234567890', Date\Date::TIMESTAMP)); - $myDate = new Date\Date('1234567890', Date\Date::TIMESTAMP); - $this->assertTrue($myDate->equals($writer->getLastBuildDate())); + $writer->setLastBuildDate($myDate); + $this->assertEquals($myDate, $writer->getLastBuildDate()); } public function testSetLastBuildDateThrowsExceptionOnInvalidParameter() @@ -906,7 +905,6 @@ public function testAddsAndOrdersEntriesByDateIfRequested() $writer->addEntry($entry); $writer->addEntry($entry2); $writer->orderByDate(); - $this->assertEquals(1230000000, $writer->getEntry(1)->getDateCreated()->get(Date\Date::TIMESTAMP)); + $this->assertEquals(1230000000, $writer->getEntry(1)->getDateCreated()->getTimestamp()); } - -} +} \ No newline at end of file diff --git a/test/Writer/Renderer/Entry/AtomTest.php b/test/Writer/Renderer/Entry/AtomTest.php index 43fc23c0..a3cc8518 100644 --- a/test/Writer/Renderer/Entry/AtomTest.php +++ b/test/Writer/Renderer/Entry/AtomTest.php @@ -20,10 +20,10 @@ */ namespace ZendTest\Feed\Writer\Renderer\Entry; + use Zend\Feed\Writer\Renderer; use Zend\Feed\Writer; use Zend\Feed\Reader; -use Zend\Date; /** * @category Zend @@ -153,7 +153,7 @@ public function testEntryUpdatedDateHasBeenSet() $renderer = new Renderer\Feed\Atom($this->_validWriter); $feed = Reader\Reader::importString($renderer->render()->saveXml()); $entry = $feed->current(); - $this->assertEquals(1234567890, $entry->getDateModified()->get(Date\Date::TIMESTAMP)); + $this->assertEquals(1234567890, $entry->getDateModified()->getTimestamp()); } /** @@ -171,7 +171,7 @@ public function testEntryPublishedDateHasBeenSet() $renderer = new Renderer\Feed\Atom($this->_validWriter); $feed = Reader\Reader::importString($renderer->render()->saveXml()); $entry = $feed->current(); - $this->assertEquals(1234567000, $entry->getDateCreated()->get(Date\Date::TIMESTAMP)); + $this->assertEquals(1234567000, $entry->getDateCreated()->getTimestamp()); } public function testEntryIncludesLinkToHtmlVersionOfFeed() diff --git a/test/Writer/Renderer/Entry/RssTest.php b/test/Writer/Renderer/Entry/RssTest.php index 11eaffa8..7fb7c37b 100644 --- a/test/Writer/Renderer/Entry/RssTest.php +++ b/test/Writer/Renderer/Entry/RssTest.php @@ -20,10 +20,10 @@ */ namespace ZendTest\Feed\Writer\Renderer\Entry; + use Zend\Feed\Writer\Renderer; use Zend\Feed\Writer; use Zend\Feed\Reader; -use Zend\Date; /** * @category Zend @@ -169,7 +169,7 @@ public function testEntryUpdatedDateHasBeenSet() $renderer = new Renderer\Feed\Rss($this->_validWriter); $feed = Reader\Reader::importString($renderer->render()->saveXml()); $entry = $feed->current(); - $this->assertEquals(1234567890, $entry->getDateModified()->get(Date\Date::TIMESTAMP)); + $this->assertEquals(1234567890, $entry->getDateModified()->getTimestamp()); } public function testEntryPublishedDateHasBeenSet() @@ -178,7 +178,7 @@ public function testEntryPublishedDateHasBeenSet() $renderer = new Renderer\Feed\Rss($this->_validWriter); $feed = Reader\Reader::importString($renderer->render()->saveXml()); $entry = $feed->current(); - $this->assertEquals(1234567000, $entry->getDateCreated()->get(Date\Date::TIMESTAMP)); + $this->assertEquals(1234567000, $entry->getDateCreated()->getTimestamp()); } public function testEntryIncludesLinkToHtmlVersionOfFeed() diff --git a/test/Writer/Renderer/Feed/AtomTest.php b/test/Writer/Renderer/Feed/AtomTest.php index 10f50581..62a706e3 100644 --- a/test/Writer/Renderer/Feed/AtomTest.php +++ b/test/Writer/Renderer/Feed/AtomTest.php @@ -20,10 +20,10 @@ */ namespace ZendTest\Feed\Writer\Renderer\Feed; + use Zend\Feed\Writer; use Zend\Feed\Writer\Renderer; use Zend\Feed\Reader; -use Zend\Date; /** * @category Zend @@ -155,7 +155,7 @@ public function testFeedUpdatedDateHasBeenSet() $atomFeed = new Renderer\Feed\Atom($this->_validWriter); $atomFeed->render(); $feed = Reader\Reader::importString($atomFeed->saveXml()); - $this->assertEquals(1234567890, $feed->getDateModified()->get(Date\Date::TIMESTAMP)); + $this->assertEquals(1234567890, $feed->getDateModified()->getTimestamp()); } /** diff --git a/test/Writer/Renderer/Feed/RssTest.php b/test/Writer/Renderer/Feed/RssTest.php index 6a360093..af88dffc 100644 --- a/test/Writer/Renderer/Feed/RssTest.php +++ b/test/Writer/Renderer/Feed/RssTest.php @@ -24,7 +24,6 @@ use Zend\Feed\Writer; use Zend\Feed\Writer\Renderer; use Zend\Feed\Reader; -use Zend\Date; /** * @category Zend @@ -155,7 +154,7 @@ public function testFeedUpdatedDateHasBeenSet() $rssFeed = new Renderer\Feed\Rss($this->_validWriter); $rssFeed->render(); $feed = Reader\Reader::importString($rssFeed->saveXml()); - $this->assertEquals(1234567890, $feed->getDateModified()->get(Date\Date::TIMESTAMP)); + $this->assertEquals(1234567890, $feed->getDateModified()->getTimestamp()); } public function testFeedUpdatedDateIfMissingThrowsNoException() @@ -171,7 +170,7 @@ public function testFeedLastBuildDateHasBeenSet() $rssFeed = new Renderer\Feed\Rss($this->_validWriter); $rssFeed->render(); $feed = Reader\Reader::importString($rssFeed->saveXml()); - $this->assertEquals(1234567890, $feed->getLastBuildDate()->get(Date\Date::TIMESTAMP)); + $this->assertEquals(1234567890, $feed->getLastBuildDate()->getTimestamp()); } public function testFeedGeneratorHasBeenSet()