fix for adding categories of multiple levels

This commit is contained in:
John Bintz 2010-02-12 18:47:48 -05:00
parent 3ed7e6a475
commit f391a933bd
2 changed files with 15 additions and 4 deletions

View File

@ -131,10 +131,12 @@ class FixtureBuilder {
$category_ids = array();
if (isset($obj['post']['categories'])) {
$category_ids_by_slug = array();
$category_ids = array();
foreach ($obj['post']['categories'] as $category) {
$category_ids_by_slug = array_merge($category_ids_by_slug, PostFixtures::create_category($category));
$created_categories = PostFixtures::create_category($category);
$category_ids[] = array_pop(array_values($created_categories));
$category_ids_by_slug = array_merge($category_ids_by_slug, $created_categories);
}
$category_ids = array_values($category_ids_by_slug);
PostFixtures::set_post_categories($post_id, $category_ids);
}

View File

@ -132,7 +132,7 @@ class FixtureBuilderTest extends PHPUnit_Framework_TestCase {
),
array(
'categories',
array('test')
array('test/test2')
),
array(
'metadata',
@ -163,7 +163,8 @@ class FixtureBuilderTest extends PHPUnit_Framework_TestCase {
)
),
'categories' => array(
1 => 'test'
1 => 'test',
2 => 'test2'
),
'tags' => array(
1 => array('tag1', 'tag2')
@ -172,6 +173,9 @@ class FixtureBuilderTest extends PHPUnit_Framework_TestCase {
1 => array(
'test' => 'test2'
)
),
'post_categories' => array(
1 => array(2)
)
)
),
@ -208,6 +212,11 @@ class FixtureBuilderTest extends PHPUnit_Framework_TestCase {
}
}
break;
case 'post_categories':
foreach ($info as $post_id => $expected_categories) {
$this->assertEquals($expected_categories, wp_get_post_categories($post_id));
}
break;
}
}