From c24214afffd635842ec59a0836cbaaf9bab99e1b Mon Sep 17 00:00:00 2001 From: John Bintz Date: Tue, 2 Feb 2010 21:12:31 -0500 Subject: [PATCH] from working --- classes/ComicPressTagBuilder.inc | 14 +++++++++++++- test/ComicPressTagBuilderTest.php | 11 +++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/classes/ComicPressTagBuilder.inc b/classes/ComicPressTagBuilder.inc index 4c11c3d..a046b72 100644 --- a/classes/ComicPressTagBuilder.inc +++ b/classes/ComicPressTagBuilder.inc @@ -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; diff --git a/test/ComicPressTagBuilderTest.php b/test/ComicPressTagBuilderTest.php index 4f5bd8f..9a01abd 100644 --- a/test/ComicPressTagBuilderTest.php +++ b/test/ComicPressTagBuilderTest.php @@ -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'))), ); }