Make WordPress Core


Ignore:
Timestamp:
03/19/2023 12:51:14 PM (14 months ago)
Author:
SergeyBiryukov
Message:

Tests: Improve documentation and variable names in some formatting tests.

Includes documenting data provider values using hash notation in the tests for:

  • convert_smilies()
  • get_url_in_content()
  • links_add_target()
  • normalize_whitespace()

Follow-up to [26191], [26327], [26328], [26972], [55562].

See #57841.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/formatting/linksAddTarget.php

    r55562 r55563  
    88
    99    /**
    10      * Validate the normalize_whitespace function
     10     * Tests the links_add_target() function.
    1111     *
    1212     * @dataProvider data_links_add_target
    1313     */
    14     public function test_links_add_target( $content, $target, $tags, $exp_str ) {
    15         if ( true === is_null( $target ) ) {
    16             $this->assertSame( $exp_str, links_add_target( $content ) );
    17         } elseif ( true === is_null( $tags ) ) {
    18             $this->assertSame( $exp_str, links_add_target( $content, $target ) );
     14    public function test_links_add_target( $content, $target, $tags, $expected ) {
     15        if ( is_null( $target ) ) {
     16            $this->assertSame( $expected, links_add_target( $content ) );
     17        } elseif ( is_null( $tags ) ) {
     18            $this->assertSame( $expected, links_add_target( $content, $target ) );
    1919        } else {
    20             $this->assertSame( $exp_str, links_add_target( $content, $target, $tags ) );
     20            $this->assertSame( $expected, links_add_target( $content, $target, $tags ) );
    2121        }
    2222    }
    2323
    2424    /**
    25      * Test Content DataProvider
     25     * Data provider.
    2626     *
    27      * array ( input_txt, converted_output_txt)
     27     * @return array {
     28     *     @type array {
     29     *         @type string $content  String to search for links in.
     30     *         @type string $target   The target to add to the links.
     31     *         @type string $tags     An array of tags to apply to.
     32     *         @type string $expected Expected output.
     33     *     }
     34     * }
    2835     */
    2936    public function data_links_add_target() {
Note: See TracChangeset for help on using the changeset viewer.