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

    r35225 r35242  
    4444        $nusers = array();
    4545        foreach ( array('administrator', 'editor', 'author', 'contributor', 'subscriber' ) as $role ) {
    46             $id = self::$factory->user->create( array( 'role' => $role ) );
     46            $id = self::factory()->user->create( array( 'role' => $role ) );
    4747            $nusers[ $id ] = $id;
    4848        }
     
    245245
    246246        foreach ( $roles as $role => $level ) {
    247             $user_id = self::$factory->user->create( array( 'role' => $role ) );
     247            $user_id = self::factory()->user->create( array( 'role' => $role ) );
    248248            $user = new WP_User( $user_id );
    249249
     
    293293
    294294    function test_get() {
    295         $user_id = self::$factory->user->create( array(
     295        $user_id = self::factory()->user->create( array(
    296296            'role' => 'author',
    297297            'user_login' => 'test_wp_user_get',
     
    311311
    312312    function test_has_prop() {
    313         $user_id = self::$factory->user->create( array(
     313        $user_id = self::factory()->user->create( array(
    314314            'role' => 'author',
    315315            'user_login' => 'test_wp_user_has_prop',
     
    328328
    329329    function test_update_user() {
    330         $user_id = self::$factory->user->create( array(
     330        $user_id = self::factory()->user->create( array(
    331331            'role' => 'author',
    332332            'user_login' => 'test_wp_update_user',
     
    384384        global $userdata, $wpdb;
    385385
    386         $user_id = self::$factory->user->create( array( 'role' => 'subscriber' ) );
     386        $user_id = self::factory()->user->create( array( 'role' => 'subscriber' ) );
    387387        wp_set_current_user( $user_id );
    388388
     
    498498     */
    499499    function test_count_many_users_posts() {
    500         $user_id_a = self::$factory->user->create( array( 'role' => 'author' ) );
    501         $user_id_b = self::$factory->user->create( array( 'role' => 'author' ) );
    502         $post_id_a = self::$factory->post->create( array( 'post_author' => $user_id_a ) );
    503         $post_id_b = self::$factory->post->create( array( 'post_author' => $user_id_b ) );
    504         $post_id_c = self::$factory->post->create( array( 'post_author' => $user_id_b, 'post_status' => 'private' ) );
     500        $user_id_a = self::factory()->user->create( array( 'role' => 'author' ) );
     501        $user_id_b = self::factory()->user->create( array( 'role' => 'author' ) );
     502        $post_id_a = self::factory()->post->create( array( 'post_author' => $user_id_a ) );
     503        $post_id_b = self::factory()->post->create( array( 'post_author' => $user_id_b ) );
     504        $post_id_c = self::factory()->post->create( array( 'post_author' => $user_id_b, 'post_status' => 'private' ) );
    505505
    506506        wp_set_current_user( $user_id_a );
     
    772772     */
    773773    public function test_wp_insert_user_should_not_truncate_to_a_duplicate_user_nicename() {
    774         $u1 = self::$factory->user->create( array(
     774        $u1 = self::factory()->user->create( array(
    775775            'user_nicename' => str_repeat( 'a', 50 ),
    776776        ) );
     
    793793     */
    794794    public function test_wp_insert_user_should_not_truncate_to_a_duplicate_user_nicename_when_suffix_has_more_than_one_character() {
    795         $users = self::$factory->user->create_many( 4, array(
     795        $users = self::factory()->user->create_many( 4, array(
    796796            'user_nicename' => str_repeat( 'a', 50 ),
    797797        ) );
     
    877877    function test_email_case() {
    878878        // Create a test user with a lower-case email address.
    879         $user_id = self::$factory->user->create( array(
     879        $user_id = self::factory()->user->create( array(
    880880            'user_email' => 'test@test.com',
    881881        ) );
     
    896896    function test_email_change() {
    897897        // Create a test user.
    898         $user_id = self::$factory->user->create( array(
     898        $user_id = self::factory()->user->create( array(
    899899            'user_email' => 'test@test.com',
    900900        ) );
     
    984984     */
    985985    function test_wp_new_user_notification_old_signature_throws_deprecated_warning() {
    986         $user = self::$factory->user->create( array(
     986        $user = self::factory()->user->create( array(
    987987            'role'       => 'author',
    988988            'user_login' => 'test_wp_new_user_notification',
Note: See TracChangeset for help on using the changeset viewer.