update to some tests
This commit is contained in:
parent
47e64c4923
commit
aa7d5e0dfa
|
@ -156,11 +156,13 @@ class ComicPressStoryline {
|
||||||
if (isset($this->_structure[$id])) {
|
if (isset($this->_structure[$id])) {
|
||||||
$all_adjacent = array();
|
$all_adjacent = array();
|
||||||
do {
|
do {
|
||||||
|
$new_id = $this->_structure[$id][$direction];
|
||||||
|
|
||||||
$has_adjacent = false;
|
$has_adjacent = false;
|
||||||
if (!in_array($id, $all_adjacent)) {
|
if (!in_array($new_id, $all_adjacent)) {
|
||||||
if ($has_adjacent = isset($this->_structure[$id][$direction])) {
|
if ($has_adjacent = isset($this->_structure[$id][$direction])) {
|
||||||
$all_adjacent[] = $this->_structure[$id][$direction];
|
$all_adjacent[] = $new_id;
|
||||||
$id = $this->_structure[$id][$direction];
|
$id = $new_id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while ($has_adjacent);
|
} while ($has_adjacent);
|
||||||
|
|
|
@ -17,11 +17,13 @@ class ComicPressBackendAttachment extends ComicPressBackend {
|
||||||
|
|
||||||
if (!empty($children)) {
|
if (!empty($children)) {
|
||||||
foreach ($children as $child) {
|
foreach ($children as $child) {
|
||||||
|
if (get_post_meta($child->ID, 'comicpress_management', true)) {
|
||||||
$result[] = new ComicPressBackendAttachment($child);
|
$result[] = new ComicPressBackendAttachment($child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,11 +88,11 @@ class ComicPressAdminTest extends PHPUnit_Framework_TestCase {
|
||||||
'post_meta' => array(),
|
'post_meta' => array(),
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'comic_image_type' => "test"
|
'comicpress_management' => "yes"
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'post_meta' => array(
|
'post_meta' => array(
|
||||||
'comic_image_type' => "test"
|
'comicpress_management' => true
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -119,12 +119,15 @@ class ComicPressAdminTest extends PHPUnit_Framework_TestCase {
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'post_parent' => "2",
|
'post_parent' => "2",
|
||||||
'auto_attach' => 1
|
'comicpress_management' => "yes"
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'post' => array(
|
'post' => array(
|
||||||
'post_parent' => 2
|
'post_parent' => 2,
|
||||||
),
|
),
|
||||||
|
'post_meta' => array(
|
||||||
|
'comicpress_management' => true
|
||||||
|
)
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
|
@ -11,21 +11,27 @@ class ComicPressBackendAttachmentTest extends PHPUnit_Framework_TestCase {
|
||||||
|
|
||||||
function providerTestGenerateFromPost() {
|
function providerTestGenerateFromPost() {
|
||||||
return array(
|
return array(
|
||||||
array(array(), false),
|
array(array(), array(), false),
|
||||||
array(array((object)array('ID' => 1)), array('attachment-1'))
|
array(array((object)array('ID' => 1)), array(), array())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider providerTestGenerateFromPost
|
* @dataProvider providerTestGenerateFromPost
|
||||||
*/
|
*/
|
||||||
function testGenerateFromPost($get_children_response, $expected_ids) {
|
function testGenerateFromPost($get_children_response, $post_meta, $expected_ids) {
|
||||||
_set_get_children(array(
|
_set_get_children(array(
|
||||||
'post_parent' => 1,
|
'post_parent' => 1,
|
||||||
'post_type' => 'attachment',
|
'post_type' => 'attachment',
|
||||||
'post_mime_type' => 'image'
|
'post_mime_type' => 'image'
|
||||||
), $get_children_response);
|
), $get_children_response);
|
||||||
|
|
||||||
|
foreach ($post_meta as $id => $meta) {
|
||||||
|
foreach ($meta as $field => $value) {
|
||||||
|
update_post_meta($id, $field, $value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$results = ComicPressBackendAttachment::generate_from_post((object)array('ID' => 1));
|
$results = ComicPressBackendAttachment::generate_from_post((object)array('ID' => 1));
|
||||||
if ($expected_ids === false) {
|
if ($expected_ids === false) {
|
||||||
$this->assertTrue(empty($results));
|
$this->assertTrue(empty($results));
|
||||||
|
|
Loading…
Reference in New Issue