Make WordPress Core

Changeset 46262


Ignore:
Timestamp:
09/23/2019 06:54:16 PM (5 years ago)
Author:
johnbillion
Message:

Build/Test tools: Ensure the create_and_get() factory method returns the appropriate WP_Error when creating a term fails.

Fixes: #47952

Location:
trunk/tests/phpunit/includes/factory
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/factory/class-wp-unittest-factory-for-term.php

    r44903 r46262  
    8686    public function create_and_get( $args = array(), $generation_definitions = null ) {
    8787        $term_id  = $this->create( $args, $generation_definitions );
     88
     89        if ( is_wp_error( $term_id ) ) {
     90            return $term_id;
     91        }
     92
    8893        $taxonomy = isset( $args['taxonomy'] ) ? $args['taxonomy'] : $this->taxonomy;
    8994        return get_term( $term_id, $taxonomy );
  • trunk/tests/phpunit/includes/factory/class-wp-unittest-factory-for-thing.php

    r44903 r46262  
    8080    public function create_and_get( $args = array(), $generation_definitions = null ) {
    8181        $object_id = $this->create( $args, $generation_definitions );
     82
     83        if ( is_wp_error( $object_id ) ) {
     84            return $object_id;
     85        }
     86
    8287        return $this->get_object_by_id( $object_id );
    8388    }
Note: See TracChangeset for help on using the changeset viewer.