diff --git a/tests/phpunit/includes/factory.php b/tests/phpunit/includes/factory.php index 4adec23e89..20bad89a96 100644 --- a/tests/phpunit/includes/factory.php +++ b/tests/phpunit/includes/factory.php @@ -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 ); } diff --git a/tests/phpunit/tests/includes/factory.php b/tests/phpunit/tests/includes/factory.php index 34516861e6..9136eeca8c 100644 --- a/tests/phpunit/tests/includes/factory.php +++ b/tests/phpunit/tests/includes/factory.php @@ -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 ); + } }