cache generate from post info

This commit is contained in:
John Bintz 2009-11-25 17:39:58 -05:00
parent 88e26c8f7d
commit 17ac695134
2 changed files with 30 additions and 1 deletions

View File

@ -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;

View File

@ -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;
}
}
}