start tests for graphical nav widget

This commit is contained in:
John Bintz 2009-10-20 21:08:17 -04:00
parent 7557e13d3b
commit a3e8903bfd
2 changed files with 106 additions and 98 deletions

View File

@ -4,8 +4,20 @@ require_once('MockPress/mockpress.php');
require_once('PHPUnit/Framework.php');
require_once(dirname(__FILE__) . '/../../widgets/graphical-navigation.php');
class GraphicsNavigationTest extends PHPUnit_Framework_TestCase {
class GraphicalNavigationTest extends PHPUnit_Framework_TestCase {
function testUpdateWidget() {
$w = new widget_comicpress_graphical_navigation();
$this->assertEquals(array(
"next" => "<b>test</b>",
"next_title" => "test",
"archive_path" => "test",
), $w->update(array(
"next" => "<b>test</b>",
"next_title" => "<b>test</b>",
"archive_path" => "<b>test</b>",
), array()));
}
}
?>

View File

@ -2,9 +2,9 @@
/*
Widget Name: Graphical Navigation
Widget URI: http://comicpress.org/
Description: You can place graphical navigation buttons on your comic, for ComicPress 2.8
Author: Philip M. Hofer (Frumph)
Version: 1.01
Description: This widget places graphical navigation buttons on your comic. For ComicPress 2.8
Author: Philip M. Hofer (Frumph) &amp; John Bintz
Version: 1.2
Author URI: http://webcomicplanet.com/
*/
@ -105,31 +105,27 @@ class widget_comicpress_graphical_navigation extends WP_Widget {
<?php }
}
/**
* Update the current widget instance.
* @param array $new_instance The new widget instance data.
* @param array $old_instance The old widget instance data.
*/
function update($new_instance, $old_instance) {
$instance = $old_instance;
$instance['first'] = $new_instance['first'];
$instance['last'] = $new_instance['last'];
$instance['story_prev'] = $new_instance['story_prev'];
$instance['story_next'] = $new_instance['story_next'];
$instance['previous'] = $new_instance['previous'];
$instance['random'] = $new_instance['random'];
$instance['archives'] = $new_instance['archives'];
$instance['comments'] = $new_instance['comments'];
$instance['next'] = $new_instance['next'];
$instance['archive_path'] = strip_tags($new_instance['archive_path']);
$instance['buyprint'] = $new_instance['buyprint'];
$instance['comictitle'] = $new_instance['comictitle'];
$instance = array();
$all_fields = explode(' ', 'first last story_prev story_next previous random archives comments next buyprint comictitle');
foreach ($all_fields as $field) {
if (isset($new_instance[$field])) {
$instance[$field] = $new_instance[$field];
}
if (isset($new_instance["${field}_title"])) {
$instance["${field}_title"] = strip_tags($new_instance["${field}_title"]);
}
}
$instance['archive_path'] = strip_tags($new_instance['archive_path']);
$instance['first_title'] = strip_tags($new_instance['first_title']);
$instance['last_title'] = strip_tags($new_instance['last_title']);
$instance['story_prev_title'] = strip_tags($new_instance['story_prev_title']);
$instance['story_next_title'] = strip_tags($new_instance['story_next_title']);
$instance['previous_title'] = strip_tags($new_instance['previous_title']);
$instance['random_title'] = strip_tags($new_instance['random_title']);
$instance['archives_title'] = strip_tags($new_instance['archives_title']);
$instance['comments_title'] = strip_tags($new_instance['comments_title']);
$instance['next_title'] = strip_tags($new_instance['next_title']);
$instance['buyprint_title'] = strip_tags($new_instance['buyprint_title']);
return $instance;
}