diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-04-09 01:44:12 +0200 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-04-09 22:52:26 +0200 |
commit | 21bd539847f33c3889c4f58f14afd672f54a410a (patch) | |
tree | d6ff27e38727197b60d1c2c47968b7f64d4f5c2f /tests/unit | |
parent | fcef0800a24818305e8a52761b05f87e13206689 (diff) |
ported to owncloud internal appframework classes, confused with how to start the app and define deps
Diffstat (limited to 'tests/unit')
31 files changed, 264 insertions, 115 deletions
diff --git a/tests/unit/api/FeedAPITest.php b/tests/unit/api/FeedAPITest.php index 6b2187657..03dd762cb 100644 --- a/tests/unit/api/FeedAPITest.php +++ b/tests/unit/api/FeedAPITest.php @@ -25,11 +25,11 @@ namespace OCA\News\API; -use \OCA\AppFramework\Http\Request; -use \OCA\AppFramework\Http\JSONResponse; -use \OCA\AppFramework\Http\Http; -use \OCA\AppFramework\Utility\ControllerTestUtility; +use \OCP\IRequest; +use \OCP\AppFramework\Http; +use \OCP\AppFramework\Http\JSONResponse; +use \OCA\News\Utility\ControllerTestUtility; use \OCA\News\BusinessLayer\BusinessLayerException; use \OCA\News\BusinessLayer\BusinessLayerConflictException; use \OCA\News\Db\Folder; @@ -52,11 +52,11 @@ class FeedAPITest extends ControllerTestUtility { protected function setUp() { $this->api = $this->getMockBuilder( - '\OCA\AppFramework\Core\API') + '\OCA\News\Core\API') ->disableOriginalConstructor() ->getMock(); $this->request = $this->getMockBuilder( - '\OCA\AppFramework\Http\Request') + '\OCP\IRequest') ->disableOriginalConstructor() ->getMock(); $this->folderBusinessLayer = $this->getMockBuilder( @@ -192,7 +192,7 @@ class FeedAPITest extends ControllerTestUtility { public function testDelete() { - $request = new Request(array('urlParams' => array( + $request = $this->getRequest(array('urlParams' => array( 'feedId' => 2 ))); $this->feedAPI = new FeedAPI( @@ -220,7 +220,7 @@ class FeedAPITest extends ControllerTestUtility { public function testDeleteDoesNotExist() { - $request = new Request(array('urlParams' => array( + $request = $this->getRequest(array('urlParams' => array( 'feedId' => 2 ))); $this->feedAPI = new FeedAPI( @@ -250,7 +250,7 @@ class FeedAPITest extends ControllerTestUtility { $feeds = array( new Feed() ); - $request = new Request(array('params' => array( + $request = $this->getRequest(array('params' => array( 'url' => 'ho', 'folderId' => 3 ))); @@ -294,7 +294,7 @@ class FeedAPITest extends ControllerTestUtility { $feeds = array( new Feed() ); - $request = new Request(array('params' => array( + $request = $this->getRequest(array('params' => array( 'url' => 'ho', 'folderId' => 3 ))); @@ -370,7 +370,7 @@ class FeedAPITest extends ControllerTestUtility { public function testRead() { - $request = new Request(array( + $request = $this->getRequest(array( 'urlParams' => array( 'feedId' => 3 ), @@ -404,7 +404,7 @@ class FeedAPITest extends ControllerTestUtility { public function testMove() { - $request = new Request(array( + $request = $this->getRequest(array( 'urlParams' => array( 'feedId' => 3 ), @@ -441,7 +441,7 @@ class FeedAPITest extends ControllerTestUtility { $feedId = 3; $feedTitle = 'test'; - $request = new Request(array( + $request = $this->getRequest(array( 'urlParams' => array( 'feedId' => $feedId ), @@ -508,7 +508,7 @@ class FeedAPITest extends ControllerTestUtility { public function testUpdate() { $feedId = 3; $userId = 'hi'; - $request = new Request(array('params' => array( + $request = $this->getRequest(array('params' => array( 'feedId' => $feedId, 'userId' => $userId ))); diff --git a/tests/unit/api/FolderAPITest.php b/tests/unit/api/FolderAPITest.php index 8c33233b0..843ac004f 100644 --- a/tests/unit/api/FolderAPITest.php +++ b/tests/unit/api/FolderAPITest.php @@ -25,11 +25,11 @@ namespace OCA\News\API; -use \OCA\AppFramework\Http\Request; -use \OCA\AppFramework\Http\JSONResponse; -use \OCA\AppFramework\Utility\ControllerTestUtility; -use \OCA\AppFramework\Http\Http; +use \OCP\IRequest; +use \OCP\AppFramework\Http; +use \OCP\AppFramework\Http\JSONResponse; +use \OCA\News\Utility\ControllerTestUtility; use \OCA\News\BusinessLayer\BusinessLayerException; use \OCA\News\BusinessLayer\BusinessLayerConflictException; use \OCA\News\BusinessLayer\BusinessLayerValidationException; @@ -53,11 +53,11 @@ class FolderAPITest extends ControllerTestUtility { protected function setUp() { $this->api = $this->getMockBuilder( - '\OCA\AppFramework\Core\API') + '\OCA\News\Core\API') ->disableOriginalConstructor() ->getMock(); $this->request = $this->getMockBuilder( - '\OCA\AppFramework\Http\Request') + '\OCP\IRequest') ->disableOriginalConstructor() ->getMock(); $this->folderBusinessLayer = $this->getMockBuilder( @@ -141,7 +141,7 @@ class FolderAPITest extends ControllerTestUtility { ); $this->folderAPI = new FolderAPI( $this->api, - new Request(array('params' => array( + $this->getRequest(array('params' => array( 'name' => $folderName ))), $this->folderBusinessLayer, @@ -214,7 +214,7 @@ class FolderAPITest extends ControllerTestUtility { $this->folderAPI = new FolderAPI( $this->api, - new Request(array('urlParams' => array( + $this->getRequest(array('urlParams' => array( 'folderId' => $folderId ))), $this->folderBusinessLayer, @@ -239,7 +239,7 @@ class FolderAPITest extends ControllerTestUtility { $this->folderAPI = new FolderAPI( $this->api, - new Request(array('urlParams' => array( + $this->getRequest(array('urlParams' => array( 'folderId' => $folderId ))), $this->folderBusinessLayer, @@ -267,7 +267,7 @@ class FolderAPITest extends ControllerTestUtility { $this->folderAPI = new FolderAPI( $this->api, - new Request( + $this->getRequest( array( 'urlParams' => array( 'folderId' => $folderId @@ -303,7 +303,7 @@ class FolderAPITest extends ControllerTestUtility { $this->folderAPI = new FolderAPI( $this->api, - new Request( + $this->getRequest( array( 'urlParams' => array( 'folderId' => $folderId @@ -339,7 +339,7 @@ class FolderAPITest extends ControllerTestUtility { $this->folderAPI = new FolderAPI( $this->api, - new Request( + $this->getRequest( array( 'urlParams' => array( 'folderId' => $folderId @@ -375,7 +375,7 @@ class FolderAPITest extends ControllerTestUtility { $this->folderAPI = new FolderAPI( $this->api, - new Request( + $this->getRequest( array( 'urlParams' => array( 'folderId' => $folderId @@ -406,7 +406,7 @@ class FolderAPITest extends ControllerTestUtility { public function testRead() { - $request = new Request(array( + $request = $this->getRequest(array( 'urlParams' => array( 'folderId' => 3 ), diff --git a/tests/unit/api/ItemAPITest.php b/tests/unit/api/ItemAPITest.php index b172d5752..5bbf7edf1 100644 --- a/tests/unit/api/ItemAPITest.php +++ b/tests/unit/api/ItemAPITest.php @@ -25,11 +25,11 @@ namespace OCA\News\API; -use \OCA\AppFramework\Http\Request; -use \OCA\AppFramework\Http\JSONResponse; -use \OCA\AppFramework\Http\Http; -use \OCA\AppFramework\Utility\ControllerTestUtility; +use \OCP\IRequest; +use \OCP\AppFramework\Http; +use \OCP\AppFramework\Http\JSONResponse; +use \OCA\News\Utility\ControllerTestUtility; use \OCA\News\BusinessLayer\BusinessLayerException; use \OCA\News\Db\Item; @@ -47,11 +47,11 @@ class ItemAPITest extends ControllerTestUtility { protected function setUp() { $this->api = $this->getMockBuilder( - '\OCA\AppFramework\Core\API') + '\OCA\News\Core\API') ->disableOriginalConstructor() ->getMock(); $this->request = $this->getMockBuilder( - '\OCA\AppFramework\Http\Request') + '\OCP\IRequest') ->disableOriginalConstructor() ->getMock(); $this->itemBusinessLayer = $this->getMockBuilder( @@ -134,7 +134,7 @@ class ItemAPITest extends ControllerTestUtility { $items = array( new Item() ); - $request = new Request(array('params' => array( + $request = $this->getRequest(array('params' => array( 'batchSize' => 30, 'offset' => 20, 'type' => 1, @@ -174,7 +174,7 @@ class ItemAPITest extends ControllerTestUtility { $items = array( new Item() ); - $request = new Request(array('params' => array( + $request = $this->getRequest(array('params' => array( 'offset' => 20, 'type' => 1, 'id' => 2, @@ -213,7 +213,7 @@ class ItemAPITest extends ControllerTestUtility { $items = array( new Item() ); - $request = new Request(array('params' => array( + $request = $this->getRequest(array('params' => array( 'lastModified' => 30, 'type' => 1, 'id' => 2, @@ -247,7 +247,7 @@ class ItemAPITest extends ControllerTestUtility { public function testRead() { - $request = new Request(array('urlParams' => array( + $request = $this->getRequest(array('urlParams' => array( 'itemId' => 2 ))); $this->itemAPI = new ItemAPI( @@ -275,7 +275,7 @@ class ItemAPITest extends ControllerTestUtility { public function testReadDoesNotExist() { - $request = new Request(array('urlParams' => array( + $request = $this->getRequest(array('urlParams' => array( 'itemId' => 2 ))); $this->itemAPI = new ItemAPI( @@ -300,7 +300,7 @@ class ItemAPITest extends ControllerTestUtility { public function testUnread() { - $request = new Request(array('urlParams' => array( + $request = $this->getRequest(array('urlParams' => array( 'itemId' => 2 ))); $this->itemAPI = new ItemAPI( @@ -328,7 +328,7 @@ class ItemAPITest extends ControllerTestUtility { public function testUnreadDoesNotExist() { - $request = new Request(array('urlParams' => array( + $request = $this->getRequest(array('urlParams' => array( 'itemId' => 2 ))); $this->itemAPI = new ItemAPI( @@ -353,7 +353,7 @@ class ItemAPITest extends ControllerTestUtility { public function testStar() { - $request = new Request(array('urlParams' => array( + $request = $this->getRequest(array('urlParams' => array( 'feedId' => 2, 'guidHash' => 'hash' ))); @@ -383,7 +383,7 @@ class ItemAPITest extends ControllerTestUtility { public function testStarDoesNotExist() { - $request = new Request(array('urlParams' => array( + $request = $this->getRequest(array('urlParams' => array( 'feedId' => 2, 'guidHash' => 'hash' ))); @@ -409,7 +409,7 @@ class ItemAPITest extends ControllerTestUtility { public function testUnstar() { - $request = new Request(array('urlParams' => array( + $request = $this->getRequest(array('urlParams' => array( 'feedId' => 2, 'guidHash' => 'hash' ))); @@ -439,7 +439,7 @@ class ItemAPITest extends ControllerTestUtility { public function testUnstarDoesNotExist() { - $request = new Request(array('urlParams' => array( + $request = $this->getRequest(array('urlParams' => array( 'feedId' => 2, 'guidHash' => 'hash' ))); @@ -465,7 +465,7 @@ class ItemAPITest extends ControllerTestUtility { public function testReadAll() { - $request = new Request(array( + $request = $this->getRequest(array( 'params' => array( 'newestItemId' => 30, ) @@ -494,7 +494,7 @@ class ItemAPITest extends ControllerTestUtility { public function testReadMultiple() { - $request = new Request(array('params' => array( + $request = $this->getRequest(array('params' => array( 'items' => array(2, 4) ))); $this->itemAPI = new ItemAPI( @@ -522,7 +522,7 @@ class ItemAPITest extends ControllerTestUtility { public function testReadMultipleDoesntCareAboutException() { - $request = new Request(array('params' => array( + $request = $this->getRequest(array('params' => array( 'items' => array(2, 4) ))); $this->itemAPI = new ItemAPI( @@ -547,7 +547,7 @@ class ItemAPITest extends ControllerTestUtility { public function testUnreadMultiple() { - $request = new Request(array('params' => array( + $request = $this->getRequest(array('params' => array( 'items' => array(2, 4) ))); $this->itemAPI = new ItemAPI( @@ -575,7 +575,7 @@ class ItemAPITest extends ControllerTestUtility { public function testStarMultiple() { - $request = new Request(array('params' => array( + $request = $this->getRequest(array('params' => array( 'items' => array( array( 'feedId' => 2, @@ -614,7 +614,7 @@ class ItemAPITest extends ControllerTestUtility { public function testStarMultipleDoesntCareAboutException() { - $request = new Request(array('params' => array( + $request = $this->getRequest(array('params' => array( 'items' => array( array( 'feedId' => 2, @@ -649,7 +649,7 @@ class ItemAPITest extends ControllerTestUtility { public function testUnstarMultiple() { - $request = new Request(array('params' => array( + $request = $this->getRequest(array('params' => array( 'items' => array( array( 'feedId' => 2, diff --git a/tests/unit/api/NewsAPITest.php b/tests/unit/api/NewsAPITest.php index 412f5e580..9fa467913 100644 --- a/tests/unit/api/NewsAPITest.php +++ b/tests/unit/api/NewsAPITest.php @@ -25,9 +25,11 @@ namespace OCA\News\API; -use \OCA\AppFramework\Http\Request; -use \OCA\AppFramework\Http\JSONResponse; -use \OCA\AppFramework\Utility\ControllerTestUtility; +use \OCP\IRequest; +use \OCP\AppFramework\Http\JSONResponse; + + +use \OCA\News\Utility\ControllerTestUtility; require_once(__DIR__ . "/../../classloader.php"); @@ -41,11 +43,11 @@ class NewsAPITest extends ControllerTestUtility { protected function setUp() { $this->api = $this->getMockBuilder( - '\OCA\AppFramework\Core\API') + '\OCA\News\Core\API') ->disableOriginalConstructor() ->getMock(); $this->request = $this->getMockBuilder( - '\OCA\AppFramework\Http\Request') + '\OCP\IRequest') ->disableOriginalConstructor() ->getMock(); $this->updater = $this->getMockBuilder( @@ -114,7 +116,7 @@ class NewsAPITest extends ControllerTestUtility { public function testCors() { - $this->request = new Request(array('server' => array())); + $this->request = $this->getRequest(array('server' => array())); $this->newsAPI = new NewsAPI($this->api, $this->request, $this->updater); $response = $this->newsAPI->cors(); @@ -129,7 +131,7 @@ class NewsAPITest extends ControllerTestUtility { public function testCorsUsesOriginIfGiven() { - $this->request = new Request(array('server' => array('HTTP_ORIGIN' => 'test'))); + $this->request = $this->getRequest(array('server' => array('HTTP_ORIGIN' => 'test'))); $this->newsAPI = new NewsAPI($this->api, $this->request, $this->updater); $response = $this->newsAPI->cors(); diff --git a/tests/unit/articleenhancer/EnhancerTest.php b/tests/unit/articleenhancer/EnhancerTest.php index 84cbe2a7c..7f782cf55 100644 --- a/tests/unit/articleenhancer/EnhancerTest.php +++ b/tests/unit/articleenhancer/EnhancerTest.php @@ -30,7 +30,7 @@ use \OCA\News\Db\Item; require_once(__DIR__ . "/../../classloader.php"); -class EnhancerTest extends \OCA\AppFramework\Utility\TestUtility { +class EnhancerTest extends \OCA\News\Utility\TestUtility { private $enhancer; private $articleEnhancer; diff --git a/tests/unit/articleenhancer/RegexArticleEnhancerTest.php b/tests/unit/articleenhancer/RegexArticleEnhancerTest.php index 2d985edf1..a43f92b1c 100644 --- a/tests/unit/articleenhancer/RegexArticleEnhancerTest.php +++ b/tests/unit/articleenhancer/RegexArticleEnhancerTest.php @@ -30,7 +30,7 @@ use \OCA\News\Db\Item; require_once(__DIR__ . "/../../classloader.php"); -class RegexArticleEnhancerTest extends \OCA\AppFramework\Utility\TestUtility { +class RegexArticleEnhancerTest extends \OCA\News\Utility\TestUtility { public function testRegexEnhancer() { diff --git a/tests/unit/articleenhancer/XPathArticleEnhancerTest.php b/tests/unit/articleenhancer/XPathArticleEnhancerTest.php index c7e61e7b8..e594e105f 100644 --- a/tests/unit/articleenhancer/XPathArticleEnhancerTest.php +++ b/tests/unit/articleenhancer/XPathArticleEnhancerTest.php @@ -30,7 +30,7 @@ use \OCA\News\Db\Item; require_once(__DIR__ . "/../../classloader.php"); -class XPathArticleEnhancerTest extends \OCA\AppFramework\Utility\TestUtility { +class XPathArticleEnhancerTest extends \OCA\News\Utility\TestUtility { private $testEnhancer; private $fileFactory; diff --git a/tests/unit/businesslayer/BusinessLayerTest.php b/tests/unit/businesslayer/BusinessLayerTest.php index 2208e34f8..7f3677d18 100644 --- a/tests/unit/businesslayer/BusinessLayerTest.php +++ b/tests/unit/businesslayer/BusinessLayerTest.php @@ -39,7 +39,7 @@ class TestBusinessLayer extends BusinessLayer { } } -class BusinessLayerTest extends \OCA\AppFramework\Utility\TestUtility { +class BusinessLayerTest extends \OCA\News\Utility\TestUtility { protected $api; protected $mapper; diff --git a/tests/unit/businesslayer/FeedBusinessLayerTest.php b/tests/unit/businesslayer/FeedBusinessLayerTest.php index 99ecee9f2..4e35326d6 100644 --- a/tests/unit/businesslayer/FeedBusinessLayerTest.php +++ b/tests/unit/businesslayer/FeedBusinessLayerTest.php @@ -34,7 +34,7 @@ use \OCA\News\Db\Item; use \OCA\News\Fetcher\Fetcher; use \OCA\News\Fetcher\FetcherException; -class FeedBusinessLayerTest extends \OCA\AppFramework\Utility\TestUtility { +class FeedBusinessLayerTest extends \OCA\News\Utility\TestUtility { private $feedMapper; private $feedBusinessLayer; diff --git a/tests/unit/businesslayer/FolderBusinessLayerTest.php b/tests/unit/businesslayer/FolderBusinessLayerTest.php index 398365739..c68d0e768 100644 --- a/tests/unit/businesslayer/FolderBusinessLayerTest.php +++ b/tests/unit/businesslayer/FolderBusinessLayerTest.php @@ -31,7 +31,7 @@ require_once(__DIR__ . "/../../classloader.php"); use \OCA\News\Db\Folder; -class FolderBusinessLayerTest extends \OCA\AppFramework\Utility\TestUtility { +class FolderBusinessLayerTest extends \OCA\News\Utility\TestUtility { private $folderMapper; private $folderBusinessLayer; diff --git a/tests/unit/businesslayer/ItemBusinessLayerTest.php b/tests/unit/businesslayer/ItemBusinessLayerTest.php index 2909dae28..349ad865c 100644 --- a/tests/unit/businesslayer/ItemBusinessLayerTest.php +++ b/tests/unit/businesslayer/ItemBusinessLayerTest.php @@ -33,7 +33,7 @@ use \OCA\News\Db\StatusFlag; use \OCA\News\Db\FeedType; -class ItemBusinessLayerTest extends \OCA\AppFramework\Utility\TestUtility { +class ItemBusinessLayerTest extends \OCA\News\Utility\TestUtility { private $api; private $mapper; diff --git a/tests/unit/businesslayer/StatusFlagTest.php b/tests/unit/businesslayer/StatusFlagTest.php index 2e7b9d4d8..d503b6630 100644 --- a/tests/unit/businesslayer/StatusFlagTest.php +++ b/tests/unit/businesslayer/StatusFlagTest.php @@ -25,13 +25,11 @@ namespace OCA\News\Db; -use \OCA\AppFramework\Utility\TestUtility; - require_once(__DIR__ . "/../../classloader.php"); -class StatusFlagTest extends TestUtility { +class StatusFlagTest extends \OCA\News\Utility\TestUtility { private $statusFlag; diff --git a/tests/unit/controller/ExportControllerTest.php b/tests/unit/controller/ExportControllerTest.php index 542053edf..0970993ca 100644 --- a/tests/unit/controller/ExportControllerTest.php +++ b/tests/unit/controller/ExportControllerTest.php @@ -25,11 +25,12 @@ namespace OCA\News\Controller; -use \OCA\AppFramework\Http\Request; -use \OCA\AppFramework\Http\TextDownloadResponse; -use \OCA\AppFramework\Http\JSONResponse; -use \OCA\AppFramework\Utility\ControllerTestUtility; +use \OCP\IRequest; +use \OCP\AppFramework\Http; +use \OCP\AppFramework\Http\JSONResponse; +use \OCA\News\Http\TextDownloadResponse; +use \OCA\News\Utility\ControllerTestUtility; use \OCA\News\Utility\OPMLExporter; use \OCA\News\Db\Item; use \OCA\News\Db\Feed; @@ -62,7 +63,7 @@ class ExportControllerTest extends ControllerTestUtility { $this->folderBusinessLayer = $this->getMockBuilder('\OCA\News\BusinessLayer\FolderBusinessLayer') ->disableOriginalConstructor() ->getMock(); - $this->request = new Request(); + $this->request = $this->getRequest(); $this->opmlExporter = new OPMLExporter(); $this->controller = new ExportController($this->api, $this->request, $this->feedBusinessLayer, $this->folderBusinessLayer, diff --git a/tests/unit/controller/FeedControllerTest.php b/tests/unit/controller/FeedControllerTest.php index aa6756e99..899cebfc0 100644 --- a/tests/unit/controller/FeedControllerTest.php +++ b/tests/unit/controller/FeedControllerTest.php @@ -25,13 +25,11 @@ namespace OCA\News\Controller; -use \OCA\AppFramework\Http\Request; -use \OCA\AppFramework\Http\JSONResponse; -use \OCA\AppFramework\Http\Http; -use \OCA\AppFramework\Utility\ControllerTestUtility; -use \OCA\AppFramework\Db\DoesNotExistException; -use \OCA\AppFramework\Db\MultipleObjectsReturnedException; +use \OCP\IRequest; +use \OCP\AppFramework\Http; +use \OCP\AppFramework\Http\JSONResponse; +use \OCA\News\Utility\ControllerTestUtility; use \OCA\News\Db\Feed; use \OCA\News\Db\FeedType; use \OCA\News\BusinessLayer\BusinessLayerException; @@ -64,7 +62,7 @@ class FeedControllerTest extends ControllerTestUtility { |