Changeset 909 in tests for trunk/tests/mail.php
- Timestamp:
- 07/19/2012 01:52:37 AM (12 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/mail.php
r904 r909 1 1 <?php 2 3 /**4 * @group pluggable5 */6 class TestAuthFunctions extends WP_UnitTestCase {7 var $user_id;8 9 function setUp() {10 parent::setUp();11 $this->user_id = $this->factory->user->create();12 }13 14 function test_auth_cookie_valid() {15 $cookie = wp_generate_auth_cookie( $this->user_id, time() + 3600, 'auth' );16 $this->assertEquals( $this->user_id, wp_validate_auth_cookie( $cookie, 'auth' ) );17 }18 19 function test_auth_cookie_invalid() {20 // 3600 or less and +3600 may occur in wp_validate_auth_cookie(),21 // as an ajax test may have defined DOING_AJAX, failing the test.22 23 $cookie = wp_generate_auth_cookie( $this->user_id, time() - 7200, 'auth' );24 $this->assertEquals( false, wp_validate_auth_cookie( $cookie, 'auth' ), 'expired cookie' );25 26 $cookie = wp_generate_auth_cookie( $this->user_id, time() + 3600, 'auth' );27 $this->assertEquals( false, wp_validate_auth_cookie( $cookie, 'logged_in' ), 'wrong auth scheme' );28 29 $cookie = wp_generate_auth_cookie( $this->user_id, time() + 3600, 'auth' );30 list($a, $b, $c) = explode('|', $cookie);31 $cookie = $a . '|' . ($b + 1) . '|' . $c;32 $this->assertEquals( false, wp_validate_auth_cookie( $this->user_id, 'auth' ), 'altered cookie' );33 }34 35 function test_auth_cookie_scheme() {36 // arbitrary scheme name37 $cookie = wp_generate_auth_cookie( $this->user_id, time() + 3600, 'foo' );38 $this->assertEquals( $this->user_id, wp_validate_auth_cookie( $cookie, 'foo' ) );39 40 // wrong scheme name - should fail41 $cookie = wp_generate_auth_cookie( $this->user_id, time() + 3600, 'foo' );42 $this->assertEquals( false, wp_validate_auth_cookie( $cookie, 'bar' ) );43 }44 }45 2 46 3 /** … … 49 6 * @ticket UT47 50 7 */ 51 class Test MailFunctionsextends WP_UnitTestCase {8 class Tests_Mail extends WP_UnitTestCase { 52 9 function setUp() { 53 10 parent::setUp(); … … 255 212 } 256 213 } 257 258 /**259 * @group pluggable260 */261 class TestRedirectFunctions extends WP_UnitTestCase {262 function test_wp_sanitize_redirect() {263 $this->assertEquals('http://example.com/watchthelinefeedgo', wp_sanitize_redirect('http://example.com/watchthelinefeed%0Ago'));264 $this->assertEquals('http://example.com/watchthelinefeedgo', wp_sanitize_redirect('http://example.com/watchthelinefeed%0ago'));265 $this->assertEquals('http://example.com/watchthecarriagereturngo', wp_sanitize_redirect('http://example.com/watchthecarriagereturn%0Dgo'));266 $this->assertEquals('http://example.com/watchthecarriagereturngo', wp_sanitize_redirect('http://example.com/watchthecarriagereturn%0dgo'));267 //Nesting checks268 $this->assertEquals('http://example.com/watchthecarriagereturngo', wp_sanitize_redirect('http://example.com/watchthecarriagereturn%0%0ddgo'));269 $this->assertEquals('http://example.com/watchthecarriagereturngo', wp_sanitize_redirect('http://example.com/watchthecarriagereturn%0%0DDgo'));270 }271 }
Note: See TracChangeset
for help on using the changeset viewer.