src/php

Thomas Brüderli bruederli at kolabsys.com
Wed Jan 30 16:40:16 CET 2013


 src/php/test.php |   19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

New commits:
commit f359eca2f4bbca80ba035f5f7e9b1fa0737099b4
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date:   Wed Jan 30 16:12:48 2013 +0100

    Add exit status to bingings test script

diff --git a/src/php/test.php b/src/php/test.php
index 207ccff..3e4f28f 100755
--- a/src/php/test.php
+++ b/src/php/test.php
@@ -1,14 +1,23 @@
 <?php
-//run using "php -d enable_dl=On -d extension=./kolabformat.so  test.php"
+//run using "php -d enable_dl=On -d extension=./kolabformat.so test.php [--verbose]"
 
 include("kolabformat.php");
 
+/////// Basic unit test facilities
+
+$errors = 0;
+$verbose = preg_match('/\s(--verbose|-v)\b/', join(' ', $_SERVER['argv']));
+
 function assertequal($got, $expect, $name) {
+	global $verbose, $errors;
+
 	if ($got == $expect) {
-		print "OK - $name\n";
+		if ($verbose)
+			print "OK - $name\n";
 		return true;
 	}
 	else {
+		$errors++;
 		print "FAIL - $name\n";
 		print "-- Expected " . var_export($expect, true) . ", got " . var_export($got, true) . " --\n";
 		return false;
@@ -31,6 +40,7 @@ function assertfalse($arg, $name) {
 	return assertequal($arg, false, $name);
 }
 
+// utility to quickly convert PHP arrays into a vector
 function array2vector($arr) {
 	$vec = new vectors;
 	foreach ((array)$arr as $val)
@@ -217,7 +227,6 @@ $c3 = kolabformat::readConfiguration($xml, false);
 
 asserttrue($c2->uid() != $c3->uid(), "Generate different UIDs for configuration objects");
 
-?>
-
-
+// terminate with error status
+exit($errors);
 





More information about the commits mailing list