Make WordPress Core

Changeset 922 in tests for trunk/tests/term.php


Ignore:
Timestamp:
07/19/2012 04:31:22 PM (13 years ago)
Author:
ryan
Message:

Don't fatal when wp_insert_term() returns WP_Error. Props kurtpayne. fixes #107

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/term.php

    r909 r922  
    2424
    2525        $t = wp_insert_term( $term, $this->taxonomy );
    26         $this->assertTrue( is_array($t) );
     26        $this->assertInternalType( 'array', $t );
    2727        $this->assertFalse( is_wp_error($t) );
    2828        $this->assertTrue( $t['term_id'] > 0 );
     
    4545        $term = rand_str();
    4646        $t = wp_insert_term( $term, $this->taxonomy );
    47 
     47        $this->assertInternalType( 'array', $t );
    4848        $this->assertEquals( $t['term_id'], term_exists($t['term_id']) );
    4949        $this->assertEquals( $t['term_id'], term_exists($term) );
     
    6767        $term = rand_str();
    6868        $t = wp_insert_term( $term, $this->taxonomy );
    69 
     69        $this->assertInternalType( 'array', $t );
    7070        $term_obj = get_term_by('name', $term, $this->taxonomy);
    7171        $this->assertEquals( $t['term_id'], term_exists($term_obj->slug) );
     
    8282            $term = rand_str();
    8383            $result = wp_insert_term( $term, $this->taxonomy );
     84            $this->assertInternalType( 'array', $result );
    8485            $term_id[$term] = $result['term_id'];
    8586        }
     
    175176            $term = rand_str();
    176177            $result = wp_insert_term( $term, $this->taxonomy );
     178            $this->assertInternalType( 'array', $result );
    177179            $terms_1[$i] = $result['term_id'];
    178180        }
     
    236238
    237239        $t = wp_insert_term( $term, 'category' );
     240        $this->assertInternalType( 'array', $t );
    238241        $t2 = wp_insert_term( $term, 'category', array( 'parent' => $t['term_id'] ) );
     242        $this->assertInternalType( 'array', $t2 );
    239243        if ( function_exists( 'term_is_ancestor_of' ) ) {
    240244            $this->assertTrue( term_is_ancestor_of( $t['term_id'], $t2['term_id'], 'category' ) );
     
    274278        // set up test data
    275279        $a = wp_insert_term( 'parent', $this->taxonomy );
     280        $this->assertInternalType( 'array', $a );
    276281        $b = wp_insert_term( 'child',  $this->taxonomy, array( 'parent' => $a['term_id'] ) );
     282        $this->assertInternalType( 'array', $b );
    277283        $c = wp_insert_term( 'neighbor', $this->taxonomy );
     284        $this->assertInternalType( 'array', $c );
    278285        $d = wp_insert_term( 'pet',  $this->taxonomy, array( 'parent' => $c['term_id'] )  );
     286        $this->assertInternalType( 'array', $c );
    279287
    280288        $a_term = get_term( $a['term_id'], $this->taxonomy );
Note: See TracChangeset for help on using the changeset viewer.