WordPress.org

Make WordPress Core

Changeset 690 in tests


Ignore:
Timestamp:
04/19/12 23:08:38 (3 years ago)
Author:
ryan
Message:

Test global authordata setup.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-testcase/test_user.php

    r676 r690  
    410410    } 
    411411 
     412    function test_global_authordata() { 
     413        global $authordata, $id; 
     414 
     415        $old_post_id = $id; 
     416 
     417        $user_id = $this->_make_user('author'); 
     418        $user = new WP_User( $user_id ); 
     419 
     420        $post = array( 
     421            'post_author' => $user_id, 
     422            'post_status' => 'publish', 
     423            'post_content' => rand_str(), 
     424            'post_title' => rand_str(), 
     425            'post_type' => 'post' 
     426        ); 
     427 
     428        // insert a post and make sure the ID is ok 
     429        $post_id = wp_insert_post( $post ); 
     430        $this->assertTrue( is_numeric( $post_id ) ); 
     431 
     432        setup_postdata( get_post( $post_id ) ); 
     433 
     434        $this->assertNotEmpty( $authordata ); 
     435        $this->assertInstanceOf( 'WP_User', $authordata ); 
     436        $this->assertEquals( $authordata->ID, $user_id ); 
     437 
     438        setup_postdata( get_post( $old_post_id ) ); 
     439 
     440        wp_delete_post( $post_id, true ); 
     441    } 
    412442} 
    413443 
Note: See TracChangeset for help on using the changeset viewer.