cache generate from post info
This commit is contained in:
parent
88e26c8f7d
commit
17ac695134
@ -132,7 +132,9 @@ class ComicPressBackendFilesystem extends ComicPressBackend {
|
|||||||
}
|
}
|
||||||
if (($filename_pattern = $this->has_common_filename_pattern($all_patterns)) !== false) {
|
if (($filename_pattern = $this->has_common_filename_pattern($all_patterns)) !== false) {
|
||||||
if (!empty($files)) {
|
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 = new ComicPressBackendFilesystem();
|
||||||
$fs->id = 'filesystem-' . $post->ID . '-' . $root;
|
$fs->id = 'filesystem-' . $post->ID . '-' . $root;
|
||||||
$fs->files_by_type = $files_for_root;
|
$fs->files_by_type = $files_for_root;
|
||||||
|
@ -141,6 +141,13 @@ class ComicPressBackendFilesystemTest extends PHPUnit_Framework_TestCase {
|
|||||||
'comic' => array('comic'),
|
'comic' => array('comic'),
|
||||||
'rss' => array('rss')
|
'rss' => array('rss')
|
||||||
), $return[0]->files_by_type);
|
), $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() {
|
function providerTestGroupByRoot() {
|
||||||
@ -167,4 +174,24 @@ class ComicPressBackendFilesystemTest extends PHPUnit_Framework_TestCase {
|
|||||||
function testGroupByRoot($pattern, $files, $expected_groupings) {
|
function testGroupByRoot($pattern, $files, $expected_groupings) {
|
||||||
$this->assertEquals($expected_groupings, $this->fs->group_by_root($pattern, $files));
|
$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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user