diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-06-12 14:50:15 +0200 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-06-12 14:50:25 +0200 |
commit | 4faa08d70891da48a0f7647f7eb8730f7f9dc82e (patch) | |
tree | a7f66c2748e2f731be2f20f2af36181a29bf6ff1 /tests | |
parent | a70a85bc1839fbd2ebb27f051fe7c473107c5204 (diff) |
add annotations for api controllers
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/controller/FeedControllerTest.php | 18 | ||||
-rw-r--r-- | tests/unit/external/FeedAPITest.php | 91 | ||||
-rw-r--r-- | tests/unit/external/FolderAPITest.php | 77 | ||||
-rw-r--r-- | tests/unit/external/ItemAPITest.php | 121 | ||||
-rw-r--r-- | tests/unit/external/NewsAPITest.php | 15 |
5 files changed, 280 insertions, 42 deletions
diff --git a/tests/unit/controller/FeedControllerTest.php b/tests/unit/controller/FeedControllerTest.php index 370158822..064fdeeb4 100644 --- a/tests/unit/controller/FeedControllerTest.php +++ b/tests/unit/controller/FeedControllerTest.php @@ -84,9 +84,9 @@ class FeedControllerTest extends ControllerTestUtility { ); $request = $this->getRequest($post); - return new FeedController($this->api, $request, + return new FeedController($this->api, $request, $this->folderBusinessLayer, - $this->feedBusinessLayer, + $this->feedBusinessLayer, $this->itemBusinessLayer); } @@ -293,7 +293,7 @@ class FeedControllerTest extends ControllerTestUtility { $response = $this->controller->active(); $this->assertEquals($result, $response->getParams()); - $this->assertTrue($response instanceof JSONResponse); + $this->assertTrue($response instanceof JSONResponse); } @@ -330,7 +330,7 @@ class FeedControllerTest extends ControllerTestUtility { $this->assertEquals($result, $response->getParams()); $this->assertTrue($response instanceof JSONResponse); - } + } public function testCreateNoItems(){ @@ -366,7 +366,7 @@ class FeedControllerTest extends ControllerTestUtility { $this->assertEquals($result, $response->getParams()); $this->assertTrue($response instanceof JSONResponse); - } + } public function testCreateReturnsErrorForInvalidCreate(){ @@ -507,7 +507,7 @@ class FeedControllerTest extends ControllerTestUtility { ->will($this->returnValue($this->user)); $this->feedBusinessLayer->expects($this->once()) ->method('move') - ->with($this->equalTo($url['feedId']), + ->with($this->equalTo($url['feedId']), $this->equalTo($post['parentFolderId']), $this->equalTo($this->user)); @@ -559,7 +559,7 @@ class FeedControllerTest extends ControllerTestUtility { ->will($this->returnValue($this->user)); $this->feedBusinessLayer->expects($this->once()) ->method('importGoogleReaderJSON') - ->with($this->equalTo($post['json']), + ->with($this->equalTo($post['json']), $this->equalTo($this->user)) ->will($this->returnValue($feed)); @@ -614,7 +614,7 @@ class FeedControllerTest extends ControllerTestUtility { ->with($this->equalTo($url['feedId'])); $response = $this->controller->restore(); - $this->assertTrue($response instanceof JSONResponse); + $this->assertTrue($response instanceof JSONResponse); } @@ -640,4 +640,4 @@ class FeedControllerTest extends ControllerTestUtility { $this->assertTrue($response instanceof JSONResponse); } -}
\ No newline at end of file +} diff --git a/tests/unit/external/FeedAPITest.php b/tests/unit/external/FeedAPITest.php index cdc04bf0c..fd65d742c 100644 --- a/tests/unit/external/FeedAPITest.php +++ b/tests/unit/external/FeedAPITest.php @@ -26,6 +26,8 @@ namespace OCA\News\External; use \OCA\AppFramework\Http\Request; +use \OCA\AppFramework\Http\JSONResponse; +use \OCA\AppFramework\Utility\ControllerTestUtility; use \OCA\News\BusinessLayer\BusinessLayerException; use \OCA\News\BusinessLayer\BusinessLayerExistsException; @@ -36,7 +38,7 @@ use \OCA\News\Db\Item; require_once(__DIR__ . "/../../classloader.php"); -class FeedAPITest extends \PHPUnit_Framework_TestCase { +class FeedAPITest extends ControllerTestUtility { private $folderBusinessLayer; private $feedBusinessLayer; @@ -76,13 +78,41 @@ class FeedAPITest extends \PHPUnit_Framework_TestCase { $this->itemBusinessLayer ); $this->user = 'tom'; - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->msg = 'hohoho'; } + private function assertDefaultAnnotations($methodName){ + $annotations = array('IsAdminExemption', 'IsSubAdminExemption', 'Ajax'); + $this->assertAnnotations($this->feedAPI, $methodName, $annotations); + } + + + public function testGetAllAnnotations(){ + $this->assertDefaultAnnotations('getAll'); + } + + + public function testCreateAnnotations(){ + $this->assertDefaultAnnotations('create'); + } + + + public function testDeleteAnnotations(){ + $this->assertDefaultAnnotations('delete'); + } + + + public function testMoveAnnotations(){ + $this->assertDefaultAnnotations('move'); + } + + + public function testReadAnnotations(){ + $this->assertDefaultAnnotations('read'); + } + + public function testGetAll() { $feeds = array( new Feed() @@ -90,6 +120,9 @@ class FeedAPITest extends \PHPUnit_Framework_TestCase { $starredCount = 3; $newestItemId = 2; + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); $this->itemBusinessLayer->expects($this->once()) ->method('starredCount') ->with($this->equalTo($this->user)) @@ -119,6 +152,9 @@ class FeedAPITest extends \PHPUnit_Framework_TestCase { ); $starredCount = 3; + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); $this->itemBusinessLayer->expects($this->once()) ->method('starredCount') ->with($this->equalTo($this->user)) @@ -151,9 +187,11 @@ class FeedAPITest extends \PHPUnit_Framework_TestCase { $this->folderBusinessLayer, $this->feedBusinessLayer, $this->itemBusinessLayer - ); + ); - + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); $this->feedBusinessLayer->expects($this->once()) ->method('delete') ->with( @@ -178,9 +216,11 @@ class FeedAPITest extends \PHPUnit_Framework_TestCase { $this->folderBusinessLayer, $this->feedBusinessLayer, $this->itemBusinessLayer - ); + ); - + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); $this->feedBusinessLayer->expects($this->once()) ->method('delete') ->will($this->throwException(new BusinessLayerException($this->msg))); @@ -207,8 +247,11 @@ class FeedAPITest extends \PHPUnit_Framework_TestCase { $this->folderBusinessLayer, $this->feedBusinessLayer, $this->itemBusinessLayer - ); + ); + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); $this->feedBusinessLayer->expects($this->once()) ->method('purgeDeleted') ->with($this->equalTo($this->user), $this->equalTo(false)); @@ -249,8 +292,11 @@ class FeedAPITest extends \PHPUnit_Framework_TestCase { $this->folderBusinessLayer, $this->feedBusinessLayer, $this->itemBusinessLayer - ); + ); + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); $this->feedBusinessLayer->expects($this->once()) ->method('purgeDeleted') ->with($this->equalTo($this->user), $this->equalTo(false)); @@ -278,6 +324,9 @@ class FeedAPITest extends \PHPUnit_Framework_TestCase { public function testCreateExists() { + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); $this->feedBusinessLayer->expects($this->once()) ->method('purgeDeleted') ->with($this->equalTo($this->user), $this->equalTo(false)); @@ -294,6 +343,9 @@ class FeedAPITest extends \PHPUnit_Framework_TestCase { public function testCreateError() { + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); $this->feedBusinessLayer->expects($this->once()) ->method('create') ->will($this->throwException(new BusinessLayerException($this->msg))); @@ -321,9 +373,11 @@ class FeedAPITest extends \PHPUnit_Framework_TestCase { $this->folderBusinessLayer, $this->feedBusinessLayer, $this->itemBusinessLayer - ); + ); - + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); $this->itemBusinessLayer->expects($this->once()) ->method('readFeed') ->with( @@ -354,9 +408,11 @@ class FeedAPITest extends \PHPUnit_Framework_TestCase { $this->folderBusinessLayer, $this->feedBusinessLayer, $this->itemBusinessLayer - ); + ); - + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); $this->feedBusinessLayer->expects($this->once()) ->method('move') ->with( @@ -372,7 +428,10 @@ class FeedAPITest extends \PHPUnit_Framework_TestCase { } - public function testMoveDoesNotExist() { + public function testMoveDoesNotExist() { + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); $this->feedBusinessLayer->expects($this->once()) ->method('move') ->will($this->throwException(new BusinessLayerException($this->msg))); @@ -383,4 +442,4 @@ class FeedAPITest extends \PHPUnit_Framework_TestCase { $this->assertEquals($this->msg, $response->getMessage()); $this->assertEquals(NewsAPIResult::NOT_FOUND_ERROR, $response->getStatusCode()); } -}
\ No newline at end of file +} diff --git a/tests/unit/external/FolderAPITest.php b/tests/unit/external/FolderAPITest.php index 1ae4bd081..f9e5490a3 100644 --- a/tests/unit/external/FolderAPITest.php +++ b/tests/unit/external/FolderAPITest.php @@ -26,6 +26,8 @@ namespace OCA\News\External; use \OCA\AppFramework\Http\Request; +use \OCA\AppFramework\Http\JSONResponse; +use \OCA\AppFramework\Utility\ControllerTestUtility; use \OCA\News\BusinessLayer\BusinessLayerException; use \OCA\News\BusinessLayer\BusinessLayerExistsException; @@ -37,7 +39,7 @@ use \OCA\News\Db\Item; require_once(__DIR__ . "/../../classloader.php"); -class FolderAPITest extends \PHPUnit_Framework_TestCase { +class FolderAPITest extends ControllerTestUtility { private $folderBusinessLayer; private $itemBusinessLayer; @@ -72,9 +74,37 @@ class FolderAPITest extends \PHPUnit_Framework_TestCase { ); $this->user = 'tom'; $this->msg = 'test'; - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); + } + + + private function assertDefaultAnnotations($methodName){ + $annotations = array('IsAdminExemption', 'IsSubAdminExemption', 'Ajax'); + $this->assertAnnotations($this->folderAPI, $methodName, $annotations); + } + + + public function testGetAllAnnotations(){ + $this->assertDefaultAnnotations('getAll'); + } + + + public function testCreateAnnotations(){ + $this->assertDefaultAnnotations('create'); + } + + + public function testDeleteAnnotations(){ + $this->assertDefaultAnnotations('delete'); + } + + + public function testUpdateAnnotations(){ + $this->assertDefaultAnnotations('update'); + } + + + public function testReadAnnotations(){ + $this->assertDefaultAnnotations('read'); } @@ -83,6 +113,9 @@ class FolderAPITest extends \PHPUnit_Framework_TestCase { 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)) @@ -112,6 +145,9 @@ class FolderAPITest extends \PHPUnit_Framework_TestCase { $this->itemBusinessLayer ); + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); $this->folderBusinessLayer->expects($this->once()) ->method('purgeDeleted') ->with($this->equalTo($this->user), $this->equalTo(false)); @@ -130,6 +166,10 @@ class FolderAPITest extends \PHPUnit_Framework_TestCase { public function testCreateAlreadyExists() { $msg = 'exists'; + + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); $this->folderBusinessLayer->expects($this->once()) ->method('purgeDeleted') ->with($this->equalTo($this->user), $this->equalTo(false)); @@ -157,6 +197,9 @@ class FolderAPITest extends \PHPUnit_Framework_TestCase { $this->itemBusinessLayer ); + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); $this->folderBusinessLayer->expects($this->once()) ->method('delete') ->with($this->equalTo($folderId), $this->equalTo($this->user)); @@ -179,6 +222,9 @@ class FolderAPITest extends \PHPUnit_Framework_TestCase { $this->itemBusinessLayer ); + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); $this->folderBusinessLayer->expects($this->once()) ->method('delete') ->will($this->throwException(new BusinessLayerException($this->msg))); @@ -202,7 +248,7 @@ class FolderAPITest extends \PHPUnit_Framework_TestCase { 'urlParams' => array( 'folderId' => $folderId ), - + 'params' => array( 'name' => $folderName ) @@ -212,6 +258,9 @@ class FolderAPITest extends \PHPUnit_Framework_TestCase { $this->itemBusinessLayer ); + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); $this->folderBusinessLayer->expects($this->once()) ->method('rename') ->with($this->equalTo($folderId), @@ -236,7 +285,7 @@ class FolderAPITest extends \PHPUnit_Framework_TestCase { 'urlParams' => array( 'folderId' => $folderId ), - + 'params' => array( 'name' => $folderName ) @@ -246,6 +295,9 @@ class FolderAPITest extends \PHPUnit_Framework_TestCase { $this->itemBusinessLayer ); + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); $this->folderBusinessLayer->expects($this->once()) ->method('rename') ->will($this->throwException(new BusinessLayerException($this->msg))); @@ -269,7 +321,7 @@ class FolderAPITest extends \PHPUnit_Framework_TestCase { 'urlParams' => array( 'folderId' => $folderId ), - + 'params' => array( 'name' => $folderName ) @@ -279,6 +331,9 @@ class FolderAPITest extends \PHPUnit_Framework_TestCase { $this->itemBusinessLayer ); + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); $this->folderBusinessLayer->expects($this->once()) ->method('rename') ->will($this->throwException(new BusinessLayerExistsException($this->msg))); @@ -305,9 +360,11 @@ class FolderAPITest extends \PHPUnit_Framework_TestCase { $request, $this->folderBusinessLayer, $this->itemBusinessLayer - ); + ); - + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); $this->itemBusinessLayer->expects($this->once()) ->method('readFolder') ->with( @@ -323,4 +380,4 @@ class FolderAPITest extends \PHPUnit_Framework_TestCase { } -}
\ No newline at end of file +} diff --git a/tests/unit/external/ItemAPITest.php b/tests/unit/external/ItemAPITest.php index 56e518da8..cc66d562d 100644 --- a/tests/unit/external/ItemAPITest.php +++ b/tests/unit/external/ItemAPITest.php @@ -26,6 +26,8 @@ namespace OCA\News\External; use \OCA\AppFramework\Http\Request; +use \OCA\AppFramework\Http\JSONResponse; +use \OCA\AppFramework\Utility\ControllerTestUtility; use \OCA\News\BusinessLayer\BusinessLayerException; use \OCA\News\Db\Item; @@ -33,7 +35,7 @@ use \OCA\News\Db\Item; require_once(__DIR__ . "/../../classloader.php"); -class ItemAPITest extends \PHPUnit_Framework_TestCase { +class ItemAPITest extends ControllerTestUtility { private $itemBusinessLayer; private $itemAPI; @@ -56,9 +58,6 @@ class ItemAPITest extends \PHPUnit_Framework_TestCase { ->disableOriginalConstructor() ->getMock(); $this->user = 'tom'; - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->itemAPI = new ItemAPI( $this->api, $this->request, @@ -68,6 +67,67 @@ class ItemAPITest extends \PHPUnit_Framework_TestCase { } + private function assertDefaultAnnotations($methodName){ + $annotations = array('IsAdminExemption', 'IsSubAdminExemption', 'Ajax'); + $this->assertAnnotations($this->itemAPI, $methodName, $annotations); + } + + + public function testGetAllAnnotations(){ + $this->assertDefaultAnnotations('getAll'); + } + + + public function testGetUpdatedAnnotations(){ + $this->assertDefaultAnnotations('getUpdated'); + } + + + public function testReadAllAnnotations(){ + $this->assertDefaultAnnotations('readAll'); + } + + + public function testReadAnnotations(){ + $this->assertDefaultAnnotations('read'); + } + + + public function testStarAnnotations(){ + $this->assertDefaultAnnotations('star'); + } + + + public function testUnreadAnnotations(){ + $this->assertDefaultAnnotations('unread'); + } + + + public function testUnstarAnnotations(){ + $this->assertDefaultAnnotations('unstar'); + } + + + public function testReadMultipleAnnotations(){ + $this->assertDefaultAnnotations('readMultiple'); + } + + + public function testStarMultipleAnnotations(){ + $this->assertDefaultAnnotations('starMultiple'); + } + + + public function testUnreadMultipleAnnotations(){ + $this->assertDefaultAnnotations('unreadMultiple'); + } + + + public function testUnstarMultipleAnnotations(){ + $this->assertDefaultAnnotations('unstarMultiple'); + } + + public function testGetAll() { $items = array( new Item() @@ -85,6 +145,9 @@ class ItemAPITest extends \PHPUnit_Framework_TestCase { $this->itemBusinessLayer ); + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); $this->itemBusinessLayer->expects($this->once()) ->method('findAll') ->with( @@ -120,6 +183,9 @@ class ItemAPITest extends \PHPUnit_Framework_TestCase { $this->itemBusinessLayer ); + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); $this->itemBusinessLayer->expects($this->once()) ->method('findAllNew') ->with( @@ -149,6 +215,9 @@ class ItemAPITest extends \PHPUnit_Framework_TestCase { $this->itemBusinessLayer ); + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); $this->itemBusinessLayer->expects($this->once()) ->method('read') ->with( @@ -175,6 +244,9 @@ class ItemAPITest extends \PHPUnit_Framework_TestCase { $this->itemBusinessLayer ); + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); $this->itemBusinessLayer->expects($this->once()) ->method('read') ->will($this->throwException(new BusinessLayerException($this->msg))); @@ -197,6 +269,9 @@ class ItemAPITest extends \PHPUnit_Framework_TestCase { $this->itemBusinessLayer ); + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); $this->itemBusinessLayer->expects($this->once()) ->method('read') ->with( @@ -223,6 +298,9 @@ class ItemAPITest extends \PHPUnit_Framework_TestCase { $this->itemBusinessLayer ); + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); $this->itemBusinessLayer->expects($this->once()) ->method('read') ->will($this->throwException(new BusinessLayerException($this->msg))); @@ -246,6 +324,9 @@ class ItemAPITest extends \PHPUnit_Framework_TestCase { $this->itemBusinessLayer ); + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); $this->itemBusinessLayer->expects($this->once()) ->method('star') ->with( @@ -274,6 +355,9 @@ class ItemAPITest extends \PHPUnit_Framework_TestCase { $this->itemBusinessLayer ); + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); $this->itemBusinessLayer->expects($this->once()) ->method('star') ->will($this->throwException(new BusinessLayerException($this->msg))); @@ -297,6 +381,9 @@ class ItemAPITest extends \PHPUnit_Framework_TestCase { $this->itemBusinessLayer ); + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); $this->itemBusinessLayer->expects($this->once()) ->method('star') ->with( @@ -325,6 +412,9 @@ class ItemAPITest extends \PHPUnit_Framework_TestCase { $this->itemBusinessLayer ); + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); $this->itemBusinessLayer->expects($this->once()) ->method('star') ->will($this->throwException(new BusinessLayerException($this->msg))); @@ -349,7 +439,9 @@ class ItemAPITest extends \PHPUnit_Framework_TestCase { $this->itemBusinessLayer ); - + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); $this->itemBusinessLayer->expects($this->once()) ->method('readAll') ->with( @@ -375,6 +467,9 @@ class ItemAPITest extends \PHPUnit_Framework_TestCase { $this->itemBusinessLayer ); + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); $this->itemBusinessLayer->expects($this->at(0)) ->method('read') ->with($this->equalTo(2), @@ -400,6 +495,9 @@ class ItemAPITest extends \PHPUnit_Framework_TestCase { $this->itemBusinessLayer ); + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); $this->itemBusinessLayer->expects($this->at(0)) ->method('read') ->will($this->throwException(new BusinessLayerException(''))); @@ -422,6 +520,9 @@ class ItemAPITest extends \PHPUnit_Framework_TestCase { $this->itemBusinessLayer ); + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); $this->itemBusinessLayer->expects($this->at(0)) ->method('read') ->with($this->equalTo(2), @@ -456,6 +557,9 @@ class ItemAPITest extends \PHPUnit_Framework_TestCase { $this->itemBusinessLayer ); + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); $this->itemBusinessLayer->expects($this->at(0)) ->method('star') ->with($this->equalTo(2), @@ -492,6 +596,9 @@ class ItemAPITest extends \PHPUnit_Framework_TestCase { $this->itemBusinessLayer ); + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); $this->itemBusinessLayer->expects($this->at(0)) ->method('star') ->will($this->throwException(new BusinessLayerException(''))); @@ -524,6 +631,9 @@ class ItemAPITest extends \PHPUnit_Framework_TestCase { $this->itemBusinessLayer ); + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); $this->itemBusinessLayer->expects($this->at(0)) ->method('star') ->with($this->equalTo(2), @@ -540,4 +650,5 @@ class ItemAPITest extends \PHPUnit_Framework_TestCase { $this->assertEquals(NewsAPIResult::OK, $response->getStatusCode()); } + } diff --git a/tests/unit/external/NewsAPITest.php b/tests/unit/external/NewsAPITest.php index 84522d75d..07ba00a1e 100644 --- a/tests/unit/external/NewsAPITest.php +++ b/tests/unit/external/NewsAPITest.php @@ -25,11 +25,13 @@ namespace OCA\News\External; +use \OCA\AppFramework\Http\JSONResponse; +use \OCA\AppFramework\Utility\ControllerTestUtility; require_once(__DIR__ . "/../../classloader.php"); -class NewsAPITest extends \PHPUnit_Framework_TestCase { +class NewsAPITest extends ControllerTestUtility { private $api; private $request; @@ -48,6 +50,15 @@ class NewsAPITest extends \PHPUnit_Framework_TestCase { } + private function assertDefaultAnnotations($methodName){ + $annotations = array('IsAdminExemption', 'IsSubAdminExemption', 'Ajax'); + $this->assertAnnotations($this->newsAPI, $methodName, $annotations); + } + + public function testVersionAnnotations(){ + $this->assertDefaultAnnotations('version'); + } + public function testGetVersion(){ $this->api->expects($this->once()) ->method('getAppValue') @@ -62,4 +73,4 @@ class NewsAPITest extends \PHPUnit_Framework_TestCase { } -}
\ No newline at end of file +} |