code coverage

This commit is contained in:
John Bintz 2010-01-31 17:34:59 -05:00
parent ab37be9aa9
commit 88da16bd69
3 changed files with 40 additions and 3 deletions

View File

@ -104,7 +104,7 @@ class ComicPressTagBuilder {
if (in_array($state, array(self::HAS_POST_METHOD, self::HAS_EXTRACT_METHOD))) { if (in_array($state, array(self::HAS_POST_METHOD, self::HAS_EXTRACT_METHOD))) {
if ($current == "in") { if ($current == "in") {
if (empty($parts)) { if (implode('', $parts) == '') {
throw new ComicPressException("No category specified in tag ${method_name}"); throw new ComicPressException("No category specified in tag ${method_name}");
} }
$is_id = false; $is_id = false;
@ -120,7 +120,7 @@ class ComicPressTagBuilder {
break; break;
} }
if (in_array($current, array('id', 'permalink', 'title', 'timestamp', 'date'))) { if (in_array($current, array('id', 'permalink', 'title', 'timestamp', 'date', 'post'))) {
if ($state == self::HAS_EXTRACT_METHOD) { if ($state == self::HAS_EXTRACT_METHOD) {
throw new ComicPressException('Only one extract method can be specified'); throw new ComicPressException('Only one extract method can be specified');
} }

View File

@ -129,7 +129,29 @@ class ComicPressAdminTest extends PHPUnit_Framework_TestCase {
array( array(
'enabled_backends' => array('ComicPressBackendURLFactory') 'enabled_backends' => array('ComicPressBackendURLFactory')
), ),
) ),
array(
array(
'category_groupings' => array()
),
array(
'category_groupings' => array(
'test' => array(
'name' => 'empty'
),
'test2' => array(
'name' => 'full',
'category' => array(1,2,3)
)
)
),
array(
'category_groupings' => array(
'full' => array(1,2,3),
'empty' => array()
)
)
),
); );
} }

View File

@ -213,6 +213,21 @@ class ComicPressTagBuilderTest extends PHPUnit_Framework_TestCase {
$this->assertEquals($expected_pieces, ComicPressTagBuilder::parse_method($method_name)); $this->assertEquals($expected_pieces, ComicPressTagBuilder::parse_method($method_name));
} }
function providerTestMethodParserExceptions() {
return array(
array('first_in_'),
array('first_post_id')
);
}
/**
* @dataProvider providerTestMethodParserExceptions
* @expectedException ComicPressException
*/
function testMethodParserExceptions($method_name) {
ComicPressTagBuilder::parse_method($method_name);
}
function testMethodParserWithParam() { function testMethodParserWithParam() {
extract($this->setupStorylineBuilderTest()); extract($this->setupStorylineBuilderTest());