Allow the configuration file to be defined by a PHP constant for phpunit
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1599 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
20
config.php
20
config.php
@@ -20,6 +20,14 @@ class config
|
||||
/** Use the .php to protect the informations */
|
||||
public $confFile = "./datas/configuration.php";
|
||||
|
||||
/** The constructor can update the confFile variable if it is defined in a
|
||||
constant */
|
||||
public function __construct ()
|
||||
{
|
||||
if (defined("CONFIGFILE"))
|
||||
$this->confFile = CONFIGFILE;
|
||||
}
|
||||
|
||||
/** List all the parameters configurable in the software */
|
||||
public function params ()
|
||||
{
|
||||
@@ -40,9 +48,13 @@ class config
|
||||
"<?php\r\n\$conf = array ();\r\n")
|
||||
=== FALSE)
|
||||
throw new Exception (sprintf (
|
||||
"No configuration file '%s' available and it can't be created",
|
||||
$this->confFile));
|
||||
_("No configuration file '%s' available and it can't be created"),
|
||||
$this->confFile));
|
||||
}
|
||||
elseif (! is_readable ($this->confFile))
|
||||
throw new Exception (sprintf (
|
||||
_("The configuration file '%s' is not readable"),
|
||||
$this->confFile));
|
||||
$conf = array ();
|
||||
$rc = include ($this->confFile);
|
||||
if ($rc !== 1)
|
||||
@@ -69,6 +81,10 @@ class config
|
||||
"No configuration file '%s' available and it can't be created",
|
||||
$this->confFile));
|
||||
}
|
||||
elseif (! is_readable ($this->confFile))
|
||||
throw new Exception (sprintf (
|
||||
_("The configuration file '%s' is not readable"),
|
||||
$this->confFile));
|
||||
if (!is_writeable ($this->confFile))
|
||||
throw new Exception (sprintf (
|
||||
"Configuration file '%s' is write protected",
|
||||
|
||||
Reference in New Issue
Block a user