Changeset 36444 for trunk/tests/phpunit/tests/formatting/redirect.php
- Timestamp:
- 02/02/2016 03:10:09 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/formatting/redirect.php
r33707 r36444 4 4 * @group pluggable 5 5 * @group formatting 6 * @group redirect 6 7 */ 7 8 class Tests_Formatting_Redirect extends WP_UnitTestCase { 9 function setUp() { 10 add_filter( 'home_url', array( $this, 'home_url' ) ); 11 } 12 13 function tearDown() { 14 remove_filter( 'home_url', array( $this, 'home_url' ) ); 15 } 16 17 function home_url() { 18 return 'http://example.com/'; 19 } 20 8 21 function test_wp_sanitize_redirect() { 9 22 $this->assertEquals('http://example.com/watchthelinefeedgo', wp_sanitize_redirect('http://example.com/watchthelinefeed%0Ago')); … … 21 34 $this->assertEquals('http://example.com/@username', wp_sanitize_redirect('http://example.com/@username')); 22 35 } 36 37 /** 38 * @dataProvider valid_url_provider 39 */ 40 function test_wp_validate_redirect_valid_url( $url, $expected ) { 41 $this->assertEquals( $expected, wp_validate_redirect( $url ) ); 42 } 43 44 /** 45 * @dataProvider invalid_url_provider 46 */ 47 function test_wp_validate_redirect_invalid_url( $url ) { 48 $this->assertEquals( false, wp_validate_redirect( $url, false ) ); 49 } 50 51 function valid_url_provider() { 52 return array( 53 array( 'http://example.com', 'http://example.com' ), 54 array( 'http://example.com/', 'http://example.com/' ), 55 array( 'https://example.com/', 'https://example.com/' ), 56 array( '//example.com', 'http://example.com' ), 57 array( '//example.com/', 'http://example.com/' ), 58 array( 'http://example.com/?foo=http://example.com/', 'http://example.com/?foo=http://example.com/' ), 59 array( 'http://user@example.com/', 'http://user@example.com/' ), 60 array( 'http://user:@example.com/', 'http://user:@example.com/' ), 61 array( 'http://user:pass@example.com/', 'http://user:pass@example.com/' ), 62 ); 63 } 64 65 function invalid_url_provider() { 66 return array( 67 // parse_url() fails 68 array( '' ), 69 array( 'http://:' ), 70 71 // non-safelisted domain 72 array( 'http://non-safelisted.example/' ), 73 74 // unsupported schemes 75 array( 'data:text/plain;charset=utf-8,Hello%20World!' ), 76 array( 'file:///etc/passwd' ), 77 array( 'ftp://example.com/' ), 78 79 // malformed input 80 array( 'http:example.com' ), 81 array( 'http:80' ), 82 array( 'http://example.com:1234:5678/' ), 83 array( 'http://user:pa:ss@example.com/' ), 84 85 array( 'http://user@@example.com' ), 86 array( 'http://user@:example.com' ), 87 array( 'http://user?@example.com' ), 88 array( 'http://user@?example.com' ), 89 array( 'http://user#@example.com' ), 90 array( 'http://user@#example.com' ), 91 92 array( 'http://user@@example.com/' ), 93 array( 'http://user@:example.com/' ), 94 array( 'http://user?@example.com/' ), 95 array( 'http://user@?example.com/' ), 96 array( 'http://user#@example.com/' ), 97 array( 'http://user@#example.com/' ), 98 99 array( 'http://user:pass@@example.com' ), 100 array( 'http://user:pass@:example.com' ), 101 array( 'http://user:pass?@example.com' ), 102 array( 'http://user:pass@?example.com' ), 103 array( 'http://user:pass#@example.com' ), 104 array( 'http://user:pass@#example.com' ), 105 106 array( 'http://user:pass@@example.com/' ), 107 array( 'http://user:pass@:example.com/' ), 108 array( 'http://user:pass?@example.com/' ), 109 array( 'http://user:pass@?example.com/' ), 110 array( 'http://user:pass#@example.com/' ), 111 array( 'http://user:pass@#example.com/' ), 112 113 array( 'http://user.pass@@example.com' ), 114 array( 'http://user.pass@:example.com' ), 115 array( 'http://user.pass?@example.com' ), 116 array( 'http://user.pass@?example.com' ), 117 array( 'http://user.pass#@example.com' ), 118 array( 'http://user.pass@#example.com' ), 119 120 array( 'http://user.pass@@example.com/' ), 121 array( 'http://user.pass@:example.com/' ), 122 array( 'http://user.pass?@example.com/' ), 123 array( 'http://user.pass@?example.com/' ), 124 array( 'http://user.pass#@example.com/' ), 125 array( 'http://user.pass@#example.com/' ), 126 ); 127 } 23 128 }
Note: See TracChangeset
for help on using the changeset viewer.