diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-04-19 11:42:27 +0200 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-04-19 11:42:40 +0200 |
commit | 3e9a13efc9d95aac61191481fc9b90cfe3ca6e41 (patch) | |
tree | ff252c7c2a378de265831a144b9e407d4d23d276 | |
parent | d328d409986a4e8c504fe65c3bf7c5b445b21814 (diff) |
added skeletons for google reader import
-rw-r--r-- | appinfo/routes.php | 8 | ||||
-rw-r--r-- | businesslayer/feedbusinesslayer.php | 11 | ||||
-rw-r--r-- | controller/feedcontroller.php | 18 | ||||
-rw-r--r-- | doc/development.rst | 3 | ||||
-rw-r--r-- | tests/unit/controller/FeedControllerTest.php | 31 | ||||
-rw-r--r-- | tests/unit/utility/FeedFetcherTest.php | 4 |
6 files changed, 73 insertions, 2 deletions
diff --git a/appinfo/routes.php b/appinfo/routes.php index 9acce6661..948a17566 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -124,6 +124,14 @@ $this->create('news_feeds_read', '/feeds/{feedId}/read')->post()->action( } ); +$this->create('news_feeds_import_googlereader', '/feeds/import/googlereader') +->post()->action( + function($params){ + App::main('ItemController', 'importGoogleReader', $params, + new DIContainer()); + } +); + /** * Items */ diff --git a/businesslayer/feedbusinesslayer.php b/businesslayer/feedbusinesslayer.php index 52009529e..983a4768a 100644 --- a/businesslayer/feedbusinesslayer.php +++ b/businesslayer/feedbusinesslayer.php @@ -175,4 +175,15 @@ class FeedBusinessLayer extends BusinessLayer { } + /** + * Imports the google reader json + * @param array $json the array with json + * @param string userId the username + * @return Feed the created feed + */ + public function importGoogleReaderJSON($json, $userId) { + + } + + } diff --git a/controller/feedcontroller.php b/controller/feedcontroller.php index 11cb60d5e..09f638170 100644 --- a/controller/feedcontroller.php +++ b/controller/feedcontroller.php @@ -196,4 +196,22 @@ class FeedController extends Controller { } + /** + * @IsAdminExemption + * @IsSubAdminExemption + * @Ajax + */ + public function importGoogleReader() { + $json = $this->params('json'); + $userId = $this->api->getUserId(); + + $feed = $this->feedBusinessLayer->importGoogleReaderJSON($json, $userId); + + $params = array( + 'feeds' => array($feed) + ); + return $this->renderJSON($params); + } + + }
\ No newline at end of file diff --git a/doc/development.rst b/doc/development.rst new file mode 100644 index 000000000..6868fe73a --- /dev/null +++ b/doc/development.rst @@ -0,0 +1,3 @@ +Getting started with development +================================ + diff --git a/tests/unit/controller/FeedControllerTest.php b/tests/unit/controller/FeedControllerTest.php index 428ecc7d4..b41977962 100644 --- a/tests/unit/controller/FeedControllerTest.php +++ b/tests/unit/controller/FeedControllerTest.php @@ -112,6 +112,10 @@ class FeedControllerTest extends ControllerTestUtility { } + public function testImportGoogleReaderAnnotations(){ + $this->assertFeedControllerAnnotations('importGoogleReader'); + } + public function testFeeds(){ $result = array( 'feeds' => array( @@ -381,4 +385,31 @@ class FeedControllerTest extends ControllerTestUtility { $this->assertTrue($response instanceof JSONResponse); } + + public function testImportGoogleReader() { + $feed = new Feed(); + + $post = array( + 'json' => 'the json' + ); + $expected = array( + 'feeds' => array($feed) + ); + $this->controller = $this->getPostController($post); + + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); + $this->feedBusinessLayer->expects($this->once()) + ->method('importGoogleReaderJSON') + ->with($this->equalTo($post['json']), + $this->equalTo($this->user)) + ->will($this->returnValue($feed)); + + $response = $this->controller->importGoogleReader(); + + $this->assertEquals($expected, $response->getParams()); + $this->assertTrue($response instanceof JSONResponse); + } + }
\ No newline at end of file diff --git a/tests/unit/utility/FeedFetcherTest.php b/tests/unit/utility/FeedFetcherTest.php index bb027a778..e4fea6b25 100644 --- a/tests/unit/utility/FeedFetcherTest.php +++ b/tests/unit/utility/FeedFetcherTest.php @@ -101,7 +101,7 @@ class FeedFetcherTest extends \OCA\AppFramework\Utility\TestUtility { $this->guid = 'hey guid here'; $this->body = 'let the bodies hit the floor'; $this->pub = 23111; - $this->author = 'boogieman'; + $this->author = 'boogieman<e;'; $this->enclosureLink = 'http://enclosure.you'; $this->feedTitle = '<e;its a title'; @@ -184,7 +184,7 @@ class FeedFetcherTest extends \OCA\AppFramework\Utility\TestUtility { ->method('get_name') ->will($this->returnValue($this->author)); $this->expectItem('get_author', $mock); - $item->setAuthor($this->author); + $item->setAuthor(html_entity_decode($this->author)); } if($enclosureType === 'audio/ogg') { |