remove all categories

This commit is contained in:
John Bintz 2009-11-22 17:58:34 -05:00
parent d69d1111f2
commit 95d7498101
2 changed files with 23 additions and 0 deletions

View File

@ -15,4 +15,10 @@ class PostFixtures {
foreach ($posts as $post) { wp_delete_post($post->ID); }
}
}
function remove_all_categories() {
foreach (get_all_category_ids() as $id) {
wp_delete_category($id);
}
}
}

View File

@ -52,4 +52,21 @@ class PostFixturesTest extends PHPUnit_Framework_TestCase {
$this->assertEquals(0, count($wp_test_expectations['posts']));
$this->assertEquals(0, count($wp_test_expectations['post_meta']));
}
function testRemoveAllCategories() {
global $wp_test_expectations;
update_option('default_category', 0);
for ($i = 0; $i < 5; ++$i) {
add_category($i, (object)array('slug' => 'test-' . $i));
}
$this->assertEquals(5, count($wp_test_expectations['categories']));
$this->pf->remove_all_categories();
$this->assertEquals(1, count($wp_test_expectations['categories']));
$result = get_category(0);
$this->assertTrue(isset($result->term_id));
}
}