Permalink
Browse files

Fixed has<Name> methods.

  • Loading branch information...
1 parent 96b6127 commit 98571321d935d97012eba78b2c5a5ffd78711f8f Stefan Priebsch committed Oct 9, 2009
Showing with 18 additions and 2 deletions.
  1. +8 −0 DocBlock.php
  2. +10 −2 DocBlockTest.php
View
@@ -51,6 +51,10 @@ class DocBlock
protected function preProcess($docblock)
{
+ if ($docblock == '') {
+ throw new RuntimeException('Empty docblock');
+ }
+
// normalize line endings
$docblock = str_replace("\r\n", "\n", $docblock);
$docblock = str_replace("\r", "\n", $docblock);
@@ -168,6 +172,10 @@ public function parse($docblock)
$this->longDescription = trim($this->longDescription);
+ if ($this->isLastLine($lineNumber)) {
+ return;
+ }
+
// skip blank lines below long description
$lineNumber = $this->skipEmptyLines($lineNumber);
}
View
@@ -55,6 +55,14 @@ protected function tearDown()
unset($this->docBlock);
}
+ /**
+ * @expectedException RuntimeException
+ */
+ public function testThrowsExceptionWhenDocBlockIsEmpty()
+ {
+ $this->docBlock->parse('');
+ }
+
public function testGetShortDescription()
{
$this->docBlock->parse(file_get_contents(__DIR__ . '/_testdata/docblock'));
@@ -163,10 +171,10 @@ public function testGetDeprecated()
/**
* Make sure that has<Name> returns false on no @<Name>.
- * Since has<Name> calls map to generic method hasTag(),
+ * Since has<Name> calls map to generic method call hasTag(<name>),
* we only need to test one arbitrary has call.
*/
- public function testHasGlobalInitiallyReturnsFalse()
+ public function testHasReturnsFalseWhenTagDoesNotExist()
{
$this->docBlock->parse(file_get_contents(__DIR__ . '/_testdata/empty'));
$this->assertFalse($this->docBlock->hasGlobal());

0 comments on commit 9857132

Please sign in to comment.