Permalink
Browse files

Reworked checks for empty sections, an empty section at the end must …

…be allowed
  • Loading branch information...
zoe slattery
zoe slattery committed May 17, 2012
1 parent a0186ae commit 537dfb7cc0f7521391ac6585a882ecf18b857ffb
@@ -49,17 +49,8 @@ public function isMet(array $testContents, array $sectionHeaders)
}
}
- //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;
}
@@ -36,8 +36,14 @@ public function compare($testHeaders)
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;

0 comments on commit 537dfb7

Please sign in to comment.