Changeset 904 in tests for trunk/tests/http/base.php
- Timestamp:
- 07/18/2012 07:01:41 PM (12 years ago)
- Location:
- trunk/tests/http
- Files:
-
- 1 added
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/http/base.php
r903 r904 10 10 * 11 11 * The WP_HTTP tests require a class-http.php file of r17550 or later. 12 */13 14 /**15 * @group http16 12 */ 17 13 abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { … … 184 180 } 185 181 } 186 187 // Stubs to test each transport188 /**189 * @group http190 */191 class WPHTTP_curl extends WP_HTTP_UnitTestCase {192 var $transport = 'curl';193 }194 /**195 * @group http196 */197 class WPHTTP_streams extends WP_HTTP_UnitTestCase {198 var $transport = 'streams';199 }200 /**201 * @group http202 */203 class WPHTTP_fsockopen extends WP_HTTP_UnitTestCase {204 var $transport = 'fsockopen';205 }206 207 /**208 * Non-transport-specific WP_HTTP Tests209 *210 * @group http211 */212 class WPHTTP extends WP_UnitTestCase {213 214 /**215 * @dataProvider make_absolute_url_testcases216 */217 function test_make_absolute_url( $relative_url, $absolute_url, $expected ) {218 if ( ! is_callable( array( 'WP_HTTP', 'make_absolute_url' ) ) ) {219 $this->markTestSkipped( "This version of WP_HTTP doesn't support WP_HTTP::make_absolute_url()" );220 return;221 }222 223 $actual = WP_HTTP::make_absolute_url( $relative_url, $absolute_url );224 $this->assertEquals( $expected, $actual );225 }226 227 function make_absolute_url_testcases() {228 // 0: The Location header, 1: The current url, 3: The expected url229 return array(230 array( 'http://site.com/', 'http://example.com/', 'http://site.com/' ), // Absolute URL provided231 array( '/location', '', '/location' ), // No current url provided232 233 array( '', 'http://example.com', 'http://example.com/' ), // No location provided234 235 // Location provided relative to site root236 array( '/root-relative-link.ext', 'http://example.com/', 'http://example.com/root-relative-link.ext' ),237 array( '/root-relative-link.ext?with=query', 'http://example.com/index.ext?query', 'http://example.com/root-relative-link.ext?with=query' ),238 239 // Location provided relative to current file/directory240 array( 'relative-file.ext', 'http://example.com/', 'http://example.com/relative-file.ext' ),241 array( 'relative-file.ext', 'http://example.com/filename', 'http://example.com/relative-file.ext' ),242 array( 'relative-file.ext', 'http://example.com/directory/', 'http://example.com/directory/relative-file.ext' ),243 244 // Location provided relative to current file/directory but in a parent directory245 array( '../file-in-parent.ext', 'http://example.com', 'http://example.com/file-in-parent.ext' ),246 array( '../file-in-parent.ext', 'http://example.com/filename', 'http://example.com/file-in-parent.ext' ),247 array( '../file-in-parent.ext', 'http://example.com/directory/', 'http://example.com/file-in-parent.ext' ),248 array( '../file-in-parent.ext', 'http://example.com/directory/filename', 'http://example.com/file-in-parent.ext' ),249 250 // Location provided in muliple levels higher, including impossible to reach (../ below DOCROOT)251 array( '../../file-in-grand-parent.ext', 'http://example.com', 'http://example.com/file-in-grand-parent.ext' ),252 array( '../../file-in-grand-parent.ext', 'http://example.com/filename', 'http://example.com/file-in-grand-parent.ext' ),253 array( '../../file-in-grand-parent.ext', 'http://example.com/directory/', 'http://example.com/file-in-grand-parent.ext' ),254 array( '../../file-in-grand-parent.ext', 'http://example.com/directory/filename/', 'http://example.com/file-in-grand-parent.ext' ),255 array( '../../file-in-grand-parent.ext', 'http://example.com/directory1/directory2/filename', 'http://example.com/file-in-grand-parent.ext' ),256 257 // Query strings should attach, or replace existing query string.258 array( '?query=string', 'http://example.com', 'http://example.com/?query=string' ),259 array( '?query=string', 'http://example.com/file.ext', 'http://example.com/file.ext?query=string' ),260 array( '?query=string', 'http://example.com/file.ext?existing=query-string', 'http://example.com/file.ext?query=string' ),261 array( 'otherfile.ext?query=string', 'http://example.com/file.ext?existing=query-string', 'http://example.com/otherfile.ext?query=string' ),262 263 // A file with a leading dot264 array( '.ext', 'http://example.com/', 'http://example.com/.ext' )265 );266 }267 }
Note: See TracChangeset
for help on using the changeset viewer.