add new filter filtering option and associated test

This commit is contained in:
John Bintz 2010-01-20 07:35:17 -05:00
parent ee7a1cdf1c
commit 001f51fe65
2 changed files with 60 additions and 0 deletions

View File

@ -19,6 +19,23 @@ function comicpress_admin_print_styles() {
wp_enqueue_style('comicpress-options', get_template_directory_uri() . '/options/options.css');
}
function comicpress_save_options_comic_filename_filters($incoming) {
$filters = array();
foreach (array_values($incoming) as $filter) {
$filters[wp_filter_nohtml_kses($filter['name'])] = wp_filter_nohtml_kses($filter['filter']);
}
if (!empty($filters)) {
if (!isset($filters['default'])) {
$cpmh = new ComicPressMediaHandling();
$filters['default'] = $cpmh->default_filter;
}
}
return $filters;
}
function comicpress_admin_page_head() { ?>
<!--[if lt ie 8]> <style> div.show { position: static; margin-top: 1px; } #cpadmin div.off { height: 22px; } </style> <![endif]-->
<?php }

View File

@ -0,0 +1,43 @@
<?php
require_once('PHPUnit/Framework.php');
require_once('MockPress/mockpress.php');
require_once(dirname(__FILE__) . '/../comicpress-options.php');
require_once(dirname(__FILE__) . '/../classes/ComicPressMediaHandling.inc');
class ComicPressOptionsAdminTest extends PHPUnit_Framework_TestCase {
function providerTestSaveComicFilenameFilters() {
$cpmh = new ComicPressMediaHandling();
return array(
array(
array(),
array()
),
array(
array(1 => array(
'name' => 'test', 'filter' => 'myfilter'
)),
array(
'default' => $cpmh->default_filter,
'test' => 'myfilter'
)
),
array(
array(1 => array(
'name' => 'default', 'filter' => 'test'
)),
array(
'default' => 'test'
)
)
);
}
/**
* @dataProvider providerTestSaveComicFilenameFilters
*/
function testSaveComicFilenameFilters($incoming, $expected) {
$this->assertEquals($expected, comicpress_save_options_comic_filename_filters($incoming));
}
}