Build/Test tools: Ensure the `create_and_get()` factory method returns the appropriate WP_Error when creating a term fails.
Fixes: #47952 git-svn-id: https://develop.svn.wordpress.org/trunk@46262 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
2b076b7709
commit
f3a268f58c
|
@ -85,6 +85,11 @@ class WP_UnitTest_Factory_For_Term extends WP_UnitTest_Factory_For_Thing {
|
||||||
*/
|
*/
|
||||||
public function create_and_get( $args = array(), $generation_definitions = null ) {
|
public function create_and_get( $args = array(), $generation_definitions = null ) {
|
||||||
$term_id = $this->create( $args, $generation_definitions );
|
$term_id = $this->create( $args, $generation_definitions );
|
||||||
|
|
||||||
|
if ( is_wp_error( $term_id ) ) {
|
||||||
|
return $term_id;
|
||||||
|
}
|
||||||
|
|
||||||
$taxonomy = isset( $args['taxonomy'] ) ? $args['taxonomy'] : $this->taxonomy;
|
$taxonomy = isset( $args['taxonomy'] ) ? $args['taxonomy'] : $this->taxonomy;
|
||||||
return get_term( $term_id, $taxonomy );
|
return get_term( $term_id, $taxonomy );
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,6 +79,11 @@ abstract class WP_UnitTest_Factory_For_Thing {
|
||||||
*/
|
*/
|
||||||
public function create_and_get( $args = array(), $generation_definitions = null ) {
|
public function create_and_get( $args = array(), $generation_definitions = null ) {
|
||||||
$object_id = $this->create( $args, $generation_definitions );
|
$object_id = $this->create( $args, $generation_definitions );
|
||||||
|
|
||||||
|
if ( is_wp_error( $object_id ) ) {
|
||||||
|
return $object_id;
|
||||||
|
}
|
||||||
|
|
||||||
return $this->get_object_by_id( $object_id );
|
return $this->get_object_by_id( $object_id );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue