code coverage
This commit is contained in:
parent
e8abf7766f
commit
3ebaf19744
2
Makefile
2
Makefile
@ -8,4 +8,4 @@ ifdef comicpress28
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
test:
|
test:
|
||||||
taskset -c 1 phpunit --syntax-check --coverage-html coverage test
|
phpunit --syntax-check --coverage-html coverage test
|
@ -11,15 +11,18 @@ class ComicPressStoryline {
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _class_exists($class) { return class_exists($class); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the flattened storyline from options.
|
* Get the flattened storyline from options.
|
||||||
*/
|
*/
|
||||||
function get_flattened_storyline() {
|
function get_flattened_storyline() {
|
||||||
if (class_exists('ComicPress')) {
|
if ($this->_class_exists('ComicPress')) {
|
||||||
$comicpress = &ComicPress::get_instance();
|
$comicpress = &ComicPress::get_instance();
|
||||||
if (isset($comicpress->comicpress_options['storyline_order'])) {
|
if (isset($comicpress->comicpress_options['storyline_order'])) {
|
||||||
return $comicpress->comicpress_options['storyline_order'];
|
return $comicpress->comicpress_options['storyline_order'];
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return get_option("comicpress-storyline-category-order");
|
return get_option("comicpress-storyline-category-order");
|
||||||
}
|
}
|
||||||
@ -30,7 +33,7 @@ class ComicPressStoryline {
|
|||||||
* Set the global storyline as a flattened storyline.
|
* Set the global storyline as a flattened storyline.
|
||||||
*/
|
*/
|
||||||
function set_flattened_storyline($storyline) {
|
function set_flattened_storyline($storyline) {
|
||||||
if (class_exists('ComicPress')) {
|
if ($this->_class_exists('ComicPress')) {
|
||||||
$comicpress = &ComicPress::get_instance();
|
$comicpress = &ComicPress::get_instance();
|
||||||
$comicpress->comicpress_options['storyline_order'] = $storyline;
|
$comicpress->comicpress_options['storyline_order'] = $storyline;
|
||||||
$comicpress->save();
|
$comicpress->save();
|
||||||
|
@ -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() {
|
function providerTestCreateStructureKey() {
|
||||||
return array(
|
return array(
|
||||||
array(false, false),
|
array(false, false),
|
||||||
@ -701,6 +717,15 @@ class ComicPressStorylineTest extends PHPUnit_Framework_TestCase {
|
|||||||
$this->assertEquals($expected_id, $this->css->_ensure_category_ids($string));
|
$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() {
|
function providerTestNormalizeCategoryGroupings() {
|
||||||
return array(
|
return array(
|
||||||
array(
|
array(
|
||||||
@ -713,6 +738,11 @@ class ComicPressStorylineTest extends PHPUnit_Framework_TestCase {
|
|||||||
array(1),
|
array(1),
|
||||||
array('test' => array(1))
|
array('test' => array(1))
|
||||||
),
|
),
|
||||||
|
array(
|
||||||
|
array('test' => array(3)),
|
||||||
|
array(1),
|
||||||
|
array()
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user