WordPress.org

Make WordPress Core

Changeset 414 in tests


Ignore:
Timestamp:
08/09/11 14:59:53 (3 years ago)
Author:
ryan
Message:

WP_User constructor tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-testcase/test_user.php

    r413 r414  
    210210        $this->assertEquals( $user->ID, $user->id ); 
    211211    } 
     212 
     213    function test_construction() { 
     214        $user_id = $this->_make_user('author'); 
     215 
     216        $user = new WP_User( $user_id ); 
     217        $this->assertInstanceOf( 'WP_User', $user ); 
     218        $this->assertEquals( $user_id, $user->ID ); 
     219 
     220        $user2 = new WP_User( 0,  $user->user_login ); 
     221        $this->assertInstanceOf( 'WP_User', $user2 ); 
     222        $this->assertEquals( $user_id, $user2->ID ); 
     223        $this->assertEquals( $user->user_login, $user2->user_login ); 
     224 
     225        $user3 = new WP_User(); 
     226        $this->assertInstanceOf( 'WP_User', $user3 ); 
     227        $this->assertEquals( 0, $user3->ID ); 
     228        $this->assertFalse( isset( $user3->user_login ) ); 
     229 
     230        $user3->init( $user->data ); 
     231        $this->assertEquals( $user_id, $user3->ID ); 
     232 
     233        $user4 = new WP_User( $user->user_login ); 
     234        $this->assertInstanceOf( 'WP_User', $user4 ); 
     235        $this->assertEquals( $user_id, $user4->ID ); 
     236        $this->assertEquals( $user->user_login, $user4->user_login ); 
     237    } 
    212238} 
    213239 
Note: See TracChangeset for help on using the changeset viewer.