From c3113206fc5a7da50a3dccd830ea3e18ca99bff5 Mon Sep 17 00:00:00 2001 From: Akademic Date: Mon, 28 Apr 2014 13:39:11 +0400 Subject: [PATCH] In test with type CEST we have several tests in one file. If one test in a file fails, all test must fail. --- App/Lib/Test.php | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/App/Lib/Test.php b/App/Lib/Test.php index dd7a8af..e55b630 100644 --- a/App/Lib/Test.php +++ b/App/Lib/Test.php @@ -82,7 +82,7 @@ class Test 'PASSED', // Functional & Acceptance Test 'OK \(' // Unit Test ), - 'failed' => 'FAILURES', + 'failed' => 'FAIL', ); /** @@ -275,14 +275,25 @@ public function getState() */ public function setLog($lines = array()) { + $has_fail = false; + $has_pass = false; foreach ($lines as $line) { - if ($this->checkLogForTestPass($line)) - $this->setPassed(); + if ($this->checkLogForTestPass($line)) { + $has_pass = true; + } + + if($this->checkLogForTestFail($line)) { + $has_fail = true; + } // Filter the line of any junk and add to the log. $this->log[] = $this->filterLog($line); } + + if( $has_pass && !$has_fail ) { + $this->setPassed(); + } } /** @@ -317,6 +328,18 @@ public function checkLogForTestPass($line) return count(preg_grep("/({$this->passed_regex})/", array($line))) > 0; } + /** + * Check if it contains any text that indiciates that the test has failed. + * + * @param string $line + * @return boolean + */ + public function checkLogForTestFail($line) + { + if(preg_match('/'.$this->responses['failed'].'/', $line)) return true; + return false; + } + /** * Reset a Test back to default. */