Term unit test factory class should override `create_and_get()` method.

The override is necessary because the `get_term()` call, which fetches the
term object, needs the `'taxonomy'` argument passed to the factory method.

Props dlh.
Fixes #32536.

git-svn-id: https://develop.svn.wordpress.org/trunk@32659 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Boone Gorges 2015-05-30 13:03:07 +00:00
parent cc19680774
commit a59ebc0ed4
2 changed files with 16 additions and 0 deletions

View File

@ -252,6 +252,12 @@ class WP_UnitTest_Factory_For_Term extends WP_UnitTest_Factory_For_Thing {
return wp_set_post_terms( $post_id, $terms, $taxonomy, $append );
}
function create_and_get( $args = array(), $generation_definitions = null ) {
$term_id = $this->create( $args, $generation_definitions );
$taxonomy = isset( $args['taxonomy'] ) ? $args['taxonomy'] : $this->taxonomy;
return get_term( $term_id, $taxonomy );
}
function get_object_by_id( $term_id ) {
return get_term( $term_id, $this->taxonomy );
}

View File

@ -28,4 +28,14 @@ class TestFactoryFor extends WP_UnitTestCase {
$term = get_term( $id, 'post_tag' );
$this->assertEquals( $id, $term->term_id );
}
/**
* @ticket 32536
*/
public function test_term_factory_create_and_get_should_return_term_object() {
register_taxonomy( 'wptests_tax', 'post' );
$term = $this->factory->term->create_and_get( array( 'taxonomy' => 'wptests_tax' ) );
$this->assertInternalType( 'object', $term );
$this->assertNotEmpty( $term->term_id );
}
}