WordPress.org

Make WordPress Core

Changeset 580 in tests


Ignore:
Timestamp:
03/18/2012 04:35:44 AM (6 years ago)
Author:
dd32
Message:

WP_HTTP Tests: Remove ternary operators and assert that it's not a WP_Error directly.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-testcase/test_http.php

    r485 r580  
    3535        // 5 : 5 & 301
    3636        $res = wp_remote_request($this->redirection_script . '?code=301&rt=' . 5, array('redirection' => 5) );
    37         $this->assertEquals(200, (is_wp_error($res) ? 0 : (int)$res['response']['code']) );
     37        $this->assertFalse( is_wp_error($res) );
     38        $this->assertEquals(200, (int)$res['response']['code'] );
    3839    }
    3940
     
    4142        // 5 : 5 & 302
    4243        $res = wp_remote_request($this->redirection_script . '?code=302&rt=' . 5, array('redirection' => 5) );
    43         $this->assertEquals(200, (is_wp_error($res) ? 0 : (int)$res['response']['code']) );
     44        $this->assertFalse( is_wp_error($res) );
     45        $this->assertEquals(200, (int)$res['response']['code'] );
    4446    }
    4547
     
    4850        // 5 > 0 & 301
    4951        $res = wp_remote_request($this->redirection_script . '?code=301&rt=' . 5, array('redirection' => 0) );
    50         $this->assertEquals(301, (is_wp_error($res) ? 0 : (int)$res['response']['code']) );
     52        $this->assertFalse( is_wp_error($res) );
     53        $this->assertEquals(301, (int)$res['response']['code'] );
    5154    }
    5255
     
    5558        // 5 > 0 & 302
    5659        $res = wp_remote_request($this->redirection_script . '?code=302&rt=' . 5, array('redirection' => 0) );
    57         $this->assertEquals(302, (is_wp_error($res) ? 0 : (int)$res['response']['code']) );
     60        $this->assertFalse( is_wp_error($res) );
     61        $this->assertEquals(302, (int)$res['response']['code'] );
    5862    }
    5963
     
    6165        // 5 - 5
    6266        $res = wp_remote_request($this->redirection_script . '?rt=' . 5, array('redirection' => 5) );
    63         $this->assertEquals(200, (is_wp_error($res) ? 0 : (int)$res['response']['code']) );
     67        $this->assertFalse( is_wp_error($res) );
     68        $this->assertEquals(200, (int)$res['response']['code'] );
    6469    }
    6570
     
    6772        // No redirections on HEAD request:
    6873        $res = wp_remote_request($this->redirection_script . '?code=302&rt=' . 1, array('method' => 'HEAD') );
    69         $this->assertEquals( 302, (is_wp_error($res) ? 0 : (int)$res['response']['code']) );
     74        $this->assertFalse( is_wp_error($res) );
     75        $this->assertEquals( 302, (int)$res['response']['code'] );
    7076    }
    7177
     
    7480        // Redirections on HEAD request when Requested
    7581        $res = wp_remote_request($this->redirection_script . '?rt=' . 5, array('redirection' => 5, 'method' => 'HEAD') );
    76         $this->assertEquals( 200, (is_wp_error($res) ? 0 : (int)$res['response']['code']) );
     82        $this->assertFalse( is_wp_error($res) );
     83        $this->assertEquals( 200, (int)$res['response']['code'] );
    7784    }
    7885
     
    99106        // 0 redirections asked for, Should return the document?
    100107        $res = wp_remote_request($this->redirection_script . '?code=302&rt=' . 5, array('redirection' => 0) );
    101         $this->assertEquals( 302, (is_wp_error($res) ? 0 : (int)$res['response']['code']) );
     108        $this->assertFalse( is_wp_error($res) );
     109        $this->assertEquals( 302, (int)$res['response']['code'] );
    102110    }
    103111
     
    116124        $headers = array('test1' => 'test', 'test2' => 0, 'test3' => '');
    117125        $res = wp_remote_request( $this->redirection_script . '?header-check', array('headers' => $headers) );
     126
     127        $this->assertFalse( is_wp_error($res) );
    118128
    119129        $headers = array();
Note: See TracChangeset for help on using the changeset viewer.