]> source.dussan.org Git - nextcloud-server.git/commitdiff
Remove OC_Config from app management template
authorMorris Jobke <hey@morrisjobke.de>
Wed, 2 Dec 2015 13:35:38 +0000 (14:35 +0100)
committerMorris Jobke <hey@morrisjobke.de>
Wed, 2 Dec 2015 13:35:38 +0000 (14:35 +0100)
* add unit test for this case

settings/controller/appsettingscontroller.php
settings/templates/apps.php
tests/settings/controller/AppSettingsControllerTest.php

index bde00df062fc7f35fcd0ef413470fe2fea4fdc5f..d0e465bfa9c14e465b9b56bd4e674fd6cc174ea1 100644 (file)
@@ -132,6 +132,7 @@ class AppSettingsController extends Controller {
                $params = [];
                $params['experimentalEnabled'] = $this->config->getSystemValue('appstore.experimental.enabled', false);
                $params['category'] = $category;
+               $params['appstoreEnabled'] = $this->config->getSystemValue('appstoreenabled', true) === true;
                $this->navigationManager->setActiveEntry('core_apps');
 
                $templateResponse = new TemplateResponse($this->appName, 'apps', $params, 'user');
index 3168fd8beebbebe9b40a6bce4e86c633d0f095a6..7213d552c084758c2fcb9c1e24bb9b5fe49a7f55 100644 (file)
@@ -29,7 +29,7 @@ script(
        </li>
 {{/each}}
 
-<?php if(OC_Config::getValue('appstoreenabled', true) === true): ?>
+<?php if($_['appstoreEnabled']): ?>
        <li>
                <a class="app-external" target="_blank" href="https://owncloud.org/dev"><?php p($l->t('Developer documentation'));?> ↗</a>
        </li>
index 09595d056613d0f88d33e26b41b232f438435835..dba5728ca4b3a22f669ac1c2b6c5006f46d01034 100644 (file)
@@ -220,9 +220,14 @@ class AppSettingsControllerTest extends TestCase {
 
        public function testViewApps() {
                $this->config
-                       ->expects($this->once())
+                       ->expects($this->at(0))
                        ->method('getSystemValue')
                        ->with('appstore.experimental.enabled', false);
+               $this->config
+                       ->expects($this->at(1))
+                       ->method('getSystemValue')
+                       ->with('appstoreenabled', true)
+                       ->will($this->returnValue(true));
                $this->navigationManager
                        ->expects($this->once())
                        ->method('setActiveEntry')
@@ -231,7 +236,7 @@ class AppSettingsControllerTest extends TestCase {
                $policy = new ContentSecurityPolicy();
                $policy->addAllowedImageDomain('https://apps.owncloud.com');
 
-               $expected = new TemplateResponse('settings', 'apps', ['experimentalEnabled' => false, 'category' => 'enabled'], 'user');
+               $expected = new TemplateResponse('settings', 'apps', ['experimentalEnabled' => false, 'category' => 'enabled', 'appstoreEnabled' => true], 'user');
                $expected->setContentSecurityPolicy($policy);
 
                $this->assertEquals($expected, $this->appSettingsController->viewApps());
@@ -239,9 +244,14 @@ class AppSettingsControllerTest extends TestCase {
 
        public function testViewAppsNotEnabled() {
                $this->config
-                       ->expects($this->once())
+                       ->expects($this->at(0))
                        ->method('getSystemValue')
                        ->with('appstore.experimental.enabled', false);
+               $this->config
+                       ->expects($this->at(1))
+                       ->method('getSystemValue')
+                       ->with('appstoreenabled', true)
+                       ->will($this->returnValue(true));
                $this->navigationManager
                        ->expects($this->once())
                        ->method('setActiveEntry')
@@ -250,9 +260,33 @@ class AppSettingsControllerTest extends TestCase {
                $policy = new ContentSecurityPolicy();
                $policy->addAllowedImageDomain('https://apps.owncloud.com');
 
-               $expected = new TemplateResponse('settings', 'apps', ['experimentalEnabled' => false, 'category' => 'disabled'], 'user');
+               $expected = new TemplateResponse('settings', 'apps', ['experimentalEnabled' => false, 'category' => 'disabled', 'appstoreEnabled' => true], 'user');
                $expected->setContentSecurityPolicy($policy);
 
                $this->assertEquals($expected, $this->appSettingsController->viewApps('disabled'));
        }
+
+       public function testViewAppsAppstoreNotEnabled() {
+               $this->config
+                       ->expects($this->at(0))
+                       ->method('getSystemValue')
+                       ->with('appstore.experimental.enabled', false);
+               $this->config
+                       ->expects($this->at(1))
+                       ->method('getSystemValue')
+                       ->with('appstoreenabled', true)
+                       ->will($this->returnValue(false));
+               $this->navigationManager
+                       ->expects($this->once())
+                       ->method('setActiveEntry')
+                       ->with('core_apps');
+
+               $policy = new ContentSecurityPolicy();
+               $policy->addAllowedImageDomain('https://apps.owncloud.com');
+
+               $expected = new TemplateResponse('settings', 'apps', ['experimentalEnabled' => false, 'category' => 'enabled', 'appstoreEnabled' => false], 'user');
+               $expected->setContentSecurityPolicy($policy);
+
+               $this->assertEquals($expected, $this->appSettingsController->viewApps());
+       }
 }