]> source.dussan.org Git - nextcloud-server.git/commitdiff
Hanlde Core and Settings app in AppFramework 774/head
authorRoeland Jago Douma <roeland@famdouma.nl>
Mon, 8 Aug 2016 18:38:10 +0000 (20:38 +0200)
committerRoeland Jago Douma <roeland@famdouma.nl>
Mon, 8 Aug 2016 18:48:16 +0000 (20:48 +0200)
'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.

lib/private/AppFramework/App.php
tests/lib/AppFramework/AppTest.php

index 01844e4c2d54b7ae8b26c99416451c4d7e14e3f4..c7670953b4e6073754948db1a998f5785a90c5fb 100644 (file)
@@ -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);
                }
index 7288e686d524016563639a4b7d971c76c5603d67..92ebd1f81e7a5de563448e18120261daefc6c33d 100644 (file)
@@ -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);
+       }
+
 }