Make WordPress Core


Ignore:
Timestamp:
10/17/2015 06:02:16 PM (9 years ago)
Author:
wonderboymusic
Message:

Unit Tests: after [35225], make factory a method/getter on WP_UnitTestCase and add magic methods for BC for every plugin that is extending WP_UnitTestCase and accessing the $factory instance prop.

Props nerrad, wonderboymusic.
See #30017, #33968.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/term/getTerm.php

    r35227 r35242  
    2525        global $wpdb;
    2626
    27         $term = self::$factory->term->create_and_get( array( 'taxonomy' => 'wptests_tax' ) );
     27        $term = self::factory()->term->create_and_get( array( 'taxonomy' => 'wptests_tax' ) );
    2828        clean_term_cache( $term->term_id, 'wptests_tax' );
    2929
     
    4747        global $wpdb;
    4848
    49         $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     49        $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    5050        clean_term_cache( $t, 'wptests_tax' );
    5151
     
    6161
    6262    public function test_output_object() {
    63         $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     63        $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    6464        $this->assertInternalType( 'object', get_term( $t, 'wptests_tax', OBJECT ) );
    6565    }
    6666
    6767    public function test_output_array_a() {
    68         $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     68        $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    6969        $term = get_term( $t, 'wptests_tax', ARRAY_A );
    7070        $this->assertInternalType( 'array', $term );
     
    7373
    7474    public function test_output_array_n() {
    75         $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     75        $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    7676        $term = get_term( $t, 'wptests_tax', ARRAY_N );
    7777        $this->assertInternalType( 'array', $term );
     
    8383
    8484    public function test_output_should_fall_back_to_object_for_invalid_input() {
    85         $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     85        $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    8686        $this->assertInternalType( 'object', get_term( $t, 'wptests_tax', 'foo' ) );
    8787    }
     
    9393        global $wpdb;
    9494
    95         $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     95        $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    9696
    9797        // Get raw data from the database.
     
    112112     */
    113113     public function test_should_return_null_when_provided_taxonomy_does_not_match_actual_term_taxonomy() {
    114         $term_id = self::$factory->term->create( array( 'taxonomy' => 'post_tag' ) );
     114        $term_id = self::factory()->term->create( array( 'taxonomy' => 'post_tag' ) );
    115115        $this->assertNull( get_term( $term_id, 'category' ) );
    116116    }
Note: See TracChangeset for help on using the changeset viewer.