diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-04-19 14:42:48 +0200 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-04-19 14:42:48 +0200 |
commit | a841116494889a90f06bb8570dbc1a8853807b38 (patch) | |
tree | 39a62209175daa14e360946b5b91566436102701 | |
parent | 76cc72393a2be7a54a849225accce6bbd1918129 (diff) |
added some hints for importing google reader items
-rw-r--r-- | businesslayer/feedbusinesslayer.php | 28 | ||||
-rw-r--r-- | dependencyinjection/dicontainer.php | 2 | ||||
-rw-r--r-- | tests/unit/businesslayer/FeedBusinessLayerTest.php | 12 |
3 files changed, 39 insertions, 3 deletions
diff --git a/businesslayer/feedbusinesslayer.php b/businesslayer/feedbusinesslayer.php index 9f3635e8a..de8d79ebf 100644 --- a/businesslayer/feedbusinesslayer.php +++ b/businesslayer/feedbusinesslayer.php @@ -26,6 +26,7 @@ namespace OCA\News\BusinessLayer; use \OCA\AppFramework\Db\DoesNotExistException; +use \OCA\AppFramework\Utility\TimeFactory; use \OCA\AppFramework\Core\API; use \OCA\News\Db\Feed; @@ -39,13 +40,16 @@ class FeedBusinessLayer extends BusinessLayer { private $feedFetcher; private $itemMapper; private $api; + private $timeFactory; public function __construct(FeedMapper $feedMapper, Fetcher $feedFetcher, - ItemMapper $itemMapper, API $api){ + ItemMapper $itemMapper, API $api, + TimeFactory $timeFactory){ parent::__construct($feedMapper); $this->feedFetcher = $feedFetcher; $this->itemMapper = $itemMapper; $this->api = $api; + $this->timeFactory = $timeFactory; } @@ -185,7 +189,29 @@ class FeedBusinessLayer extends BusinessLayer { * @return Feed the created feed */ public function importGoogleReaderJSON($json, $userId) { + $url = 'http://owncloud/googlereader'; + // TODO: write unittests that ensure that the correct + // feed parameters are being returned + + // you need to check first if the feed exists and if it does + // use that feed to add the items and to return + // if this has not been saved, these are the values + // that need to be set fyi + $feed = new Feed(); + $feed->setUserId($userId); + $feed->setUrlHash(md5($url)); + $feed->setUrl($url); + $feed->setTitle('Google Reader'); + $feed->setAdded($this->timeFactory->getTime()); + $feed->setFolderId(0); + $feed->setPreventUpdate(true); + + + // TODO: after saving the above feed, query the feed from the + // database to get the unreadCount (this is being set in the + // sql query) see line 177 + return $feed; } diff --git a/dependencyinjection/dicontainer.php b/dependencyinjection/dicontainer.php index 9ea52b505..2fc894a70 100644 --- a/dependencyinjection/dicontainer.php +++ b/dependencyinjection/dicontainer.php @@ -107,7 +107,7 @@ class DIContainer extends BaseContainer { $this['FeedBusinessLayer'] = $this->share(function($c){ return new FeedBusinessLayer($c['FeedMapper'], $c['Fetcher'], - $c['ItemMapper'], $c['API']); + $c['ItemMapper'], $c['API'], $c['TimeFactory']); }); $this['ItemBusinessLayer'] = $this->share(function($c){ diff --git a/tests/unit/businesslayer/FeedBusinessLayerTest.php b/tests/unit/businesslayer/FeedBusinessLayerTest.php index 465dda8cb..18c30e277 100644 --- a/tests/unit/businesslayer/FeedBusinessLayerTest.php +++ b/tests/unit/businesslayer/FeedBusinessLayerTest.php @@ -44,9 +44,18 @@ class FeedBusinessLayerTest extends \OCA\AppFramework\Utility\TestUtility { private $fetcher; private $itemMapper; private $threshold; + private $time; protected function setUp(){ $this->api = $this->getAPIMock(); + $this->time = 222; + $timeFactory = $this->getMockBuilder( + '\OCA\AppFramework\Utility\TimeFactory') + ->disableOriginalConstructor() + ->getMock(); + $timeFactory->expects($this->any()) + ->method('getTime') + ->will($this->returnValue($this->time)); $this->mapper = $this->getMockBuilder('\OCA\News\Db\FeedMapper') ->disableOriginalConstructor() ->getMock(); @@ -57,7 +66,8 @@ class FeedBusinessLayerTest extends \OCA\AppFramework\Utility\TestUtility { ->disableOriginalConstructor() ->getMock(); $this->businessLayer = new FeedBusinessLayer($this->mapper, - $this->fetcher, $this->itemMapper, $this->api); + $this->fetcher, $this->itemMapper, $this->api, + $timeFactory); $this->user = 'jack'; $response = 'hi'; |