create categories
This commit is contained in:
parent
fe4f6a867b
commit
33eeae55c8
@ -32,4 +32,14 @@ class PostFixtures {
|
|||||||
}
|
}
|
||||||
return compact('posts', 'categories');
|
return compact('posts', 'categories');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function create_categories($categories) {
|
||||||
|
$category_ids_by_slug = array();
|
||||||
|
if (is_array($categories)) {
|
||||||
|
foreach ($categories as $category) {
|
||||||
|
$category_ids_by_slug[$category] = wp_insert_category(array('slug' => $category));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $category_ids_by_slug;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,4 +106,21 @@ class PostFixturesTest extends PHPUnit_Framework_TestCase {
|
|||||||
function testProcessData($data, $expected_output) {
|
function testProcessData($data, $expected_output) {
|
||||||
$this->assertEquals($expected_output, $this->pf->process_data($data));
|
$this->assertEquals($expected_output, $this->pf->process_data($data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function providerTestCreateCategories() {
|
||||||
|
return array(
|
||||||
|
array(false, array()),
|
||||||
|
array(array(), array()),
|
||||||
|
array(array('test'), array('test' => 1))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider providerTestCreateCategories
|
||||||
|
*/
|
||||||
|
function testCreateCategories($input, $expected_output) {
|
||||||
|
global $wp_test_expectations;
|
||||||
|
|
||||||
|
$this->assertEquals($expected_output, $this->pf->create_categories($input));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user