aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2014-07-01 20:39:13 +0200
committerVincent Petry <pvince81@owncloud.com>2014-07-01 20:39:13 +0200
commit3d921ed3c35cba877015062fef27f2ad83717e7e (patch)
tree4d228a4d434c92454c598123f96ba41bafd4be90 /tests
parent19a6dc5420d3a27c50590b2f060700edff2ef73e (diff)
parent7c174520289dc5337dda1d32352e7542cb329670 (diff)
downloadnextcloud-server-3d921ed3c35cba877015062fef27f2ad83717e7e.tar.gz
nextcloud-server-3d921ed3c35cba877015062fef27f2ad83717e7e.zip
Merge pull request #9334 from owncloud/defaultappfix
Default app fix
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/util.php68
1 files changed, 68 insertions, 0 deletions
diff --git a/tests/lib/util.php b/tests/lib/util.php
index aaa47f033de..c2bb99c3b2e 100644
--- a/tests/lib/util.php
+++ b/tests/lib/util.php
@@ -290,4 +290,72 @@ class Test_Util extends PHPUnit_Framework_TestCase {
array(array('g1', 'g2', 'g3'), array('g1', 'g2'), array('g1', 'g2', 'g3'), true),
);
}
+
+ /**
+ * Test default apps
+ *
+ * @dataProvider defaultAppsProvider
+ */
+ function testDefaultApps($defaultAppConfig, $expectedPath, $enabledApps) {
+ $oldDefaultApps = \OCP\Config::getSystemValue('core', 'defaultapp', '');
+ // CLI is doing messy stuff with the webroot, so need to work it around
+ $oldWebRoot = \OC::$WEBROOT;
+ \OC::$WEBROOT = '';
+
+ Dummy_OC_App::setEnabledApps($enabledApps);
+ \OCP\Config::setSystemValue('defaultapp', $defaultAppConfig);
+ $this->assertEquals('http://localhost/' . $expectedPath, \OC_Util::getDefaultPageUrl());
+
+ // restore old state
+ \OC::$WEBROOT = $oldWebRoot;
+ Dummy_OC_App::restore();
+ \OCP\Config::setSystemValue('defaultapp', $oldDefaultApps);
+ }
+
+ function defaultAppsProvider() {
+ return array(
+ // none specified, default to files
+ array(
+ '',
+ 'index.php/apps/files/',
+ array('files'),
+ ),
+ // unexisting or inaccessible app specified, default to files
+ array(
+ 'unexist',
+ 'index.php/apps/files/',
+ array('files'),
+ ),
+ // non-standard app
+ array(
+ 'calendar',
+ 'index.php/apps/calendar/',
+ array('files', 'calendar'),
+ ),
+ // non-standard app with fallback
+ array(
+ 'contacts,calendar',
+ 'index.php/apps/calendar/',
+ array('files', 'calendar'),
+ ),
+ );
+ }
+
+}
+
+/**
+ * Dummy OC Apps class to make it possible to override
+ * enabled apps
+ */
+class Dummy_OC_App extends OC_App {
+ private static $enabledAppsCacheBackup;
+
+ public static function setEnabledApps($enabledApps) {
+ self::$enabledAppsCacheBackup = self::$enabledAppsCache;
+ self::$enabledAppsCache = $enabledApps;
+ }
+
+ public static function restore() {
+ self::$enabledAppsCache = self::$enabledAppsCacheBackup;
+ }
}