com phpruntests: Reworked checks for empty sections, an empty section at the end must be allowed: src/testcase/preconditions/rtHasNoEmptySections.php
src/testcase/sections/outputsections/rtExpectHeadersSection.php
| From: | Zoe Slattery | Date: | Thu, 17 May 2012 16:32:57 +0000 |
| Subject: | com phpruntests: Reworked checks for empty sections, an empty section at the end must be allowed: src/testcase/preconditions/rtHasNoEmptySections.php src/testcase/sections/outputsections/rtExpectHeadersSection.php |
||
| Groups: | php.qa | ||
| Request: | Send a blank email to php-qa+get-66569@lists.php.net to get a copy of this message | ||
Commit: 537dfb7cc0f7521391ac6585a882ecf18b857ffb
Author: zoe slattery <zoe@php.net> Thu, 17 May 2012 17:32:57 +0100
Parents: a0186aee4d2207977f1a935022ad9c5727bf9556
Branches: master
Link: http://git.php.net/?p=phpruntests.git;a=commitdiff;h=537dfb7cc0f7521391ac6585a882ecf18b857ffb
Log:
Reworked checks for empty sections, an empty section at the end must be allowed
Changed paths:
M src/testcase/preconditions/rtHasNoEmptySections.php
M src/testcase/sections/outputsections/rtExpectHeadersSection.php
Diff:
diff --git a/src/testcase/preconditions/rtHasNoEmptySections.php
b/src/testcase/preconditions/rtHasNoEmptySections.php
index b5b9047..92d5e29 100644
--- a/src/testcase/preconditions/rtHasNoEmptySections.php
+++ b/src/testcase/preconditions/rtHasNoEmptySections.php
@@ -49,17 +49,8 @@ class rtHasNoEmptySections implements rtTestPreCondition
}
}
- //Catch an empty section, section header then blank line
- if($this->isSectionHeading($thisLine)) {
- if($nextLine == ""){
- return false;
- }
- }
-
- //catch an empty section, last line is a section header
- if($this->isSectionHeading($nextLine)) {
- return false;
- }
+ //This doesn't catch an empty EXPECT section at the end of the test
+ //This is deliberate. It's reasonable to have an empty EXPECT section while developing
the test
return true;
}
diff --git a/src/testcase/sections/outputsections/rtExpectHeadersSection.php
b/src/testcase/sections/outputsections/rtExpectHeadersSection.php
index 9bd07d2..faaf239 100644
--- a/src/testcase/sections/outputsections/rtExpectHeadersSection.php
+++ b/src/testcase/sections/outputsections/rtExpectHeadersSection.php
@@ -36,8 +36,14 @@ class rtExpectHeadersSection extends rtOutputSection
list($headerKey, $headerValue) = explode(':', $line, 2);
$this->outputHeaders[trim($headerKey)] = trim($headerValue);
}
- }
+ }
+ //Check for an empty section. Having an empty EXPECT setion at the end of a test is
allowed
+ //but the test should fail.
+ if(implode($this->sectionContents) == "") {
+ return false;
+ }
+
foreach($this->expectedPattern as $headerKey => $headerValue) {
if (!isset($this->outputHeaders[$headerKey]) || $this->outputHeaders[$headerKey]
!= $headerValue) {
return false;