Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Made phing files match coding standards

  • Loading branch information...
commit 3b0c099795511189a176642b54c5bb8cc64e94c5 1 parent 81abbcf
Eric Barnes authored
Showing with 43 additions and 42 deletions.
  1. +1 −1  README.md
  2. +1 −1  phing/README.md
  3. +41 −40 phing/TestRunnerTask.php
2  README.md
View
@@ -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.
2  phing/README.md
View
@@ -7,7 +7,7 @@ Frank Hmeidan - <http://twitter.com/frankhmeidan>
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:
<target name="unit_test">
<taskdef classname="phing.tasks.ext.TestRunnerTask" name="unit-test" />
81 phing/TestRunnerTask.php
View
@@ -1,63 +1,64 @@
<?php
-
require_once "phing/Task.php";
-
/**
- *
* Runs the unit tests
- *
+ *
* @package phing.tasks.ext
*/
class TestRunnerTask extends Task {
protected $url = NULL;
-
-
+
public function init() { }
-
+
/**
* Invoking this task will cause the unit tests to be executed.
*/
- public function main() {
+ public function main()
+ {
if (empty($this->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;
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.