code coverage

This commit is contained in:
John Bintz 2009-11-24 22:24:49 -05:00
parent e8abf7766f
commit 3ebaf19744
3 changed files with 36 additions and 3 deletions

View File

@ -8,4 +8,4 @@ ifdef comicpress28
endif
test:
taskset -c 1 phpunit --syntax-check --coverage-html coverage test
phpunit --syntax-check --coverage-html coverage test

View File

@ -11,15 +11,18 @@ class ComicPressStoryline {
return $this;
}
function _class_exists($class) { return class_exists($class); }
/**
* Get the flattened storyline from options.
*/
function get_flattened_storyline() {
if (class_exists('ComicPress')) {
if ($this->_class_exists('ComicPress')) {
$comicpress = &ComicPress::get_instance();
if (isset($comicpress->comicpress_options['storyline_order'])) {
return $comicpress->comicpress_options['storyline_order'];
}
} else {
return get_option("comicpress-storyline-category-order");
}
@ -30,7 +33,7 @@ class ComicPressStoryline {
* Set the global storyline as a flattened storyline.
*/
function set_flattened_storyline($storyline) {
if (class_exists('ComicPress')) {
if ($this->_class_exists('ComicPress')) {
$comicpress = &ComicPress::get_instance();
$comicpress->comicpress_options['storyline_order'] = $storyline;
$comicpress->save();

View File

@ -106,6 +106,22 @@ class ComicPressStorylineTest extends PHPUnit_Framework_TestCase {
}
}
function testGetFlattenedStorylineNoComicPress() {
$css = $this->getMock('ComicPressStoryline', array('_class_exists'));
$css->expects($this->once())->method('_class_exists')->will($this->returnValue(false));
update_option('comicpress-storyline-category-order', 'test');
$this->assertEquals('test', $css->get_flattened_storyline());
}
function testGetFlattenedStorylineNoComicPressStorylineOrder() {
$comicpress = ComicPress::get_instance();
unset($comicpress->comicpress_options['storyline_order']);
$this->assertEquals(false, $this->css->get_flattened_storyline());
}
function providerTestCreateStructureKey() {
return array(
array(false, false),
@ -701,6 +717,15 @@ class ComicPressStorylineTest extends PHPUnit_Framework_TestCase {
$this->assertEquals($expected_id, $this->css->_ensure_category_ids($string));
}
function testEnsureCategoryIDsBadGrouping() {
$comicpress = ComicPress::get_instance();
$comicpress->comicpress_options['category_groupings'] = array(
'comic' => 1,
);
$this->assertEquals(array(1), $this->css->_ensure_category_ids('comic'));
}
function providerTestNormalizeCategoryGroupings() {
return array(
array(
@ -713,6 +738,11 @@ class ComicPressStorylineTest extends PHPUnit_Framework_TestCase {
array(1),
array('test' => array(1))
),
array(
array('test' => array(3)),
array(1),
array()
),
);
}