function get_shortdesc() {
if ( !preg_match( '|^([^@][^\n]+)\n*|', $this->docComment, $matches ) )
- return false;
+ return '';
return $matches[1];
}
if ( preg_match( '|^@' . $name . '\s+([a-z-_]+)|m', $this->docComment, $matches ) )
return $matches[1];
- return false;
+ return '';
}
function get_synopsis() {
if ( !preg_match( '|^@synopsis\s+(.+)|m', $this->docComment, $matches ) )
- return false;
+ return '';
return $matches[1];
}
class DocParserTests extends PHPUnit_Framework_TestCase {
+ function test_empty() {
+ $doc = new DocParser( '' );
+
+ $this->assertEquals( '', $doc->get_shortdesc() );
+ $this->assertEquals( '', $doc->get_longdesc() );
+ $this->assertEquals( '', $doc->get_synopsis() );
+ $this->assertEquals( '', $doc->get_tag('alias') );
+ }
+
function test_only_tags() {
$doc = new DocParser( <<<EOB
/**
EOB
);
- $this->assertFalse( $doc->get_shortdesc() );
- $this->assertFalse( $doc->get_longdesc() );
- $this->assertFalse( $doc->get_synopsis() );
- $this->assertFalse( $doc->get_tag('foo') );
+ $this->assertEquals( '', $doc->get_shortdesc() );
+ $this->assertEquals( '', $doc->get_longdesc() );
+ $this->assertEquals( '', $doc->get_synopsis() );
+ $this->assertEquals( '', $doc->get_tag('foo') );
$this->assertEquals( 'rock-on', $doc->get_tag('alias') );
}
);
$this->assertEquals( 'Rock and roll!', $doc->get_shortdesc() );
- $this->assertFalse( $doc->get_longdesc() );
- $this->assertFalse( $doc->get_synopsis() );
+ $this->assertEquals( '', $doc->get_longdesc() );
+ $this->assertEquals( '', $doc->get_synopsis() );
$this->assertEquals( 'rock-on', $doc->get_tag('alias') );
}