remove cascade search, supplanted by find file
This commit is contained in:
parent
f38823df7b
commit
bd1c206ba4
|
@ -108,23 +108,6 @@ class ComicPress {
|
|||
|
||||
return $wp_query;
|
||||
}
|
||||
|
||||
/**
|
||||
* See if a file exists in either child or parent theme, and if it does, return the path to that file.
|
||||
* @param string $path The path to find.
|
||||
* @param string $force_parent If true, always find the parent.
|
||||
* @return string|boolean The path to the file, or false if not found.
|
||||
*/
|
||||
function cascade_search($path, $force_parent = false) {
|
||||
$dirs_to_search = array(get_template_directory());
|
||||
if (!$force_parent) { array_unshift($dirs_to_search, get_stylesheet_directory()); }
|
||||
|
||||
foreach ($dirs_to_search as $dir) {
|
||||
$dir = trailingslashit($dir);
|
||||
if (file_exists($dir . $path)) { return $dir . $path; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search a path for directories named after the slugs provided.
|
||||
|
|
|
@ -14,37 +14,6 @@ class ComicPressTest extends PHPUnit_Framework_TestCase {
|
|||
vfsStreamWrapper::setRoot(new vfsStreamDirectory('root'));
|
||||
}
|
||||
|
||||
function providerTestCascadeSearch() {
|
||||
$parent = vfsStream::url('root/parent/file');
|
||||
$child = vfsStream::url('root/child/file');
|
||||
|
||||
return array(
|
||||
array(array(), false, false),
|
||||
array(array('child'), false, $child),
|
||||
array(array('parent'), false, $parent),
|
||||
array(array('child', 'parent'), false, $child),
|
||||
array(array('child', 'parent'), true, $parent),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerTestCascadeSearch
|
||||
*/
|
||||
function testCascadeSearch($create, $force_parent, $expected_result) {
|
||||
mkdir(vfsStream::url('root/parent'), 0777);
|
||||
mkdir(vfsStream::url('root/child'), 0777);
|
||||
|
||||
_set_template_directory(vfsStream::url('root/parent'));
|
||||
_set_stylesheet_directory(vfsStream::url('root/child'));
|
||||
|
||||
foreach ($create as $type) {
|
||||
file_put_contents(vfsStream::url("root/${type}/file"), 'file');
|
||||
}
|
||||
|
||||
$result = $this->cp->cascade_search('file', $force_parent);
|
||||
$this->assertTrue($result === $expected_result);
|
||||
}
|
||||
|
||||
function providerTestCategorySearch() {
|
||||
return array(
|
||||
array(
|
||||
|
|
Loading…
Reference in New Issue