diff --git a/classes/ComicPress.inc b/classes/ComicPress.inc
index 3aaead3..6418b14 100644
--- a/classes/ComicPress.inc
+++ b/classes/ComicPress.inc
@@ -52,6 +52,8 @@ class ComicPress {
}
}
+ // @codeCoverageIgnoreStart
+
/**
* Initialize the class.
*/
@@ -75,6 +77,8 @@ class ComicPress {
}
}
+ // WordPress Filters
+
function intermediate_image_sizes($sizes) {
return array_merge($sizes, array('comic', 'rss', 'archive', 'mini'));
}
@@ -90,7 +94,6 @@ class ComicPress {
function announce_activated_helpers() {
echo "
[ Activated ComicPress helpers: " . implode(", ", array_keys($this->comicpress_options['helpers'])) . " ]";
}
-
/**
* Gather blog posts for the given index page.
*/
@@ -112,6 +115,8 @@ class ComicPress {
return $wp_query;
}
+ // @codeCoverageIgnoreEnd
+
/**
* Search a path for directories named after the slugs provided.
* @param array $categories A list of category slugs going from child -> parent -> root.
diff --git a/classes/ComicPressAdmin.inc b/classes/ComicPressAdmin.inc
index a9a5e2e..5820ef7 100644
--- a/classes/ComicPressAdmin.inc
+++ b/classes/ComicPressAdmin.inc
@@ -1,6 +1,7 @@
render_comic_image_ordering(true, $info['post_id']);
exit(0);
}
+ // @codeCoverageIgnoreEnd
/**
* Update attachment information.
@@ -261,8 +265,8 @@ class ComicPressAdmin {
}
}
break;
+ // @codeCoverageIgnoreStart
case 'helpers':
- case 'addons':
foreach ($info[$option] as $type => $set) {
$this->comicpress->comicpress_options[$option][$type] = true;
}
@@ -271,11 +275,13 @@ class ComicPressAdmin {
$storyline = new ComicPressStoryline();
$storyline->normalize($info[$option]);
break;
+ // @codeCoverageIgnoreEnd
}
}
}
}
+ // @codeCoverageIgnoreStart
function _json_decode($string) {
if (function_exists('json_decode')) {
return json_decode($string);
@@ -295,24 +301,32 @@ class ComicPressAdmin {
}
}
- /**
- * Update the zoom slider info.
- * @param $info The browser input.
- */
+ /**
+ * Update the zoom slider info.
+ * @param $info The browser input.
+ */
function handle_update_zoom_slider($info) {
$this->is_ajax = true;
$current_user = wp_get_current_user();
if (!empty($current_user)) {
- $comicpress_meta = get_usermeta($current_user->ID, 'comicpress-settings');
- if (!is_array($comicpress_meta)) { $comicpress_meta = array(); }
- $comicpress_meta['zoom_level'] = $info['zoom_level'];
- update_usermeta($current_user->ID, 'comicpress-settings', $comicpress_meta);
+ $this->_update_zoom_slider_meta($current_user->ID, $info['zoom_level']);
exit(0);
}
header('HTTP/1.1 500 Internal Server Error');
exit(0);
}
+ // @codeCoverageIgnoreEnd
+
+ /**
+ * Update the user's zoom slider metadata.
+ */
+ function _update_zoom_slider_meta($user_id, $level) {
+ $comicpress_meta = get_usermeta($user_id, 'comicpress-settings');
+ if (!is_array($comicpress_meta)) { $comicpress_meta = array(); }
+ $comicpress_meta['zoom_level'] = $level;
+ update_usermeta($user_id, 'comicpress-settings', $comicpress_meta);
+ }
/**
* Handle an update.
@@ -347,17 +361,7 @@ class ComicPressAdmin {
}
}
- /**
- * Create the dropdown for choosing a layout.
- */
- function create_layout_options($layouts, $current_layout) {
- $output = array();
- foreach ($layouts as $layout_filename => $info) {
- $output[] = '';
- }
- return implode("\n", $output);
- }
-
+ // @codeCoverageIgnoreStart
var $messages = array(
'info' => array(),
'warn' => array(),
@@ -379,6 +383,7 @@ class ComicPressAdmin {
}
}
}
+ // @codeCoverageIgnoreEnd
}
?>
\ No newline at end of file
diff --git a/classes/ComicPressDBInterface.inc b/classes/ComicPressDBInterface.inc
index 41af87a..abf4a2d 100644
--- a/classes/ComicPressDBInterface.inc
+++ b/classes/ComicPressDBInterface.inc
@@ -10,6 +10,7 @@ class ComicPressDBInterface {
return $instance;
}
+ // @codeCoverageIgnoreStart
function _get_categories() { return get_categories("hide_empty=0"); }
function get_terminal_post($first = true, $include_categories = null) {
@@ -96,4 +97,4 @@ class ComicPressDBInterface {
function get_next_post($categories = array(), $override_post = null) { return $this->get_adjacent_post($categories, true, $override_post); }
}
-?>
\ No newline at end of file
+// @codeCoverageIngoreEnd
diff --git a/classes/backends/ComicPressBackendAttachment.inc b/classes/backends/ComicPressBackendAttachment.inc
index e1f25f6..2a99d73 100644
--- a/classes/backends/ComicPressBackendAttachment.inc
+++ b/classes/backends/ComicPressBackendAttachment.inc
@@ -36,6 +36,7 @@ class ComicPressBackendAttachment extends ComicPressBackend {
$this->type = get_post_meta($this->attachment->ID, 'comic_image_type', true);
}
+ // @codeCoverageIgnoreStart
function dims($size = 'comic') {
$metadata = image_downsize($this->attachment->ID, $size);
if (!empty($metadata)) {
@@ -64,6 +65,7 @@ class ComicPressBackendAttachment extends ComicPressBackend {
function title() { return $this->attachment->post_excerpt; }
function get_info() { return array(); }
+ // @codeCoverageIgnoreEnd
}
?>
\ No newline at end of file
diff --git a/test/ComicPressAdminTest.php b/test/ComicPressAdminTest.php
index 9ddd5bd..863f15d 100644
--- a/test/ComicPressAdminTest.php
+++ b/test/ComicPressAdminTest.php
@@ -178,18 +178,26 @@ class ComicPressAdminTest extends PHPUnit_Framework_TestCase {
}
}
- function providerTestHandleUpdateOverridePartial() {
+ function providerTestUpdateZoomSliderMeta() {
return array(
- array(
- 'hello',
- 'Update partial'
- ),
- array(
- 'meow',
- 'Delete override partial'
- ),
+ array(false),
+ array(array()),
+ array(array('zoom_level' => 50))
);
}
+
+ /**
+ * @dataProvider providerTestUpdateZoomSliderMeta
+ */
+ function testUpdateZoomSliderMeta($initial_usermeta) {
+ update_usermeta(1, 'comicpress-settings', $initial_usermeta);
+
+ $this->admin->_update_zoom_slider_meta(1, 100);
+
+ $this->assertEquals(array(
+ 'zoom_level' => 100
+ ), get_usermeta(1, 'comicpress-settings'));
+ }
}
?>
diff --git a/test/ComicPressTest.php b/test/ComicPressTest.php
index 3f643a1..9f77df9 100644
--- a/test/ComicPressTest.php
+++ b/test/ComicPressTest.php
@@ -123,6 +123,26 @@ class ComicPressTest extends PHPUnit_Framework_TestCase {
$this->assertEquals($expected_path_result, $this->cp->find_file('index.inc', $search_path, $post_categories));
}
+
+ function providerTestLoad() {
+ return array(
+ array(false, 'default'),
+ array(array(), 'default'),
+ array(array(
+ 'comic_dimensions' => '1000x'
+ ), '1000x')
+ );
+ }
+
+ /**
+ * @dataProvider providerTestLoad
+ */
+ function testLoad($options_array, $expected_dimensions) {
+ update_option('comicpress-options', $options_array);
+ if ($expected_dimensions == 'default') { $expected_dimensions = $this->cp->comicpress_options['comic_dimensions']; }
+ $this->cp->load();
+ $this->assertEquals($expected_dimensions, $this->cp->comicpress_options['comic_dimensions']);
+ }
}
?>
\ No newline at end of file
diff --git a/test/backends/ComicPressBackendAttachmentTest.php b/test/backends/ComicPressBackendAttachmentTest.php
index 9147e8a..641f342 100644
--- a/test/backends/ComicPressBackendAttachmentTest.php
+++ b/test/backends/ComicPressBackendAttachmentTest.php
@@ -12,7 +12,9 @@ class ComicPressBackendAttachmentTest extends PHPUnit_Framework_TestCase {
function providerTestGenerateFromPost() {
return array(
array(array(), array(), false),
- array(array((object)array('ID' => 1)), array(), array())
+ array(array((object)array('ID' => 2)), array(), array()),
+ array(array((object)array('ID' => 2)), array('managed' => false), array()),
+ array(array((object)array('ID' => 2)), array('managed' => true), array('attachment-2')),
);
}
@@ -26,11 +28,7 @@ class ComicPressBackendAttachmentTest extends PHPUnit_Framework_TestCase {
'post_mime_type' => 'image'
), $get_children_response);
- foreach ($post_meta as $id => $meta) {
- foreach ($meta as $field => $value) {
- update_post_meta($id, $field, $value);
- }
- }
+ update_post_meta(2, 'comicpress', $post_meta);
$results = ComicPressBackendAttachment::generate_from_post((object)array('ID' => 1));
if ($expected_ids === false) {