WordPress.org

Make WordPress Core

Changeset 1018 in tests


Ignore:
Timestamp:
09/13/12 16:30:54 (2 years ago)
Author:
nacin
Message:

Convert the balanceTags() to use data providers. see #WP1597.

File:
1 edited

Legend:

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

    r904 r1018  
    66class Tests_Formatting_BalanceTags extends WP_UnitTestCase { 
    77 
     8    function nestable_tags() { 
     9        return array( 
     10            array( 'blockquote', 'div', 'object', 'q', 'span' ) 
     11        ); 
     12    } 
     13 
     14    // This is a complete(?) listing of valid single/self-closing tags. 
     15    function single_tags() { 
     16        return array( 
     17            array( 'area' ), array( 'base' ), array( 'basefont' ), array( 'br' ), array( 'col' ), array( 'command' ), 
     18            array( 'embed' ), array( 'frame' ), array( 'hr' ), array( 'img' ), array( 'input' ), array( 'isindex' ), 
     19            array( 'link' ), array( 'meta' ), array( 'param' ), array( 'source' ), 
     20        ); 
     21    } 
     22 
    823    // These are single/self-closing tags that WP has traditionally recognized. 
    9     var $basic_single_tags = array( 'br', 'hr', 'img', 'input' ); 
    10  
    11     // This is a complete(?) listing of valid single/self-closing tags. 
    12     var $single_tags = array( 
    13         'area', 'base', 'basefont', 'br', 'col', 'command', 
    14         'embed', 'frame', 'hr', 'img', 'input', 'isindex', 
    15         'link', 'meta', 'param', 'source' ); 
    16  
    17     // Tags that can be directly nested within themselves, i.e. <div><div>Test</div></div> 
    18     var $nestable_tags = array( 'blockquote', 'div', 'q', 'span' ); 
    19     // Use this instead if/when #20401 gets fixed 
    20     //var $nestable_tags = array( 'blockquote', 'div', 'object', 'q', 'span' ); 
    21  
    22     // These are single tags WP has traditionally properly handled 
    23     // This test can be removed if #1597 is fixed and the next test passes, as 
    24     //   it supercedes this test. 
    25     function test_selfcloses_unclosed_basic_known_single_tags() { 
    26         foreach ( $this->basic_single_tags as $tag ) { 
    27             $this->assertEquals( "<$tag />", balanceTags( "<$tag>", true ) ); 
    28         } 
     24    function basic_single_tags() { 
     25        return array( 
     26            array( 'br' ), array( 'hr' ), array( 'img' ), array( 'input' ) 
     27        ); 
     28    } 
     29 
     30    /** 
     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 ) ); 
    2939    } 
    3040 
     
    3343     * 
    3444     * @ticket 1597 
    35      */ 
    36     function test_selfcloses_unclosed_known_single_tags() { 
    37  
    38         foreach ( $this->single_tags as $tag ) { 
    39             $this->assertEquals( "<$tag />", balanceTags( "<$tag>", true ) ); 
    40         } 
    41     } 
    42  
    43     // These are single tags WP has traditionally properly handled 
    44     // This test can be removed if #1597 is fixed and the next test passes, as 
    45     //   it supercedes this test. 
    46     function test_selfcloses_basic_known_single_tags_having_closing_tag() { 
    47         foreach ( $this->basic_single_tags as $tag ) { 
    48             $this->assertEquals( "<$tag />", balanceTags( "<$tag></$tag>", true ) ); 
    49         } 
     45     * @dataProvider single_tags 
     46     */ 
     47    function test_selfcloses_unclosed_known_single_tags( $tag ) { 
     48        $this->assertEquals( "<$tag />", balanceTags( "<$tag>", true ) ); 
     49    } 
     50 
     51    /** 
     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 ) ); 
    5060    } 
    5161 
     
    5565     * 
    5666     * @ticket 1597 
    57      */ 
    58     function test_selfcloses_known_single_tags_having_closing_tag() { 
    59  
    60         foreach ( $this->single_tags as $tag ) { 
    61             $this->assertEquals( "<$tag />", balanceTags( "<$tag></$tag>", true ) ); 
    62         } 
     67     * @dataProvider single_tags 
     68     */ 
     69    function test_selfcloses_known_single_tags_having_closing_tag( $tag ) { 
     70        $this->assertEquals( "<$tag />", balanceTags( "<$tag></$tag>", true ) ); 
     71    } 
     72 
     73    /** 
     74     * @ticket 1597 
     75     * @dataProvider single_tags 
     76     */ 
     77    function test_closes_unknown_single_tags_followed_by_closing_tag( $tag ) { 
     78        $this->assertEquals( "<$tag></$tag>", balanceTags( "<$tag/></$tag>", true ) ); 
    6379    } 
    6480 
Note: See TracChangeset for help on using the changeset viewer.