WordPress.org

Make WordPress Core

Changeset 1084 in tests


Ignore:
Timestamp:
10/16/12 20:07:34 (18 months ago)
Author:
ryan
Message:

Test passing WP_User and stdClass to the WP_User constructor. Assert that WP_User_Query returns WP_User objects when querying 'all' and 'all_with_meta'. see #WP22057

Location:
trunk/tests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/user.php

    r997 r1084  
    272272        $this->assertEquals( $user_id, $user5->ID ); 
    273273        $this->assertEquals( $user->user_login, $user5->user_login ); 
     274 
     275        $user6 = new WP_User( $user ); 
     276        $this->assertInstanceOf( 'WP_User', $user6 ); 
     277        $this->assertEquals( $user_id, $user6->ID ); 
     278        $this->assertEquals( $user->user_login, $user6->user_login ); 
     279 
     280        $user7 = new WP_User( $user->data ); 
     281        $this->assertInstanceOf( 'WP_User', $user7 ); 
     282        $this->assertEquals( $user_id, $user7->ID ); 
     283        $this->assertEquals( $user->user_login, $user7->user_login ); 
    274284    } 
    275285 
  • trunk/tests/user/query.php

    r1047 r1084  
    55 * @group user 
    66 */ 
    7 class Tests_WP_User_Query extends WP_UnitTestCase { 
     7class Tests_User_Query extends WP_UnitTestCase { 
    88 
    99    protected $user_id; 
     
    5757        $this->assertNotContains( $this->user_id, $ids ); 
    5858    } 
     59 
     60    function test_get_all() { 
     61        $this->factory->user->create_many( 10, array( 
     62            'role' => 'author' 
     63        ) ); 
     64 
     65        $users = new WP_User_Query( array( 'blog_id' => get_current_blog_id() ) ); 
     66        $users = $users->get_results(); 
     67        $this->assertEquals( 12, count( $users ) ); 
     68        foreach ( $users as $user ) { 
     69            $this->assertInstanceOf( 'WP_User', $user ); 
     70        } 
     71 
     72        $users = new WP_User_Query( array( 'blog_id' => get_current_blog_id(), 'fields' => 'all_with_meta' ) ); 
     73        $users = $users->get_results(); 
     74        $this->assertEquals( 12, count( $users ) ); 
     75        foreach ( $users as $user ) { 
     76            $this->assertInstanceOf( 'WP_User', $user ); 
     77        } 
     78    } 
    5979} 
Note: See TracChangeset for help on using the changeset viewer.