more code coverage fixes
This commit is contained in:
parent
95aeb3f45c
commit
510fadcf43
|
@ -83,6 +83,7 @@ class ComicPressComicPost {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @codeCoverageIgnoreStart
|
||||||
/**
|
/**
|
||||||
* Sort the remaining comic images by file date.
|
* Sort the remaining comic images by file date.
|
||||||
* @param object $a
|
* @param object $a
|
||||||
|
@ -94,6 +95,7 @@ class ComicPressComicPost {
|
||||||
$b_date = isset($b->post_date) ? $b->post_date : 0;
|
$b_date = isset($b->post_date) ? $b->post_date : 0;
|
||||||
return $a_date - $b_date;
|
return $a_date - $b_date;
|
||||||
}
|
}
|
||||||
|
// @codeCoverageIgnoreEnd
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change the ordering of comic images in the associated post.
|
* Change the ordering of comic images in the associated post.
|
||||||
|
|
|
@ -12,6 +12,11 @@ class ComicPressComicPostTest extends PHPUnit_Framework_TestCase {
|
||||||
|
|
||||||
function providerTestNormalizeOrdering() {
|
function providerTestNormalizeOrdering() {
|
||||||
return array(
|
return array(
|
||||||
|
array(
|
||||||
|
false,
|
||||||
|
array('attachment-1' => array('enabled' => false), 'attachment-2' => array('enabled' => true)),
|
||||||
|
false,
|
||||||
|
),
|
||||||
array(
|
array(
|
||||||
array('attachment-1'),
|
array('attachment-1'),
|
||||||
array(),
|
array(),
|
||||||
|
@ -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, 'children' => array('rss' => array('attachment-2' => true)))),
|
||||||
array('attachment-1' => array('enabled' => 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(
|
||||||
array('attachment-1', 'attachment-2', 'attachment-3'),
|
array('attachment-1', 'attachment-2', 'attachment-3'),
|
||||||
array('attachment-1' => array('enabled' => false, 'children' => array('rss' => array('attachment-2' => true)))),
|
array('attachment-1' => array('enabled' => false, 'children' => array('rss' => array('attachment-2' => true)))),
|
||||||
|
@ -41,10 +51,14 @@ class ComicPressComicPostTest extends PHPUnit_Framework_TestCase {
|
||||||
function testNormalizeOrdering($attachments, $current_meta, $expected_result) {
|
function testNormalizeOrdering($attachments, $current_meta, $expected_result) {
|
||||||
$p = $this->getMock('ComicPressComicPost', array('get_attachments'));
|
$p = $this->getMock('ComicPressComicPost', array('get_attachments'));
|
||||||
|
|
||||||
|
if (is_array($attachments)) {
|
||||||
$attachment_objects = array();
|
$attachment_objects = array();
|
||||||
foreach ($attachments as $attachment) {
|
foreach ($attachments as $attachment) {
|
||||||
$attachment_objects[] = (object)array('id' => $attachment);
|
$attachment_objects[] = (object)array('id' => $attachment);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$attachment_objects = $attachments;
|
||||||
|
}
|
||||||
|
|
||||||
$p->expects($this->any())->method('get_attachments')->will($this->returnValue($attachment_objects));
|
$p->expects($this->any())->method('get_attachments')->will($this->returnValue($attachment_objects));
|
||||||
|
|
||||||
|
@ -54,8 +68,12 @@ class ComicPressComicPostTest extends PHPUnit_Framework_TestCase {
|
||||||
$p->post = (object)array('ID' => 1);
|
$p->post = (object)array('ID' => 1);
|
||||||
|
|
||||||
$this->assertEquals($expected_result, $p->normalize_ordering());
|
$this->assertEquals($expected_result, $p->normalize_ordering());
|
||||||
|
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));
|
$this->assertEquals($expected_result, get_post_meta(1, 'image-ordering', true));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function providerTestChangeComicImageOrdering() {
|
function providerTestChangeComicImageOrdering() {
|
||||||
return array(
|
return array(
|
||||||
|
|
Loading…
Reference in New Issue