Changeset 329 in tests
- Timestamp:
- 01/21/2011 05:45:55 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
wp-testcase/test_includes_pluggable.php
r322 r329 2 2 3 3 class 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 5 16 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' ) ); 8 19 } 9 20 10 21 function test_auth_cookie_invalid() { 11 22 // 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' ) ); 14 25 15 26 // 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' ) ); 18 29 19 30 // altered 20 $cookie = wp_generate_auth_cookie( 1, time() + 3600, 'auth');31 $cookie = wp_generate_auth_cookie( $this->user_id, time() + 3600, 'auth' ); 21 32 list($a, $b, $c) = explode('|', $cookie); 22 33 $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' ) ); 24 35 } 25 36 26 37 function test_auth_cookie_scheme() { 27 38 // 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' ) ); 30 41 31 42 // 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' ) ); 35 45 } 36 37 46 } 38 47 39 48 class TestMailFunctions extends WPTestCase { 40 41 49 function test_wp_mail_custom_boundaries() { 42 50 $to = 'user@example.com'; … … 86 94 ------=_Part_4892_25692638.1192452070893-- 87 95 '; 88 96 89 97 unset($GLOBALS['phpmailer']->mock_sent); 90 98 $_SERVER['SERVER_NAME'] = 'example.com'; 91 99 wp_mail($to, $subject, $body, $headers); 92 100 93 101 // We need some better assertions here but these catch the failure for now. 94 102 $this->assertEquals($body, $GLOBALS['phpmailer']->mock_sent[0]['body']); … … 97 105 unset( $_SERVER['SERVER_NAME'] ); 98 106 } 99 107 100 108 function test_wp_mail_plain_and_html() { 101 109 $this->knownWPBug(15448); … … 105 113 $messages = array( 'text/plain' => 'Here is some plain text.', 106 114 'text/html' =>'<html><head></head><body>Here is the HTML ;-)<body></html>' ); 107 115 108 116 unset($GLOBALS['phpmailer']->mock_sent); 109 117 $_SERVER['SERVER_NAME'] = 'example.com'; … … 133 141 unset( $_SERVER['SERVER_NAME'] ); 134 142 } 135 136 143 } 137 144 … … 146 153 $this->assertEquals('http://example.com/watchthecarriagereturngo', wp_sanitize_redirect('http://example.com/watchthecarriagereturn%0%0DDgo')); 147 154 } 148 149 155 } 150 156 151 157 class TestUserFunction extends _WPEmptyBlog { 152 153 158 var $user_ids = array(); 154 159 … … 156 161 parent::setUp(); 157 162 // keep track of users we create 158 $ user_ids = array();163 $this->user_ids = array(); 159 164 } 160 165 … … 162 167 parent::tearDown(); 163 168 // 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 ); 166 171 } 167 172 173 // #13317 168 174 function test_get_userdata() { 169 $this->knownWPBug(13317);170 175 $id = $this->_make_user('administrator'); 171 172 176 $this->assertFalse( get_userdata( 0 ) ); 173 177 $this->assertFalse( get_userdata( 'string' ) ); 174 178 $this->assertFalse( get_userdata( array( 'array' ) ) ); 175 176 179 } 177 180 }
Note: See TracChangeset
for help on using the changeset viewer.