From 3b1727e47674254209cdc0a9348512c3cbfc80b9 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Thu, 4 Feb 2010 20:55:03 -0500 Subject: [PATCH] move storyline structure to tag builder --- classes/ComicPressTagBuilder.inc | 4 ++++ functions.inc | 12 +----------- test/ComicPressTagBuilderTest.php | 14 ++++++++++++++ test/FunctionsTest.php | 8 -------- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/classes/ComicPressTagBuilder.inc b/classes/ComicPressTagBuilder.inc index bd7f50a..4e4f4e6 100644 --- a/classes/ComicPressTagBuilder.inc +++ b/classes/ComicPressTagBuilder.inc @@ -2,6 +2,7 @@ require_once('ComicPressStoryline.inc'); +// TODO Loop preservation class ComicPressTagBuilderFactory { private $storyline, $dbi; @@ -59,6 +60,7 @@ class ComicPressTagBuilder { return new ComicPressComicPost($post); } + // TODO categories (SC and SL) public function __call($method, $arguments) { $ok = false; $return = $this; @@ -115,6 +117,8 @@ class ComicPressTagBuilder { $which = (isset($arguments[1])) ? $arguments[1] : 'default'; return ComicPressBackend::generate_from_id($arguments[0][$which]); } + case 'structure': + return $this->storyline->_structure; default: $methods = $this->parse_method($method, $arguments); if (!empty($methods)) { diff --git a/functions.inc b/functions.inc index edee442..ad2346d 100644 --- a/functions.inc +++ b/functions.inc @@ -18,7 +18,7 @@ foreach (array( } // Global template functions for ComicPress - +// TODO is this even necessary anymore? function F($name, $path, $override_post = null) { global $post; @@ -66,16 +66,6 @@ function Unprotect() { $__post = $__wp_query = null; } -/** - * Return the raw storyline structure. - * @return array The astoryline structure from ComicPressStoryline - */ -function SL() { - $storyline = new ComicPressStoryline(); - $storyline->read_from_options(); - return $storyline->_structure; -} - /** * Get a category relative to the provided category. * If no category is provided, use the current post's category. diff --git a/test/ComicPressTagBuilderTest.php b/test/ComicPressTagBuilderTest.php index bdd880f..e8110af 100644 --- a/test/ComicPressTagBuilderTest.php +++ b/test/ComicPressTagBuilderTest.php @@ -364,4 +364,18 @@ class ComicPressTagBuilderTest extends PHPUnit_Framework_TestCase { $this->assertEquals('my-backend', $core->media(array('default' => 'my-image'))); } + + function testCategoryStructure() { + $storyline = new ComicPressStoryline(); + $storyline->set_flattened_storyline('0/1,0/2,0/3'); + + $dbi = $this->getMock('ComicPressDBInterface'); + $core = new ComicPressTagBuilderFactory($dbi); + + $this->assertEquals(array( + '1' => array('next' => 2, 'level' => 1), + '2' => array('next' => 3, 'previous' => 1, 'level' => 1), + '3' => array('previous' => 2, 'level' => 1), + ), $core->structure()); + } } diff --git a/test/FunctionsTest.php b/test/FunctionsTest.php index ea5b337..4909d3d 100644 --- a/test/FunctionsTest.php +++ b/test/FunctionsTest.php @@ -61,14 +61,6 @@ class FunctionsTest extends PHPUnit_Framework_TestCase { $this->assertTrue(is_null($__wp_query)); } - function testSL() { - $s = new ComicPressStoryline(); - $s->set_flattened_storyline('0/1,0/2,0/2/3'); - $s->read_from_options(); - - $this->assertEquals($s->_structure, SL()); - } - function providerTestSC() { return array( array('next', 1, 2),