working on tag building
This commit is contained in:
parent
6f5a5dc396
commit
424382906e
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once('ComicPressDBInterface.inc');
|
require_once('ComicPressDBInterface.inc');
|
||||||
|
require_once('ComicPress.inc');
|
||||||
|
|
||||||
class ComicPressStoryline {
|
class ComicPressStoryline {
|
||||||
var $_structure;
|
var $_structure;
|
||||||
|
@ -42,6 +42,10 @@ class ComicPressTagBuilder {
|
|||||||
case 'last':
|
case 'last':
|
||||||
$this->post = call_user_func(array($this->dbi, "get_${method}_post"), $this->storyline->build_from_restrictions($this->restrictions), $this->parent_post);
|
$this->post = call_user_func(array($this->dbi, "get_${method}_post"), $this->storyline->build_from_restrictions($this->restrictions), $this->parent_post);
|
||||||
break;
|
break;
|
||||||
|
case 'in':
|
||||||
|
if (!isset($arguments[0])) { throw new Exception('Need to specify a category'); }
|
||||||
|
$this->restrictions[] = array('child_of', $arguments[0]);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -10,12 +10,50 @@ class ComicPressTagBuilderTest extends PHPUnit_Framework_TestCase {
|
|||||||
_reset_wp();
|
_reset_wp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function testNewFactory() {
|
||||||
|
$core = new ComicPressTagBuilderFactory();
|
||||||
|
}
|
||||||
|
|
||||||
function providerTestBuilder() {
|
function providerTestBuilder() {
|
||||||
return array(
|
return array(
|
||||||
array(
|
array(
|
||||||
array('next'),
|
array(
|
||||||
|
array('next')
|
||||||
|
),
|
||||||
array('get_next_post', array(1,2,3,4,5), 'current-post')
|
array('get_next_post', array(1,2,3,4,5), 'current-post')
|
||||||
)
|
),
|
||||||
|
array(
|
||||||
|
array(
|
||||||
|
array('previous'),
|
||||||
|
),
|
||||||
|
array('get_previous_post', array(1,2,3,4,5), 'current-post')
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array(
|
||||||
|
array('first'),
|
||||||
|
),
|
||||||
|
array('get_first_post', array(1,2,3,4,5), 'current-post')
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array(
|
||||||
|
array('last'),
|
||||||
|
),
|
||||||
|
array('get_last_post', array(1,2,3,4,5), 'current-post')
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array(
|
||||||
|
array('in', 'category-1'),
|
||||||
|
array('last')
|
||||||
|
),
|
||||||
|
array('get_last_post', array(1), 'current-post')
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array(
|
||||||
|
array('in', 2),
|
||||||
|
array('first')
|
||||||
|
),
|
||||||
|
array('get_first_post', array(2,3,4), 'current-post')
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,7 +61,7 @@ class ComicPressTagBuilderTest extends PHPUnit_Framework_TestCase {
|
|||||||
* @dataProvider providerTestBuilder
|
* @dataProvider providerTestBuilder
|
||||||
*/
|
*/
|
||||||
function testStorylineBuilder($instructions, $expected_dbi_call) {
|
function testStorylineBuilder($instructions, $expected_dbi_call) {
|
||||||
global $post;
|
global $post, $wp_test_expectations;
|
||||||
$post = 'current-post';
|
$post = 'current-post';
|
||||||
|
|
||||||
$method = array_shift($expected_dbi_call);
|
$method = array_shift($expected_dbi_call);
|
||||||
@ -38,17 +76,18 @@ class ComicPressTagBuilderTest extends PHPUnit_Framework_TestCase {
|
|||||||
$storyline->set_flattened_storyline('0/1,0/2,0/2/3,0/2/4,0/5');
|
$storyline->set_flattened_storyline('0/1,0/2,0/2/3,0/2/4,0/5');
|
||||||
|
|
||||||
foreach (array(
|
foreach (array(
|
||||||
array('cat_ID' => 1, 'cat_name' => 'Test 1', 'category_nicename' => 'category-1', 'category_parent' => 0),
|
1 => array('cat_name' => 'Test 1', 'category_nicename' => 'category-1', 'category_parent' => 0),
|
||||||
array('cat_ID' => 2, 'cat_name' => 'Test 2', 'category_nicename' => 'category-2', 'category_parent' => 0),
|
2 => array('cat_name' => 'Test 2', 'category_nicename' => 'category-2', 'category_parent' => 0),
|
||||||
array('cat_ID' => 3, 'cat_name' => 'Test 3', 'category_nicename' => 'category-3', 'category_parent' => 2),
|
3 => array('cat_name' => 'Test 3', 'category_nicename' => 'category-3', 'category_parent' => 2),
|
||||||
array('cat_ID' => 4, 'cat_name' => 'Test 4', 'category_nicename' => 'category-4', 'category_parent' => 2),
|
4 => array('cat_name' => 'Test 4', 'category_nicename' => 'category-4', 'category_parent' => 2),
|
||||||
array('cat_ID' => 5, 'cat_name' => 'Test 5', 'category_nicename' => 'category-5', 'category_parent' => 0),
|
5 => array('cat_name' => 'Test 5', 'category_nicename' => 'category-5', 'category_parent' => 0),
|
||||||
) as $category) {
|
) as $id => $category) {
|
||||||
wp_insert_category($category);
|
add_category($id, (object)$category);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($instructions as $instruction) {
|
foreach ($instructions as $instruction) {
|
||||||
$core = $core->{$instruction}();
|
$method = array_shift($instruction);
|
||||||
|
$core = call_user_func_array(array($core, $method), $instruction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user