Make WordPress Core

Changeset 34646


Ignore:
Timestamp:
09/27/2015 10:26:16 PM (9 years ago)
Author:
johnbillion
Message:

Switch several assertions to assertNotWPError() so more context is provided when the assertion fails.

Location:
trunk/tests/phpunit/tests
Files:
4 edited

Legend:

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

    r34639 r34646  
    5353        // 5 : 5 & 301
    5454        $res = wp_remote_request($this->redirection_script . '?code=301&rt=' . 5, array('redirection' => 5) );
    55         $this->assertFalse( is_wp_error($res) );
     55        $this->assertNotWPError( $res );
    5656        $this->assertEquals(200, (int)$res['response']['code'] );
    5757    }
     
    6060        // 5 : 5 & 302
    6161        $res = wp_remote_request($this->redirection_script . '?code=302&rt=' . 5, array('redirection' => 5) );
    62         $this->assertFalse( is_wp_error($res) );
     62        $this->assertNotWPError( $res );
    6363        $this->assertEquals(200, (int)$res['response']['code'] );
    6464    }
     
    7070        // 5 > 0 & 301
    7171        $res = wp_remote_request($this->redirection_script . '?code=301&rt=' . 5, array('redirection' => 0) );
    72         $this->assertFalse( is_wp_error($res) );
     72        $this->assertNotWPError( $res );
    7373        $this->assertEquals(301, (int)$res['response']['code'] );
    7474    }
     
    8080        // 5 > 0 & 302
    8181        $res = wp_remote_request($this->redirection_script . '?code=302&rt=' . 5, array('redirection' => 0) );
    82         $this->assertFalse( is_wp_error($res) );
     82        $this->assertNotWPError( $res );
    8383        $this->assertEquals(302, (int)$res['response']['code'] );
    8484    }
     
    8787        // 5 - 5
    8888        $res = wp_remote_request($this->redirection_script . '?rt=' . 5, array('redirection' => 5) );
    89         $this->assertFalse( is_wp_error($res) );
     89        $this->assertNotWPError( $res );
    9090        $this->assertEquals(200, (int)$res['response']['code'] );
    9191    }
     
    9494        // No redirections on HEAD request:
    9595        $res = wp_remote_request($this->redirection_script . '?code=302&rt=' . 1, array('method' => 'HEAD') );
    96         $this->assertFalse( is_wp_error($res) );
     96        $this->assertNotWPError( $res );
    9797        $this->assertEquals( 302, (int)$res['response']['code'] );
    9898    }
     
    104104        // Redirections on HEAD request when Requested
    105105        $res = wp_remote_request($this->redirection_script . '?rt=' . 5, array('redirection' => 5, 'method' => 'HEAD') );
    106         $this->assertFalse( is_wp_error($res) );
     106        $this->assertNotWPError( $res );
    107107        $this->assertEquals( 200, (int)$res['response']['code'] );
    108108    }
     
    123123        // 4 < 5 (close edgecase)
    124124        $res = wp_remote_request($this->redirection_script . '?rt=' . 4, array('redirection' => 5) );
    125         $this->assertFalse( is_wp_error($res) );
     125        $this->assertNotWPError( $res );
    126126    }
    127127
     
    132132        // 0 redirections asked for, Should return the document?
    133133        $res = wp_remote_request($this->redirection_script . '?code=302&rt=' . 5, array('redirection' => 0) );
    134         $this->assertFalse( is_wp_error($res) );
     134        $this->assertNotWPError( $res );
    135135        $this->assertEquals( 302, (int)$res['response']['code'] );
    136136    }
     
    144144        // Prints PASS on initial load, FAIL if the client follows the specified redirection
    145145        $res = wp_remote_request( $this->redirection_script . '?201-location=true' );
    146         $this->assertFalse( is_wp_error( $res ) );
     146        $this->assertNotWPError( $res );
    147147        $this->assertEquals( 'PASS', $res['body']);
    148148    }
     
    170170        $res = wp_remote_request( $this->redirection_script . '?header-check', array('headers' => $headers) );
    171171
    172         $this->assertFalse( is_wp_error($res) );
     172        $this->assertNotWPError( $res );
    173173
    174174        $headers = array();
     
    199199        }
    200200
    201         $this->assertFalse( is_wp_error( $res ) );
     201        $this->assertNotWPError( $res );
    202202        $this->assertEquals( '', $res['body'] ); // The body should be empty.
    203203        $this->assertEquals( $size, $res['headers']['content-length'] ); // Check the headers are returned (and the size is the same..)
     
    220220        }
    221221
    222         $this->assertFalse( is_wp_error( $res ) );
     222        $this->assertNotWPError( $res );
    223223        $this->assertEquals( $size, $filesize ); // Check that the file is written to disk correctly without any extra characters
    224224
     
    236236        $res = wp_remote_request( $url, array( 'timeout' => 30, 'limit_response_size' => $size ) );
    237237
    238         $this->assertFalse( is_wp_error( $res ) );
     238        $this->assertNotWPError( $res );
    239239        $this->assertEquals( $size, strlen( $res['body'] ) );
    240240    }
  • trunk/tests/phpunit/tests/term.php

    r34627 r34646  
    412412        $t = wp_insert_category( array( 'cat_name' => $term ) );
    413413        $this->assertTrue( is_numeric($t) );
    414         $this->assertFalse( is_wp_error($t) );
     414        $this->assertNotWPError( $t );
    415415        $this->assertTrue( $t > 0 );
    416416        $this->assertEquals( $initial_count + 1, wp_count_terms( 'category' ) );
  • trunk/tests/phpunit/tests/term/wpInsertTerm.php

    r31812 r34646  
    2828        $t = wp_insert_term( $term, $taxonomy );
    2929        $this->assertInternalType( 'array', $t );
    30         $this->assertFalse( is_wp_error($t) );
     30        $this->assertNotWPError( $t );
    3131        $this->assertTrue( $t['term_id'] > 0 );
    3232        $this->assertTrue( $t['term_taxonomy_id'] > 0 );
     
    162162    public function test_wp_insert_term_duplicate_name() {
    163163        $term = $this->factory->tag->create_and_get( array( 'name' => 'Bozo' ) );
    164         $this->assertFalse( is_wp_error( $term ) );
     164        $this->assertNotWPError( $term );
    165165        $this->assertTrue( empty( $term->errors ) );
    166166
    167167        // Test existing term name with unique slug
    168168        $term1 = $this->factory->tag->create( array( 'name' => 'Bozo', 'slug' => 'bozo1' ) );
    169         $this->assertFalse( is_wp_error( $term1 ) );
     169        $this->assertNotWPError( $term1 );
    170170
    171171        // Test an existing term name
     
    201201
    202202        $term13 = $this->factory->tag->create( array( 'name' => 'A' ) );
    203         $this->assertFalse( is_wp_error( $term13 ) );
     203        $this->assertNotWPError( $term13 );
    204204        $term14 = $this->factory->tag->create( array( 'name' => 'A' ) );
    205205        $this->assertTrue( is_wp_error( $term14 ) );
    206206        $term15 = $this->factory->tag->create( array( 'name' => 'A+', 'slug' => 'a' ) );
    207         $this->assertFalse( is_wp_error( $term15 ) );
     207        $this->assertNotWPError( $term15 );
    208208        $term16 = $this->factory->tag->create( array( 'name' => 'A+' ) );
    209209        $this->assertTrue( is_wp_error( $term16 ) );
    210210        $term17 = $this->factory->tag->create( array( 'name' => 'A++' ) );
    211         $this->assertFalse( is_wp_error( $term17 ) );
     211        $this->assertNotWPError( $term17 );
    212212        $term18 = $this->factory->tag->create( array( 'name' => 'A-', 'slug' => 'a' ) );
    213         $this->assertFalse( is_wp_error( $term18 ) );
     213        $this->assertNotWPError( $term18 );
    214214        $term19 = $this->factory->tag->create( array( 'name' => 'A-' ) );
    215215        $this->assertTrue( is_wp_error( $term19 ) );
    216216        $term20 = $this->factory->tag->create( array( 'name' => 'A--' ) );
    217         $this->assertFalse( is_wp_error( $term20 ) );
     217        $this->assertNotWPError( $term20 );
    218218    }
    219219
     
    277277        ) );
    278278
    279         $this->assertFalse( is_wp_error( $t2 ) );
     279        $this->assertNotWPError( $t2 );
    280280
    281281        $t2_term = get_term( $t2['term_id'], 'wptests_tax' );
     
    369369        ) );
    370370
    371         $this->assertFalse( is_wp_error( $t4 ) );
     371        $this->assertNotWPError( $t4 );
    372372        $t4_term = get_term( $t4['term_id'], 'wptests_tax' );
    373373
     
    392392        ) );
    393393
    394         $this->assertFalse( is_wp_error( $t2 ) );
     394        $this->assertNotWPError( $t2 );
    395395
    396396        $t2_term = get_term( $t2['term_id'], 'wptests_tax' );
     
    456456        ) );
    457457
    458         $this->assertFalse( is_wp_error( $created ) );
     458        $this->assertNotWPError( $created );
    459459
    460460        $new_term = get_term( $created['term_id'], 'wptests_tax_2' );
     
    487487        ) );
    488488
    489         $this->assertFalse( is_wp_error( $created ) );
     489        $this->assertNotWPError( $created );
    490490
    491491        $new_term = get_term( $created['term_id'], 'wptests_tax_2' );
  • trunk/tests/phpunit/tests/term/wpUpdateTerm.php

    r33652 r34646  
    189189        ) );
    190190
    191         $this->assertFalse( is_wp_error( $updated ) );
     191        $this->assertNotWPError( $updated );
    192192
    193193        $t1_term = get_term( $t1, 'wptests_tax' );
     
    219219        ) );
    220220
    221         $this->assertFalse( is_wp_error( $updated ) );
     221        $this->assertNotWPError( $updated );
    222222
    223223        $t2_term = get_term( $t2, 'wptests_tax_2' );
     
    257257        ) );
    258258
    259         $this->assertFalse( is_wp_error( $updated ) );
     259        $this->assertNotWPError( $updated );
    260260
    261261        $t3_term = get_term( $t3, 'wptests_tax' );
Note: See TracChangeset for help on using the changeset viewer.