WordPress.org

Make WordPress Core

Changeset 429 in tests


Ignore:
Timestamp:
08/24/2011 07:34:15 PM (7 years ago)
Author:
ryan
Message:

Test WP_User::has_prop() and WP_User::get(). Add test for WP_User contruction with null ID.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-testcase/test_user.php

    r414 r429  
    235235        $this->assertEquals( $user_id, $user4->ID );
    236236        $this->assertEquals( $user->user_login, $user4->user_login );
     237
     238        $user5 = new WP_User( null, $user->user_login );
     239        $this->assertInstanceOf( 'WP_User', $user5 );
     240        $this->assertEquals( $user_id, $user5->ID );
     241        $this->assertEquals( $user->user_login, $user5->user_login );
     242    }
     243
     244    function test_get() {
     245        $user_id = $this->_make_user('author', 'test_wp_user_get', 'password', 'test@test.com');
     246
     247        $user = new WP_User( $user_id );
     248        $this->assertEquals( 'test_wp_user_get', $user->get( 'user_login' ) );
     249        $this->assertEquals( 'test@test.com', $user->get( 'user_email' ) );
     250        $this->assertEquals( 0, $user->get( 'use_ssl' ) );
     251        $this->assertEquals( '', $user->get( 'field_that_does_not_exist' ) );
     252
     253        update_user_meta( $user_id, 'dashed-key', 'abcdefg' );
     254        $this->assertEquals( 'abcdefg', $user->get( 'dashed-key' ) );
     255    }
     256
     257    function test_has_prop() {
     258        $user_id = $this->_make_user('author', 'test_wp_user_has_prop', 'password', 'test2@test.com');
     259
     260        $user = new WP_User( $user_id );
     261        $this->assertTrue( $user->has_prop( 'user_email') );
     262        $this->assertTrue( $user->has_prop( 'use_ssl' ) );
     263        $this->assertFalse( $user->has_prop( 'field_that_does_not_exist' ) );
     264
     265        update_user_meta( $user_id, 'dashed-key', 'abcdefg' );
     266        $this->assertTrue( $user->has_prop( 'dashed-key' ) );
    237267    }
    238268}
Note: See TracChangeset for help on using the changeset viewer.