diff options
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/external/APIResultTest.php | 45 | ||||
-rw-r--r-- | tests/unit/external/FeedAPITest.php | 4 | ||||
-rw-r--r-- | tests/unit/external/FolderAPITest.php | 89 |
3 files changed, 136 insertions, 2 deletions
diff --git a/tests/unit/external/APIResultTest.php b/tests/unit/external/APIResultTest.php new file mode 100644 index 000000000..2287e683a --- /dev/null +++ b/tests/unit/external/APIResultTest.php @@ -0,0 +1,45 @@ +<?php + +/** +* ownCloud - News +* +* @author Alessandro Cosentino +* @author Bernhard Posselt +* @copyright 2012 Alessandro Cosentino cosenal@gmail.com +* @copyright 2012 Bernhard Posselt nukeawhale@gmail.com +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE +* License as published by the Free Software Foundation; either +* version 3 of the License, or any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU AFFERO GENERAL PUBLIC LICENSE for more details. +* +* You should have received a copy of the GNU Affero General Public +* License along with this library. If not, see <http://www.gnu.org/licenses/>. +* +*/ + +namespace OCA\News\External; + +require_once(__DIR__ . "/../../classloader.php"); + + +class APIResultTest extends \PHPUnit_Framework_TestCase { + + + public function testGetStatusCode() { + $result = new APIResult(null, APIResult::SERVER_ERROR); + $this->assertEquals(996, $result->getStatusCode()); + } + + public function testGetData() { + $result = new APIResult('hi'); + $this->assertEquals('hi', $result->getData()); + $this->assertEquals(100, $result->getStatusCode()); + } + +}
\ No newline at end of file diff --git a/tests/unit/external/FeedAPITest.php b/tests/unit/external/FeedAPITest.php index b3c945115..7b66733bd 100644 --- a/tests/unit/external/FeedAPITest.php +++ b/tests/unit/external/FeedAPITest.php @@ -105,7 +105,7 @@ class FeedAPITest extends \PHPUnit_Framework_TestCase { 'feeds' => array($feeds[0]->toAPI()), 'starredCount' => $starredCount, 'newestItemId' => $newestItemId - ), $response); + ), $response->getData()); } @@ -136,7 +136,7 @@ class FeedAPITest extends \PHPUnit_Framework_TestCase { $this->assertEquals(array( 'feeds' => array($feeds[0]->toAPI()), 'starredCount' => $starredCount, - ), $response); + ), $response->getData()); } diff --git a/tests/unit/external/FolderAPITest.php b/tests/unit/external/FolderAPITest.php new file mode 100644 index 000000000..61339c7ab --- /dev/null +++ b/tests/unit/external/FolderAPITest.php @@ -0,0 +1,89 @@ +<?php + +/** +* ownCloud - News +* +* @author Alessandro Cosentino +* @author Bernhard Posselt +* @copyright 2012 Alessandro Cosentino cosenal@gmail.com +* @copyright 2012 Bernhard Posselt nukeawhale@gmail.com +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE +* License as published by the Free Software Foundation; either +* version 3 of the License, or any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU AFFERO GENERAL PUBLIC LICENSE for more details. +* +* You should have received a copy of the GNU Affero General Public +* License along with this library. If not, see <http://www.gnu.org/licenses/>. +* +*/ + +namespace OCA\News\External; + +use \OCA\News\BusinessLayer\BusinessLayerException; + +use \OCA\News\Db\Folder; +use \OCA\News\Db\Feed; +use \OCA\News\Db\Item; + +require_once(__DIR__ . "/../../classloader.php"); + + +class FolderAPITest extends \PHPUnit_Framework_TestCase { + + private $folderBusinessLayer; + private $folderAPI; + private $api; + private $user; + private $request; + + protected function setUp() { + $this->api = $this->folderBusinessLayer = $this->getMockBuilder( + '\OCA\AppFramework\Core\API') + ->disableOriginalConstructor() + ->getMock(); + $this->request = $this->folderBusinessLayer = $this->getMockBuilder( + '\OCA\AppFramework\Http\Request') + ->disableOriginalConstructor() + ->getMock(); + $this->folderBusinessLayer = $this->getMockBuilder( + '\OCA\News\BusinessLayer\FolderBusinessLayer') + ->disableOriginalConstructor() + ->getMock(); + $this->feedAPI = new FolderAPI( + $this->api, + $this->request, + $this->folderBusinessLayer + ); + $this->user = 'tom'; + } + + + public function testGetAll() { + $folders = array( + new Folder() + ); + + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); + $this->folderBusinessLayer->expects($this->once()) + ->method('findAll') + ->with($this->equalTo($this->user)) + ->will($this->returnValue($folders)); + + $response = $this->feedAPI->getAll(); + + $this->assertEquals(array( + 'folders' => array($folders[0]->toAPI()) + ), $response->getData()); + } + + + +}
\ No newline at end of file |