Make WordPress Core

Changeset 904 in tests for trunk/tests/http/base.php


Ignore:
Timestamp:
07/18/2012 07:01:41 PM (12 years ago)
Author:
nacin
Message:

Rename tests to conform to this standard: the class Tests_A_B_C.php should be found in Tests/A/B/C.php.

One class per file. Tests are now organized by general component, rather than by the core file they are found in.

Work in progress. Some classes need to be renamed, and some files still need to be moved (and split up).

Location:
trunk/tests/http
Files:
1 added
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/tests/http/base.php

    r903 r904  
    1010 *
    1111 * The WP_HTTP tests require a class-http.php file of r17550 or later.
    12  */
    13 
    14 /**
    15  * @group http
    1612 */
    1713abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase {
     
    184180    }
    185181}
    186 
    187 // Stubs to test each transport
    188 /**
    189  * @group http
    190  */
    191 class WPHTTP_curl extends WP_HTTP_UnitTestCase {
    192     var $transport = 'curl';
    193 }
    194 /**
    195  * @group http
    196  */
    197 class WPHTTP_streams extends WP_HTTP_UnitTestCase {
    198     var $transport = 'streams';
    199 }
    200 /**
    201  * @group http
    202  */
    203 class WPHTTP_fsockopen extends WP_HTTP_UnitTestCase {
    204     var $transport = 'fsockopen';
    205 }
    206 
    207 /**
    208  * Non-transport-specific WP_HTTP Tests
    209  *
    210  * @group http
    211  */
    212 class WPHTTP extends WP_UnitTestCase {
    213 
    214     /**
    215      * @dataProvider make_absolute_url_testcases
    216      */
    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 url
    229         return array(
    230             array( 'http://site.com/', 'http://example.com/', 'http://site.com/' ), // Absolute URL provided
    231             array( '/location', '', '/location' ), // No current url provided
    232 
    233             array( '', 'http://example.com', 'http://example.com/' ), // No location provided
    234 
    235             // Location provided relative to site root
    236             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/directory
    240             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 directory
    245             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 dot
    264             array( '.ext', 'http://example.com/', 'http://example.com/.ext' )
    265         );
    266     }
    267 }
Note: See TracChangeset for help on using the changeset viewer.