backend filesystem code coveragae
This commit is contained in:
parent
f1845daed5
commit
7afe5f7f83
5
Makefile
5
Makefile
|
@ -1,8 +1,11 @@
|
||||||
comicpress28 = $(realpath ../../themes/comicpress-2.8)
|
comicpress28 = $(realpath ../../themes/comicpress-2.8)
|
||||||
|
|
||||||
.PHONY : copy-storyline
|
.PHONY : copy-storyline test
|
||||||
|
|
||||||
copy-storyline :
|
copy-storyline :
|
||||||
ifdef comicpress28
|
ifdef comicpress28
|
||||||
cp classes/ComicPressDBInterface.inc classes/ComicPressNavigation.inc classes/ComicPressStoryline.inc $(comicpress28)/classes
|
cp classes/ComicPressDBInterface.inc classes/ComicPressNavigation.inc classes/ComicPressStoryline.inc $(comicpress28)/classes
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
test:
|
||||||
|
taskset -c 1 phpunit --syntax-check --coverage-html coverage test
|
|
@ -29,12 +29,18 @@ class ComicPressBackendFilesystem extends ComicPressBackend {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while ($any_found);
|
}
|
||||||
|
// @codeCoverageIgnoreStart
|
||||||
|
while ($any_found);
|
||||||
|
// @codeCoverageIgnoreEnd
|
||||||
|
|
||||||
return $this->_searches;
|
return $this->_searches;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @codeCoverageIgnoreStart
|
||||||
function _replace_wordpress($post, $type) { return ABSPATH; }
|
function _replace_wordpress($post, $type) { return ABSPATH; }
|
||||||
|
// @codeCoverageIgnoreEnd
|
||||||
|
|
||||||
function _replace_type($post, $type) { return $type; }
|
function _replace_type($post, $type) { return $type; }
|
||||||
function _replace_y_m_d($post, $type) { return date('Y-m-d', strtotime($post->post_date)); }
|
function _replace_y_m_d($post, $type) { return date('Y-m-d', strtotime($post->post_date)); }
|
||||||
function _replace_year($post, $type) { return date('Y', strtotime($post->post_date)); }
|
function _replace_year($post, $type) { return date('Y', strtotime($post->post_date)); }
|
||||||
|
@ -50,10 +56,14 @@ class ComicPressBackendFilesystem extends ComicPressBackend {
|
||||||
array_unshift($all_slugs, $category->slug);
|
array_unshift($all_slugs, $category->slug);
|
||||||
$current_parent = $category->parent;
|
$current_parent = $category->parent;
|
||||||
} else {
|
} else {
|
||||||
|
$all_slugs = array();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while ($keep_searching);
|
}
|
||||||
|
// @codeCoverageIgnoreStart
|
||||||
|
while ($keep_searching);
|
||||||
|
// @codeCoverageIgnoreEnd
|
||||||
|
|
||||||
$new_searches = array();
|
$new_searches = array();
|
||||||
$slug_count = count($all_slugs);
|
$slug_count = count($all_slugs);
|
||||||
|
|
|
@ -15,6 +15,7 @@ class ComicPressBackendFilesystemTest extends PHPUnit_Framework_TestCase {
|
||||||
return array(
|
return array(
|
||||||
array('/comic/*.jpg', array('/comic/*.jpg')),
|
array('/comic/*.jpg', array('/comic/*.jpg')),
|
||||||
array('%wordpress%/comic/*.jpg', array('/wordpress/comic/*.jpg')),
|
array('%wordpress%/comic/*.jpg', array('/wordpress/comic/*.jpg')),
|
||||||
|
array('%test%/comic/*.jpg', array('/comic/*.jpg')),
|
||||||
array('%wordpress%/%type%/*.jpg', array('/wordpress/comic/*.jpg')),
|
array('%wordpress%/%type%/*.jpg', array('/wordpress/comic/*.jpg')),
|
||||||
array('%wordpress%/comic/%y-m-d%*.jpg', array('/wordpress/comic/2009-01-01*.jpg')),
|
array('%wordpress%/comic/%y-m-d%*.jpg', array('/wordpress/comic/2009-01-01*.jpg')),
|
||||||
array('%wordpress%/comic/%year%/%y-m-d%*.jpg', array('/wordpress/comic/2009/2009-01-01*.jpg')),
|
array('%wordpress%/comic/%year%/%y-m-d%*.jpg', array('/wordpress/comic/2009/2009-01-01*.jpg')),
|
||||||
|
@ -25,25 +26,38 @@ class ComicPressBackendFilesystemTest extends PHPUnit_Framework_TestCase {
|
||||||
'/wordpress/comic/parent/2009-01-01*.jpg',
|
'/wordpress/comic/parent/2009-01-01*.jpg',
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
array(
|
||||||
|
'%wordpress%/comic/%categories%/%y-m-d%*.jpg',
|
||||||
|
array(
|
||||||
|
'/wordpress/comic//2009-01-01*.jpg',
|
||||||
|
),
|
||||||
|
2
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider providerTestProcessSearchString
|
* @dataProvider providerTestProcessSearchString
|
||||||
*/
|
*/
|
||||||
function testProcessSearchString($string, $expected_searches) {
|
function testProcessSearchString($string, $expected_searches, $post_id_to_use = 1) {
|
||||||
$fs = $this->getMock('ComicPressBackendFilesystem', array('_replace_wordpress'));
|
$fs = $this->getMock('ComicPressBackendFilesystem', array('_replace_wordpress'));
|
||||||
|
|
||||||
$fs->expects($this->any())->method('_replace_wordpress')->will($this->returnValue('/wordpress'));
|
$fs->expects($this->any())->method('_replace_wordpress')->will($this->returnValue('/wordpress'));
|
||||||
|
|
||||||
$post = (object)array('ID' => 1, 'post_date' => '2009-01-01');
|
$posts = array(
|
||||||
|
1 => (object)array('ID' => 1, 'post_date' => '2009-01-01'),
|
||||||
|
2 => (object)array('ID' => 2, 'post_date' => '2009-01-01'),
|
||||||
|
);
|
||||||
|
|
||||||
add_category(1, (object)array('slug' => 'parent', 'parent' => 0));
|
add_category(1, (object)array('slug' => 'parent', 'parent' => 0));
|
||||||
add_category(2, (object)array('slug' => 'child', 'parent' => 1));
|
add_category(2, (object)array('slug' => 'child', 'parent' => 1));
|
||||||
|
add_category(4, (object)array('slug' => 'bad', 'parent' => 3));
|
||||||
|
|
||||||
wp_set_post_categories(1, array(2));
|
wp_set_post_categories(1, array(2));
|
||||||
|
wp_set_post_categories(2, array(4));
|
||||||
|
|
||||||
$fs->search_string = $string;
|
$fs->search_string = $string;
|
||||||
|
|
||||||
$this->assertEquals($expected_searches, $fs->process_search_string($post, 'comic'));
|
$this->assertEquals($expected_searches, $fs->process_search_string($posts[$post_id_to_use], 'comic'));
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue