WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/17/2015 06:02:16 PM (6 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/adminbar.php

    r35225 r35242  
    1616     */
    1717    function test_content_post_type() {
    18         wp_set_current_user( self::$factory->user->create( array( 'role' => 'editor' ) ) );
     18        wp_set_current_user( self::factory()->user->create( array( 'role' => 'editor' ) ) );
    1919
    2020        register_post_type( 'content', array( 'show_in_admin_bar' => true ) );
     
    3535     */
    3636    function test_merging_existing_meta_values() {
    37         wp_set_current_user( self::$factory->user->create( array( 'role' => 'editor' ) ) );
     37        wp_set_current_user( self::factory()->user->create( array( 'role' => 'editor' ) ) );
    3838
    3939        $admin_bar = new WP_Admin_Bar;
     
    6363        }
    6464
    65         $nobody = self::$factory->user->create( array( 'role' => '' ) );
     65        $nobody = self::factory()->user->create( array( 'role' => '' ) );
    6666        $this->assertFalse( user_can( $nobody, 'read' ) );
    6767
     
    9393        }
    9494
    95         $editor = self::$factory->user->create( array( 'role' => 'editor' ) );
     95        $editor = self::factory()->user->create( array( 'role' => 'editor' ) );
    9696        $this->assertTrue( user_can( $editor, 'read' ) );
    9797
     
    126126        }
    127127
    128         $admin  = self::$factory->user->create( array( 'role' => 'administrator' ) );
    129         $editor = self::$factory->user->create( array( 'role' => 'editor' ) );
     128        $admin  = self::factory()->user->create( array( 'role' => 'administrator' ) );
     129        $editor = self::factory()->user->create( array( 'role' => 'editor' ) );
    130130
    131131        $this->assertTrue( user_can( $admin, 'read' ) );
    132132        $this->assertTrue( user_can( $editor, 'read' ) );
    133133
    134         $new_blog_id = self::$factory->blog->create( array(
     134        $new_blog_id = self::factory()->blog->create( array(
    135135            'user_id' => $admin,
    136136        ) );
     
    180180        }
    181181
    182         $admin  = self::$factory->user->create( array( 'role' => 'administrator' ) );
    183         $nobody = self::$factory->user->create( array( 'role' => '' ) );
     182        $admin  = self::factory()->user->create( array( 'role' => 'administrator' ) );
     183        $nobody = self::factory()->user->create( array( 'role' => '' ) );
    184184
    185185        $this->assertTrue( user_can( $admin, 'read' ) );
    186186        $this->assertFalse( user_can( $nobody, 'read' ) );
    187187
    188         $new_blog_id = self::$factory->blog->create( array(
     188        $new_blog_id = self::factory()->blog->create( array(
    189189            'user_id' => $admin,
    190190        ) );
Note: See TracChangeset for help on using the changeset viewer.