diff --git a/README.md b/README.md index 4499805..fedfad2 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ Once you have installed you can either run tests through the browser or via comm * Command Link - `$ php unit_test.php` * XML Results - `$ php unit_test_xml.php` -### NOTES: +## NOTES: Inside the "tests" directory I include two example test files. The test_users_model.php will not run on its own because your application would not include the same users model as the example file. It is supplied just as a guide. diff --git a/phing/README.md b/phing/README.md index 973047f..b2ace25 100644 --- a/phing/README.md +++ b/phing/README.md @@ -7,7 +7,7 @@ Frank Hmeidan - Place the TestRunnerTask.php file in the following location: "phing/tasks/ext/TestRunnerTask.php" -Next create this in your Phing build file: +Next create this in your Phing build file: diff --git a/phing/TestRunnerTask.php b/phing/TestRunnerTask.php index 532b7fa..e5889e9 100644 --- a/phing/TestRunnerTask.php +++ b/phing/TestRunnerTask.php @@ -1,63 +1,64 @@ url) || filter_var($this->url, FILTER_VALIDATE_URL) === FALSE) { - throw new BuildException('Invalid URL: You must specify a valid URL.'); - } - - echo "Running unit tests...\n"; - - $testResults = $this->doPOST($this->url, 'all', '1'); - - if ($testResults == NULL || $testResults == '' || !isset($testResults)){ - throw new BuildException('No results page returned from POST request on $url'); - } - - /* Check if there is the string 'FAILED' anywhere in the output - if not, we've succeeded. */ - if (strpos($testResults, 'FAILED') != FALSE){ - throw new BuildException("There were test case failures - build terminated."); - } else { - echo "\n ----- all tested PASSED ----- \n"; - } - - return; + throw new BuildException('Invalid URL: You must specify a valid URL.'); + } + + echo "Running unit tests...\n"; + + $testResults = $this->doPOST($this->url, 'all', '1'); + + if ($testResults == NULL || $testResults == '' || !isset($testResults)) + { + throw new BuildException('No results page returned from POST request on $url'); + } + + /* Check if there is the string 'FAILED' anywhere in the output - if not, we've succeeded. */ + if (strpos($testResults, 'FAILED') != FALSE) + { + throw new BuildException("There were test case failures - build terminated."); + } + else + { + echo "\n ----- all tested PASSED ----- \n"; + } + + return; } - public function setURL($url){ + public function setURL($url) + { $this->url = $url; } - function doPOST($url, $key, $value) { - + function doPOST($url, $key, $value) + { $context = stream_context_create(array( - 'http' => array( - 'method' => 'POST', - 'header' => "Content-type: application/x-www-form-urlencoded\r\n", - 'content' => http_build_query(array($key => $value)), - ))); - - $ret = file_get_contents($url, false, $context); - - return $ret; - } + 'http' => array( + 'method' => 'POST', + 'header' => "Content-type: application/x-www-form-urlencoded\r\n", + 'content' => http_build_query(array($key => $value)), + ))); + + $ret = file_get_contents($url, false, $context); + return $ret; + } }