WordPress.org

Make WordPress Core

Changeset 695 in tests


Ignore:
Timestamp:
04/24/12 15:01:34 (2 years ago)
Author:
nacin
Message:

get_the_author_meta() unit tests for [WP20575]. Clean up the setup and teardown of TestWPAuthor.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-testcase/test_includes_author.php

    r692 r695  
    1717        $this->_deprecated_errors = array(); 
    1818 
    19         global $id; 
    20  
    21         $this->old_post_id = $id; 
    22  
    23         $this->author_id = $this->_make_user( 'author', 'test_author' ); 
     19        $this->author_id = $this->_make_user( 'author', 'test_author' );     
    2420        $user = new WP_User( $this->author_id ); 
    2521 
     
    4036    function tearDown() { 
    4137        parent::tearDown(); 
     38 
    4239        // delete any users that were created during tests 
    4340        $this->_destroy_users(); 
    4441 
    45         setup_postdata( get_post( $this->old_post_id ) ); 
     42        wp_reset_postdata(); 
    4643    } 
    4744 
     
    6360 
    6461    function test_get_the_author_meta() { 
    65         $user = new WP_User( $this->author_id ); 
    66  
    6762        $this->assertEquals( 'test_author', get_the_author_meta( 'login' ) ); 
    6863        $this->assertEquals( 'test_author', get_the_author_meta( 'user_login' ) ); 
     
    8378 
    8479        $this->assertEquals( '', get_the_author_meta( 'does_not_exist' ) ); 
    85          
     80    } 
     81 
     82    function test_get_the_author_meta_no_authordata() { 
     83        unset( $GLOBALS['authordata'] ); 
     84        $this->assertEquals( '', get_the_author_meta( 'id' ) ); 
     85        $this->assertEquals( '', get_the_author_meta( 'user_login' ) ); 
     86        $this->assertEquals( '', get_the_author_meta( 'does_not_exist' ) ); 
    8687    } 
    8788} 
Note: See TracChangeset for help on using the changeset viewer.