From 88da16bd69811ec6459ce80557d64530633d467c Mon Sep 17 00:00:00 2001 From: John Bintz Date: Sun, 31 Jan 2010 17:34:59 -0500 Subject: [PATCH] code coverage --- classes/ComicPressTagBuilder.inc | 4 ++-- test/ComicPressAdminTest.php | 24 +++++++++++++++++++++++- test/ComicPressTagBuilderTest.php | 15 +++++++++++++++ 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/classes/ComicPressTagBuilder.inc b/classes/ComicPressTagBuilder.inc index 92238fd..861480b 100644 --- a/classes/ComicPressTagBuilder.inc +++ b/classes/ComicPressTagBuilder.inc @@ -104,7 +104,7 @@ class ComicPressTagBuilder { if (in_array($state, array(self::HAS_POST_METHOD, self::HAS_EXTRACT_METHOD))) { if ($current == "in") { - if (empty($parts)) { + if (implode('', $parts) == '') { throw new ComicPressException("No category specified in tag ${method_name}"); } $is_id = false; @@ -120,7 +120,7 @@ class ComicPressTagBuilder { 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) { throw new ComicPressException('Only one extract method can be specified'); } diff --git a/test/ComicPressAdminTest.php b/test/ComicPressAdminTest.php index 0ed9642..ef2aab0 100644 --- a/test/ComicPressAdminTest.php +++ b/test/ComicPressAdminTest.php @@ -129,7 +129,29 @@ class ComicPressAdminTest extends PHPUnit_Framework_TestCase { array( '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() + ) + ) + ), ); } diff --git a/test/ComicPressTagBuilderTest.php b/test/ComicPressTagBuilderTest.php index eb199ff..2a36999 100644 --- a/test/ComicPressTagBuilderTest.php +++ b/test/ComicPressTagBuilderTest.php @@ -213,6 +213,21 @@ class ComicPressTagBuilderTest extends PHPUnit_Framework_TestCase { $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() { extract($this->setupStorylineBuilderTest());