WordPress.org

Make WordPress Core

Changeset 371 in tests


Ignore:
Timestamp:
06/06/2011 10:27:53 PM (7 years ago)
Author:
aaroncampbell
Message:

shortcode_unautop() tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-testcase/test_shortcode.php

    r366 r371  
    1313        'baz' => 'default baz',
    1414    ), $atts));
    15    
     15
    1616    return "foo = {$foo}";
    1717}
     
    5151        $this->content = null;
    5252        $this->tagname = null;
    53        
    54     }
    55    
     53
     54    }
     55
    5656    function _shortcode_tag($atts, $content=NULL, $tagname=NULL) {
    5757        $this->atts = $atts;
     
    5959        $this->tagname = $tagname;
    6060    }
    61    
     61
    6262    function test_noatts() {
    6363        do_shortcode('[test-shortcode-tag /]');
     
    6565        $this->assertEquals( 'test-shortcode-tag', $this->tagname );
    6666    }
    67    
     67
    6868    function test_one_att() {
    6969        do_shortcode('[test-shortcode-tag foo="asdf" /]');
     
    7171        $this->assertEquals( 'test-shortcode-tag', $this->tagname );
    7272    }
    73    
     73
    7474    function test_not_a_tag() {
    7575        $out = do_shortcode('[not-a-shortcode-tag]');
    7676        $this->assertEquals( '[not-a-shortcode-tag]', $out );
    7777    }
    78    
     78
    7979    function test_two_atts() {
    8080        do_shortcode('[test-shortcode-tag foo="asdf" bar="bing" /]');
     
    8282        $this->assertEquals( 'test-shortcode-tag', $this->tagname );
    8383    }
    84    
     84
    8585    function test_noatts_enclosing() {
    8686        do_shortcode('[test-shortcode-tag]content[/test-shortcode-tag]');
     
    8989        $this->assertEquals( 'test-shortcode-tag', $this->tagname );
    9090    }
    91    
     91
    9292    function test_one_att_enclosing() {
    9393        do_shortcode('[test-shortcode-tag foo="bar"]content[/test-shortcode-tag]');
     
    9696        $this->assertEquals( 'test-shortcode-tag', $this->tagname );
    9797    }
    98    
     98
    9999    function test_two_atts_enclosing() {
    100100        do_shortcode('[test-shortcode-tag foo="bar" baz="bing"]content[/test-shortcode-tag]');
     
    150150        $this->assertEquals('foo = ', $out);
    151151    }
    152    
     152
    153153    function test_footag_val() {
    154154        $val = rand_str();
     
    156156        $this->assertEquals('foo = '.$val, $out);
    157157    }
    158    
     158
    159159    function test_nested_tags() {
    160160        $out = do_shortcode('[baztag][dumptag abc="foo" def=123 http://wordpress.com/][/baztag]');
     
    167167        $this->assertEquals($expected, $out);
    168168    }
    169    
     169
    170170    function test_tag_escaped() {
    171171        $this->knownWPBug(6518);
    172        
     172
    173173        $out = do_shortcode('[[footag]] [[bartag foo="bar"]]');
    174174        $this->assertEquals('[footag] [bartag foo="bar"]', $out);
     
    176176        $out = do_shortcode('[[footag /]] [[bartag foo="bar" /]]');
    177177        $this->assertEquals('[footag /] [bartag foo="bar" /]', $out);
    178        
     178
    179179        $out = do_shortcode('[[baztag foo="bar"]the content[/baztag]]');
    180180        $this->assertEquals('[baztag foo="bar"]the content[/baztag]', $out);
    181        
     181
    182182        // double escaped
    183183        $out = do_shortcode('[[[footag]]] [[[bartag foo="bar"]]]');
    184184        $this->assertEquals('[[footag]] [[bartag foo="bar"]]', $out);
    185185    }
    186    
     186
    187187    function test_tag_not_escaped() {
    188188        // these have square brackets on either end but aren't actually escaped
     
    195195        $out = do_shortcode('[[baztag foo="bar"]the content[/baztag]');
    196196        $this->assertEquals('[content = the content', $out);
    197        
     197
    198198        $out = do_shortcode('[[not-a-tag]]');
    199199        $this->assertEquals('[[not-a-tag]]', $out);
     
    202202        $this->assertEquals('[[foo =  foo = bar]]', $out);
    203203    }
    204    
     204
    205205    function test_mixed_tags() {
    206206        $in = <<<EOF
     
    226226foo = no foo
    227227
    228 content = 
     228content =
    229229Here's some content
    230230on more than one line
     
    239239        $this->assertEquals(strip_ws($expected), strip_ws($out));
    240240    }
    241    
     241
    242242    //TODO Review this test as it may be incorrect
    243243    function test_utf8_whitespace_1() {
     
    257257        $this->assertEquals( '', $this->content );
    258258    }
    259    
     259
    260260/*
    261261enabled = the shortcode works as normal (default)
     
    273273        $this->assertEquals( $expected, $out );
    274274    }
    275    
     275
    276276    function test_shortcodes_disabled() {
    277277        if ( !is_callable('set_all_shortcode_status') )
     
    282282        $this->assertEquals( $expected, $out );
    283283    }
    284    
     284
    285285    function test_shortcodes_strip() {
    286286        if ( !is_callable('set_all_shortcode_status') )
     
    291291        $this->assertEquals( $expected, $out );
    292292    }
    293    
     293
    294294    function test_shortcodes_faux() {
    295295        if ( !is_callable('set_all_shortcode_status') )
     
    301301    }
    302302
     303    function test_shortcode_unautop() {
     304        // a blank line is added at the end, so test with it already there
     305        $test_string = <<<EOF
     306[footag]
     307
     308EOF;
     309
     310        $this->assertEquals( $test_string, shortcode_unautop( wpautop( $test_string ) ) );
     311    }
     312
     313    function test_multiple_shortcode_unautop() {
     314        // a blank line is added at the end, so test with it already there
     315        $test_string = <<<EOF
     316[footag]
     317[footag]
     318
     319EOF;
     320
     321        $actual = shortcode_unautop( wpautop( $test_string ) );
     322        $this->assertEquals( $test_string, $actual );
     323    }
     324
    303325}
    304326//http://core.trac.wordpress.org/ticket/10326
Note: See TracChangeset for help on using the changeset viewer.