Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

updating to make HelperArguments and HelperConfig handle some of the …

…configuration basics. A sample config ini file is also included
  • Loading branch information...
commit fb232e10ec000ed72ea2c8b2d916f058c30c2a75 1 parent d86489d
Chris Cornutt authored
2  config.ini.dist
View
@@ -0,0 +1,2 @@
+[tests]
+directory = /www/htdocs/frisk/tests
3  frisk
View
@@ -28,9 +28,10 @@ echo "Start!\n\n";
$runner = new Runner();
try{
HelperArguments::execute($_SERVER['argv']);
+ HelperConfig::execute(null);
$runner->execute();
echo "=====================\n";
- echo 'ending status: '; print_r($runner->testResults);
+ //echo 'ending status: '; print_r($runner->testResults);
}catch(Exception $e){
echo $e->getMessage();
}
2  lib/Helper/HelperArguments.php
View
@@ -67,7 +67,7 @@ public static function isArgument($name)
*/
public static function getArgument($name)
{
- return (isset(self::$currentArguments)) ? self::$currentArguments : null;
+ return (isset(self::$currentArguments[$name])) ? self::$currentArguments[$name] : null;
}
}
26 lib/Helper/HelperConfig.php
View
@@ -9,17 +9,33 @@ class HelperConfig extends Helper
{
/**
* Current configuration container
+ * Sets up some defaults
*/
- static $currentConfig = array();
+ static $currentConfig = array(
+ 'tests_directory' => './tests'
+ );
- public function execute()
+ public function execute($optionalConfig)
{
// if the "config" value of the arguments is set, look for that file....
- if($configFile=HelperArguments::get('config')){
+ if($configFile=HelperArguments::getArgument('config')){
+ self::loadConfig($configFile);
+ }
+ }
+
+ private function loadConfig($configFilePath)
+ {
+ if(is_file($configFilePath)){
+ $configSettings = parse_ini_file($configFilePath,true);
+ foreach($configSettings as $sectionName => $sectionValue){
+ foreach($sectionValue as $settingName => $settingValue){
+ $configName = $sectionName.'_'.$settingName;
+ HelperConfig::setConfigValue($configName,$settingValue);
+ }
+ }
}else{
- // load in default settings
-
+ throw new Exception(get_class().': Config file not found!');
}
}
2  lib/Runner.php
View
@@ -8,7 +8,7 @@ class Runner
public $testResults = array();
public function __construct(){
- $this->testsDir=__DIR__.'/../tests';
+ $this->testsDir = HelperConfig::getConfigValue('tests_directory');
}
public function execute($tests=null)
Please sign in to comment.
Something went wrong with that request. Please try again.