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/query.php

    r35225 r35242  
    126126
    127127    public function test_transform_query_resulting_field_sanitized() {
    128         $t1 = self::$factory->category->create( array( 'slug' => 'foo', ) );
    129         $t2 = self::$factory->category->create( array( 'slug' => 'bar', ) );
    130         $p = self::$factory->post->create();
     128        $t1 = self::factory()->category->create( array( 'slug' => 'foo', ) );
     129        $t2 = self::factory()->category->create( array( 'slug' => 'bar', ) );
     130        $p = self::factory()->post->create();
    131131        wp_set_post_categories( $p, $t1 );
    132132
     
    151151
    152152    public function test_transform_query_field_slug() {
    153         $t1 = self::$factory->category->create( array( 'slug' => 'foo', ) );
    154         $p = self::$factory->post->create();
     153        $t1 = self::factory()->category->create( array( 'slug' => 'foo', ) );
     154        $p = self::factory()->post->create();
    155155        $tt_ids = wp_set_post_categories( $p, $t1 );
    156156
     
    169169
    170170    public function test_transform_query_field_name() {
    171         $t1 = self::$factory->category->create( array( 'slug' => 'foo', 'name' => 'Foo', ) );
    172         $p = self::$factory->post->create();
     171        $t1 = self::factory()->category->create( array( 'slug' => 'foo', 'name' => 'Foo', ) );
     172        $p = self::factory()->post->create();
    173173        $tt_ids = wp_set_post_categories( $p, $t1 );
    174174
     
    187187
    188188    public function test_transform_query_field_term_taxonomy_id() {
    189         $t1 = self::$factory->category->create( array( 'slug' => 'foo', 'name' => 'Foo', ) );
    190         $p = self::$factory->post->create();
     189        $t1 = self::factory()->category->create( array( 'slug' => 'foo', 'name' => 'Foo', ) );
     190        $p = self::factory()->post->create();
    191191        $tt_ids = wp_set_post_categories( $p, $t1 );
    192192
     
    205205
    206206    public function test_transform_query_field_term_taxonomy_default() {
    207         $t1 = self::$factory->category->create( array( 'slug' => 'foo', 'name' => 'Foo', ) );
    208         $p = self::$factory->post->create();
     207        $t1 = self::factory()->category->create( array( 'slug' => 'foo', 'name' => 'Foo', ) );
     208        $p = self::factory()->post->create();
    209209        $tt_ids = wp_set_post_categories( $p, $t1 );
    210210
     
    241241        register_taxonomy( 'wptests_tax', 'post' );
    242242
    243         $t1 = self::$factory->term->create( array(
    244             'taxonomy' => 'wptests_tax',
    245         ) );
    246         $t2 = self::$factory->term->create( array(
    247             'taxonomy' => 'wptests_tax',
    248         ) );
    249         $t3 = self::$factory->term->create( array(
     243        $t1 = self::factory()->term->create( array(
     244            'taxonomy' => 'wptests_tax',
     245        ) );
     246        $t2 = self::factory()->term->create( array(
     247            'taxonomy' => 'wptests_tax',
     248        ) );
     249        $t3 = self::factory()->term->create( array(
    250250            'taxonomy' => 'wptests_tax',
    251251        ) );
     
    285285        register_taxonomy( 'wptests_tax', 'post' );
    286286
    287         $t1 = self::$factory->term->create( array(
    288             'taxonomy' => 'wptests_tax',
    289         ) );
    290         $t2 = self::$factory->term->create( array(
    291             'taxonomy' => 'wptests_tax',
    292         ) );
    293         $t3 = self::$factory->term->create( array(
     287        $t1 = self::factory()->term->create( array(
     288            'taxonomy' => 'wptests_tax',
     289        ) );
     290        $t2 = self::factory()->term->create( array(
     291            'taxonomy' => 'wptests_tax',
     292        ) );
     293        $t3 = self::factory()->term->create( array(
    294294            'taxonomy' => 'wptests_tax',
    295295        ) );
     
    328328        register_taxonomy( 'wptests_tax', 'post' );
    329329
    330         $t1 = self::$factory->term->create( array(
    331             'taxonomy' => 'wptests_tax',
    332         ) );
    333         $t2 = self::$factory->term->create( array(
    334             'taxonomy' => 'wptests_tax',
    335         ) );
    336         $t3 = self::$factory->term->create( array(
     330        $t1 = self::factory()->term->create( array(
     331            'taxonomy' => 'wptests_tax',
     332        ) );
     333        $t2 = self::factory()->term->create( array(
     334            'taxonomy' => 'wptests_tax',
     335        ) );
     336        $t3 = self::factory()->term->create( array(
    337337            'taxonomy' => 'wptests_tax',
    338338        ) );
Note: See TracChangeset for help on using the changeset viewer.