more code coverage fixes

This commit is contained in:
John Bintz 2009-11-11 07:49:54 -05:00
parent 95aeb3f45c
commit 510fadcf43
2 changed files with 25 additions and 5 deletions

View File

@ -83,6 +83,7 @@ class ComicPressComicPost {
return false;
}
// @codeCoverageIgnoreStart
/**
* Sort the remaining comic images by file date.
* @param object $a
@ -94,6 +95,7 @@ class ComicPressComicPost {
$b_date = isset($b->post_date) ? $b->post_date : 0;
return $a_date - $b_date;
}
// @codeCoverageIgnoreEnd
/**
* Change the ordering of comic images in the associated post.

View File

@ -12,7 +12,12 @@ class ComicPressComicPostTest extends PHPUnit_Framework_TestCase {
function providerTestNormalizeOrdering() {
return array(
array(
array(
false,
array('attachment-1' => array('enabled' => false), 'attachment-2' => array('enabled' => true)),
false,
),
array(
array('attachment-1'),
array(),
array('attachment-1' => array('enabled' => true))
@ -27,6 +32,11 @@ class ComicPressComicPostTest extends PHPUnit_Framework_TestCase {
array('attachment-1' => array('enabled' => true, 'children' => array('rss' => array('attachment-2' => true)))),
array('attachment-1' => array('enabled' => true))
),
array(
array('attachment-1', 'attachment-2'),
array('attachment-1' => array('enabled' => true, 'children' => array('rss' => array('attachment-2' => true, 'attachment-3' => true)))),
array('attachment-1' => array('enabled' => true, 'children' => array('rss' => array('attachment-2' => true))))
),
array(
array('attachment-1', 'attachment-2', 'attachment-3'),
array('attachment-1' => array('enabled' => false, 'children' => array('rss' => array('attachment-2' => true)))),
@ -41,9 +51,13 @@ class ComicPressComicPostTest extends PHPUnit_Framework_TestCase {
function testNormalizeOrdering($attachments, $current_meta, $expected_result) {
$p = $this->getMock('ComicPressComicPost', array('get_attachments'));
$attachment_objects = array();
foreach ($attachments as $attachment) {
$attachment_objects[] = (object)array('id' => $attachment);
if (is_array($attachments)) {
$attachment_objects = array();
foreach ($attachments as $attachment) {
$attachment_objects[] = (object)array('id' => $attachment);
}
} else {
$attachment_objects = $attachments;
}
$p->expects($this->any())->method('get_attachments')->will($this->returnValue($attachment_objects));
@ -54,7 +68,11 @@ class ComicPressComicPostTest extends PHPUnit_Framework_TestCase {
$p->post = (object)array('ID' => 1);
$this->assertEquals($expected_result, $p->normalize_ordering());
$this->assertEquals($expected_result, get_post_meta(1, 'image-ordering', true));
if ($expected_result === false) {
$this->assertEquals($current_meta, get_post_meta(1, 'image-ordering', true));
} else {
$this->assertEquals($expected_result, get_post_meta(1, 'image-ordering', true));
}
}
function providerTestChangeComicImageOrdering() {