Make WordPress Core

Ticket #26222: 26222.diff

File 26222.diff, 3.1 KB (added by coffee2code, 12 years ago)
  • tests/phpunit/tests/formatting/balanceTags.php

     
    77
    88        function nestable_tags() {
    99                return array(
    10                         array( 'blockquote', 'div', 'object', 'q', 'span' )
     10                        array( 'blockquote' ), array( 'div' ), array( 'object' ), array( 'q' ), array( 'span' ),
    1111                );
    1212        }
    1313
     
    2020                );
    2121        }
    2222
    23         // These are single/self-closing tags that WP has traditionally recognized.
    24         function basic_single_tags() {
    25                 return array(
    26                         array( 'br' ), array( 'hr' ), array( 'img' ), array( 'input' )
    27                 );
    28         }
    29 
    3023        /**
    31          * These are single tags WP has traditionally properly handled
    32          * This test can be removed if #1597 is fixed and the next test passes, as
    33          * it supercedes this test.
    34          *
    35          * @dataProvider basic_single_tags
    36          */
    37         function test_selfcloses_unclosed_basic_known_single_tags( $tag ) {
    38                 $this->assertEquals( "<$tag />", balanceTags( "<$tag>", true ) );
    39         }
    40 
    41         /**
    4224         * If a recognized valid single tag appears unclosed, it should get self-closed
    4325         *
    44          * @ticket 1597
    4526         * @dataProvider single_tags
    4627         */
    4728        function test_selfcloses_unclosed_known_single_tags( $tag ) {
     
    4930        }
    5031
    5132        /**
    52          * These are single tags WP has traditionally properly handled
    53          * This test can be removed if #1597 is fixed and the next test passes, as
    54          * it supercedes this test.
    55          *
    56          * @dataProvider basic_single_tags
    57          */
    58         function test_selfcloses_basic_known_single_tags_having_closing_tag( $tag ) {
    59                 $this->assertEquals( "<$tag />", balanceTags( "<$tag></$tag>", true ) );
    60         }
    61 
    62         /**
    6333         * If a recognized valid single tag is given a closing tag, the closing tag
    6434         *   should get removed and tag should be self-closed.
    6535         *
    66          * @ticket 1597
    6736         * @dataProvider single_tags
    6837         */
    6938        function test_selfcloses_known_single_tags_having_closing_tag( $tag ) {
    7039                $this->assertEquals( "<$tag />", balanceTags( "<$tag></$tag>", true ) );
    7140        }
    7241
    73         /**
    74          * @ticket 1597
    75          */
    7642        function test_closes_unknown_single_tags_with_closing_tag() {
    7743
    7844                $inputs = array(
     
    12187                }
    12288        }
    12389
    124         function test_balances_nestable_tags() {
     90        /**
     91         * @dataProvider nestable_tags
     92         */
     93        function test_balances_nestable_tags( $tag ) {
    12594                $inputs = array(
    126                         '<q>Test<q>Test</q>',
    127                         '<div><div>Test',
    128                         '<div>Test</div></div>',
     95                        "<$tag>Test<$tag>Test</$tag>",
     96                        "<$tag><$tag>Test",
     97                        "<$tag>Test</$tag></$tag>",
    12998                );
    13099                $expected = array(
    131                         '<q>Test<q>Test</q></q>',
    132                         '<div><div>Test</div></div>',
    133                         '<div>Test</div>',
     100                        "<$tag>Test<$tag>Test</$tag></$tag>",
     101                        "<$tag><$tag>Test</$tag></$tag>",
     102                        "<$tag>Test</$tag>",
    134103                );
    135104
    136105                foreach ( $inputs as $key => $input ) {
     
    152121                }
    153122        }
    154123
    155         /**
    156          * @ticket 20401
    157          */
    158124        function test_allows_immediately_nested_object_tags() {
    159 
    160125                $object = '<object id="obj1"><param name="param1"/><object id="obj2"><param name="param2"/></object></object>';
    161126                $this->assertEquals( $object, balanceTags( $object, true ) );
    162127        }