Changeset 713 in tests
- Timestamp:
- 05/10/2012 09:32:52 PM (14 years ago)
- File:
-
- 1 edited
-
wp-testcase/test_http.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
wp-testcase/test_http.php
r580 r713 167 167 var $transport = 'fsockopen'; 168 168 } 169 170 171 // non-transport-specific WP_HTTP Tests 172 class WPHTTP extends WPTestCase { 173 174 /** 175 * @dataProvider make_absolute_url_testcases 176 */ 177 function test_make_absolute_url( $relative_url, $absolute_url, $expected ) { 178 if ( ! is_callable( array( 'WP_HTTP', 'make_absolute_url' ) ) ) { 179 $this->markTestSkipped( "This version of WP_HTTP does't support WP_HTTP::make_absolute_url()" ); 180 return; 181 } 182 183 $actual = WP_HTTP::make_absolute_url( $relative_url, $absolute_url ); 184 $this->assertEquals( $expected, $actual ); 185 } 186 187 function make_absolute_url_testcases() { 188 // 0: The Location header, 1: The current url, 3: The expected url 189 return array( 190 array( 'http://site.com/', 'http://example.com/', 'http://site.com/' ), // Absolute URL provided 191 array( '/location', '', '/location' ), // No current url provided 192 193 array( '', 'http://example.com', 'http://example.com/' ), // No location provided 194 195 // Location provided relative to site root 196 array( '/root-relative-link.ext', 'http://example.com/', 'http://example.com/root-relative-link.ext' ), 197 array( '/root-relative-link.ext?with=query', 'http://example.com/index.ext?query', 'http://example.com/root-relative-link.ext?with=query' ), 198 199 // Location provided relative to current file/directory 200 array( 'relative-file.ext', 'http://example.com/', 'http://example.com/relative-file.ext' ), 201 array( 'relative-file.ext', 'http://example.com/filename', 'http://example.com/relative-file.ext' ), 202 array( 'relative-file.ext', 'http://example.com/directory/', 'http://example.com/directory/relative-file.ext' ), 203 204 // Location provided relative to current file/directory but in a parent directory 205 array( '../file-in-parent.ext', 'http://example.com', 'http://example.com/file-in-parent.ext' ), 206 array( '../file-in-parent.ext', 'http://example.com/filename', 'http://example.com/file-in-parent.ext' ), 207 array( '../file-in-parent.ext', 'http://example.com/directory/', 'http://example.com/file-in-parent.ext' ), 208 array( '../file-in-parent.ext', 'http://example.com/directory/filename', 'http://example.com/file-in-parent.ext' ), 209 210 // Location provided in muliple levels higher, including impossible to reach (../ below DOCROOT) 211 array( '../../file-in-grand-parent.ext', 'http://example.com', 'http://example.com/file-in-grand-parent.ext' ), 212 array( '../../file-in-grand-parent.ext', 'http://example.com/filename', 'http://example.com/file-in-grand-parent.ext' ), 213 array( '../../file-in-grand-parent.ext', 'http://example.com/directory/', 'http://example.com/file-in-grand-parent.ext' ), 214 array( '../../file-in-grand-parent.ext', 'http://example.com/directory/filename/', 'http://example.com/file-in-grand-parent.ext' ), 215 array( '../../file-in-grand-parent.ext', 'http://example.com/directory1/directory2/filename', 'http://example.com/file-in-grand-parent.ext' ), 216 217 // Query strings should attach, or replace existing query string. 218 array( '?query=string', 'http://example.com', 'http://example.com/?query=string' ), 219 array( '?query=string', 'http://example.com/file.ext', 'http://example.com/file.ext?query=string' ), 220 array( '?query=string', 'http://example.com/file.ext?existing=query-string', 'http://example.com/file.ext?query=string' ), 221 array( 'otherfile.ext?query=string', 'http://example.com/file.ext?existing=query-string', 'http://example.com/otherfile.ext?query=string' ), 222 223 // A file with a leading dot 224 array( '.ext', 'http://example.com/', 'http://example.com/.ext' ) 225 ); 226 } 227 }
Note: See TracChangeset
for help on using the changeset viewer.