wpmu handling

This commit is contained in:
John Bintz 2009-12-01 21:40:40 -05:00
parent 1f428c786a
commit 6aea00a8d0
2 changed files with 14 additions and 3 deletions

View File

@ -58,13 +58,19 @@ class ComicPressMediaHandling {
return $result; return $result;
} }
function _abspath() { return ABSPATH; } function _abspath() {
return ABSPATH;
}
function _expand_filter_callback($matches) { function _expand_filter_callback($matches) {
$value = ''; $value = '';
switch (strtolower($matches[1])) { switch (strtolower($matches[1])) {
case 'wordpress': case 'wordpress':
$value = $this->_abspath(); if ($path = get_option('upload_path')) {
$value = $path;
} else {
$value = $this->_abspath();
}
break; break;
case 'type-folder': case 'type-folder':
$value = $this->type_filter; $value = $this->type_filter;

View File

@ -85,16 +85,21 @@ class ComicPressMediaHandlingTest extends PHPUnit_Framework_TestCase {
array('%wordpress%/%type-folder%', vfsStream::url('root') . '/comic'), array('%wordpress%/%type-folder%', vfsStream::url('root') . '/comic'),
array('%date-Y%', '2009'), array('%date-Y%', '2009'),
array('%wordpress%/%type-folder%/%date-Y-m-d%*.*', vfsStream::url('root') . '/comic/2009-01-01.*\..*'), array('%wordpress%/%type-folder%/%date-Y-m-d%*.*', vfsStream::url('root') . '/comic/2009-01-01.*\..*'),
array('%wordpress%/%type-folder%/%date-Y-m-d%*.*', '/wpmupath/comic/2009-01-01.*\..*', '/wpmupath'),
); );
} }
/** /**
* @dataProvider providerTestExpandFilter * @dataProvider providerTestExpandFilter
*/ */
function testExpandFilter($filter, $expected_result) { function testExpandFilter($filter, $expected_result, $use_option_path = false) {
$cpmh = $this->getMock('ComicPressMediaHandling', array('_abspath')); $cpmh = $this->getMock('ComicPressMediaHandling', array('_abspath'));
$cpmh->expects($this->any())->method('_abspath')->will($this->returnValue(vfsStream::url('root'))); $cpmh->expects($this->any())->method('_abspath')->will($this->returnValue(vfsStream::url('root')));
if ($use_option_path !== false) {
update_option('upload_path', $use_option_path);
}
$this->assertEquals($expected_result, $cpmh->_expand_filter($filter, 'comic', (object)array('ID' => 1, 'post_date' => '2009-01-01 15:00:00'))); $this->assertEquals($expected_result, $cpmh->_expand_filter($filter, 'comic', (object)array('ID' => 1, 'post_date' => '2009-01-01 15:00:00')));
} }
} }