Merge branch 'master' into media-handling

This commit is contained in:
John Bintz 2009-12-04 21:28:00 -05:00
commit 4f05e6de19
2 changed files with 24 additions and 6 deletions

View File

@ -2,7 +2,8 @@
class ComicPressMediaHandling {
var $root_filter = '%wordpress%/%type-folder%/';
var $default_filter = '%wordpress%/%type-folder%/%date-Y-m-d%*.*';
var $default_filter = '%wordpress%/%type-folder%/{date}*.*';
var $default_filename_filter = '%date-Y-m-d%';
function _bundle_global_variables() {
global $comic_folder, $archive_comic_folder, $rss_comic_folder, $mini_comic_folder;
@ -32,7 +33,14 @@ class ComicPressMediaHandling {
}
}
return $this->default_filter;
$filter = $this->default_filter;
if ($result = get_option('comicpress-manager-cpm-date-format')) {
$filter = str_replace('{date}', "%date-${result}%", $filter);
} else {
$filter = str_replace('{date}', $this->default_filename_filter, $filter);
}
return $filter;
}
function _convert_to_percent_filter($old) {

View File

@ -35,10 +35,12 @@ class ComicPressMediaHandlingTest extends PHPUnit_Framework_TestCase {
function providerTestGetFilter() {
$cpmh = new ComicPressMediaHandling();
$default = str_replace('{date}', $cpmh->default_filename_filter, $cpmh->default_filter);
return array(
array(null, $cpmh->default_filter),
array('fail', $cpmh->default_filter),
array(array(), $cpmh->default_filter),
array(null, $default),
array('fail', $default),
array(array(), $default),
array('test', 'test')
);
}
@ -51,8 +53,10 @@ class ComicPressMediaHandlingTest extends PHPUnit_Framework_TestCase {
$comic_filename_filters['test'] = 'test';
$default = str_replace('{date}', $this->cpmh->default_filename_filter, $this->cpmh->default_filter);
$cpmh = $this->getMock('ComicPressMediaHandling', array('_convert_to_percent_filter'));
if ($expected_result !== $cpmh->default_filter) {
if ($expected_result !== $default) {
$cpmh->expects($this->once())->method('_convert_to_percent_filter')->with($expected_result)->will($this->returnValue($expected_result));
} else {
$cpmh->expects($this->never())->method('_convert_to_percent_filter');
@ -61,6 +65,12 @@ class ComicPressMediaHandlingTest extends PHPUnit_Framework_TestCase {
$this->assertEquals($expected_result, $cpmh->_get_filter($filter_to_use));
}
function testGetFilterCPMOption() {
update_option('comicpress-manager-cpm-date-format', 'test');
$this->assertEquals(str_replace('{date}', '%date-test%', $this->cpmh->default_filter), $this->cpmh->_get_filter());
}
function providerTestConvertToPercentFilter() {
return array(
array('', '%wordpress%/%type-folder%/'),