working on actually getting this thing working

This commit is contained in:
John Bintz 2010-02-10 18:31:31 -05:00
parent 5e2579e568
commit c781cab239
4 changed files with 27 additions and 4 deletions

View File

@ -45,15 +45,14 @@ class ComicPressDBInterface {
$this->_prepare_wp_query(); $this->_prepare_wp_query();
if (!is_array($categories)) { $categories = array($categories); } if (!is_array($categories)) { $categories = array($categories); }
$sort_order = $first ? "asc" : "desc"; $sort_order = $first ? "asc" : "desc";
$terminal_comic_query = new WP_Query(); $terminal_comic_query = new WP_Query();
$terminal_comic_query->query(array( $terminal_comic_query->query(array(
'showposts' => 1, 'showposts' => 1,
'order' => $sort_order, 'order' => $sort_order,
'category__in' => $categories, 'category__in' => $categories
'status' => 'publish'
)); ));
$post = false; $post = false;
if ($terminal_comic_query->have_posts()) { if ($terminal_comic_query->have_posts()) {
$post = reset($terminal_comic_query->posts); $post = reset($terminal_comic_query->posts);

View File

@ -112,7 +112,13 @@ class ComicPressTagBuilder {
switch ($method) { switch ($method) {
case 'setup': case 'setup':
if (empty($this->post)) { throw new Exception('You need to have retrieved a post for setup to work'); } if (empty($this->post)) {
if (isset($arguments[0])) {
throw new ComicPressException('You need to have retrieved a post for setup to work');
} else {
return false;
}
}
$this->_setup_postdata($this->post); $this->_setup_postdata($this->post);
return $this->post; return $this->post;
case 'from': case 'from':

View File

@ -31,6 +31,8 @@ add_action('init', '__comicpress_init');
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
function __comicpress_init() { function __comicpress_init() {
global $core;
$classes_search = array( $classes_search = array(
'/classes/', '/classes/backends/' '/classes/', '/classes/backends/'
); );
@ -47,4 +49,8 @@ function __comicpress_init() {
$comicpress_admin = new ComicPressAdmin(); $comicpress_admin = new ComicPressAdmin();
$comicpress_admin->init(); $comicpress_admin->init();
$comicpress_admin->handle_update(); $comicpress_admin->handle_update();
if (!is_admin()) {
$core = new ComicPressTagBuilderFactory();
}
} }

View File

@ -523,6 +523,18 @@ class ComicPressTagBuilderTest extends PHPUnit_Framework_TestCase {
ComicPress::get_instance(true); ComicPress::get_instance(true);
} }
/**
* @expectedException ComicPressException
*/
function testSetupEmptyPostException() {
$core = new ComicPressTagBuilderFactory();
unset($core->post);
$this->assertTrue(false === $core->setup());
$core->setup(true);
}
function providerTestProtect() { function providerTestProtect() {
return array( return array(
array(null, 'test'), array(null, 'test'),