WordPress.org

Make WordPress Core


Ignore:
Timestamp:
01/09/2019 05:43:14 AM (4 months ago)
Author:
pento
Message:

Docs: Add docblocks for the PHPUnit factory objects.

Props andizer.
Fixes #44521.

File:
1 edited

Legend:

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

    r42343 r44497  
    2525    }
    2626
     27    /**
     28     * Creates a term object.
     29     *
     30     * @param array $args Array or string of arguments for inserting a term.
     31     *
     32     * @return array|WP_Error
     33     */
    2734    function create_object( $args ) {
    2835        $args         = array_merge( array( 'taxonomy' => $this->taxonomy ), $args );
     
    3441    }
    3542
     43    /**
     44     * Updates the term.
     45     *
     46     * @param int|object   $term   The term to update.
     47     * @param array|string $fields The context in which to relate the term to the object.
     48     *
     49     * @return int The term id.
     50     */
    3651    function update_object( $term, $fields ) {
    3752        $fields = array_merge( array( 'taxonomy' => $this->taxonomy ), $fields );
     
    4358    }
    4459
     60    /**
     61     * Attach terms on the given post.
     62     *
     63     * @param int          $post_id  The Post ID.
     64     * @param string|array $terms    An array of terms to set for the post, or a string of terms
     65     *                               separated by commas. Hierarchical taxonomies must always pass IDs rather
     66     *                               than names so that children with the same names but different parents
     67     *                               aren't confused.
     68     * @param string       $taxonomy Taxonomy name.
     69     * @param bool         $append   Optional. If true, don't delete existing terms, just add on. If false,
     70     *                               replace the terms with the new terms. Default true.
     71     *
     72     * @return array|false|WP_Error Array of term taxonomy IDs of affected terms. WP_Error or false on failure.
     73     */
    4574    function add_post_terms( $post_id, $terms, $taxonomy, $append = true ) {
    4675        return wp_set_post_terms( $post_id, $terms, $taxonomy, $append );
     
    4877
    4978    /**
    50      * @return array|null|WP_Error|WP_Term
     79     * Create a term and returns it as a object.
     80     *
     81     * @param array $args                   Array or string of arguments for inserting a term.
     82     * @param null  $generation_definitions The default values.
     83     *
     84     * @return null|WP_Error|WP_Term WP_Term on success. WP_error if taxonomy does not exist. Null for miscellaneous failure.
    5185     */
    5286    function create_and_get( $args = array(), $generation_definitions = null ) {
     
    5690    }
    5791
     92    /**
     93     * Retrieves the term by given term id.
     94     *
     95     * @param int $term_id The term id to retrieve.
     96     *
     97     * @return null|WP_Error|WP_Term WP_Term on success. WP_error if taxonomy does not exist. Null for miscellaneous failure.
     98     */
    5899    function get_object_by_id( $term_id ) {
    59100        return get_term( $term_id, $this->taxonomy );
Note: See TracChangeset for help on using the changeset viewer.