- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/includes/factory/class-wp-unittest-factory-for-term.php
r40968 r42343 17 17 function __construct( $factory = null, $taxonomy = null ) { 18 18 parent::__construct( $factory ); 19 $this->taxonomy = $taxonomy ? $taxonomy : self::DEFAULT_TAXONOMY;19 $this->taxonomy = $taxonomy ? $taxonomy : self::DEFAULT_TAXONOMY; 20 20 $this->default_generation_definitions = array( 21 'name' => new WP_UnitTest_Generator_Sequence( 'Term %s' ),22 'taxonomy' => $this->taxonomy,21 'name' => new WP_UnitTest_Generator_Sequence( 'Term %s' ), 22 'taxonomy' => $this->taxonomy, 23 23 'description' => new WP_UnitTest_Generator_Sequence( 'Term description %s' ), 24 24 ); … … 26 26 27 27 function create_object( $args ) { 28 $args = array_merge( array( 'taxonomy' => $this->taxonomy ), $args );28 $args = array_merge( array( 'taxonomy' => $this->taxonomy ), $args ); 29 29 $term_id_pair = wp_insert_term( $args['name'], $args['taxonomy'], $args ); 30 if ( is_wp_error( $term_id_pair ) ) 30 if ( is_wp_error( $term_id_pair ) ) { 31 31 return $term_id_pair; 32 } 32 33 return $term_id_pair['term_id']; 33 34 } … … 35 36 function update_object( $term, $fields ) { 36 37 $fields = array_merge( array( 'taxonomy' => $this->taxonomy ), $fields ); 37 if ( is_object( $term ) ) 38 if ( is_object( $term ) ) { 38 39 $taxonomy = $term->taxonomy; 40 } 39 41 $term_id_pair = wp_update_term( $term, $taxonomy, $fields ); 40 42 return $term_id_pair['term_id']; … … 49 51 */ 50 52 function create_and_get( $args = array(), $generation_definitions = null ) { 51 $term_id = $this->create( $args, $generation_definitions );53 $term_id = $this->create( $args, $generation_definitions ); 52 54 $taxonomy = isset( $args['taxonomy'] ) ? $args['taxonomy'] : $this->taxonomy; 53 55 return get_term( $term_id, $taxonomy );
Note: See TracChangeset
for help on using the changeset viewer.