summaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2014-10-09 09:08:19 +0200
committerBernhard Posselt <dev@bernhard-posselt.com>2014-10-09 09:09:59 +0200
commit8462bed7820cecc23a0e0d64aa50db7be92272d9 (patch)
treed670947a499cd7f173ebb6c88b303aefc239b65a /config
parent900dbbb61e45ba6557db08ee33f6badbb8939efe (diff)
cleanup test method in appconfig class, add test for item serialization
Diffstat (limited to 'config')
-rw-r--r--config/appconfig.php56
1 files changed, 35 insertions, 21 deletions
diff --git a/config/appconfig.php b/config/appconfig.php
index 52e82dc25..3729e56b2 100644
--- a/config/appconfig.php
+++ b/config/appconfig.php
@@ -153,51 +153,65 @@ class AppConfig {
}
}
- private function testDatabaseDependencies($databases, $databaseType) {
- if(!in_array($databaseType, $databases)) {
+
+ private function testDatabaseDependencies() {
+ if(array_key_exists('databases', $this->config)) {
+ $databases = $this->config['databases'];
+ $databaseType = $this->databaseType;
+
+ if(!in_array($databaseType, $databases)) {
return 'Database ' . $databaseType . ' not supported.' .
'App is only compatible with ' .
implode(', ', $databases);
- } else {
- return '';
+ }
}
+ return '';
}
- /**
- * Validates all dependencies that the app has
- * @throws DependencyException if one version is not satisfied
- */
- public function testDependencies() {
- $msg = '';
-
- // test databases
- if(array_key_exists('databases', $this->config)) {
- $msg .= $this->testDatabaseDependencies(
- $this->config['databases'], $this->databaseType
- );
- }
- // test dependencies
+ private function testPHPDependencies() {
if(array_key_exists('dependencies', $this->config)) {
$deps = $this->config['dependencies'];
if (array_key_exists('php', $deps)) {
- $msg .= $this->requireVersion($this->phpVersion, $deps['php'],
+ return $this->requireVersion($this->phpVersion, $deps['php'],
'PHP');
}
+ }
+ return '';
+ }
+
+
+ private function testLibraryDependencies() {
+ if(array_key_exists('dependencies', $this->config)) {
+
+ $deps = $this->config['dependencies'];
+
if (array_key_exists('libs', $deps)) {
foreach ($deps['libs'] as $lib => $versions) {
if(array_key_exists($lib, $this->installedExtensions)) {
- $msg .= $this->requireVersion($this->installedExtensions[$lib],
+ return $this->requireVersion($this->installedExtensions[$lib],
$versions, 'PHP extension ' . $lib);
} else {
- $msg .= 'PHP extension ' . $lib . ' required but not installed';
+ return 'PHP extension ' . $lib . ' required but not installed';
}
}
}
}
+ return '';
+ }
+
+
+ /**
+ * Validates all dependencies that the app has
+ * @throws DependencyException if one version is not satisfied
+ */
+ public function testDependencies() {
+ $msg = $this->testDatabaseDependencies();
+ $msg .= $this->testPHPDependencies();
+ $msg .= $this->testLibraryDependencies();
if($msg !== '') {
throw new DependencyException($msg);