Make WordPress Core

Changeset 61715


Ignore:
Timestamp:
02/22/2026 10:35:20 PM (8 months ago)
Author:
SergeyBiryukov
Message:

Tests: Use named data provider in a balanceTags() test.

Follow-up to [661/tests], [45929].

Props rahmohn.
See #64225.

File:
1 edited

Legend:

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

    r55562 r61715  
    206206
    207207        /**
     208         * Tests closing unknown single tags.
     209         *
    208210         * @ticket 1597
    209          */
    210         public function test_closes_unknown_single_tags_with_closing_tag() {
    211 
    212                 $inputs   = array(
    213                         '<strong/>',
    214                         '<em />',
    215                         '<p class="main1"/>',
    216                         '<p class="main2" />',
    217                         '<STRONG/>',
    218                 );
    219                 $expected = array(
    220                         '<strong></strong>',
    221                         '<em></em>',
    222                         '<p class="main1"></p>',
    223                         '<p class="main2"></p>',
     211         * @dataProvider data_unknown_single_tags_with_closing_tag
     212         */
     213        public function test_closes_unknown_single_tags_with_closing_tag( $input, $expected ) {
     214                $this->assertSame( $expected, balanceTags( $input, true ) );
     215        }
     216
     217        /**
     218         * Data provider for test_closes_unknown_single_tags_with_closing_tag.
     219         *
     220         * @return array<string, array<string, string>>
     221         */
     222        public function data_unknown_single_tags_with_closing_tag() {
     223                return array(
     224                        'default'              => array( '<strong/>', '<strong></strong>' ),
     225                        'with-space'           => array( '<em />', '<em></em>' ),
     226                        'with-class'           => array( '<p class="main1"/>', '<p class="main1"></p>' ),
     227                        'with-class-and-space' => array( '<p class="main2" />', '<p class="main2"></p>' ),
    224228                        // Valid tags are transformed to lowercase.
    225                         '<strong></strong>',
    226                 );
    227 
    228                 foreach ( $inputs as $key => $input ) {
    229                         $this->assertSame( $expected[ $key ], balanceTags( $inputs[ $key ], true ) );
    230                 }
     229                        'uppercase'            => array( '<STRONG/>', '<strong></strong>' ),
     230                );
    231231        }
    232232
Note: See TracChangeset for help on using the changeset viewer.