diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2016-08-08 20:38:10 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2016-08-08 20:48:16 +0200 |
commit | 0032a5c2d1e43e9b355b887f15e3caee17048d6e (patch) | |
tree | 53a59e7199677d22b7147ba16bbae90da393b5ef | |
parent | 679185028fea894fd4fe2183859610aa32228ae4 (diff) | |
download | nextcloud-server-0032a5c2d1e43e9b355b887f15e3caee17048d6e.tar.gz nextcloud-server-0032a5c2d1e43e9b355b887f15e3caee17048d6e.zip |
Hanlde Core and Settings app in AppFramework
'core' and 'settings' are just apps but we treat them slightly
different. Make sure that we construct the correct namespace so we can
actually do automatic AppFramework stuff.
-rw-r--r-- | lib/private/AppFramework/App.php | 8 | ||||
-rw-r--r-- | tests/lib/AppFramework/AppTest.php | 51 |
2 files changed, 58 insertions, 1 deletions
diff --git a/lib/private/AppFramework/App.php b/lib/private/AppFramework/App.php index 01844e4c2d5..c7670953b4e 100644 --- a/lib/private/AppFramework/App.php +++ b/lib/private/AppFramework/App.php @@ -93,7 +93,13 @@ class App { try { $controller = $container->query($controllerName); } catch(QueryException $e) { - $appNameSpace = self::buildAppNamespace($appName); + if ($appName === 'core') { + $appNameSpace = 'OC\\Core'; + } else if ($appName === 'settings') { + $appNameSpace = 'OC\\Settings'; + } else { + $appNameSpace = self::buildAppNamespace($appName); + } $controllerName = $appNameSpace . '\\Controller\\' . $controllerName; $controller = $container->query($controllerName); } diff --git a/tests/lib/AppFramework/AppTest.php b/tests/lib/AppFramework/AppTest.php index 7288e686d52..92ebd1f81e7 100644 --- a/tests/lib/AppFramework/AppTest.php +++ b/tests/lib/AppFramework/AppTest.php @@ -162,4 +162,55 @@ class AppTest extends \Test\TestCase { App::main($this->controllerName, $this->controllerMethod, $this->container, []); } + public function testCoreApp() { + $this->container['AppName'] = 'core'; + $this->container['OC\Core\Controller\Foo'] = $this->controller; + + $return = array(null, array(), array(), null, new Response()); + $this->dispatcher->expects($this->once()) + ->method('dispatch') + ->with($this->equalTo($this->controller), + $this->equalTo($this->controllerMethod)) + ->will($this->returnValue($return)); + + $this->io->expects($this->never()) + ->method('setOutput'); + + App::main('Foo', $this->controllerMethod, $this->container); + } + + public function testSettingsApp() { + $this->container['AppName'] = 'settings'; + $this->container['OC\Settings\Controller\Foo'] = $this->controller; + + $return = array(null, array(), array(), null, new Response()); + $this->dispatcher->expects($this->once()) + ->method('dispatch') + ->with($this->equalTo($this->controller), + $this->equalTo($this->controllerMethod)) + ->will($this->returnValue($return)); + + $this->io->expects($this->never()) + ->method('setOutput'); + + App::main('Foo', $this->controllerMethod, $this->container); + } + + public function testApp() { + $this->container['AppName'] = 'bar'; + $this->container['OCA\Bar\Controller\Foo'] = $this->controller; + + $return = array(null, array(), array(), null, new Response()); + $this->dispatcher->expects($this->once()) + ->method('dispatch') + ->with($this->equalTo($this->controller), + $this->equalTo($this->controllerMethod)) + ->will($this->returnValue($return)); + + $this->io->expects($this->never()) + ->method('setOutput'); + + App::main('Foo', $this->controllerMethod, $this->container); + } + } |