Make WordPress Core

Changeset 32659


Ignore:
Timestamp:
05/30/2015 01:03:07 PM (11 years ago)
Author:
boonebgorges
Message:

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.

Location:
trunk/tests/phpunit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/factory.php

    r27178 r32659  
    251251        function add_post_terms( $post_id, $terms, $taxonomy, $append = true ) {
    252252                return wp_set_post_terms( $post_id, $terms, $taxonomy, $append );
     253        }
     254
     255        function create_and_get( $args = array(), $generation_definitions = null ) {
     256                $term_id = $this->create( $args, $generation_definitions );
     257                $taxonomy = isset( $args['taxonomy'] ) ? $args['taxonomy'] : $this->taxonomy;
     258                return get_term( $term_id, $taxonomy );
    253259        }
    254260
  • trunk/tests/phpunit/tests/includes/factory.php

    r25002 r32659  
    2929                $this->assertEquals( $id, $term->term_id );
    3030        }
     31
     32        /**
     33         * @ticket 32536
     34         */
     35        public function test_term_factory_create_and_get_should_return_term_object() {
     36                register_taxonomy( 'wptests_tax', 'post' );
     37                $term = $this->factory->term->create_and_get( array( 'taxonomy' => 'wptests_tax' ) );
     38                $this->assertInternalType( 'object', $term );
     39                $this->assertNotEmpty( $term->term_id );
     40        }
    3141}
Note: See TracChangeset for help on using the changeset viewer.