more coverage stuff
This commit is contained in:
parent
e678291d40
commit
ce6912c24e
@ -209,34 +209,6 @@ class ComicPress {
|
||||
return $available_backends;
|
||||
}
|
||||
|
||||
// @codeCoverageIgnoreStart
|
||||
|
||||
function announce_activated_helpers() {
|
||||
echo "<center>[ <strong>Activated ComicPress helpers:</strong> " . implode(", ", array_keys($this->comicpress_options['helpers'])) . " ]</center>";
|
||||
}
|
||||
/**
|
||||
* Gather blog posts for the given index page.
|
||||
*/
|
||||
function get_index_blog_posts_query() {
|
||||
global $post, $paged;
|
||||
|
||||
$t = $post;
|
||||
|
||||
$wp_query = new WP_Query();
|
||||
$wp_query->query(
|
||||
'showposts=' .
|
||||
(int)$this->comicpress_options['blogpost_count'] .
|
||||
'&cat=-' .
|
||||
$this->comicpress_options['comic_category_id'] .
|
||||
'&paged=' .
|
||||
$paged
|
||||
);
|
||||
|
||||
return $wp_query;
|
||||
}
|
||||
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
||||
/**
|
||||
* Search a path for directories named after the slugs provided.
|
||||
* @param array $categories A list of category slugs going from child -> parent -> root.
|
||||
|
@ -40,6 +40,11 @@ class ComicPressTagBuilderFactory {
|
||||
|
||||
return $is_in;
|
||||
}
|
||||
|
||||
public function find_file($name, $path = '', $categories = null) {
|
||||
$comicpress = ComicPress::get_instance();
|
||||
return $comicpress->find_file($name, $path, $categories);
|
||||
}
|
||||
}
|
||||
|
||||
class ComicPressTagBuilder {
|
||||
|
@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
foreach (array(
|
||||
'F' => 3,
|
||||
'Protect' => 0,
|
||||
'Restore' => 0,
|
||||
'Unprotect' => 0,
|
||||
@ -13,17 +12,6 @@ foreach (array(
|
||||
}
|
||||
}
|
||||
|
||||
// Global template functions for ComicPress
|
||||
// TODO is this even necessary anymore?
|
||||
function F($name, $path, $override_post = null) {
|
||||
global $post;
|
||||
|
||||
$comic_post = new ComicPressComicPost(is_null($override_post) ? $post : $override_post);
|
||||
|
||||
$comicpress = ComicPress::get_instance();
|
||||
return $comicpress->find_file($name, $path, $comic_post->find_parents());
|
||||
}
|
||||
|
||||
/**
|
||||
* Protect global $post and $wp_query.
|
||||
* @param object $use_this_post If provided, after saving the current post, set up this post for template tag use.
|
||||
|
@ -505,4 +505,21 @@ class ComicPressTagBuilderTest extends PHPUnit_Framework_TestCase {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function testFindFilePassthru() {
|
||||
$dbi = $this->getMock('ComicPressDBInterface');
|
||||
$core = new ComicPressTagBuilderFactory($dbi);
|
||||
|
||||
$comicpress = $this->getMock('ComicPress', array('find_file'));
|
||||
$comicpress->expects($this->once())
|
||||
->method('find_file')
|
||||
->with('name', 'path', 'categories')
|
||||
->will($this->returnValue('file'));
|
||||
|
||||
ComicPress::get_instance($comicpress);
|
||||
|
||||
$this->assertEquals('file', $core->find_file('name', 'path', 'categories'));
|
||||
|
||||
ComicPress::get_instance(true);
|
||||
}
|
||||
}
|
||||
|
@ -363,4 +363,8 @@ class ComicPressTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
$this->assertEquals($expected_backends, $cp->comicpress_options['enabled_backends']);
|
||||
}
|
||||
|
||||
function testGetInstanceObjectOverride() {
|
||||
$this->assertEquals((object)array(), ComicPress::get_instance((object)array()));
|
||||
}
|
||||
}
|
||||
|
@ -60,35 +60,4 @@ class FunctionsTest extends PHPUnit_Framework_TestCase {
|
||||
$this->assertTrue(is_null($__post));
|
||||
$this->assertTrue(is_null($__wp_query));
|
||||
}
|
||||
|
||||
function providerTestF() {
|
||||
return array(
|
||||
array(null, array(1 => 'one')),
|
||||
array((object)array('ID' => 2), array(2 => 'two'))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerTestF
|
||||
*/
|
||||
function testF($post_to_use, $expected_parents) {
|
||||
global $post;
|
||||
|
||||
$post = (object)array('ID' => 1);
|
||||
|
||||
add_category(1, (object)array('slug' => 'one'));
|
||||
add_category(2, (object)array('slug' => 'two'));
|
||||
|
||||
wp_set_post_categories(1, array(1));
|
||||
wp_set_post_categories(2, array(2));
|
||||
|
||||
$comicpress = $this->getMock('ComicPress', array('find_file'));
|
||||
$comicpress->expects($this->once())->method('find_file')->with('name', 'path', $expected_parents)->will($this->returnValue('done'));
|
||||
|
||||
ComicPress::get_instance($comicpress);
|
||||
|
||||
$this->assertEquals('done', F('name', 'path', $post_to_use));
|
||||
|
||||
ComicPress::get_instance(true);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user