Make WordPress Core


Ignore:
Timestamp:
10/17/2015 06:02:16 PM (11 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/customize/nav-menus.php

    r35225 r35242  
    2323                parent::setUp();
    2424                require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
    25                 wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
     25                wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    2626                global $wp_customize;
    2727                $this->wp_customize = new WP_Customize_Manager();
     
    125125
    126126                // Create pages.
    127                 self::$factory->post->create_many( 12, array( 'post_type' => 'page' ) );
     127                self::factory()->post->create_many( 12, array( 'post_type' => 'page' ) );
    128128
    129129                // Home is included in menu items when page is zero.
     
    146146
    147147                // Create page.
    148                 $post_id = self::$factory->post->create( array( 'post_title' => 'Post Title' ) );
     148                $post_id = self::factory()->post->create( array( 'post_title' => 'Post Title' ) );
    149149
    150150                // Create pages.
    151                 self::$factory->post->create_many( 10 );
     151                self::factory()->post->create_many( 10 );
    152152
    153153                // Expected menu item array.
     
    176176
    177177                // Create page.
    178                 $page_id = self::$factory->post->create( array( 'post_title' => 'Page Title', 'post_type' => 'page' ) );
     178                $page_id = self::factory()->post->create( array( 'post_title' => 'Page Title', 'post_type' => 'page' ) );
    179179
    180180                // Expected menu item array.
     
    202202
    203203                // Create post.
    204                 $post_id = self::$factory->post->create( array( 'post_title' => 'Post Title' ) );
     204                $post_id = self::factory()->post->create( array( 'post_title' => 'Post Title' ) );
    205205
    206206                // Expected menu item array.
     
    228228
    229229                // Create term.
    230                 $term_id = self::$factory->category->create( array( 'name' => 'Term Title' ) );
     230                $term_id = self::factory()->category->create( array( 'name' => 'Term Title' ) );
    231231
    232232                // Expected menu item array.
     
    280280                // Create posts
    281281                $post_ids = array();
    282                 $post_ids[] = self::$factory->post->create( array( 'post_title' => 'Search & Test' ) );
    283                 $post_ids[] = self::$factory->post->create( array( 'post_title' => 'Some Other Title' ) );
     282                $post_ids[] = self::factory()->post->create( array( 'post_title' => 'Search & Test' ) );
     283                $post_ids[] = self::factory()->post->create( array( 'post_title' => 'Some Other Title' ) );
    284284
    285285                // Create terms
    286286                $term_ids = array();
    287                 $term_ids[] = self::$factory->category->create( array( 'name' => 'Dogs Are Cool' ) );
    288                 $term_ids[] = self::$factory->category->create( array( 'name' => 'Cats Drool' ) );
     287                $term_ids[] = self::factory()->category->create( array( 'name' => 'Dogs Are Cool' ) );
     288                $term_ids[] = self::factory()->category->create( array( 'name' => 'Cats Drool' ) );
    289289
    290290                // Test empty results
     
    387387                do_action( 'customize_register', $this->wp_customize );
    388388                $menu_id = wp_create_nav_menu( 'Primary' );
    389                 $post_id = self::$factory->post->create( array( 'post_title' => 'Hello World' ) );
     389                $post_id = self::factory()->post->create( array( 'post_title' => 'Hello World' ) );
    390390                $item_id = wp_update_nav_menu_item( $menu_id, 0, array(
    391391                        'menu-item-type'      => 'post_type',
Note: See TracChangeset for help on using the changeset viewer.