WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/25/2016 05:48:22 AM (5 years ago)
Author:
jeremyfelt
Message:

Multisite: Replace get_blog_details() in add_user_to_blog() with get_site().

Adds tests for add_user_to_blog().

Props flixos90.
Fixes #38356.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/user/multisite.php

    r37318 r38903  
    366366        $this->assertEquals( $u_obj->ID, username_exists( $u_obj->user_login ) );
    367367    }
     368
     369    /**
     370     * @ticket 38356
     371     */
     372    public function test_add_user_to_blog_subscriber() {
     373        $site_id = self::factory()->blog->create();
     374        $user_id = self::factory()->user->create();
     375
     376        add_user_to_blog( $site_id, $user_id, 'subscriber' );
     377
     378        switch_to_blog( $site_id );
     379        $user = get_user_by( 'id', $user_id );
     380        restore_current_blog();
     381
     382        wpmu_delete_blog( $site_id );
     383        wpmu_delete_user( $user_id );
     384
     385        $this->assertContains( 'subscriber', $user->roles );
     386    }
     387
     388    /**
     389     * @ticket 38356
     390     */
     391    public function test_add_user_to_blog_invalid_user() {
     392        $site_id = self::factory()->blog->create();
     393
     394        $result = add_user_to_blog( 73622, $site_id, 'subscriber' );
     395        wpmu_delete_blog( $site_id );
     396
     397        $this->assertWPError( $result );
     398    }
    368399}
    369400
Note: See TracChangeset for help on using the changeset viewer.