from working

This commit is contained in:
John Bintz 2010-02-02 21:12:31 -05:00
parent 672d8a2255
commit c24214afff
2 changed files with 24 additions and 1 deletions

View File

@ -45,6 +45,16 @@ class ComicPressTagBuilder {
if (empty($this->post)) { throw new Exception('You need to have retrieved a post for setup to work'); }
$this->_setup_postdata($this->post);
return $this->post;
case 'from':
if (!isset($arguments[0])) {
throw new ComicPressException('Need to specify a post');
}
if (!is_object($arguments[0]) && !is_array($arguments[0])) {
throw new ComicPressException('Provided post needs to be an array or object');
}
$this->parent_post = (object)$arguments[0];
$ok = true;
break;
case 'next':
case 'previous':
case 'first':
@ -53,7 +63,9 @@ class ComicPressTagBuilder {
$ok = true;
break;
case 'in':
if (!isset($arguments[0])) { throw new Exception('Need to specify a category'); }
if (!isset($arguments[0])) {
throw new ComicPressException('Need to specify a category');
}
$this->restrictions[] = array('child_of', $arguments[0]);
$ok = true;
break;

View File

@ -63,6 +63,14 @@ class ComicPressTagBuilderTest extends PHPUnit_Framework_TestCase {
array('get_first_post', array(2,3,4), 'current-post'),
true
),
array(
array(
array('from', (object)array('other-post' => 'post')),
array('in', 2),
array('first')
),
array('get_first_post', array(2,3,4), (object)array('other-post' => 'post')),
)
);
}
@ -168,6 +176,9 @@ class ComicPressTagBuilderTest extends PHPUnit_Framework_TestCase {
array(array('bad')),
array(array(array('in', 1), 'bad')),
array(array(array('in', 1), 'date')),
array(array(array('from', 'test'))),
array(array(array('in'))),
array(array(array('from'))),
);
}