From 17ac695134f4fe7d6bd932261fcd0c639096d5e6 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Wed, 25 Nov 2009 17:39:58 -0500 Subject: [PATCH] cache generate from post info --- .../backends/ComicPressBackendFilesystem.inc | 4 ++- .../ComicPressBackendFilesystemTest.php | 27 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/classes/backends/ComicPressBackendFilesystem.inc b/classes/backends/ComicPressBackendFilesystem.inc index 62416a7..1e236de 100644 --- a/classes/backends/ComicPressBackendFilesystem.inc +++ b/classes/backends/ComicPressBackendFilesystem.inc @@ -132,7 +132,9 @@ class ComicPressBackendFilesystem extends ComicPressBackend { } if (($filename_pattern = $this->has_common_filename_pattern($all_patterns)) !== false) { if (!empty($files)) { - foreach ($this->group_by_root($filename_pattern, $files) as $root => $files_for_root) { + $grouped_by_root = $this->group_by_root($filename_pattern, $files); + update_post_meta($post->ID, 'backend_filesystem_files_by_type', $grouped_by_root); + foreach ($grouped_by_root as $root => $files_for_root) { $fs = new ComicPressBackendFilesystem(); $fs->id = 'filesystem-' . $post->ID . '-' . $root; $fs->files_by_type = $files_for_root; diff --git a/test/backends/ComicPressBackendFilesystemTest.php b/test/backends/ComicPressBackendFilesystemTest.php index 8c0725c..85e8429 100644 --- a/test/backends/ComicPressBackendFilesystemTest.php +++ b/test/backends/ComicPressBackendFilesystemTest.php @@ -141,6 +141,13 @@ class ComicPressBackendFilesystemTest extends PHPUnit_Framework_TestCase { 'comic' => array('comic'), 'rss' => array('rss') ), $return[0]->files_by_type); + + $this->assertEquals(array( + 'root' => array( + 'comic' => array('comic'), + 'rss' => array('rss'), + ) + ), get_post_meta(1, 'backend_filesystem_files_by_type', true)); } function providerTestGroupByRoot() { @@ -167,4 +174,24 @@ class ComicPressBackendFilesystemTest extends PHPUnit_Framework_TestCase { function testGroupByRoot($pattern, $files, $expected_groupings) { $this->assertEquals($expected_groupings, $this->fs->group_by_root($pattern, $files)); } + + function providerTestGenerateFromID() { + return array( + array('blah', false) + ); + } + + /** + * @dataProvider providerTestGenerateFromID + */ + function testGenerateFromID($id, $is_successful) { + $this->markTestIncomplete(); + wp_insert_post((object)array('ID' => 1)); + + if ($is_successful) { + $return = new ComicPressBackendFilesystem(); + } else { + $return = false; + } + } }