From 0804292f027e84f172014ba057c1075349dc4d0e Mon Sep 17 00:00:00 2001 From: Stefan Gehrig Date: Sat, 31 Jul 2010 18:02:59 +0200 Subject: [PATCH 01/13] updateing --- src/Reader/Entry/Rss.php | 84 ++++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/src/Reader/Entry/Rss.php b/src/Reader/Entry/Rss.php index fe2f36a7..16c4baeb 100644 --- a/src/Reader/Entry/Rss.php +++ b/src/Reader/Entry/Rss.php @@ -13,40 +13,39 @@ * to license@zend.com so we can send you a copy immediately. * * @category Zend - * @package Reader\Reader + * @package Zend_Feed_Reader * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Rss.php 22300 2010-05-26 10:13:34Z padraic $ + * @version $Id$ */ /** -* @namespace -*/ + * @namespace + */ namespace Zend\Feed\Reader\Entry; use Zend\Feed\Reader; use Zend\Date; /** -* @uses \Zend\Date\Date -* @uses \Zend\Feed\Exception -* @uses \Zend\Feed\Reader\Reader -* @uses \Zend\Feed\Reader\Collection\Category -* @uses \Zend\Feed\Reader\EntryAbstract -* @uses \Zend\Feed\Reader\EntryInterface -* @uses \Zend\Feed\Reader\Extension\Atom\Entry -* @uses \Zend\Feed\Reader\Extension\Content\Entry -* @uses \Zend\Feed\Reader\Extension\DublinCore\Entry -* @uses \Zend\Feed\Reader\Extension\Slash\Entry -* @uses \Zend\Feed\Reader\Extension\Thread\Entry -* @uses \Zend\Feed\Reader\Extension\WellformedWeb\Entry -* @category Zend -* @package Reader\Reader -* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) -* @license http://framework.zend.com/license/new-bsd New BSD License -*/ -class Rss extends AbstractEntry implements Reader\Entry + * @uses \Zend\Date\Date + * @uses \Zend\Feed\Exception + * @uses \Zend\Feed\Reader\Reader + * @uses \Zend\Feed\Reader\Collection\Category + * @uses \Zend\Feed\Reader\AbstractEntry + * @uses \Zend\Feed\Reader\Entry + * @uses \Zend\Feed\Reader\Extension\Atom\Entry + * @uses \Zend\Feed\Reader\Extension\Content\Entry + * @uses \Zend\Feed\Reader\Extension\DublinCore\Entry + * @uses \Zend\Feed\Reader\Extension\Slash\Entry + * @uses \Zend\Feed\Reader\Extension\Thread\Entry + * @uses Zend_Feed_Reader_Extension_WellformedWeb_Entry + * @category Zend + * @package Zend_Feed_Reader + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + */ +class RSS extends Reader\AbstractEntry implements Reader\Entry { - /** * XPath query for RDF * @@ -64,7 +63,7 @@ class Rss extends AbstractEntry implements Reader\Entry /** * Constructor * - * @param Zend_Feed_Entry_Abstract $entry + * @param \Zend\Feed\Entry\AbstractEntry $entry * @param string $entryKey * @param string $type * @return void @@ -77,23 +76,23 @@ public function __construct(\DOMElement $entry, $entryKey, $type = null) $pluginLoader = Reader\Reader::getPluginLoader(); - $dublinCoreClass = $pluginLoader->getClassName('DublinCore\\Entry'); - $this->_extensions['DublinCore\\Entry'] = new $dublinCoreClass($entry, $entryKey, $type); + $dublinCoreClass = $pluginLoader->getClassName('DublinCore\Entry'); + $this->_extensions['DublinCore\Entry'] = new $dublinCoreClass($entry, $entryKey, $type); - $contentClass = $pluginLoader->getClassName('Content\\Entry'); - $this->_extensions['Content\\Entry'] = new $contentClass($entry, $entryKey, $type); + $contentClass = $pluginLoader->getClassName('Content\Entry'); + $this->_extensions['Content\Entry'] = new $contentClass($entry, $entryKey, $type); - $atomClass = $pluginLoader->getClassName('Atom\\Entry'); - $this->_extensions['Atom\\Entry'] = new $atomClass($entry, $entryKey, $type); + $atomClass = $pluginLoader->getClassName('Atom\Entry'); + $this->_extensions['Atom\Entry'] = new $atomClass($entry, $entryKey, $type); - $wfwClass = $pluginLoader->getClassName('WellFormedWeb\\Entry'); - $this->_extensions['WellFormedWeb\\Entry'] = new $wfwClass($entry, $entryKey, $type); + $wfwClass = $pluginLoader->getClassName('WellFormedWeb\Entry'); + $this->_extensions['WellFormedWeb\Entry'] = new $wfwClass($entry, $entryKey, $type); - $slashClass = $pluginLoader->getClassName('Slash\\Entry'); - $this->_extensions['Slash\\Entry'] = new $slashClass($entry, $entryKey, $type); + $slashClass = $pluginLoader->getClassName('Slash\Entry'); + $this->_extensions['Slash\Entry'] = new $slashClass($entry, $entryKey, $type); - $threadClass = $pluginLoader->getClassName('Thread\\Entry'); - $this->_extensions['Thread\\Entry'] = new $threadClass($entry, $entryKey, $type); + $threadClass = $pluginLoader->getClassName('Thread\Entry'); + $this->_extensions['Thread\Entry'] = new $threadClass($entry, $entryKey, $type); } /** @@ -233,8 +232,10 @@ public function getDateModified() if ($dateModifiedParsed) { $date = new Date\Date($dateModifiedParsed); } else { - $dateStandards = array(Date\Date::RSS, Date\Date::RFC_822, - Date\Date::RFC_2822, Date\Date::DATES); + $dateStandards = array( + Date\Date::RSS, Date\Date::RFC_822, + Date\Date::RFC_2822, Date\Date::DATES, + ); $date = new Date\Date; foreach ($dateStandards as $standard) { try { @@ -242,8 +243,7 @@ public function getDateModified() break; } catch (Date\Exception $e) { if ($standard == Date\Date::DATES) { - require_once 'Zend/Feed/Exception.php'; - throw new Exception( + throw new \Zend\Feed\Exception( 'Could not load date due to unrecognised' .' format (should follow RFC 822 or 2822):' . $e->getMessage(), @@ -440,7 +440,7 @@ public function getLinks() /** * Get all categories * - * @return Reader\Reader_Collection_Category + * @return \Zend\Feed\Reader\Collection\Category */ public function getCategories() { @@ -620,7 +620,7 @@ public function getCommentFeedLink() /** * Set the XPath query (incl. on all Extensions) * - * @param \DOMXPath $xpath + * @param DOMXPath $xpath */ public function setXpath(\DOMXPath $xpath) { From d9859ee8c976ed680e298e55f0f54354a21e375c Mon Sep 17 00:00:00 2001 From: Stefan Gehrig Date: Sat, 31 Jul 2010 18:11:28 +0200 Subject: [PATCH 02/13] Revert "updateing" This reverts commit 7f7c19da825c7771f685ba594b506414bf8e9cb4. --- src/Reader/Entry/Rss.php | 84 ++++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/src/Reader/Entry/Rss.php b/src/Reader/Entry/Rss.php index 16c4baeb..fe2f36a7 100644 --- a/src/Reader/Entry/Rss.php +++ b/src/Reader/Entry/Rss.php @@ -13,39 +13,40 @@ * to license@zend.com so we can send you a copy immediately. * * @category Zend - * @package Zend_Feed_Reader + * @package Reader\Reader * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ + * @version $Id: Rss.php 22300 2010-05-26 10:13:34Z padraic $ */ /** - * @namespace - */ +* @namespace +*/ namespace Zend\Feed\Reader\Entry; use Zend\Feed\Reader; use Zend\Date; /** - * @uses \Zend\Date\Date - * @uses \Zend\Feed\Exception - * @uses \Zend\Feed\Reader\Reader - * @uses \Zend\Feed\Reader\Collection\Category - * @uses \Zend\Feed\Reader\AbstractEntry - * @uses \Zend\Feed\Reader\Entry - * @uses \Zend\Feed\Reader\Extension\Atom\Entry - * @uses \Zend\Feed\Reader\Extension\Content\Entry - * @uses \Zend\Feed\Reader\Extension\DublinCore\Entry - * @uses \Zend\Feed\Reader\Extension\Slash\Entry - * @uses \Zend\Feed\Reader\Extension\Thread\Entry - * @uses Zend_Feed_Reader_Extension_WellformedWeb_Entry - * @category Zend - * @package Zend_Feed_Reader - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class RSS extends Reader\AbstractEntry implements Reader\Entry +* @uses \Zend\Date\Date +* @uses \Zend\Feed\Exception +* @uses \Zend\Feed\Reader\Reader +* @uses \Zend\Feed\Reader\Collection\Category +* @uses \Zend\Feed\Reader\EntryAbstract +* @uses \Zend\Feed\Reader\EntryInterface +* @uses \Zend\Feed\Reader\Extension\Atom\Entry +* @uses \Zend\Feed\Reader\Extension\Content\Entry +* @uses \Zend\Feed\Reader\Extension\DublinCore\Entry +* @uses \Zend\Feed\Reader\Extension\Slash\Entry +* @uses \Zend\Feed\Reader\Extension\Thread\Entry +* @uses \Zend\Feed\Reader\Extension\WellformedWeb\Entry +* @category Zend +* @package Reader\Reader +* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) +* @license http://framework.zend.com/license/new-bsd New BSD License +*/ +class Rss extends AbstractEntry implements Reader\Entry { + /** * XPath query for RDF * @@ -63,7 +64,7 @@ class RSS extends Reader\AbstractEntry implements Reader\Entry /** * Constructor * - * @param \Zend\Feed\Entry\AbstractEntry $entry + * @param Zend_Feed_Entry_Abstract $entry * @param string $entryKey * @param string $type * @return void @@ -76,23 +77,23 @@ public function __construct(\DOMElement $entry, $entryKey, $type = null) $pluginLoader = Reader\Reader::getPluginLoader(); - $dublinCoreClass = $pluginLoader->getClassName('DublinCore\Entry'); - $this->_extensions['DublinCore\Entry'] = new $dublinCoreClass($entry, $entryKey, $type); + $dublinCoreClass = $pluginLoader->getClassName('DublinCore\\Entry'); + $this->_extensions['DublinCore\\Entry'] = new $dublinCoreClass($entry, $entryKey, $type); - $contentClass = $pluginLoader->getClassName('Content\Entry'); - $this->_extensions['Content\Entry'] = new $contentClass($entry, $entryKey, $type); + $contentClass = $pluginLoader->getClassName('Content\\Entry'); + $this->_extensions['Content\\Entry'] = new $contentClass($entry, $entryKey, $type); - $atomClass = $pluginLoader->getClassName('Atom\Entry'); - $this->_extensions['Atom\Entry'] = new $atomClass($entry, $entryKey, $type); + $atomClass = $pluginLoader->getClassName('Atom\\Entry'); + $this->_extensions['Atom\\Entry'] = new $atomClass($entry, $entryKey, $type); - $wfwClass = $pluginLoader->getClassName('WellFormedWeb\Entry'); - $this->_extensions['WellFormedWeb\Entry'] = new $wfwClass($entry, $entryKey, $type); + $wfwClass = $pluginLoader->getClassName('WellFormedWeb\\Entry'); + $this->_extensions['WellFormedWeb\\Entry'] = new $wfwClass($entry, $entryKey, $type); - $slashClass = $pluginLoader->getClassName('Slash\Entry'); - $this->_extensions['Slash\Entry'] = new $slashClass($entry, $entryKey, $type); + $slashClass = $pluginLoader->getClassName('Slash\\Entry'); + $this->_extensions['Slash\\Entry'] = new $slashClass($entry, $entryKey, $type); - $threadClass = $pluginLoader->getClassName('Thread\Entry'); - $this->_extensions['Thread\Entry'] = new $threadClass($entry, $entryKey, $type); + $threadClass = $pluginLoader->getClassName('Thread\\Entry'); + $this->_extensions['Thread\\Entry'] = new $threadClass($entry, $entryKey, $type); } /** @@ -232,10 +233,8 @@ public function getDateModified() if ($dateModifiedParsed) { $date = new Date\Date($dateModifiedParsed); } else { - $dateStandards = array( - Date\Date::RSS, Date\Date::RFC_822, - Date\Date::RFC_2822, Date\Date::DATES, - ); + $dateStandards = array(Date\Date::RSS, Date\Date::RFC_822, + Date\Date::RFC_2822, Date\Date::DATES); $date = new Date\Date; foreach ($dateStandards as $standard) { try { @@ -243,7 +242,8 @@ public function getDateModified() break; } catch (Date\Exception $e) { if ($standard == Date\Date::DATES) { - throw new \Zend\Feed\Exception( + require_once 'Zend/Feed/Exception.php'; + throw new Exception( 'Could not load date due to unrecognised' .' format (should follow RFC 822 or 2822):' . $e->getMessage(), @@ -440,7 +440,7 @@ public function getLinks() /** * Get all categories * - * @return \Zend\Feed\Reader\Collection\Category + * @return Reader\Reader_Collection_Category */ public function getCategories() { @@ -620,7 +620,7 @@ public function getCommentFeedLink() /** * Set the XPath query (incl. on all Extensions) * - * @param DOMXPath $xpath + * @param \DOMXPath $xpath */ public function setXpath(\DOMXPath $xpath) { From 7a0847ff2510143371e52c1836bba0ca0800433f Mon Sep 17 00:00:00 2001 From: Marc Bennewitz Date: Sun, 5 Feb 2012 14:43:18 +0100 Subject: [PATCH 03/13] replaced is_null($foo->$bar()) with $foo->$bar() === null --- src/PubSubHubbub/Subscriber.php | 2 +- src/Reader/Extension/Atom/Entry.php | 2 +- src/Reader/Extension/Atom/Feed.php | 2 +- src/Reader/Feed/Rss.php | 10 +++++----- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/PubSubHubbub/Subscriber.php b/src/PubSubHubbub/Subscriber.php index 8f669290..e64bcfe5 100644 --- a/src/PubSubHubbub/Subscriber.php +++ b/src/PubSubHubbub/Subscriber.php @@ -715,7 +715,7 @@ protected function _getRequestParameters($hubUrl, $mode) $params['hub.callback'] = rtrim($this->getCallbackUrl(), '/') . '/' . PubSubHubbub::urlencode($key); } - if ($mode == 'subscribe' && !is_null($this->getLeaseSeconds())) { + if ($mode == 'subscribe' && $this->getLeaseSeconds() !== null) { $params['hub.lease_seconds'] = $this->getLeaseSeconds(); } diff --git a/src/Reader/Extension/Atom/Entry.php b/src/Reader/Extension/Atom/Entry.php index f35645dc..becc58b2 100644 --- a/src/Reader/Extension/Atom/Entry.php +++ b/src/Reader/Extension/Atom/Entry.php @@ -563,7 +563,7 @@ public function getSource() protected function _absolutiseUri($link) { if (!Uri\UriFactory::factory($link)->isValid()) { - if (!is_null($this->getBaseUrl())) { + if ($this->getBaseUrl() !== null) { $link = $this->getBaseUrl() . $link; if (!Uri\UriFactory::factory($link)->isValid()) { $link = null; diff --git a/src/Reader/Extension/Atom/Feed.php b/src/Reader/Extension/Atom/Feed.php index 0120b721..fb764af2 100644 --- a/src/Reader/Extension/Atom/Feed.php +++ b/src/Reader/Extension/Atom/Feed.php @@ -504,7 +504,7 @@ protected function _getAuthor(\DOMElement $element) protected function _absolutiseUri($link) { if (!Uri\UriFactory::factory($link)->isValid()) { - if (!is_null($this->getBaseUrl())) { + if ($this->getBaseUrl() !== null) { $link = $this->getBaseUrl() . $link; if (!Uri\UriFactory::factory($link)->isValid()) { $link = null; diff --git a/src/Reader/Feed/Rss.php b/src/Reader/Feed/Rss.php index a9e59c87..98360e3c 100644 --- a/src/Reader/Feed/Rss.php +++ b/src/Reader/Feed/Rss.php @@ -167,7 +167,7 @@ public function getCopyright() $copyright = $this->_xpath->evaluate('string(/rss/channel/copyright)'); } - if (!$copyright && !is_null($this->getExtension('DublinCore'))) { + if (!$copyright && $this->getExtension('DublinCore') !== null) { $copyright = $this->getExtension('DublinCore')->getCopyright(); } @@ -331,7 +331,7 @@ public function getDescription() $description = $this->_xpath->evaluate('string(/rdf:RDF/rss:channel/rss:description)'); } - if (!$description && !is_null($this->getExtension('DublinCore'))) { + if (!$description && $this->getExtension('DublinCore') !== null) { $description = $this->getExtension('DublinCore')->getDescription(); } @@ -366,7 +366,7 @@ public function getId() $id = $this->_xpath->evaluate('string(/rss/channel/guid)'); } - if (!$id && !is_null($this->getExtension('DublinCore'))) { + if (!$id && $this->getExtension('DublinCore') !== null) { $id = $this->getExtension('DublinCore')->getId(); } @@ -461,7 +461,7 @@ public function getLanguage() $language = $this->_xpath->evaluate('string(/rss/channel/language)'); } - if (!$language && !is_null($this->getExtension('DublinCore'))) { + if (!$language && $this->getExtension('DublinCore') !== null) { $language = $this->getExtension('DublinCore')->getLanguage(); } @@ -599,7 +599,7 @@ public function getTitle() $title = $this->_xpath->evaluate('string(/rdf:RDF/rss:channel/rss:title)'); } - if (!$title && !is_null($this->getExtension('DublinCore'))) { + if (!$title && $this->getExtension('DublinCore') !== null) { $title = $this->getExtension('DublinCore')->getTitle(); } From bf56ddec526a65668ec612d59e3af80cc16d59ac Mon Sep 17 00:00:00 2001 From: Adam Lundrigan Date: Sat, 25 Feb 2012 17:05:08 -0330 Subject: [PATCH 04/13] [ZF-12023] Zend\Feed\Writer\AbstractFeed should accept UNIX timestamps which are <>10 digits --- src/Writer/AbstractFeed.php | 6 +++--- test/Writer/FeedTest.php | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/Writer/AbstractFeed.php b/src/Writer/AbstractFeed.php index a15b6cd3..0ee97fc0 100644 --- a/src/Writer/AbstractFeed.php +++ b/src/Writer/AbstractFeed.php @@ -144,7 +144,7 @@ public function setDateCreated($date = null) $zdate = null; if ($date === null) { $zdate = new Date\Date; - } elseif (ctype_digit($date) && strlen($date) == 10) { + } elseif (ctype_digit($date)) { $zdate = new Date\Date($date, Date\Date::TIMESTAMP); } elseif ($date instanceof Date\Date) { $zdate = $date; @@ -164,7 +164,7 @@ public function setDateModified($date = null) $zdate = null; if ($date === null) { $zdate = new Date\Date; - } elseif (ctype_digit($date) && strlen($date) == 10) { + } elseif (ctype_digit($date)) { $zdate = new Date\Date($date, Date\Date::TIMESTAMP); } elseif ($date instanceof Date\Date) { $zdate = $date; @@ -184,7 +184,7 @@ public function setLastBuildDate($date = null) $zdate = null; if ($date === null) { $zdate = new Date\Date; - } elseif (ctype_digit($date) && strlen($date) == 10) { + } elseif (ctype_digit($date)) { $zdate = new Date\Date($date, Date\Date::TIMESTAMP); } elseif ($date instanceof Date\Date) { $zdate = $date; diff --git a/test/Writer/FeedTest.php b/test/Writer/FeedTest.php index 53b4d800..907b6b64 100644 --- a/test/Writer/FeedTest.php +++ b/test/Writer/FeedTest.php @@ -203,6 +203,17 @@ public function testSetDateCreatedUsesGivenUnixTimestamp() $this->assertTrue($myDate->equals($writer->getDateCreated())); } + /** + * @group ZF-12023 + */ + public function testSetDateCreatedUsesGivenUnixTimestampThatIsLessThanTenDigits() + { + $writer = new Writer\Feed; + $writer->setDateCreated(123456789); + $myDate = new Date\Date('123456789', Date\Date::TIMESTAMP); + $this->assertTrue($myDate->equals($writer->getDateCreated())); + } + public function testSetDateCreatedUsesZendDateObject() { $writer = new Writer\Feed; @@ -226,6 +237,17 @@ public function testSetDateModifiedUsesGivenUnixTimestamp() $myDate = new Date\Date('1234567890', Date\Date::TIMESTAMP); $this->assertTrue($myDate->equals($writer->getDateModified())); } + + /** + * @group ZF-12023 + */ + public function testSetDateModifiedUsesGivenUnixTimestampThatIsLessThanTenDigits() + { + $writer = new Writer\Feed; + $writer->setDateModified(123456789); + $myDate = new Date\Date('123456789', Date\Date::TIMESTAMP); + $this->assertTrue($myDate->equals($writer->getDateModified())); + } public function testSetDateModifiedUsesZendDateObject() { @@ -283,6 +305,17 @@ public function testSetLastBuildDateUsesGivenUnixTimestamp() $this->assertTrue($myDate->equals($writer->getLastBuildDate())); } + /** + * @group ZF-12023 + */ + public function testSetLastBuildDateUsesGivenUnixTimestampThatIsLessThanTenDigits() + { + $writer = new Writer\Feed; + $writer->setLastBuildDate(123456789); + $myDate = new Date\Date('123456789', Date\Date::TIMESTAMP); + $this->assertTrue($myDate->equals($writer->getLastBuildDate())); + } + public function testSetLastBuildDateUsesZendDateObject() { $writer = new Writer\Feed; From 00fc5c40d31a9ad4743dd049537a227ace92cf65 Mon Sep 17 00:00:00 2001 From: Adam Lundrigan Date: Sat, 25 Feb 2012 17:44:43 -0330 Subject: [PATCH 05/13] [ZF-12070] Fix remaining classes in Zend\Feed\Writer to accept UNIX timestamps which are <>10 digits --- src/Writer/Deleted.php | 2 +- src/Writer/Entry.php | 4 ++-- test/Writer/DeletedTest.php | 13 ++++++++++++- test/Writer/EntryTest.php | 22 ++++++++++++++++++++++ 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/Writer/Deleted.php b/src/Writer/Deleted.php index dd2a51a4..1d15b690 100644 --- a/src/Writer/Deleted.php +++ b/src/Writer/Deleted.php @@ -131,7 +131,7 @@ public function setWhen($date = null) $zdate = null; if ($date === null) { $zdate = new Date\Date; - } elseif (ctype_digit($date) && strlen($date) == 10) { + } elseif (ctype_digit($date)) { $zdate = new Date\Date($date, Date\Date::TIMESTAMP); } elseif ($date instanceof Date\Date) { $zdate = $date; diff --git a/src/Writer/Entry.php b/src/Writer/Entry.php index 318391a0..34b3bf86 100644 --- a/src/Writer/Entry.php +++ b/src/Writer/Entry.php @@ -197,7 +197,7 @@ public function setDateCreated($date = null) $zdate = null; if ($date === null) { $zdate = new Date\Date; - } elseif (ctype_digit($date) && strlen($date) == 10) { + } elseif (ctype_digit($date)) { $zdate = new Date\Date($date, Date\Date::TIMESTAMP); } elseif ($date instanceof Date\Date) { $zdate = $date; @@ -217,7 +217,7 @@ public function setDateModified($date = null) $zdate = null; if ($date === null) { $zdate = new Date\Date; - } elseif (ctype_digit($date) && strlen($date) == 10) { + } elseif (ctype_digit($date)) { $zdate = new Date\Date($date, Date\Date::TIMESTAMP); } elseif ($date instanceof Date\Date) { $zdate = $date; diff --git a/test/Writer/DeletedTest.php b/test/Writer/DeletedTest.php index 7791e0e9..452c2dcd 100644 --- a/test/Writer/DeletedTest.php +++ b/test/Writer/DeletedTest.php @@ -76,7 +76,18 @@ public function testSetWhenUsesGivenUnixTimestamp() $myDate = new Date\Date('1234567890', Date\Date::TIMESTAMP); $this->assertTrue($myDate->equals($entry->getWhen())); } - + + /** + * @group ZF-12070 + */ + public function testSetWhenUsesGivenUnixTimestampWhenItIsLessThanTenDigits() + { + $entry = new Writer\Deleted; + $entry->setWhen(123456789); + $myDate = new Date\Date('123456789', Date\Date::TIMESTAMP); + $this->assertTrue($myDate->equals($entry->getWhen())); + } + public function testSetWhenUsesZendDateObject() { $entry = new Writer\Deleted; diff --git a/test/Writer/EntryTest.php b/test/Writer/EntryTest.php index 616ca60c..510c494d 100644 --- a/test/Writer/EntryTest.php +++ b/test/Writer/EntryTest.php @@ -266,6 +266,17 @@ public function testSetDateCreatedUsesGivenUnixTimestamp() $this->assertTrue($myDate->equals($entry->getDateCreated())); } + /** + * @group ZF-12070 + */ + public function testSetDateCreatedUsesGivenUnixTimestampWhenItIsLessThanTenDigits() + { + $entry = new Writer\Entry; + $entry->setDateCreated(123456789); + $myDate = new Date\Date('123456789', Date\Date::TIMESTAMP); + $this->assertTrue($myDate->equals($entry->getDateCreated())); + } + public function testSetDateCreatedUsesZendDateObject() { $entry = new Writer\Entry; @@ -290,6 +301,17 @@ public function testSetDateModifiedUsesGivenUnixTimestamp() $this->assertTrue($myDate->equals($entry->getDateModified())); } + /** + * @group ZF-12070 + */ + public function testSetDateModifiedUsesGivenUnixTimestampWhenItIsLessThanTenDigits() + { + $entry = new Writer\Entry; + $entry->setDateModified(123456789); + $myDate = new Date\Date('123456789', Date\Date::TIMESTAMP); + $this->assertTrue($myDate->equals($entry->getDateModified())); + } + public function testSetDateModifiedUsesZendDateObject() { $entry = new Writer\Entry; From b861e1379110936cac9038f468d7864c101a426f Mon Sep 17 00:00:00 2001 From: Robert Basic Date: Sun, 4 Mar 2012 19:15:42 +0100 Subject: [PATCH 06/13] fix prefix for reader extensions --- test/Reader/ReaderTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Reader/ReaderTest.php b/test/Reader/ReaderTest.php index f127cc5b..f70e8d46 100644 --- a/test/Reader/ReaderTest.php +++ b/test/Reader/ReaderTest.php @@ -315,7 +315,7 @@ public function testAddsPrefixPath() public function testRegistersUserExtension() { try { - Reader\Reader::addPrefixPath('My\\FeedReader\\Extension', dirname(__FILE__) . '/_files/My/Extension'); + Reader\Reader::addPrefixPath('My\\Extension', dirname(__FILE__) . '/_files/My/Extension'); Reader\Reader::registerExtension('JungleBooks'); } catch(\Exception $e) { $this->fail($e->getMessage()); From e35eb58869ada90ae6cfa9498b932fc0d0844e98 Mon Sep 17 00:00:00 2001 From: Robert Basic Date: Sun, 4 Mar 2012 20:04:02 +0100 Subject: [PATCH 07/13] update how a http response is created --- test/ReaderTest.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/ReaderTest.php b/test/ReaderTest.php index a8b13f87..79263e49 100644 --- a/test/ReaderTest.php +++ b/test/ReaderTest.php @@ -289,8 +289,12 @@ public function testGetsFeedLinksAndNormalisesRelativeUrlsOnUriWithPath() try { $currClient = Reader\Reader::getHttpClient(); + $response = new \Zend\Http\Response; + $response->setContent(''); + $response->setStatusCode(200); + $testAdapter = new \Zend\Http\Client\Adapter\Test(); - $testAdapter->setResponse(new \Zend\Http\Response(200, array(), '')); + $testAdapter->setResponse($response); Reader\Reader::setHttpClient(new \Zend\Http\Client(null, array('adapter' => $testAdapter))); $links = Reader\Reader::findFeedLinks('http://foo/bar'); From 5b4608a1f55a213cbd83e7468f581c18c40af61d Mon Sep 17 00:00:00 2001 From: Robert Basic Date: Sun, 4 Mar 2012 20:06:17 +0100 Subject: [PATCH 08/13] refactor methods to new coding standards --- src/Reader/FeedSet.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Reader/FeedSet.php b/src/Reader/FeedSet.php index 83155136..5c5f429e 100644 --- a/src/Reader/FeedSet.php +++ b/src/Reader/FeedSet.php @@ -65,16 +65,16 @@ public function addLinks(\DOMNodeList $links, $uri) continue; } if (!isset($this->rss) && $link->getAttribute('type') == 'application/rss+xml') { - $this->rss = $this->_absolutiseUri(trim($link->getAttribute('href')), $uri); + $this->rss = $this->absolutiseUri(trim($link->getAttribute('href')), $uri); } elseif(!isset($this->atom) && $link->getAttribute('type') == 'application/atom+xml') { - $this->atom = $this->_absolutiseUri(trim($link->getAttribute('href')), $uri); + $this->atom = $this->absolutiseUri(trim($link->getAttribute('href')), $uri); } elseif(!isset($this->rdf) && $link->getAttribute('type') == 'application/rdf+xml') { - $this->rdf = $this->_absolutiseUri(trim($link->getAttribute('href')), $uri); + $this->rdf = $this->absolutiseUri(trim($link->getAttribute('href')), $uri); } $this[] = new self(array( 'rel' => 'alternate', 'type' => $link->getAttribute('type'), - 'href' => $this->_absolutiseUri(trim($link->getAttribute('href')), $uri), + 'href' => $this->absolutiseUri(trim($link->getAttribute('href')), $uri), )); } } @@ -82,7 +82,7 @@ public function addLinks(\DOMNodeList $links, $uri) /** * Attempt to turn a relative URI into an absolute URI */ - protected function _absolutiseUri($link, $uri = null) + protected function absolutiseUri($link, $uri = null) { if (!Uri\UriFactory::factory($link)->isValid()) { if ($uri !== null) { @@ -92,7 +92,7 @@ protected function _absolutiseUri($link, $uri = null) $link = $uri->getPath() . '/' . $link; } - $link = $uri->getScheme() . '://' . $uri->getHost() . '/' . $this->_canonicalizePath($link); + $link = $uri->getScheme() . '://' . $uri->getHost() . '/' . $this->canonicalizePath($link); if (!Uri\UriFactory::factory($link)->isValid()) { $link = null; } @@ -104,7 +104,7 @@ protected function _absolutiseUri($link, $uri = null) /** * Canonicalize relative path */ - protected function _canonicalizePath($path) + protected function canonicalizePath($path) { $parts = array_filter(explode('/', $path)); $absolutes = array(); From 9eccfc0ba27c966b1b60d34f5b9a3846385b82c1 Mon Sep 17 00:00:00 2001 From: Robert Basic Date: Sun, 4 Mar 2012 21:27:26 +0100 Subject: [PATCH 09/13] Uri::isValid will validate a relative URI too, so first make sure it is not an absolute one. no need to absolutise an absolute uri --- src/Reader/FeedSet.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Reader/FeedSet.php b/src/Reader/FeedSet.php index 5c5f429e..54378d00 100644 --- a/src/Reader/FeedSet.php +++ b/src/Reader/FeedSet.php @@ -84,7 +84,8 @@ public function addLinks(\DOMNodeList $links, $uri) */ protected function absolutiseUri($link, $uri = null) { - if (!Uri\UriFactory::factory($link)->isValid()) { + $linkUri = Uri\UriFactory::factory($link); + if (!$linkUri->isAbsolute() or !$linkUri->isValid()) { if ($uri !== null) { $uri = Uri\UriFactory::factory($uri); From 99a0db334498ec0981d430c2f000ed39f84e28ef Mon Sep 17 00:00:00 2001 From: Robert Basic Date: Sun, 4 Mar 2012 23:00:44 +0100 Subject: [PATCH 10/13] fix most of the zend\feed errors due to old zend\db --- src/PubSubHubbub/Model/AbstractModel.php | 6 ++- src/PubSubHubbub/Model/Subscription.php | 8 +-- test/PubSubHubbub/Subscriber/CallbackTest.php | 54 +++++++++---------- test/PubSubHubbub/SubscriberTest.php | 6 +-- 4 files changed, 38 insertions(+), 36 deletions(-) diff --git a/src/PubSubHubbub/Model/AbstractModel.php b/src/PubSubHubbub/Model/AbstractModel.php index 77dbb1be..add51525 100644 --- a/src/PubSubHubbub/Model/AbstractModel.php +++ b/src/PubSubHubbub/Model/AbstractModel.php @@ -23,6 +23,8 @@ */ namespace Zend\Feed\PubSubHubbub\Model; +use \Zend\Db\TableGateway; + /** * @uses \Zend\Db\Table\Table * @uses \Zend\Registry @@ -47,12 +49,12 @@ class AbstractModel * @param \Zend\Db\Table\AbstractTable $tableGateway * @return void */ - public function __construct(\Zend\Db\Table\AbstractTable $tableGateway = null) + public function __construct(TableGateway\TableGatewayInterface $tableGateway = null) { if ($tableGateway === null) { $parts = explode('\\', get_class($this)); $table = strtolower(array_pop($parts)); - $this->_db = new \Zend\Db\Table\Table($table); + $this->_db = new TableGateway\TableGateway($table); } else { $this->_db = $tableGateway; } diff --git a/src/PubSubHubbub/Model/Subscription.php b/src/PubSubHubbub/Model/Subscription.php index e1181dd6..0b3039d7 100644 --- a/src/PubSubHubbub/Model/Subscription.php +++ b/src/PubSubHubbub/Model/Subscription.php @@ -86,9 +86,9 @@ public function getSubscription($key) throw new PubSubHubbub\Exception('Invalid parameter "key"' .' of "' . $key . '" must be a non-empty string'); } - $result = $this->_db->find($key); + $result = $this->_db->select(array('id' => $key)); if (count($result)) { - return $result->current()->toArray(); + return $result->current()->getArrayCopy(); } return false; } @@ -105,7 +105,7 @@ public function hasSubscription($key) throw new PubSubHubbub\Exception('Invalid parameter "key"' .' of "' . $key . '" must be a non-empty string'); } - $result = $this->_db->find($key); + $result = $this->_db->select(array('id' => $key)); if (count($result)) { return true; } @@ -120,7 +120,7 @@ public function hasSubscription($key) */ public function deleteSubscription($key) { - $result = $this->_db->find($key); + $result = $this->_db->select(array('id' => $key)); if (count($result)) { $this->_db->delete( $this->_db->getAdapter()->quoteInto('id = ?', $key) diff --git a/test/PubSubHubbub/Subscriber/CallbackTest.php b/test/PubSubHubbub/Subscriber/CallbackTest.php index 80308e5a..038e7ea7 100644 --- a/test/PubSubHubbub/Subscriber/CallbackTest.php +++ b/test/PubSubHubbub/Subscriber/CallbackTest.php @@ -45,13 +45,13 @@ public function setUp() $this->_callback = new \Zend\Feed\PubSubHubbub\Subscriber\Callback; $this->_adapter = $this->_getCleanMock( - 'Zend\Db\Adapter\AbstractAdapter' + '\Zend\Db\Adapter\Adapter' ); $this->_tableGateway = $this->_getCleanMock( - 'Zend\Db\Table\AbstractTable' + '\Zend\Db\TableGateway\TableGateway' ); $this->_rowset = $this->_getCleanMock( - 'Zend\Db\Table\AbstractRowset' + 'Zend\Db\ResultSet\ResultSet' ); $this->_tableGateway->expects($this->any())->method('getAdapter') @@ -144,7 +144,7 @@ public function testThrowsExceptionOnSettingAnyScalarTypeCastToAZeroOrLessIntege public function testCanSetStorageImplementation() { - $storage = new Model\Subscription($this->_tableGateway); + $storage = new Model\Subscription($this->_tableGateway); $this->_callback->setStorage($storage); $this->assertThat($this->_callback->getStorage(), $this->identicalTo($storage)); } @@ -154,14 +154,14 @@ public function testCanSetStorageImplementation() */ public function testValidatesValidHttpGetData() { - $mockReturnValue = $this->getMock('Result', array('toArray')); - $mockReturnValue->expects($this->any())->method('toArray')->will($this->returnValue(array( + $mockReturnValue = $this->getMock('Result', array('getArrayCopy')); + $mockReturnValue->expects($this->any())->method('getArrayCopy')->will($this->returnValue(array( 'verify_token' => hash('sha256', 'cba') ))); $this->_tableGateway->expects($this->any()) - ->method('find') - ->with($this->equalTo('verifytokenkey')) + ->method('select') + ->with($this->equalTo(array('id' => 'verifytokenkey'))) ->will($this->returnValue($this->_rowset)); $this->_rowset->expects($this->any()) ->method('current') @@ -205,15 +205,15 @@ public function testReturnsFalseIfVerifyTokenMissingFromHttpGetData() public function testReturnsTrueIfModeSetAsUnsubscribeFromHttpGetData() { - $mockReturnValue = $this->getMock('Result', array('toArray')); - $mockReturnValue->expects($this->any())->method('toArray')->will($this->returnValue(array( + $mockReturnValue = $this->getMock('Result', array('getArrayCopy')); + $mockReturnValue->expects($this->any())->method('getArrayCopy')->will($this->returnValue(array( 'verify_token' => hash('sha256', 'cba') ))); $this->_get['hub_mode'] = 'unsubscribe'; $this->_tableGateway->expects($this->any()) - ->method('find') - ->with($this->equalTo('verifytokenkey')) + ->method('select') + ->with($this->equalTo(array('id' => 'verifytokenkey'))) ->will($this->returnValue($this->_rowset)); $this->_rowset->expects($this->any()) ->method('current') @@ -267,8 +267,8 @@ public function testRespondsToValidConfirmationWith200Response() { $this->_get['hub_mode'] = 'unsubscribe'; $this->_tableGateway->expects($this->any()) - ->method('find') - ->with($this->equalTo('verifytokenkey')) + ->method('select') + ->with($this->equalTo(array('id' => 'verifytokenkey'))) ->will($this->returnValue($this->_rowset)); $t = new Date\Date; @@ -279,7 +279,7 @@ public function testRespondsToValidConfirmationWith200Response() 'lease_seconds' => 10000 ); - $row = new \Zend\Db\Table\Row(array('data' => $rowdata)); + $row = new \Zend\Db\ResultSet\Row($rowdata); $this->_rowset->expects($this->any()) ->method('current') @@ -307,8 +307,8 @@ public function testRespondsToValidConfirmationWith200Response() public function testRespondsToValidConfirmationWithBodyContainingHubChallenge() { $this->_tableGateway->expects($this->any()) - ->method('find') - ->with($this->equalTo('verifytokenkey')) + ->method('select') + ->with($this->equalTo(array('id' => 'verifytokenkey'))) ->will($this->returnValue($this->_rowset)); $t = new Date\Date; @@ -319,7 +319,7 @@ public function testRespondsToValidConfirmationWithBodyContainingHubChallenge() 'lease_seconds' => 10000 ); - $row = new \Zend\Db\Table\Row(array('data' => $rowdata)); + $row = new \Zend\Db\ResultSet\Row($rowdata); $this->_rowset->expects($this->any()) ->method('current') @@ -352,8 +352,8 @@ public function testRespondsToValidFeedUpdateRequestWith200Response() $GLOBALS['HTTP_RAW_POST_DATA'] = $feedXml; // dirty alternative to php://input $this->_tableGateway->expects($this->any()) - ->method('find') - ->with($this->equalTo('verifytokenkey')) + ->method('select') + ->with($this->equalTo(array('id' => 'verifytokenkey'))) ->will($this->returnValue($this->_rowset)); $t = new Date\Date; @@ -363,7 +363,7 @@ public function testRespondsToValidFeedUpdateRequestWith200Response() 'created_time' => time() ); - $row = new \Zend\Db\Table\Row(array('data' => $rowdata)); + $row = new \Zend\Db\ResultSet\Row(array('data' => $rowdata)); $this->_rowset->expects($this->any()) ->method('current') @@ -415,8 +415,8 @@ public function testRespondsToInvalidFeedUpdateWrongFeedTypeForMimeWith200Respon $GLOBALS['HTTP_RAW_POST_DATA'] = $feedXml; $this->_tableGateway->expects($this->any()) - ->method('find') - ->with($this->equalTo('verifytokenkey')) + ->method('select') + ->with($this->equalTo(array('id' => 'verifytokenkey'))) ->will($this->returnValue($this->_rowset)); $rowdata = array( @@ -426,7 +426,7 @@ public function testRespondsToInvalidFeedUpdateWrongFeedTypeForMimeWith200Respon 'lease_seconds' => 10000 ); - $row = new \Zend\Db\Table\Row(array('data' => $rowdata)); + $row = new \Zend\Db\ResultSet\Row(array('data' => $rowdata)); $this->_rowset->expects($this->any()) ->method('current') @@ -449,8 +449,8 @@ public function testRespondsToValidFeedUpdateWithXHubOnBehalfOfHeader() $GLOBALS['HTTP_RAW_POST_DATA'] = $feedXml; $this->_tableGateway->expects($this->any()) - ->method('find') - ->with($this->equalTo('verifytokenkey')) + ->method('select') + ->with($this->equalTo(array('id' => 'verifytokenkey'))) ->will($this->returnValue($this->_rowset)); $rowdata = array( @@ -460,7 +460,7 @@ public function testRespondsToValidFeedUpdateWithXHubOnBehalfOfHeader() 'lease_seconds' => 10000 ); - $row = new \Zend\Db\Table\Row(array('data' => $rowdata)); + $row = new \Zend\Db\ResultSet\Row(array('data' => $rowdata)); $this->_rowset->expects($this->any()) ->method('current') diff --git a/test/PubSubHubbub/SubscriberTest.php b/test/PubSubHubbub/SubscriberTest.php index 284bfbb6..484ad86c 100644 --- a/test/PubSubHubbub/SubscriberTest.php +++ b/test/PubSubHubbub/SubscriberTest.php @@ -52,10 +52,10 @@ public function setUp() PubSubHubbub\PubSubHubbub::setHttpClient($client); $this->_subscriber = new \Zend\Feed\PubSubHubbub\Subscriber; $this->_adapter = $this->_getCleanMock( - '\Zend\Db\Adapter\AbstractAdapter' + '\Zend\Db\Adapter\Adapter' ); $this->_tableGateway = $this->_getCleanMock( - '\Zend\Db\Table\AbstractTable' + '\Zend\Db\TableGateway\TableGateway' ); $this->_tableGateway->expects($this->any())->method('getAdapter') ->will($this->returnValue($this->_adapter)); @@ -323,7 +323,7 @@ public function testPreferredVerificationModeDefaultsToSync() public function testCanSetStorageImplementation() { - $storage = new \Zend\Feed\PubSubHubbub\Model\Subscription($this->_tableGateway); + $storage = new \Zend\Feed\PubSubHubbub\Model\Subscription($this->_tableGateway); $this->_subscriber->setStorage($storage); $this->assertThat($this->_subscriber->getStorage(), $this->identicalTo($storage)); } From 65f763779ffc956f6d0052df3463dbacd75d16ea Mon Sep 17 00:00:00 2001 From: Robert Basic Date: Sun, 4 Mar 2012 23:31:36 +0100 Subject: [PATCH 11/13] fix zend\feed errors due to old zend\db usage --- src/PubSubHubbub/Model/Subscription.php | 6 +++--- test/PubSubHubbub/Subscriber/CallbackTest.php | 19 +++++++------------ 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/PubSubHubbub/Model/Subscription.php b/src/PubSubHubbub/Model/Subscription.php index 0b3039d7..d0aa6a3d 100644 --- a/src/PubSubHubbub/Model/Subscription.php +++ b/src/PubSubHubbub/Model/Subscription.php @@ -53,7 +53,7 @@ public function setSubscription(array $data) 'ID must be set before attempting a save' ); } - $result = $this->_db->find($data['id']); + $result = $this->_db->select(array('id' => $data['id'])); if ($result && (0 < count($result))) { $data['created_time'] = $result->current()->created_time; $now = new Date\Date; @@ -65,7 +65,7 @@ public function setSubscription(array $data) } $this->_db->update( $data, - $this->_db->getAdapter()->quoteInto('id = ?', $data['id']) + array('id' => $data['id']) ); return false; } @@ -123,7 +123,7 @@ public function deleteSubscription($key) $result = $this->_db->select(array('id' => $key)); if (count($result)) { $this->_db->delete( - $this->_db->getAdapter()->quoteInto('id = ?', $key) + array('id' => $key) ); return true; } diff --git a/test/PubSubHubbub/Subscriber/CallbackTest.php b/test/PubSubHubbub/Subscriber/CallbackTest.php index 038e7ea7..b08e07e7 100644 --- a/test/PubSubHubbub/Subscriber/CallbackTest.php +++ b/test/PubSubHubbub/Subscriber/CallbackTest.php @@ -279,7 +279,8 @@ public function testRespondsToValidConfirmationWith200Response() 'lease_seconds' => 10000 ); - $row = new \Zend\Db\ResultSet\Row($rowdata); + $row = new \Zend\Db\ResultSet\Row; + $row->exchangeArray($rowdata); $this->_rowset->expects($this->any()) ->method('current') @@ -293,12 +294,8 @@ public function testRespondsToValidConfirmationWith200Response() ->method('update') ->with( $this->equalTo(array('id'=>'verifytokenkey','verify_token'=>hash('sha256', 'cba'),'created_time'=>$t->get(Date\Date::TIMESTAMP),'lease_seconds'=>1234567,'subscription_state'=>'verified','expiration_time'=>$t->add(1234567,Date\Date::SECOND)->get('yyyy-MM-dd HH:mm:ss'))), - $this->equalTo('id = \'verifytokenkey\'') + $this->equalTo(array('id' => 'verifytokenkey')) ); - $this->_adapter->expects($this->once()) - ->method('quoteInto') - ->with($this->equalTo('id = ?'), $this->equalTo('verifytokenkey')) - ->will($this->returnValue('id = \'verifytokenkey\'')); $this->_callback->handle($this->_get); $this->assertTrue($this->_callback->getHttpResponse()->getHttpResponseCode() == 200); @@ -319,7 +316,8 @@ public function testRespondsToValidConfirmationWithBodyContainingHubChallenge() 'lease_seconds' => 10000 ); - $row = new \Zend\Db\ResultSet\Row($rowdata); + $row = new \Zend\Db\ResultSet\Row; + $row->exchangeArray($rowdata); $this->_rowset->expects($this->any()) ->method('current') @@ -333,12 +331,9 @@ public function testRespondsToValidConfirmationWithBodyContainingHubChallenge() ->method('update') ->with( $this->equalTo(array('id'=>'verifytokenkey','verify_token'=>hash('sha256', 'cba'),'created_time'=>$t->get(Date\Date::TIMESTAMP),'lease_seconds'=>1234567,'subscription_state'=>'verified','expiration_time'=>$t->add(1234567,Date\Date::SECOND)->get('yyyy-MM-dd HH:mm:ss'))), - $this->equalTo('id = \'verifytokenkey\'') + $this->equalTo(array('id' => 'verifytokenkey')) ); - $this->_adapter->expects($this->once()) - ->method('quoteInto') - ->with($this->equalTo('id = ?'), $this->equalTo('verifytokenkey')) - ->will($this->returnValue('id = \'verifytokenkey\'')); + $this->_callback->handle($this->_get); $this->assertTrue($this->_callback->getHttpResponse()->getBody() == 'abc'); } From 8bb941b0deb0c708e2de90e2c84761ff5cfbef2e Mon Sep 17 00:00:00 2001 From: Robert Basic Date: Mon, 5 Mar 2012 00:33:19 +0100 Subject: [PATCH 12/13] update to new zend\db, test fails tho, need to figure out whats going on --- test/PubSubHubbub/Model/SubscriptionTest.php | 21 ++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/test/PubSubHubbub/Model/SubscriptionTest.php b/test/PubSubHubbub/Model/SubscriptionTest.php index 781ae11e..763a743c 100644 --- a/test/PubSubHubbub/Model/SubscriptionTest.php +++ b/test/PubSubHubbub/Model/SubscriptionTest.php @@ -21,6 +21,8 @@ namespace ZendTest\Feed\PubSubHubbub\Model; use Zend\Feed\PubSubHubbub\Model\Subscription; +use \Zend\Db\Adapter\Adapter as DbAdapter; +use \Zend\Db\TableGateway\TableGateway; /** * @category Zend @@ -38,8 +40,11 @@ class SubscriptionTest extends \PHPUnit_Framework_TestCase */ public function testAllOperations() { - $this->_initDb(); - $subscription = new Subscription(); + $adapter = $this->_initDb(); + $table = new TableGateway('subscription', $adapter); + + $subscription = new Subscription($table); + $id = uniqid(); $this->assertFalse($subscription->hasSubscription($id)); $this->assertFalse($subscription->getSubscription($id)); @@ -68,18 +73,18 @@ public function testImpemetsSubscriptionInterface() protected function _initDb() { - $this->markTestSkipped('Skip until not ported to new Zend\Db'); if (!extension_loaded('pdo') || !in_array('sqlite', \PDO::getAvailableDrivers()) ) { $this->markTestSkipped('Test only with pdo_sqlite'); } - $db = \Zend\Db\Db::factory('Pdo\Sqlite', array('dbname' => ':memory:')); - \Zend\Db\Table\AbstractTable::setDefaultAdapter($db); - $this->_createTable(); + $db = new DbAdapter(array('driver' => 'pdo_sqlite', 'dsn' => 'sqlite::memory:')); + $this->_createTable($db); + + return $db; } - protected function _createTable() + protected function _createTable($db) { $sql = "CREATE TABLE subscription (" . "id varchar(32) PRIMARY KEY NOT NULL DEFAULT '', " @@ -93,6 +98,6 @@ protected function _createTable() . "subscription_state varchar(12) DEFAULT NULL" . ");"; - \Zend\Db\Table\AbstractTable::getDefaultAdapter()->getConnection()->query($sql); + $db->query($sql)->execute(); } } From d49dbc202590ca05838ce42ae59ef3f90adeaacd Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Mon, 5 Mar 2012 13:17:42 -0600 Subject: [PATCH 13/13] Mark test as incomplete - Because PDO_SQLite does not return a row count, it means that count($resultSet) always returns 0, which means hasSubscriptions() always returns false, regardless of whether or not there are items in the resultset. Behavior will be added to the drivers at a later date to correct this situation. --- test/PubSubHubbub/Model/SubscriptionTest.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/PubSubHubbub/Model/SubscriptionTest.php b/test/PubSubHubbub/Model/SubscriptionTest.php index 763a743c..adb7c96c 100644 --- a/test/PubSubHubbub/Model/SubscriptionTest.php +++ b/test/PubSubHubbub/Model/SubscriptionTest.php @@ -40,7 +40,9 @@ class SubscriptionTest extends \PHPUnit_Framework_TestCase */ public function testAllOperations() { - $adapter = $this->_initDb(); + $this->markTestIncomplete('PDO_Sqlite does not return row count, and no solution in Zend\Db yet for this'); + + $adapter = $this->initDb(); $table = new TableGateway('subscription', $adapter); $subscription = new Subscription($table); @@ -71,7 +73,7 @@ public function testImpemetsSubscriptionInterface() unset($reflection); } - protected function _initDb() + protected function initDb() { if (!extension_loaded('pdo') || !in_array('sqlite', \PDO::getAvailableDrivers()) @@ -79,12 +81,12 @@ protected function _initDb() $this->markTestSkipped('Test only with pdo_sqlite'); } $db = new DbAdapter(array('driver' => 'pdo_sqlite', 'dsn' => 'sqlite::memory:')); - $this->_createTable($db); + $this->createTable($db); return $db; } - protected function _createTable($db) + protected function createTable($db) { $sql = "CREATE TABLE subscription (" . "id varchar(32) PRIMARY KEY NOT NULL DEFAULT '', "