diff options
Diffstat (limited to 'tests/lib/app.php')
-rw-r--r-- | tests/lib/app.php | 48 |
1 files changed, 14 insertions, 34 deletions
diff --git a/tests/lib/app.php b/tests/lib/app.php index 0c0eb28b3ba..86a407c1a95 100644 --- a/tests/lib/app.php +++ b/tests/lib/app.php @@ -1,4 +1,5 @@ <?php + /** * Copyright (c) 2012 Bernhard Posselt <dev@bernhard-posselt.com> * Copyright (c) 2014 Vincent Petry <pvince81@owncloud.com> @@ -6,11 +7,8 @@ * later. * See the COPYING-README file. */ - class Test_App extends \Test\TestCase { - private $oldAppConfigService; - const TEST_USER1 = 'user1'; const TEST_USER2 = 'user2'; const TEST_USER3 = 'user3'; @@ -398,10 +396,9 @@ class Test_App extends \Test\TestCase { 'appforgroup12' => '["group2","group1"]', ) ) - ); + ); $apps = \OC_App::getEnabledApps(true, $forceAll); - $this->assertEquals($expectedApps, $apps); $this->restoreAppConfig(); \OC_User::setUserId(null); @@ -412,6 +409,8 @@ class Test_App extends \Test\TestCase { $group1->delete(); $group2->delete(); + + $this->assertEquals($expectedApps, $apps); } /** @@ -432,7 +431,7 @@ class Test_App extends \Test\TestCase { 'app2' => 'no', ) ) - ); + ); $apps = \OC_App::getEnabledApps(true); $this->assertEquals(array('files', 'app3'), $apps); @@ -447,30 +446,6 @@ class Test_App extends \Test\TestCase { $user1->delete(); } - /** - * Tests that the apps list is re-requested (not cached) when - * no user is set. - */ - public function testEnabledAppsNoCache() { - $this->setupAppConfigMock()->expects($this->exactly(2)) - ->method('getValues') - ->will($this->returnValue( - array( - 'app3' => 'yes', - 'app2' => 'no', - ) - ) - ); - - $apps = \OC_App::getEnabledApps(true); - $this->assertEquals(array('files', 'app3'), $apps); - - // mock should be called again here - $apps = \OC_App::getEnabledApps(false); - $this->assertEquals(array('files', 'app3'), $apps); - - $this->restoreAppConfig(); - } private function setupAppConfigMock() { $appConfig = $this->getMock( @@ -487,22 +462,27 @@ class Test_App extends \Test\TestCase { /** * Register an app config mock for testing purposes. + * * @param $appConfig app config mock */ private function registerAppConfig($appConfig) { - $this->oldAppConfigService = \OC::$server->query('AppConfig'); \OC::$server->registerService('AppConfig', function ($c) use ($appConfig) { return $appConfig; }); + \OC::$server->registerService('AppManager', function (\OC\Server $c) use ($appConfig) { + return new \OC\App\AppManager($c->getUserSession(), $appConfig, $c->getGroupManager()); + }); } /** * Restore the original app config service. */ private function restoreAppConfig() { - $oldService = $this->oldAppConfigService; - \OC::$server->registerService('AppConfig', function ($c) use ($oldService){ - return $oldService; + \OC::$server->registerService('AppConfig', function ($c) { + return new \OC\AppConfig(\OC_DB::getConnection()); + }); + \OC::$server->registerService('AppManager', function (\OC\Server $c) { + return new \OC\App\AppManager($c->getUserSession(), $c->getAppConfig(), $c->getGroupManager()); }); // Remove the cache of the mocked apps list with a forceRefresh |