WordPress.org

Make WordPress Core

Changeset 329 in tests


Ignore:
Timestamp:
01/21/11 17:45:55 (4 years ago)
Author:
duck_
Message:

Fixes to test_includes_pluggable.php, mainly TestAuthFunctions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-testcase/test_includes_pluggable.php

    r322 r329  
    22 
    33class TestAuthFunctions extends WPTestCase { 
    4      
     4    var $user_id; 
     5 
     6    function setUp() { 
     7        parent::setUp(); 
     8        $this->user_id = $this->_make_user(); 
     9    } 
     10 
     11    function tearDown() { 
     12        wp_delete_user( $this->user_id ); 
     13        parent::tearDown(); 
     14    } 
     15 
    516    function test_auth_cookie_valid() { 
    6         $cookie = wp_generate_auth_cookie(1, time() + 3600, 'auth'); 
    7         $this->assertEquals( 1, wp_validate_auth_cookie($cookie, 'auth') ); 
     17        $cookie = wp_generate_auth_cookie( $this->user_id, time() + 3600, 'auth' ); 
     18        $this->assertEquals( $this->user_id, wp_validate_auth_cookie( $cookie, 'auth' ) ); 
    819    } 
    920 
    1021    function test_auth_cookie_invalid() { 
    1122        // expired 
    12         $cookie = wp_generate_auth_cookie(1, time() - 3600, 'auth'); 
    13         $this->assertEquals( false, wp_validate_auth_cookie($cookie, 'auth') ); 
     23        $cookie = wp_generate_auth_cookie( $this->user_id, time() - 3600, 'auth' ); 
     24        $this->assertEquals( false, wp_validate_auth_cookie( $cookie, 'auth' ) ); 
    1425 
    1526        // wrong auth scheme 
    16         $cookie = wp_generate_auth_cookie(1, time() + 3600, 'auth'); 
    17         $this->assertEquals( false, wp_validate_auth_cookie($cookie, 'logged_in') ); 
     27        $cookie = wp_generate_auth_cookie( $this->user_id, time() + 3600, 'auth' ); 
     28        $this->assertEquals( false, wp_validate_auth_cookie( $cookie, 'logged_in' ) ); 
    1829 
    1930        // altered 
    20         $cookie = wp_generate_auth_cookie(1, time() + 3600, 'auth'); 
     31        $cookie = wp_generate_auth_cookie( $this->user_id, time() + 3600, 'auth' ); 
    2132        list($a, $b, $c) = explode('|', $cookie); 
    2233        $cookie = $a . '|' . ($b + 1) . '|' . $c; 
    23         $this->assertEquals( false, wp_validate_auth_cookie($cookie, 'auth') ); 
     34        $this->assertEquals( false, wp_validate_auth_cookie( $this->user_id, 'auth' ) ); 
    2435    } 
    25      
     36 
    2637    function test_auth_cookie_scheme() { 
    2738        // arbitrary scheme name 
    28         $cookie = wp_generate_auth_cookie(1, time() + 3600, 'foo'); 
    29         $this->assertEquals( 1, wp_validate_auth_cookie($cookie, 'foo') ); 
     39        $cookie = wp_generate_auth_cookie( $this->user_id, time() + 3600, 'foo' ); 
     40        $this->assertEquals( $this->user_id, wp_validate_auth_cookie( $cookie, 'foo' ) ); 
    3041 
    3142        // wrong scheme name - should fail 
    32         $cookie = wp_generate_auth_cookie(1, time() + 3600, 'foo'); 
    33         $this->assertEquals( false, wp_validate_auth_cookie($cookie, 'bar') ); 
    34          
     43        $cookie = wp_generate_auth_cookie( $this->user_id, time() + 3600, 'foo' ); 
     44        $this->assertEquals( false, wp_validate_auth_cookie( $cookie, 'bar' ) ); 
    3545    } 
    36  
    3746} 
    3847 
    3948class TestMailFunctions extends WPTestCase { 
    40      
    4149    function test_wp_mail_custom_boundaries() { 
    4250        $to = 'user@example.com'; 
     
    8694------=_Part_4892_25692638.1192452070893-- 
    8795'; 
    88          
     96 
    8997        unset($GLOBALS['phpmailer']->mock_sent); 
    9098        $_SERVER['SERVER_NAME'] = 'example.com'; 
    9199        wp_mail($to, $subject, $body, $headers); 
    92          
     100 
    93101        // We need some better assertions here but these catch the failure for now. 
    94102        $this->assertEquals($body, $GLOBALS['phpmailer']->mock_sent[0]['body']); 
     
    97105        unset( $_SERVER['SERVER_NAME'] ); 
    98106    } 
    99      
     107 
    100108    function test_wp_mail_plain_and_html() { 
    101109        $this->knownWPBug(15448); 
     
    105113        $messages = array( 'text/plain' => 'Here is some plain text.', 
    106114                       'text/html' =>'<html><head></head><body>Here is the HTML ;-)<body></html>' ); 
    107          
     115 
    108116        unset($GLOBALS['phpmailer']->mock_sent); 
    109117        $_SERVER['SERVER_NAME'] = 'example.com'; 
     
    133141        unset( $_SERVER['SERVER_NAME'] ); 
    134142    } 
    135      
    136143} 
    137144 
     
    146153        $this->assertEquals('http://example.com/watchthecarriagereturngo', wp_sanitize_redirect('http://example.com/watchthecarriagereturn%0%0DDgo')); 
    147154    } 
    148      
    149155} 
    150156 
    151157class TestUserFunction extends _WPEmptyBlog { 
    152  
    153158    var $user_ids = array(); 
    154159 
     
    156161        parent::setUp(); 
    157162        // keep track of users we create 
    158         $user_ids = array(); 
     163        $this->user_ids = array(); 
    159164    } 
    160165 
     
    162167        parent::tearDown(); 
    163168        // delete any users that were created during tests 
    164         foreach ($this->user_ids as $id) 
    165             wp_delete_user($id); 
     169        foreach ( $this->user_ids as $id ) 
     170            wp_delete_user( $id ); 
    166171    } 
    167      
     172 
     173    // #13317 
    168174    function test_get_userdata() { 
    169         $this->knownWPBug(13317); 
    170175        $id = $this->_make_user('administrator'); 
    171          
    172176        $this->assertFalse( get_userdata( 0 ) ); 
    173177        $this->assertFalse( get_userdata( 'string' ) ); 
    174178        $this->assertFalse( get_userdata( array( 'array' ) ) ); 
    175          
    176179    } 
    177180} 
Note: See TracChangeset for help on using the changeset viewer.