diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-04-12 14:53:02 +0200 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-04-12 14:53:02 +0200 |
commit | a069add71e642f37c6309c3bd7af74761acef929 (patch) | |
tree | 59b3326de202dd5a8bb5e29ae1a626794fb6b349 /tests/unit/controller | |
parent | e8767f75116ff7ef2b7a349480151c9f66bbade0 (diff) |
implement export, needs proper unittests though, fix 31
Diffstat (limited to 'tests/unit/controller')
-rw-r--r-- | tests/unit/controller/ExportControllerTest.php | 45 | ||||
-rw-r--r-- | tests/unit/controller/FeedControllerTest.php | 2 |
2 files changed, 42 insertions, 5 deletions
diff --git a/tests/unit/controller/ExportControllerTest.php b/tests/unit/controller/ExportControllerTest.php index 913b091c6..b835e585a 100644 --- a/tests/unit/controller/ExportControllerTest.php +++ b/tests/unit/controller/ExportControllerTest.php @@ -26,11 +26,12 @@ namespace OCA\News\Controller; use \OCA\AppFramework\Http\Request; -use \OCA\AppFramework\Http\JSONResponse; +use \OCA\AppFramework\Http\TextDownloadResponse; use \OCA\AppFramework\Utility\ControllerTestUtility; use \OCA\AppFramework\Db\DoesNotExistException; use \OCA\AppFramework\Db\MultipleObjectsReturnedException; +use \OCA\News\Utility\OPMLExporter; require_once(__DIR__ . "/../../classloader.php"); @@ -40,22 +41,58 @@ class ExportControllerTest extends ControllerTestUtility { private $api; private $request; private $controller; - + private $user; + private $feedBl; + private $folderBl; + private $opmlExporter; /** * Gets run before each test */ public function setUp(){ $this->api = $this->getAPIMock(); + $this->feedBl = $this->getMockBuilder('\OCA\News\Bl\FeedBl') + ->disableOriginalConstructor() + ->getMock(); + $this->folderBl = $this->getMockBuilder('\OCA\News\Bl\FolderBl') + ->disableOriginalConstructor() + ->getMock(); $this->request = new Request(); - $this->controller = new ExportController($this->api, $this->request); + $this->opmlExporter = new OPMLExporter(); + $this->controller = new ExportController($this->api, $this->request, + $this->feedBl, $this->folderBl, $this->opmlExporter); + $this->user = 'john'; } public function testOpmlAnnotations(){ - $annotations = array('IsAdminExemption', 'IsSubAdminExemption', 'Ajax'); + $annotations = array('IsAdminExemption', 'IsSubAdminExemption', + 'CSRFExemption'); $this->assertAnnotations($this->controller, 'opml', $annotations); } + public function testOpmlExportNoFeeds(){ + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); + $this->feedBl->expects($this->once()) + ->method('findAll') + ->with($this->equalTo($this->user)) + ->will($this->returnValue(array())); + $this->folderBl->expects($this->once()) + ->method('findAll') + ->with($this->equalTo($this->user)) + ->will($this->returnValue(array())); + + $return = $this->controller->opml(); + $this->assertTrue($return instanceof TextDownloadResponse); + + // TODO: check if its empty xml structure + } + + + // TODO more tests for this + + }
\ No newline at end of file diff --git a/tests/unit/controller/FeedControllerTest.php b/tests/unit/controller/FeedControllerTest.php index e3dc60a28..e7c7c29e3 100644 --- a/tests/unit/controller/FeedControllerTest.php +++ b/tests/unit/controller/FeedControllerTest.php @@ -122,7 +122,7 @@ class FeedControllerTest extends ControllerTestUtility { ->method('getUserId') ->will($this->returnValue($this->user)); $this->bl->expects($this->once()) - ->method('findAllFromUser') + ->method('findAll') ->with($this->equalTo($this->user)) ->will($this->returnValue($result['feeds'])); |