Make WordPress Core

Changeset 343 in tests for wp-testcase/test_http.php


Ignore:
Timestamp:
03/24/2011 04:48:35 AM (15 years ago)
Author:
dd32
Message:

Clarify requirements for WPHTTP tests; Document issues;

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-testcase/test_http.php

    r342 r343  
    11<?php
    22// Note, When running these tests, remember that some things are done differently based on safe_mode
    3 // You can run the test in safe_mode like such: php -d safe_mode=on wp-test.php
     3// You can run the test in safe_mode like such: php -d safe_mode=on wp-test.php - you may also need `-d safe_mode_gid=1` to relax the safe_mode checks to allow inclusion of PEAR.
     4// The WP_HTTP tests require a class-http.php file of r17550 or later.
    45class WPHTTP extends WPTestCase {
    56    var $redirection_script = 'http://tools.dd32.id.au/redirect/'; // You can use your own version here, You can find it in wp-testdata/WPHTTP-testcase-redirection-script.php
     
    89        if ( 'WPHTTP' == get_class($this) ) {
    910            $this->markTestSkipped('The class WPHTTP must be extended in order to run. See the WPHTTP_exthttp, WPHTTP_curl, WPHTTP_streams & WPHTTP_fsockopen testcases.');
     11            return;
     12        }
     13
     14        if ( is_callable( array('WP_HTTP', '_getTransport') ) ) {
     15            $this->markTestSkipped('The WP_HTTP tests require a class-http.php file of r17550 or later.');
    1016            return;
    1117        }
     
    7581        // 10 > 5
    7682        $res = wp_remote_request($this->redirection_script . '?rt=' . 10, array('redirection' => 5) );
    77         $this->assertTrue( is_wp_error($res) );
     83        $this->assertTrue( is_wp_error($res), print_r($res, true) );
    7884    }
    7985    function test_redirections_greater_edgecase() {
     
    8894    }
    8995    function test_redirections_zero_redirections_specified() {
    90         //$this->knownWPBug(16855); // enhancement not implemented
     96        $this->knownWPBug(16855);
    9197        // 0 redirections asked for, Should return the document?
    92         //$res = wp_remote_request($this->redirection_script . '?code=302&rt=' . 5, array('redirection' => 0) );
    93         //$this->assertEquals( 302, (is_wp_error($res) ? 0 : (int)$res['response']['code']) );     
     98        $res = wp_remote_request($this->redirection_script . '?code=302&rt=' . 5, array('redirection' => 0) );
     99        $this->assertEquals( 302, (is_wp_error($res) ? 0 : (int)$res['response']['code']) );       
    94100    }
    95101   
    96102    function test_location_header_on_200() {
    97         $this->knownWPBug(16889);
     103        //$this->knownWPBug(16889);
     104        // Is this valid? Streams, cURL and therefor, PHP Extension (ie. all PHP Internal) follow redirects on all status codes, currently all of WP_HTTP follows this template.
     105       
    98106        // Do not redirect on non 3xx status codes
    99         $res = wp_remote_request( $this->redirection_script . '?200-location=true' ); // Prints PASS on initial load, FAIL if the client follows the specified redirection
    100         $this->assertEquals( 'PASS', $res['body']);
     107        //$res = wp_remote_request( $this->redirection_script . '?200-location=true' ); // Prints PASS on initial load, FAIL if the client follows the specified redirection
     108        //$this->assertEquals( 'PASS', $res['body']);
    101109    }
    102110   
     
    118126        $this->assertTrue( isset($headers['test1']) && 'test' == $headers['test1'] );
    119127        $this->assertTrue( isset($headers['test2']) && '0' === $headers['test2'] );
    120         $this->assertTrue( isset($headers['test3']) && '' === $headers['test3'] ); // cURL Note: It doesnt seem to send empty headers
     128        $this->assertTrue( isset($headers['test3']) && '' === $headers['test3'] ); // cURL (&HTTPExt w/ cURL Wrappers) Note: Will never pass, cURL does not pass headers with an empty value.
    121129    }
    122130}
Note: See TracChangeset for help on using the changeset viewer.