- Timestamp:
- 12/28/2022 02:07:16 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/includes/factory/class-wp-unittest-factory-for-bookmark.php
r46586 r55019 9 9 * @since 4.6.0 10 10 * 11 * @method int create( $args = array(), $generation_definitions = null )12 * @method object create_and_get( $args = array(), $generation_definitions = null )13 * @method int[] create_many( $count, $args = array(), $generation_definitions = null )11 * @method int|WP_Error create( $args = array(), $generation_definitions = null ) 12 * @method object|WP_Error create_and_get( $args = array(), $generation_definitions = null ) 13 * @method (int|WP_Error)[] create_many( $count, $args = array(), $generation_definitions = null ) 14 14 */ 15 15 class WP_UnitTest_Factory_For_Bookmark extends WP_UnitTest_Factory_For_Thing { … … 23 23 } 24 24 25 /** 26 * Creates a link object. 27 * 28 * @since 4.6.0 29 * @since 6.2.0 Returns a WP_Error object on failure. 30 * 31 * @param array $args Arguments for the link object. 32 * 33 * @return int|WP_Error The link ID on success, WP_Error object on failure. 34 */ 25 35 public function create_object( $args ) { 26 return wp_insert_link( $args );36 return wp_insert_link( $args, true ); 27 37 } 28 38 39 /** 40 * Updates a link object. 41 * 42 * @since 4.6.0 43 * @since 6.2.0 Returns a WP_Error object on failure. 44 * 45 * @param int $link_id ID of the link to update. 46 * @param array $fields The fields to update. 47 * 48 * @return int|WP_Error The link ID on success, WP_Error object on failure. 49 */ 29 50 public function update_object( $link_id, $fields ) { 30 51 $fields['link_id'] = $link_id; 31 return wp_update_link( $fields ); 52 53 $result = wp_update_link( $fields ); 54 55 if ( 0 === $result ) { 56 return new WP_Error( 'link_update_error', __( 'Could not update link.' ) ); 57 } 58 59 return $result; 32 60 } 33 61 62 /** 63 * Retrieves a link by a given ID. 64 * 65 * @since 4.6.0 66 * 67 * @param int $link_id ID of the link to retrieve. 68 * 69 * @return object|null The link object on success, null on failure. 70 */ 34 71 public function get_object_by_id( $link_id ) { 35 72 return get_bookmark( $link_id );
Note: See TracChangeset
for help on using the changeset viewer.