From b9f3136f3a7564b983aef6564f9c7488d5b2b25b Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Sun, 20 Apr 2014 12:14:42 +0200 Subject: get rid of unneeded settings core class and inject it from the core container --- tests/unit/controller/ApiControllerTest.php | 5 +++-- tests/unit/controller/FeedControllerTest.php | 18 ++++++++++------- tests/unit/controller/ItemControllerTest.php | 30 ++++++++++++++++++---------- tests/unit/controller/PageControllerTest.php | 30 ++++++++++++++++++---------- tests/unit/db/MapperFactoryTest.php | 2 +- 5 files changed, 55 insertions(+), 30 deletions(-) (limited to 'tests/unit') diff --git a/tests/unit/controller/ApiControllerTest.php b/tests/unit/controller/ApiControllerTest.php index 79a7d02e9..8975819ea 100644 --- a/tests/unit/controller/ApiControllerTest.php +++ b/tests/unit/controller/ApiControllerTest.php @@ -33,7 +33,7 @@ class ApiControllerTest extends ControllerTestUtility { protected function setUp() { $this->appName = 'news'; $this->settings = $this->getMockBuilder( - '\OCA\News\Core\Settings') + '\OCP\IConfig') ->disableOriginalConstructor() ->getMock(); $this->request = $this->getMockBuilder( @@ -71,7 +71,8 @@ class ApiControllerTest extends ControllerTestUtility { public function testGetVersion(){ $this->settings->expects($this->once()) ->method('getAppValue') - ->with($this->equalTo('installed_version')) + ->with($this->equalTo($this->appName), + $this->equalTo('installed_version')) ->will($this->returnValue('1.0')); $response = $this->newsAPI->version(); diff --git a/tests/unit/controller/FeedControllerTest.php b/tests/unit/controller/FeedControllerTest.php index f25d4beed..a8309b41c 100644 --- a/tests/unit/controller/FeedControllerTest.php +++ b/tests/unit/controller/FeedControllerTest.php @@ -44,7 +44,7 @@ class FeedControllerTest extends ControllerTestUtility { $this->appName = 'news'; $this->user = 'jack'; $this->settings = $this->getMockBuilder( - '\OCA\News\Core\Settings') + '\OCP\IConfig') ->disableOriginalConstructor() ->getMock(); $this->itemBusinessLayer = $this->getMockBuilder('\OCA\News\BusinessLayer\ItemBusinessLayer') @@ -61,8 +61,8 @@ class FeedControllerTest extends ControllerTestUtility { $this->folderBusinessLayer, $this->feedBusinessLayer, $this->itemBusinessLayer, - $this->user, - $this->settings); + $this->settings, + $this->user); } private function assertFeedControllerAnnotations($methodName){ @@ -82,8 +82,8 @@ class FeedControllerTest extends ControllerTestUtility { $this->folderBusinessLayer, $this->feedBusinessLayer, $this->itemBusinessLayer, - $this->user, - $this->settings); + $this->settings, + $this->user); } @@ -189,11 +189,15 @@ class FeedControllerTest extends ControllerTestUtility { private function activeInitMocks($id, $type){ $this->settings->expects($this->at(0)) ->method('getUserValue') - ->with($this->equalTo('lastViewedFeedId')) + ->with($this->equalTo($this->user), + $this->equalTo($this->appName), + $this->equalTo('lastViewedFeedId')) ->will($this->returnValue($id)); $this->settings->expects($this->at(1)) ->method('getUserValue') - ->with($this->equalTo('lastViewedFeedType')) + ->with($this->equalTo($this->user), + $this->equalTo($this->appName), + $this->equalTo('lastViewedFeedType')) ->will($this->returnValue($type)); } diff --git a/tests/unit/controller/ItemControllerTest.php b/tests/unit/controller/ItemControllerTest.php index c28eac9fa..6bc5595d8 100644 --- a/tests/unit/controller/ItemControllerTest.php +++ b/tests/unit/controller/ItemControllerTest.php @@ -44,7 +44,7 @@ class ItemControllerTest extends ControllerTestUtility { $this->appName = 'news'; $this->user = 'jackob'; $this->settings = $this->getMockBuilder( - '\OCA\News\Core\Settings') + '\OCP\IConfig') ->disableOriginalConstructor() ->getMock(); $this->itemBusinessLayer = @@ -57,8 +57,8 @@ class ItemControllerTest extends ControllerTestUtility { ->getMock(); $this->request = $this->getRequest(); $this->controller = new ItemController($this->appName, $this->request, - $this->feedBusinessLayer, $this->itemBusinessLayer, $this->user, - $this->settings); + $this->feedBusinessLayer, $this->itemBusinessLayer, $this->settings, + $this->user); $this->newestItemId = 12312; } @@ -70,8 +70,8 @@ class ItemControllerTest extends ControllerTestUtility { $request = $this->getRequest($post); return new ItemController($this->appName, $request, - $this->feedBusinessLayer, $this->itemBusinessLayer, $this->user, - $this->settings); + $this->feedBusinessLayer, $this->itemBusinessLayer, $this->settings, + $this->user); } @@ -297,15 +297,21 @@ class ItemControllerTest extends ControllerTestUtility { private function itemsApiExpects($id, $type){ $this->settings->expects($this->once()) ->method('getUserValue') - ->with($this->equalTo('showAll')) + ->with($this->equalTo($this->user), + $this->equalTo($this->appName), + $this->equalTo('showAll')) ->will($this->returnValue('1')); $this->settings->expects($this->at(1)) ->method('setUserValue') - ->with($this->equalTo('lastViewedFeedId'), + ->with($this->equalTo($this->user), + $this->equalTo($this->appName), + $this->equalTo('lastViewedFeedId'), $this->equalTo($id)); $this->settings->expects($this->at(2)) ->method('setUserValue') - ->with($this->equalTo('lastViewedFeedType'), + ->with($this->equalTo($this->user), + $this->equalTo($this->appName), + $this->equalTo('lastViewedFeedType'), $this->equalTo($type)); } @@ -434,7 +440,9 @@ class ItemControllerTest extends ControllerTestUtility { $this->settings->expects($this->once()) ->method('getUserValue') - ->with($this->equalTo('showAll')) + ->with($this->equalTo($this->user), + $this->equalTo($this->appName), + $this->equalTo('showAll')) ->will($this->returnValue('1')); $this->feedBusinessLayer->expects($this->once()) @@ -479,7 +487,9 @@ class ItemControllerTest extends ControllerTestUtility { $this->settings->expects($this->once()) ->method('getUserValue') - ->with($this->equalTo('showAll')) + ->with($this->equalTo($this->user), + $this->equalTo($this->appName), + $this->equalTo('showAll')) ->will($this->returnValue('1')); $this->itemBusinessLayer->expects($this->once()) diff --git a/tests/unit/controller/PageControllerTest.php b/tests/unit/controller/PageControllerTest.php index 898226361..49e155bd0 100644 --- a/tests/unit/controller/PageControllerTest.php +++ b/tests/unit/controller/PageControllerTest.php @@ -37,15 +37,15 @@ class PageControllerTest extends ControllerTestUtility { */ public function setUp(){ $this->appName = 'news'; + $this->user = 'becka'; $this->l10n = $this->getMock('L10N', array('findLanguage')); $this->settings = $this->getMockBuilder( - '\OCA\News\Core\Settings') + '\OCP\IConfig') ->disableOriginalConstructor() ->getMock(); $this->request = $this->getRequest(); $this->controller = new PageController($this->appName, $this->request, - $this->settings, $this->l10n); - $this->user = 'becka'; + $this->settings, $this->l10n, $this->user); } @@ -83,11 +83,15 @@ class PageControllerTest extends ControllerTestUtility { ->will($this->returnValue('de')); $this->settings->expects($this->at(0)) ->method('getUserValue') - ->with($this->equalTo('showAll')) + ->with($this->equalTo($this->user), + $this->equalTo($this->appName), + $this->equalTo('showAll')) ->will($this->returnValue('1')); $this->settings->expects($this->at(1)) ->method('getUserValue') - ->with($this->equalTo('compact')) + ->with($this->equalTo($this->user), + $this->equalTo($this->appName), + $this->equalTo('compact')) ->will($this->returnValue('1')); $response = $this->controller->settings(); @@ -102,15 +106,19 @@ class PageControllerTest extends ControllerTestUtility { 'compact' => true ))); $this->controller = new PageController($this->appName, $request, - $this->settings, $this->l10n); + $this->settings, $this->l10n, $this->user); $this->settings->expects($this->at(0)) ->method('setUserValue') - ->with($this->equalTo('showAll'), + ->with($this->equalTo($this->user), + $this->equalTo($this->appName), + $this->equalTo('showAll'), $this->equalTo(true)); $this->settings->expects($this->at(1)) ->method('setUserValue') - ->with($this->equalTo('compact'), + ->with($this->equalTo($this->user), + $this->equalTo($this->appName), + $this->equalTo('compact'), $this->equalTo(true)); $response = $this->controller->updateSettings(); @@ -123,11 +131,13 @@ class PageControllerTest extends ControllerTestUtility { 'showAll' => true ))); $this->controller = new PageController($this->appName, $request, - $this->settings, $this->l10n); + $this->settings, $this->l10n, $this->user); $this->settings->expects($this->once()) ->method('setUserValue') - ->with($this->equalTo('showAll'), + ->with($this->equalTo($this->user), + $this->equalTo($this->appName), + $this->equalTo('showAll'), $this->equalTo(true)); $response = $this->controller->updateSettings(); diff --git a/tests/unit/db/MapperFactoryTest.php b/tests/unit/db/MapperFactoryTest.php index 3e82c1555..a83eca8ec 100644 --- a/tests/unit/db/MapperFactoryTest.php +++ b/tests/unit/db/MapperFactoryTest.php @@ -23,7 +23,7 @@ class MapperFactoryTest extends \PHPUnit_Framework_TestCase { private $settings; public function setUp() { - $this->settings = $this->getMockBuilder('\OCA\News\Core\Settings') + $this->settings = $this->getMockBuilder('\OCP\IConfig') ->disableOriginalConstructor() ->getMock(); $this->db = $this->getMockBuilder('\OCA\News\Core\Db') -- cgit v1.2.3