- Timestamp:
- 12/28/2022 02:07:16 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/includes/factory/class-wp-unittest-factory-for-post.php
r49789 r55019 7 7 * as a way to indicate expected return values from the given factory methods. 8 8 * 9 * @method int create( $args = array(), $generation_definitions = null )10 * @method WP_Post create_and_get( $args = array(), $generation_definitions = null )11 * @method int[] create_many( $count, $args = array(), $generation_definitions = null )9 * @method int|WP_Error create( $args = array(), $generation_definitions = null ) 10 * @method WP_Post|WP_Error create_and_get( $args = array(), $generation_definitions = null ) 11 * @method (int|WP_Error)[] create_many( $count, $args = array(), $generation_definitions = null ) 12 12 */ 13 13 class WP_UnitTest_Factory_For_Post extends WP_UnitTest_Factory_For_Thing { … … 27 27 * Creates a post object. 28 28 * 29 * @since UT (3.7.0) 30 * @since 6.2.0 Returns a WP_Error object on failure. 31 * 29 32 * @param array $args Array with elements for the post. 30 33 * 31 * @return int The post ID on success. The value 0on failure.34 * @return int|WP_Error The post ID on success, WP_Error object on failure. 32 35 */ 33 36 public function create_object( $args ) { 34 return wp_insert_post( $args );37 return wp_insert_post( $args, true ); 35 38 } 36 39 … … 38 41 * Updates an existing post object. 39 42 * 43 * @since UT (3.7.0) 44 * @since 6.2.0 Returns a WP_Error object on failure. 45 * 40 46 * @param int $post_id ID of the post to update. 41 47 * @param array $fields Post data. 42 48 * 43 * @return int The post ID on success. The value 0on failure.49 * @return int|WP_Error The post ID on success, WP_Error object on failure. 44 50 */ 45 51 public function update_object( $post_id, $fields ) { 46 52 $fields['ID'] = $post_id; 47 return wp_update_post( $fields );53 return wp_update_post( $fields, true ); 48 54 } 49 55 50 56 /** 51 57 * Retrieves a post by a given ID. 58 * 59 * @since UT (3.7.0) 52 60 * 53 61 * @param int $post_id ID of the post to retrieve.
Note: See TracChangeset
for help on using the changeset viewer.