From ca3299a01e0fe5856a376d653a6076f4d0bac18f Mon Sep 17 00:00:00 2001 From: John Bintz Date: Sat, 7 Nov 2009 17:13:13 -0500 Subject: [PATCH] works w/o specifying post --- classes/ComicPress.inc | 8 ++++++++ test/ComicPressTest.php | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/classes/ComicPress.inc b/classes/ComicPress.inc index 9d1c0fe..acb12ac 100644 --- a/classes/ComicPress.inc +++ b/classes/ComicPress.inc @@ -1,5 +1,7 @@ find_parents(); + } + foreach (array(get_stylesheet_directory(), get_template_directory()) as $dir) { $dir = trailingslashit($dir) . $path; $dirs_to_search = $this->category_search($categories, $dir); diff --git a/test/ComicPressTest.php b/test/ComicPressTest.php index 317894c..cf69a34 100644 --- a/test/ComicPressTest.php +++ b/test/ComicPressTest.php @@ -76,6 +76,14 @@ class ComicPressTest extends PHPUnit_Framework_TestCase { ), array('chapter-1', 'comic'), vfsStream::url('root/child/partials/comic/index.inc') + ), + array( + array( + 'root/child/partials/index.inc', + 'root/child/partials/comic/index.inc' + ), + null, + vfsStream::url('root/child/partials/comic/index.inc') ) ); } @@ -84,6 +92,8 @@ class ComicPressTest extends PHPUnit_Framework_TestCase { * @dataProvider providerTestFindFile */ function testFindFile($files_to_setup, $post_categories, $expected_path_result) { + global $post; + mkdir(vfsStream::url('root/parent/partials/comic/chapter-1'), 0777, true); mkdir(vfsStream::url('root/child/partials/comic/chapter-1'), 0777, true); @@ -94,6 +104,12 @@ class ComicPressTest extends PHPUnit_Framework_TestCase { _set_template_directory(vfsStream::url('root/parent')); _set_stylesheet_directory(vfsStream::url('root/child')); + $post = (object)array('ID' => 1); + wp_set_post_categories(1, array(2)); + + add_category(1, (object)array('slug' => 'comic', 'parent' => 0)); + add_category(2, (object)array('slug' => 'chapter-1', 'parent' => 1)); + $this->assertEquals($expected_path_result, $this->cp->find_file('index.inc', 'partials', $post_categories)); } }