Make WordPress Core

Changeset 39174


Ignore:
Timestamp:
11/09/2016 12:01:42 AM (9 years ago)
Author:
johnbillion
Message:

Build/Test Tools: Utilise assertWPError() and assertNotWPError() in more places.

See #38716

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

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/general/errors.php

    r29854 r39174  
    1010        $error = new WP_Error( 'foo', 'message', 'data' );
    1111
    12         $this->assertTrue( is_wp_error( $error ) );
     12        $this->assertWPError( $error );
    1313        $this->assertEquals( 'foo', $error->get_error_code() );
    1414        $this->assertEquals( 'message', $error->get_error_message() );
     
    2020        $error->add( 'foo', 'message', 'data' );
    2121
    22         $this->assertTrue( is_wp_error( $error ) );
     22        $this->assertWPError( $error );
    2323        $this->assertEquals( 'foo', $error->get_error_code() );
    2424        $this->assertEquals( 'message', $error->get_error_message() );
     
    3131        $error->add( 'bar', 'bar message', 'bar data' );
    3232
    33         $this->assertTrue( is_wp_error( $error ) );
     33        $this->assertWPError( $error );
    3434        $this->assertEquals( 'foo', $error->get_error_code() );
    3535        $this->assertEquals( 'foo message', $error->get_error_message() );
  • trunk/tests/phpunit/tests/http/base.php

    r38757 r39174  
    132132        // 10 > 5
    133133        $res = wp_remote_request($this->redirection_script . '?rt=' . 10, array('redirection' => 5) );
    134         $this->assertTrue( is_wp_error($res), print_r($res, true) );
     134        $this->assertWPError( $res );
    135135    }
    136136
     
    138138        // 6 > 5 (close edgecase)
    139139        $res = wp_remote_request($this->redirection_script . '?rt=' . 6, array('redirection' => 5) );
    140         $this->assertTrue( is_wp_error($res) );
     140        $this->assertWPError( $res );
    141141    }
    142142
     
    388388
    389389        $res = wp_remote_get( 'https://wordpress.org/' );
    390         $this->assertTrue( ! is_wp_error( $res ), print_r( $res, true ) );
     390        $this->assertNotWPError( $res );
    391391    }
    392392
  • trunk/tests/phpunit/tests/import/parser.php

    r33250 r39174  
    3030            $parser = new $p;
    3131            $result = $parser->parse($file);
    32             $this->assertTrue( is_wp_error( $result ) );
     32            $this->assertWPError( $result );
    3333            $this->assertEquals( 'There was an error when reading this WXR file', $result->get_error_message() );
    3434        }
     
    4343                $parser = new $p;
    4444                $result = $parser->parse( $file );
    45                 $this->assertTrue( is_wp_error( $result ) );
     45                $this->assertWPError( $result );
    4646                $this->assertEquals( 'This does not appear to be a WXR file, missing/invalid WXR version number', $result->get_error_message() );
    4747            }
  • trunk/tests/phpunit/tests/post.php

    r38810 r39174  
    382382        // Test both return paths with or without WP_Error
    383383        $insert_post = wp_insert_post( $post, true );
    384         $this->assertTrue( is_wp_error( $insert_post ), 'Did not get a WP_Error back from wp_insert_post' );
     384        $this->assertWPError( $insert_post );
    385385        $this->assertEquals( 'invalid_date', $insert_post->get_error_code() );
    386386
  • trunk/tests/phpunit/tests/term/getTheTerms.php

    r38398 r39174  
    144144        $p = self::$post_ids[0];
    145145        $terms = get_the_terms( $p, 'this-taxonomy-does-not-exist' );
    146         $this->assertTrue( is_wp_error( $terms ) );
     146        $this->assertWPError( $terms );
    147147    }
    148148
  • trunk/tests/phpunit/tests/term/taxQuery.php

    r37682 r39174  
    232232        $tq->transform_query( $tq->queries[0], 'term_taxonomy_id' );
    233233
    234         $this->assertTrue( is_wp_error( $tq->queries[0] ) );
     234        $this->assertWPError( $tq->queries[0] );
    235235    }
    236236
  • trunk/tests/phpunit/tests/term/wpInsertTerm.php

    r38382 r39174  
    4949        $found = wp_insert_term( 'foo', 'bar' );
    5050
    51         $this->assertTrue( is_wp_error( $found ) );
     51        $this->assertWPError( $found );
    5252        $this->assertSame( 'invalid_taxonomy', $found->get_error_code() );
    5353    }
     
    5858        remove_filter( 'pre_insert_term', array( $this, '_pre_insert_term_callback' ) );
    5959
    60         $this->assertTrue( is_wp_error( $found ) );
     60        $this->assertWPError( $found );
    6161        $this->assertSame( 'custom_error', $found->get_error_code() );
    6262    }
     
    6565        $found = wp_insert_term( 0, 'post_tag' );
    6666
    67         $this->assertTrue( is_wp_error( $found ) );
     67        $this->assertWPError( $found );
    6868        $this->assertSame( 'invalid_term_id', $found->get_error_code() );
    6969    }
     
    7272        $found = wp_insert_term( '  ', 'post_tag' );
    7373
    74         $this->assertTrue( is_wp_error( $found ) );
     74        $this->assertWPError( $found );
    7575        $this->assertSame( 'empty_term_name', $found->get_error_code() );
    7676    }
     
    8181        ) );
    8282
    83         $this->assertTrue( is_wp_error( $found ) );
     83        $this->assertWPError( $found );
    8484        $this->assertSame( 'missing_parent', $found->get_error_code() );
    8585    }
     
    171171        // Test an existing term name
    172172        $term2 = self::factory()->tag->create( array( 'name' => 'Bozo' ) );
    173         $this->assertTrue( is_wp_error( $term2 ) );
     173        $this->assertWPError( $term2 );
    174174        $this->assertNotEmpty( $term2->errors );
    175175
     
    180180        $term6 = self::factory()->tag->create( array( 'name' => 'T$$$$' ) );
    181181        $term7 = self::factory()->tag->create( array( 'name' => 'T$$$$' ) );
    182         $this->assertTrue( is_wp_error( $term7 ) );
     182        $this->assertWPError( $term7 );
    183183        $this->assertNotEmpty( $term7->errors );
    184184        $this->assertEquals( $term6, $term7->error_data['term_exists'] );
     
    193193        $term11 = self::factory()->tag->create( array( 'name' => '$$$$' ) );
    194194        $term12 = self::factory()->tag->create( array( 'name' => '$$$$' ) );
    195         $this->assertTrue( is_wp_error( $term12 ) );
     195        $this->assertWPError( $term12 );
    196196        $this->assertNotEmpty( $term12->errors );
    197197        $this->assertEquals( $term11, $term12->error_data['term_exists'] );
     
    203203        $this->assertNotWPError( $term13 );
    204204        $term14 = self::factory()->tag->create( array( 'name' => 'A' ) );
    205         $this->assertTrue( is_wp_error( $term14 ) );
     205        $this->assertWPError( $term14 );
    206206        $term15 = self::factory()->tag->create( array( 'name' => 'A+', 'slug' => 'a' ) );
    207207        $this->assertNotWPError( $term15 );
    208208        $term16 = self::factory()->tag->create( array( 'name' => 'A+' ) );
    209         $this->assertTrue( is_wp_error( $term16 ) );
     209        $this->assertWPError( $term16 );
    210210        $term17 = self::factory()->tag->create( array( 'name' => 'A++' ) );
    211211        $this->assertNotWPError( $term17 );
     
    213213        $this->assertNotWPError( $term18 );
    214214        $term19 = self::factory()->tag->create( array( 'name' => 'A-' ) );
    215         $this->assertTrue( is_wp_error( $term19 ) );
     215        $this->assertWPError( $term19 );
    216216        $term20 = self::factory()->tag->create( array( 'name' => 'A--' ) );
    217217        $this->assertNotWPError( $term20 );
  • trunk/tests/phpunit/tests/term/wpSetObjectTerms.php

    r38667 r39174  
    166166        // bogus taxonomy
    167167        $result = wp_set_object_terms( self::$post_ids[0], array(rand_str()), rand_str() );
    168         $this->assertTrue( is_wp_error($result) );
     168        $this->assertWPError( $result );
    169169    }
    170170
  • trunk/tests/phpunit/tests/term/wpUpdateTerm.php

    r37593 r39174  
    88        $found = wp_update_term( 1, 'bar' );
    99
    10         $this->assertTrue( is_wp_error( $found ) );
     10        $this->assertWPError( $found );
    1111        $this->assertSame( 'invalid_taxonomy', $found->get_error_code() );
    1212    }
     
    1515        $found = wp_update_term( '', 'post_tag' );
    1616
    17         $this->assertTrue( is_wp_error( $found ) );
     17        $this->assertWPError( $found );
    1818        $this->assertSame( 'invalid_term', $found->get_error_code() );
    1919    }
     
    6161        ) );
    6262
    63         $this->assertTrue( is_wp_error( $found ) );
     63        $this->assertWPError( $found );
    6464        $this->assertSame( 'empty_term_name', $found->get_error_code() );
    6565        _unregister_taxonomy( 'wptests_tax' );
  • trunk/tests/phpunit/tests/xmlrpc/wp/editProfile.php

    r38938 r39174  
    5252        $auth_new = wp_authenticate( 'author', $new_pass );
    5353        $this->assertInstanceOf( 'WP_User', $auth_old );
    54         $this->assertTrue( is_wp_error( $auth_new ) );
     54        $this->assertWPError( $auth_new );
    5555    }
    5656
Note: See TracChangeset for help on using the changeset viewer.