WordPress.org

Make WordPress Core

Changeset 50265


Ignore:
Timestamp:
02/09/2021 01:22:47 PM (10 months ago)
Author:
johnbillion
Message:

Build/Test Tools: Various docblock improvements within test utilities.

See #51802

Location:
trunk/tests/phpunit/includes
Files:
3 edited

Legend:

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

    r46586 r50265  
    99
    1010    /**
     11     * Generates post fixtures for use in tests.
     12     *
    1113     * @var WP_UnitTest_Factory_For_Post
    1214     */
     
    1416
    1517    /**
     18     * Generates attachment fixtures for use in tests.
     19     *
    1620     * @var WP_UnitTest_Factory_For_Attachment
    1721     */
     
    1923
    2024    /**
     25     * Generates comment fixtures for use in tests.
     26     *
    2127     * @var WP_UnitTest_Factory_For_Comment
    2228     */
     
    2430
    2531    /**
     32     * Generates user fixtures for use in tests.
     33     *
    2634     * @var WP_UnitTest_Factory_For_User
    2735     */
     
    2937
    3038    /**
     39     * Generates taxonomy term fixtures for use in tests.
     40     *
    3141     * @var WP_UnitTest_Factory_For_Term
    3242     */
     
    3444
    3545    /**
     46     * Generates category fixtures for use in tests.
     47     *
    3648     * @var WP_UnitTest_Factory_For_Term
    3749     */
     
    3951
    4052    /**
     53     * Generates tag fixtures for use in tests.
     54     *
    4155     * @var WP_UnitTest_Factory_For_Term
    4256     */
     
    4458
    4559    /**
     60     * Generates bookmark (link) fixtures for use in tests.
     61     *
    4662     * @since 4.6.0
    4763     * @var WP_UnitTest_Factory_For_Bookmark
     
    5066
    5167    /**
     68     * Generates blog (site) fixtures for use in Multisite tests.
     69     *
    5270     * @var WP_UnitTest_Factory_For_Blog
    5371     */
     
    5573
    5674    /**
     75     * Generates network fixtures for use in Multisite tests.
     76     *
    5777     * @var WP_UnitTest_Factory_For_Network
    5878     */
  • trunk/tests/phpunit/includes/mock-mailer.php

    r49184 r50265  
    7777 * @since 4.4.0
    7878 *
    79  * @return object|bool
     79 * @return MockPHPMailer|false
    8080 */
    8181function tests_retrieve_phpmailer_instance() {
  • trunk/tests/phpunit/includes/utils.php

    r49193 r50265  
    33// Misc help functions and utilities.
    44
     5/**
     6 * Returns a string of the required length containing random characters. Note that
     7 * the maximum possible string length is 32.
     8 *
     9 * @param int $len Optional. The required length. Default 32.
     10 * @return string The string.
     11 */
    512function rand_str( $len = 32 ) {
    613    return substr( md5( uniqid( rand() ) ), 0, $len );
    714}
    815
     16/**
     17 * Returns a string of the required length containing random characters.
     18 *
     19 * @param int $len The required length.
     20 * @return string The string.
     21 */
    922function rand_long_str( $length ) {
    1023    $chars  = 'abcdefghijklmnopqrstuvwxyz';
     
    1932}
    2033
    21 // Strip leading and trailing whitespace from each line in the string.
     34/**
     35 * Strips leading and trailing whitespace from each line in the string.
     36 *
     37 * @param string $txt The text.
     38 * @return string Text with line-leading and line-trailing whitespace stripped.
     39 */
    2240function strip_ws( $txt ) {
    2341    $lines  = explode( "\n", $txt );
     
    3452/*
    3553 * Helper class for testing code that involves actions and filters.
     54 *
    3655 * Typical use:
    37  * $ma = new MockAction();
    38  * add_action( 'foo', array( &$ma, 'action' ) );
     56 *
     57 *     $ma = new MockAction();
     58 *     add_action( 'foo', array( &$ma, 'action' ) );
    3959 */
    4060class MockAction {
     
    241261}
    242262
     263/**
     264 * Converts an XML string into an array tree structure.
     265 *
     266 * The output of this function can be passed to xml_find() to find nodes by their path.
     267 *
     268 * @param string $in The XML string.
     269 * @return array XML as an array.
     270 */
    243271function xml_to_array( $in ) {
    244272    $p = new TestXMLParser( $in );
     
    246274}
    247275
     276/**
     277 * Finds XML nodes by a given "path".
     278 *
     279 * Example usage:
     280 *
     281 *     $tree = xml_to_array( $rss );
     282 *     $items = xml_find( $tree, 'rss', 'channel', 'item' );
     283 *
     284 * @param array     $tree     An array tree structure of XML, typically from xml_to_array().
     285 * @param string ...$elements Names of XML nodes to create a "path" to find within the XML.
     286 * @return array Array of matching XML node information.
     287 */
    248288function xml_find( $tree, ...$elements ) {
    249289    $n   = count( $elements );
Note: See TracChangeset for help on using the changeset viewer.