[icinga-checkins] icinga.org: icinga-web/mhein/testing: * Fixes some errors in TestInit

git at icinga.org git at icinga.org
Tue Jun 7 13:15:45 CEST 2011


Module: icinga-web
Branch: mhein/testing
Commit: d4c7d729b8edb3fd3bb1f061e9a99e478375545a
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=d4c7d729b8edb3fd3bb1f061e9a99e478375545a

Author: Marius Hein <marius.hein at netways.de>
Date:   Tue Jun  7 13:05:23 2011 +0200

* Fixes some errors in TestInit

---

 configure                  |    4 ++--
 configure.ac               |    2 +-
 tests/phpunit/TestInit.php |   26 +++++++++++++++++++++++---
 3 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/configure b/configure
index 58104e7..44bd6c5 100755
--- a/configure
+++ b/configure
@@ -2618,7 +2618,7 @@ fi
 
 
 
-ac_config_files="$ac_config_files Makefile lib/Makefile pub/Makefile etc/Makefile bin/Makefile doc/Makefile app/Makefile etc/sitecfg/Makefile app/config/databases.xml app/config/icinga.xml app/config/settings.xml app/modules/Web/config/icinga-io.xml app/modules/AppKit/cache/Widgets/SquishLoader.xml etc/build.properties tests/php/test.properties etc/apache2/icinga-web.conf bin/clearcache.sh pub/.htaccess pub/soap/.htaccess"
+ac_config_files="$ac_config_files Makefile lib/Makefile pub/Makefile etc/Makefile bin/Makefile doc/Makefile app/Makefile etc/sitecfg/Makefile app/config/databases.xml app/config/icinga.xml app/config/settings.xml app/modules/Web/config/icinga-io.xml app/modules/AppKit/cache/Widgets/SquishLoader.xml etc/build.properties tests/phpunit/test.properties etc/apache2/icinga-web.conf bin/clearcache.sh pub/.htaccess pub/soap/.htaccess"
 
 
 cat >confcache <<\_ACEOF
@@ -3341,7 +3341,7 @@ do
     "app/modules/Web/config/icinga-io.xml") CONFIG_FILES="$CONFIG_FILES app/modules/Web/config/icinga-io.xml" ;;
     "app/modules/AppKit/cache/Widgets/SquishLoader.xml") CONFIG_FILES="$CONFIG_FILES app/modules/AppKit/cache/Widgets/SquishLoader.xml" ;;
     "etc/build.properties") CONFIG_FILES="$CONFIG_FILES etc/build.properties" ;;
-    "tests/php/test.properties") CONFIG_FILES="$CONFIG_FILES tests/php/test.properties" ;;
+    "tests/phpunit/test.properties") CONFIG_FILES="$CONFIG_FILES tests/phpunit/test.properties" ;;
     "etc/apache2/icinga-web.conf") CONFIG_FILES="$CONFIG_FILES etc/apache2/icinga-web.conf" ;;
     "bin/clearcache.sh") CONFIG_FILES="$CONFIG_FILES bin/clearcache.sh" ;;
     "pub/.htaccess") CONFIG_FILES="$CONFIG_FILES pub/.htaccess" ;;
diff --git a/configure.ac b/configure.ac
index dec535b..3ed6717 100755
--- a/configure.ac
+++ b/configure.ac
@@ -299,7 +299,7 @@ AC_CONFIG_FILES([
 	app/modules/Web/config/icinga-io.xml
 	app/modules/AppKit/cache/Widgets/SquishLoader.xml
 	etc/build.properties
-	tests/php/test.properties
+	tests/phpunit/test.properties
 	etc/apache2/icinga-web.conf
 	bin/clearcache.sh
 	pub/.htaccess
diff --git a/tests/phpunit/TestInit.php b/tests/phpunit/TestInit.php
index 7280de0..5f4b980 100755
--- a/tests/phpunit/TestInit.php
+++ b/tests/phpunit/TestInit.php
@@ -2,6 +2,8 @@
 
 class IcingaWebTestTool {
     
+    const PROPERTIES_FILE = "tests/phpunit/test.properties";
+    
     private static $path_test = null;
     private static $path_root = null;
     
@@ -21,9 +23,21 @@ class IcingaWebTestTool {
         return self::$path_test;
     }
     
+    /**
+     * Loads the ini file with test properties to make it
+     * project wide available for testing
+     * @throws Exception
+     * @return array Array of parsed properties
+     */
     private static function parseTestProperties() {
-        $file = self::getRootPath(). "/tests/php/test.properties";
-        return self::$properties = parse_ini_file($file);
+        $file = self::getRootPath(). '/'. self::PROPERTIES_FILE;
+        self::$properties = parse_ini_file($file);
+        
+        if (!is_array(self::$properties)) {
+            throw new Exception('Propertiesfile '. $file. ' not found!');
+        }
+        
+        return self::$properties;
     }
     
     public static function getProperties() {
@@ -45,7 +59,7 @@ class IcingaWebTestTool {
 	*   If phpUnit provides an assertInstanceOf class (>= v.3.5) this one will be used, 
 	*	otherwise it will be checked directly here. 
 	*	@param $expected 	The expected Instance
-	*	@paran $actual		The object to test
+	*	@param $actual		The object to test
 	*	@param $message		The message to return if assertion fails (optional)
 	*/
 	public static function assertInstanceOf($expected,$actual,$message = '') {
@@ -79,6 +93,12 @@ class IcingaWebTestTool {
 
 class IcingaWebTestBootstrap {
     
+    /**
+     * Starts an agavi context for testing purposes. This was bundled into the
+     * test bootstrap method to call this only once
+     * @param string $env	Name of the context
+     * @return AgaviContext	The created context
+     */
     public function bootstrapAgavi($env='testing') {
         
         require IcingaWebTestTool::getRootPath(). '/lib/agavi/src/agavi.php';





More information about the icinga-checkins mailing list