diff --git a/Tester/NetteTestCase.php b/Tester/NetteTestCase.php index a7954e33..df273166 100644 --- a/Tester/NetteTestCase.php +++ b/Tester/NetteTestCase.php @@ -66,23 +66,25 @@ public function run() { $this->execute(); $tests = 0; - $trim = isset($this->sections['expect']); // compare output - $output = self::normalize($this->output, $trim); - $expectedOutput = self::normalize($this->getExpectedOutput(), $trim); + $expectedOutput = $this->getExpectedOutput(); if ($expectedOutput !== NULL) { $tests++; + $trim = isset($this->sections['expect']); + $output = self::normalize($this->output, $trim); + $expectedOutput = self::normalize($expectedOutput, $trim); if (!$this->compare($output, $expectedOutput)) { throw new NetteTestCaseException("Output doesn't match."); } } // compare headers - $expectedHeaders = self::normalize($this->getExpectedHeaders(), TRUE); + $expectedHeaders = $this->getExpectedHeaders(); if ($expectedHeaders !== NULL) { $tests++; $headers = array_change_key_case(self::parseLines($this->headers, ':'), CASE_LOWER); + $expectedHeaders = self::normalize($expectedHeaders, TRUE); $expectedHeaders = array_change_key_case(self::parseLines($expectedHeaders, ':'), CASE_LOWER); foreach ($expectedHeaders as $name => $header) { if (!isset($headers[$name])) { @@ -229,7 +231,7 @@ public static function parseSections($testFile) $sections['options']['name'] = preg_match('#^\s*\*\s*TEST:(.*)#mi', $phpDoc, $matches) ? trim($matches[1]) : $testFile; // file parts - $tmp = preg_split('#^-{3,}([^ -]+)-{1,}(?:\r?\n|$)#m', $content, -1, PREG_SPLIT_DELIM_CAPTURE); + $tmp = preg_split('#^-{3,}([^\s-]+)-{1,}(?:\r?\n|$)#m', $content, -1, PREG_SPLIT_DELIM_CAPTURE); $i = 1; while (isset($tmp[$i])) { $sections[strtolower($tmp[$i])] = $tmp[$i+1]; diff --git a/Tester/RunTests.php b/Tester/RunTests.php index e0b30c34..dd7dd234 100644 --- a/Tester/RunTests.php +++ b/Tester/RunTests.php @@ -86,18 +86,17 @@ public function run() $count++; $testCase = new NetteTestCase($entry, $this->cmdLine); try { - echo '.'; $testCase->run(); + echo '.'; $passed[] = array($testCase->getName(), $entry); } catch (NetteTestCaseException $e) { echo 'F'; $failed[] = array($testCase->getName(), $entry, $e->getMessage()); - if ($testCase->getExpectedOutput() !== NULL) { - $this->log($entry, $testCase->getOutput(), self::OUTPUT); - $this->log($entry, $testCase->getExpectedOutput(), self::EXPECTED); - } + $this->log($entry, $testCase->getOutput(), self::OUTPUT); + $this->log($entry, $testCase->getExpectedOutput(), self::EXPECTED); + if ($testCase->getExpectedHeaders() !== NULL) { $this->log($entry, $testCase->getHeaders(), self::OUTPUT, self::HEADERS); $this->log($entry, $testCase->getExpectedHeaders(), self::EXPECTED, self::HEADERS); diff --git a/Tester/initialize.php b/Tester/initialize.php index 7972bde6..561db648 100644 --- a/Tester/initialize.php +++ b/Tester/initialize.php @@ -92,13 +92,25 @@ public static function purge($dir) /** - * Writes new heading. + * Writes new section. * @param string * @return void */ - public static function heading($heading) + public static function section($heading = NULL) { - echo "$heading\n" . str_repeat('-', strlen($heading)) . "\n\n"; + echo $heading ? "==> $heading\n\n" : "===\n\n"; + } + + + + /** + * Writes new message. + * @param string + * @return void + */ + public static function message($message) + { + echo "$message\n\n"; } diff --git a/tests/Test.dump().001.phpt b/tests/Test.dump().001.phpt index 8d069162..93568ddc 100644 --- a/tests/Test.dump().001.phpt +++ b/tests/Test.dump().001.phpt @@ -1,7 +1,7 @@ int(30) } -Section -------- +==> Section + +=== diff --git a/tests/Test.getSection().phpt b/tests/Test.getSection().phpt index 49c8e099..52007c6b 100644 --- a/tests/Test.getSection().phpt +++ b/tests/Test.getSection().phpt @@ -1,7 +1,7 @@ string(5) "Nette" "package" => string(10) "Nette\Test" "subpackage" => string(9) "UnitTests" - "name" => string(21) "Nette\Test::heading()" + "name" => string(24) "Nette\Test::getSection()" }