summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2014-01-20 12:14:09 -0800
committerThomas Müller <thomas.mueller@tmit.eu>2014-01-20 12:14:09 -0800
commit0f794b6889d05508c86449dacdee3e05bd47d071 (patch)
tree46e085ffd3c57270f9d3904b1bc7c6d8ba099785 /lib
parent92d8db6f19971d2df3b229e8b12a35cac03607c3 (diff)
parent164915a3f8c420b4274ebf3841044f18ca7435a4 (diff)
downloadnextcloud-server-0f794b6889d05508c86449dacdee3e05bd47d071.tar.gz
nextcloud-server-0f794b6889d05508c86449dacdee3e05bd47d071.zip
Merge pull request #6820 from owncloud/phpunit-test-config
Load a separate config (if present) when running unit tests
Diffstat (limited to 'lib')
-rw-r--r--lib/base.php14
-rw-r--r--lib/private/config.php2
-rw-r--r--lib/private/legacy/config.php1
-rwxr-xr-xlib/private/util.php2
4 files changed, 14 insertions, 5 deletions
diff --git a/lib/base.php b/lib/base.php
index f30575c7b12..0597183adcf 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -57,6 +57,9 @@ class OC {
* web path in 'url'
*/
public static $APPSROOTS = array();
+
+ public static $configDir;
+
/*
* requested app
*/
@@ -100,6 +103,13 @@ class OC {
get_include_path()
);
+ if(defined('PHPUNIT_RUN') and PHPUNIT_RUN and is_dir(OC::$SERVERROOT . '/tests/config/')) {
+ self::$configDir = OC::$SERVERROOT . '/tests/config/';
+ } else {
+ self::$configDir = OC::$SERVERROOT . '/config/';
+ }
+ OC_Config::$object = new \OC\Config(self::$configDir);
+
OC::$SUBURI = str_replace("\\", "/", substr(realpath($_SERVER["SCRIPT_FILENAME"]), strlen(OC::$SERVERROOT)));
$scriptName = OC_Request::scriptName();
if (substr($scriptName, -1) == '/') {
@@ -175,8 +185,8 @@ class OC {
}
public static function checkConfig() {
- if (file_exists(OC::$SERVERROOT . "/config/config.php")
- and !is_writable(OC::$SERVERROOT . "/config/config.php")
+ if (file_exists(self::$configDir . "/config.php")
+ and !is_writable(self::$configDir . "/config.php")
) {
$defaults = new OC_Defaults();
if (self::$CLI) {
diff --git a/lib/private/config.php b/lib/private/config.php
index caf7b1d7066..8a9d5ca6158 100644
--- a/lib/private/config.php
+++ b/lib/private/config.php
@@ -50,7 +50,7 @@ class Config {
protected $debugMode;
/**
- * @param $configDir path to the config dir, needs to end with '/'
+ * @param string $configDir path to the config dir, needs to end with '/'
*/
public function __construct($configDir) {
$this->configDir = $configDir;
diff --git a/lib/private/legacy/config.php b/lib/private/legacy/config.php
index c457979113e..ab67c8d3020 100644
--- a/lib/private/legacy/config.php
+++ b/lib/private/legacy/config.php
@@ -38,7 +38,6 @@
* This class is responsible for reading and writing config.php, the very basic
* configuration file of ownCloud.
*/
-OC_Config::$object = new \OC\Config(OC::$SERVERROOT.'/config/');
class OC_Config {
/**
diff --git a/lib/private/util.php b/lib/private/util.php
index b8d2da8a072..72afa6f9478 100755
--- a/lib/private/util.php
+++ b/lib/private/util.php
@@ -312,7 +312,7 @@ class OC_Util {
.'" target="_blank">giving the webserver write access to the root directory</a>.';
// Check if config folder is writable.
- if(!is_writable(OC::$SERVERROOT."/config/") or !is_readable(OC::$SERVERROOT."/config/")) {
+ if(!is_writable(OC::$configDir) or !is_readable(OC::$configDir)) {
$errors[] = array(
'error' => "Can't write into config directory",
'hint' => 'This can usually be fixed by '