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();
if (!is_array($categories)) { $categories = array($categories); }
$sort_order = $first ? "asc" : "desc";
$terminal_comic_query = new WP_Query();
$terminal_comic_query->query(array(
'showposts' => 1,
'order' => $sort_order,
'category__in' => $categories,
'status' => 'publish'
'category__in' => $categories
));
$post = false;
if ($terminal_comic_query->have_posts()) {
$post = reset($terminal_comic_query->posts);

View File

@ -112,7 +112,13 @@ class ComicPressTagBuilder {
switch ($method) {
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);
return $this->post;
case 'from':

View File

@ -31,6 +31,8 @@ add_action('init', '__comicpress_init');
// @codeCoverageIgnoreStart
function __comicpress_init() {
global $core;
$classes_search = array(
'/classes/', '/classes/backends/'
);
@ -47,4 +49,8 @@ function __comicpress_init() {
$comicpress_admin = new ComicPressAdmin();
$comicpress_admin->init();
$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);
}
/**
* @expectedException ComicPressException
*/
function testSetupEmptyPostException() {
$core = new ComicPressTagBuilderFactory();
unset($core->post);
$this->assertTrue(false === $core->setup());
$core->setup(true);
}
function providerTestProtect() {
return array(
array(null, 'test'),