Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (7 years ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/shortcode.php

    r41724 r42343  
    1010        parent::setUp();
    1111
    12         foreach ( $this->shortcodes as $shortcode )
     12        foreach ( $this->shortcodes as $shortcode ) {
    1313            add_shortcode( $shortcode, array( $this, '_shortcode_' . str_replace( '-', '_', $shortcode ) ) );
    14 
    15         $this->atts = null;
     14        }
     15
     16        $this->atts    = null;
    1617        $this->content = null;
    1718        $this->tagname = null;
     
    2829
    2930    function _shortcode_test_shortcode_tag( $atts, $content = null, $tagname = null ) {
    30         $this->atts = $atts;
    31         $this->content = $content;
    32         $this->tagname = $tagname;
    33         $this->filter_atts_out = null;
     31        $this->atts              = $atts;
     32        $this->content           = $content;
     33        $this->tagname           = $tagname;
     34        $this->filter_atts_out   = null;
    3435        $this->filter_atts_pairs = null;
    35         $this->filter_atts_atts = null;
     36        $this->filter_atts_atts  = null;
    3637    }
    3738
     
    4344    // [bartag foo="bar"]
    4445    function _shortcode_bartag( $atts ) {
    45         extract(shortcode_atts(array(
    46             'foo' => 'no foo',
    47             'baz' => 'default baz',
    48         ), $atts, 'bartag'));
     46        extract(
     47            shortcode_atts(
     48                array(
     49                    'foo' => 'no foo',
     50                    'baz' => 'default baz',
     51                ), $atts, 'bartag'
     52            )
     53        );
    4954
    5055        return "foo = {$foo}";
     
    5358    // [baztag]content[/baztag]
    5459    function _shortcode_baztag( $atts, $content = '' ) {
    55         return 'content = '.do_shortcode($content);
     60        return 'content = ' . do_shortcode( $content );
    5661    }
    5762
    5863    function _shortcode_dumptag( $atts ) {
    5964        $out = '';
    60         foreach ($atts as $k=>$v)
     65        foreach ( $atts as $k => $v ) {
    6166            $out .= "$k = $v\n";
     67        }
    6268        return $out;
    6369    }
     
    9096
    9197    function test_noatts() {
    92         do_shortcode('[test-shortcode-tag /]');
     98        do_shortcode( '[test-shortcode-tag /]' );
    9399        $this->assertEquals( '', $this->atts );
    94100        $this->assertEquals( 'test-shortcode-tag', $this->tagname );
     
    96102
    97103    function test_one_att() {
    98         do_shortcode('[test-shortcode-tag foo="asdf" /]');
    99         $this->assertEquals( array('foo' => 'asdf'), $this->atts );
     104        do_shortcode( '[test-shortcode-tag foo="asdf" /]' );
     105        $this->assertEquals( array( 'foo' => 'asdf' ), $this->atts );
    100106        $this->assertEquals( 'test-shortcode-tag', $this->tagname );
    101107    }
    102108
    103109    function test_not_a_tag() {
    104         $out = do_shortcode('[not-a-shortcode-tag]');
     110        $out = do_shortcode( '[not-a-shortcode-tag]' );
    105111        $this->assertEquals( '[not-a-shortcode-tag]', $out );
    106112    }
     
    128134     */
    129135    function test_tag_hyphen() {
    130         $this->assertEquals( '_shortcode_hyphen', do_shortcode( '[hyphen]' ) );
    131         $this->assertEquals( '_shortcode_hyphen_foo', do_shortcode( '[hyphen-foo]' ) );
    132         $this->assertEquals( '_shortcode_hyphen_foo_bar', do_shortcode( '[hyphen-foo-bar]' ) );
     136        $this->assertEquals( '_shortcode_hyphen', do_shortcode( '[hyphen]' ) );
     137        $this->assertEquals( '_shortcode_hyphen_foo', do_shortcode( '[hyphen-foo]' ) );
     138        $this->assertEquals( '_shortcode_hyphen_foo_bar', do_shortcode( '[hyphen-foo-bar]' ) );
    133139        $this->assertEquals( '[hyphen-baz]', do_shortcode( '[hyphen-baz]' ) );
    134140        $this->assertEquals( '[hyphen-foo-bar-baz]', do_shortcode( '[hyphen-foo-bar-baz]' ) );
     
    139145     */
    140146    function test_attr_hyphen() {
    141         do_shortcode('[test-shortcode-tag foo="foo" foo-bar="foo-bar" foo-bar-="foo-bar-" -foo-bar="-foo-bar" -foo-bar-="-foo-bar-" foo-bar-baz="foo-bar-baz" -foo-bar-baz="-foo-bar-baz" foo--bar="foo--bar" /]');
     147        do_shortcode( '[test-shortcode-tag foo="foo" foo-bar="foo-bar" foo-bar-="foo-bar-" -foo-bar="-foo-bar" -foo-bar-="-foo-bar-" foo-bar-baz="foo-bar-baz" -foo-bar-baz="-foo-bar-baz" foo--bar="foo--bar" /]' );
    142148        $expected_attrs = array(
    143             'foo' => 'foo',
    144             'foo-bar' => 'foo-bar',
    145             'foo-bar-' => 'foo-bar-',
    146             '-foo-bar' => '-foo-bar',
    147             '-foo-bar-' => '-foo-bar-',
    148             'foo-bar-baz' => 'foo-bar-baz',
     149            'foo'          => 'foo',
     150            'foo-bar'      => 'foo-bar',
     151            'foo-bar-'     => 'foo-bar-',
     152            '-foo-bar'     => '-foo-bar',
     153            '-foo-bar-'    => '-foo-bar-',
     154            'foo-bar-baz'  => 'foo-bar-baz',
    149155            '-foo-bar-baz' => '-foo-bar-baz',
    150             'foo--bar' => 'foo--bar',
     156            'foo--bar'     => 'foo--bar',
    151157        );
    152158        $this->assertEquals( $expected_attrs, $this->atts );
     
    154160
    155161    function test_two_atts() {
    156         do_shortcode('[test-shortcode-tag foo="asdf" bar="bing" /]');
    157         $this->assertEquals( array('foo' => 'asdf', 'bar' => 'bing'), $this->atts );
     162        do_shortcode( '[test-shortcode-tag foo="asdf" bar="bing" /]' );
     163        $this->assertEquals(
     164            array(
     165                'foo' => 'asdf',
     166                'bar' => 'bing',
     167            ), $this->atts
     168        );
    158169        $this->assertEquals( 'test-shortcode-tag', $this->tagname );
    159170    }
    160171
    161172    function test_noatts_enclosing() {
    162         do_shortcode('[test-shortcode-tag]content[/test-shortcode-tag]');
     173        do_shortcode( '[test-shortcode-tag]content[/test-shortcode-tag]' );
    163174        $this->assertEquals( '', $this->atts );
    164175        $this->assertEquals( 'content', $this->content );
     
    167178
    168179    function test_one_att_enclosing() {
    169         do_shortcode('[test-shortcode-tag foo="bar"]content[/test-shortcode-tag]');
    170         $this->assertEquals( array('foo' => 'bar'), $this->atts );
     180        do_shortcode( '[test-shortcode-tag foo="bar"]content[/test-shortcode-tag]' );
     181        $this->assertEquals( array( 'foo' => 'bar' ), $this->atts );
    171182        $this->assertEquals( 'content', $this->content );
    172183        $this->assertEquals( 'test-shortcode-tag', $this->tagname );
     
    174185
    175186    function test_two_atts_enclosing() {
    176         do_shortcode('[test-shortcode-tag foo="bar" baz="bing"]content[/test-shortcode-tag]');
    177         $this->assertEquals( array('foo' => 'bar', 'baz' => 'bing'), $this->atts );
     187        do_shortcode( '[test-shortcode-tag foo="bar" baz="bing"]content[/test-shortcode-tag]' );
     188        $this->assertEquals(
     189            array(
     190                'foo' => 'bar',
     191                'baz' => 'bing',
     192            ), $this->atts
     193        );
    178194        $this->assertEquals( 'content', $this->content );
    179195        $this->assertEquals( 'test-shortcode-tag', $this->tagname );
     
    181197
    182198    function test_unclosed() {
    183         $out = do_shortcode('[test-shortcode-tag]');
     199        $out = do_shortcode( '[test-shortcode-tag]' );
    184200        $this->assertEquals( '', $out );
    185201        $this->assertEquals( '', $this->atts );
     
    188204
    189205    function test_positional_atts_num() {
    190         $out = do_shortcode('[test-shortcode-tag 123]');
     206        $out = do_shortcode( '[test-shortcode-tag 123]' );
    191207        $this->assertEquals( '', $out );
    192         $this->assertEquals( array(0=>'123'), $this->atts );
     208        $this->assertEquals( array( 0 => '123' ), $this->atts );
    193209        $this->assertEquals( 'test-shortcode-tag', $this->tagname );
    194210    }
    195211
    196212    function test_positional_atts_url() {
    197         $out = do_shortcode('[test-shortcode-tag http://www.youtube.com/watch?v=eBGIQ7ZuuiU]');
     213        $out = do_shortcode( '[test-shortcode-tag http://www.youtube.com/watch?v=eBGIQ7ZuuiU]' );
    198214        $this->assertEquals( '', $out );
    199         $this->assertEquals( array(0=>'http://www.youtube.com/watch?v=eBGIQ7ZuuiU'), $this->atts );
     215        $this->assertEquals( array( 0 => 'http://www.youtube.com/watch?v=eBGIQ7ZuuiU' ), $this->atts );
    200216        $this->assertEquals( 'test-shortcode-tag', $this->tagname );
    201217    }
    202218
    203219    function test_positional_atts_quotes() {
    204         $out = do_shortcode('[test-shortcode-tag "something in quotes" "something else"]');
     220        $out = do_shortcode( '[test-shortcode-tag "something in quotes" "something else"]' );
    205221        $this->assertEquals( '', $out );
    206         $this->assertEquals( array(0=>'something in quotes', 1=>'something else'), $this->atts );
     222        $this->assertEquals(
     223            array(
     224                0 => 'something in quotes',
     225                1 => 'something else',
     226            ), $this->atts
     227        );
    207228        $this->assertEquals( 'test-shortcode-tag', $this->tagname );
    208229    }
    209230
    210231    function test_positional_atts_mixed() {
    211         $out = do_shortcode('[test-shortcode-tag 123 https://wordpress.org/ 0 "foo" bar]');
     232        $out = do_shortcode( '[test-shortcode-tag 123 https://wordpress.org/ 0 "foo" bar]' );
    212233        $this->assertEquals( '', $out );
    213         $this->assertEquals( array(0=>'123', 1=>'https://wordpress.org/', 2=>'0', 3=>'foo', 4=>'bar'), $this->atts );
     234        $this->assertEquals(
     235            array(
     236                0 => '123',
     237                1 => 'https://wordpress.org/',
     238                2 => '0',
     239                3 => 'foo',
     240                4 => 'bar',
     241            ), $this->atts
     242        );
    214243        $this->assertEquals( 'test-shortcode-tag', $this->tagname );
    215244    }
    216245
    217246    function test_positional_and_named_atts() {
    218         $out = do_shortcode('[test-shortcode-tag 123 url=https://wordpress.org/ foo bar="baz"]');
     247        $out = do_shortcode( '[test-shortcode-tag 123 url=https://wordpress.org/ foo bar="baz"]' );
    219248        $this->assertEquals( '', $out );
    220         $this->assertEquals( array(0=>'123', 'url' => 'https://wordpress.org/', 1=>'foo', 'bar' => 'baz'), $this->atts );
     249        $this->assertEquals(
     250            array(
     251                0     => '123',
     252                'url' => 'https://wordpress.org/',
     253                1     => 'foo',
     254                'bar' => 'baz',
     255            ), $this->atts
     256        );
    221257        $this->assertEquals( 'test-shortcode-tag', $this->tagname );
    222258    }
    223259
    224260    function test_footag_default() {
    225         $out = do_shortcode('[footag]');
    226         $this->assertEquals('foo = ', $out);
     261        $out = do_shortcode( '[footag]' );
     262        $this->assertEquals( 'foo = ', $out );
    227263    }
    228264
    229265    function test_footag_val() {
    230266        $val = rand_str();
    231         $out = do_shortcode('[footag foo="'.$val.'"]');
    232         $this->assertEquals('foo = '.$val, $out);
     267        $out = do_shortcode( '[footag foo="' . $val . '"]' );
     268        $this->assertEquals( 'foo = ' . $val, $out );
    233269    }
    234270
    235271    function test_nested_tags() {
    236         $out = do_shortcode('[baztag][dumptag abc="foo" def=123 https://wordpress.org/][/baztag]');
     272        $out      = do_shortcode( '[baztag][dumptag abc="foo" def=123 https://wordpress.org/][/baztag]' );
    237273        $expected = "content = abc = foo\ndef = 123\n0 = https://wordpress.org\n";
    238         $this->assertEquals($expected, $out);
     274        $this->assertEquals( $expected, $out );
    239275    }
    240276
     
    243279     */
    244280    function test_tag_escaped() {
    245         $out = do_shortcode('[[footag]] [[bartag foo="bar"]]');
    246         $this->assertEquals('[footag] [bartag foo="bar"]', $out);
    247 
    248         $out = do_shortcode('[[footag /]] [[bartag foo="bar" /]]');
    249         $this->assertEquals('[footag /] [bartag foo="bar" /]', $out);
    250 
    251         $out = do_shortcode('[[baztag foo="bar"]the content[/baztag]]');
    252         $this->assertEquals('[baztag foo="bar"]the content[/baztag]', $out);
     281        $out = do_shortcode( '[[footag]] [[bartag foo="bar"]]' );
     282        $this->assertEquals( '[footag] [bartag foo="bar"]', $out );
     283
     284        $out = do_shortcode( '[[footag /]] [[bartag foo="bar" /]]' );
     285        $this->assertEquals( '[footag /] [bartag foo="bar" /]', $out );
     286
     287        $out = do_shortcode( '[[baztag foo="bar"]the content[/baztag]]' );
     288        $this->assertEquals( '[baztag foo="bar"]the content[/baztag]', $out );
    253289
    254290        // double escaped
    255         $out = do_shortcode('[[[footag]]] [[[bartag foo="bar"]]]');
    256         $this->assertEquals('[[footag]] [[bartag foo="bar"]]', $out);
     291        $out = do_shortcode( '[[[footag]]] [[[bartag foo="bar"]]]' );
     292        $this->assertEquals( '[[footag]] [[bartag foo="bar"]]', $out );
    257293    }
    258294
    259295    function test_tag_not_escaped() {
    260296        // these have square brackets on either end but aren't actually escaped
    261         $out = do_shortcode('[[footag] [bartag foo="bar"]]');
    262         $this->assertEquals('[foo =  foo = bar]', $out);
    263 
    264         $out = do_shortcode('[[footag /] [bartag foo="bar" /]]');
    265         $this->assertEquals('[foo =  foo = bar]', $out);
    266 
    267         $out = do_shortcode('[[baztag foo="bar"]the content[/baztag]');
    268         $this->assertEquals('[content = the content', $out);
    269 
    270         $out = do_shortcode('[[not-a-tag]]');
    271         $this->assertEquals('[[not-a-tag]]', $out);
    272 
    273         $out = do_shortcode('[[[footag] [bartag foo="bar"]]]');
    274         $this->assertEquals('[[foo =  foo = bar]]', $out);
     297        $out = do_shortcode( '[[footag] [bartag foo="bar"]]' );
     298        $this->assertEquals( '[foo =  foo = bar]', $out );
     299
     300        $out = do_shortcode( '[[footag /] [bartag foo="bar" /]]' );
     301        $this->assertEquals( '[foo =  foo = bar]', $out );
     302
     303        $out = do_shortcode( '[[baztag foo="bar"]the content[/baztag]' );
     304        $this->assertEquals( '[content = the content', $out );
     305
     306        $out = do_shortcode( '[[not-a-tag]]' );
     307        $this->assertEquals( '[[not-a-tag]]', $out );
     308
     309        $out = do_shortcode( '[[[footag] [bartag foo="bar"]]]' );
     310        $this->assertEquals( '[[foo =  foo = bar]]', $out );
    275311    }
    276312
    277313    function test_mixed_tags() {
    278         $in = <<<EOF
     314        $in       = <<<EOF
    279315So this is a post with [footag foo="some stuff"] and a bunch of tags.
    280316
     
    308344
    309345EOF;
    310         $out = do_shortcode($in);
    311         $this->assertEquals(strip_ws($expected), strip_ws($out));
     346        $out      = do_shortcode( $in );
     347        $this->assertEquals( strip_ws( $expected ), strip_ws( $out ) );
    312348    }
    313349
     
    317353    function test_utf8_whitespace_1() {
    318354        // NO-BREAK SPACE: U+00A0
    319         do_shortcode("[test-shortcode-tag foo=\"bar\" \xC2\xA0baz=\"123\"]");
    320         $this->assertEquals( array('foo' => 'bar', 'baz' => '123'), $this->atts );
     355        do_shortcode( "[test-shortcode-tag foo=\"bar\" \xC2\xA0baz=\"123\"]" );
     356        $this->assertEquals(
     357            array(
     358                'foo' => 'bar',
     359                'baz' => '123',
     360            ), $this->atts
     361        );
    321362        $this->assertEquals( '', $this->content );
    322363    }
     
    327368    function test_utf8_whitespace_2() {
    328369        // ZERO WIDTH SPACE: U+200B
    329         do_shortcode("[test-shortcode-tag foo=\"bar\" \xE2\x80\x8Babc=\"def\"]");
    330         $this->assertEquals( array('foo' => 'bar', 'abc' => 'def'), $this->atts );
     370        do_shortcode( "[test-shortcode-tag foo=\"bar\" \xE2\x80\x8Babc=\"def\"]" );
     371        $this->assertEquals(
     372            array(
     373                'foo' => 'bar',
     374                'abc' => 'def',
     375            ), $this->atts
     376        );
    331377        $this->assertEquals( '', $this->content );
    332378    }
     
    383429    // Store passed in shortcode_atts_{$shortcode} args
    384430    function _filter_atts( $out, $pairs, $atts ) {
    385         $this->filter_atts_out = $out;
     431        $this->filter_atts_out   = $out;
    386432        $this->filter_atts_pairs = $pairs;
    387         $this->filter_atts_atts = $atts;
     433        $this->filter_atts_atts  = $atts;
    388434        return $out;
    389435    }
     
    392438    function _filter_atts2( $out, $pairs, $atts ) {
    393439        // If foo attribute equals "foo1", change it to be default value
    394         if ( isset( $out['foo'] ) && 'foo1' == $out['foo'] )
     440        if ( isset( $out['foo'] ) && 'foo1' == $out['foo'] ) {
    395441            $out['foo'] = $pairs['foo'];
     442        }
    396443
    397444        // If baz attribute is set, remove it
    398         if ( isset( $out['baz'] ) )
     445        if ( isset( $out['baz'] ) ) {
    399446            unset( $out['baz'] );
     447        }
    400448
    401449        $this->filter_atts_out = $out;
     
    406454        add_filter( 'shortcode_atts_bartag', array( $this, '_filter_atts' ), 10, 3 );
    407455
    408         do_shortcode('[bartag foo="foo1" /]');
    409         $this->assertEquals( array( 'foo' => 'foo1', 'baz' => 'default baz' ), $this->filter_atts_out );
    410         $this->assertEquals( array( 'foo' => 'no foo', 'baz' => 'default baz' ), $this->filter_atts_pairs );
     456        do_shortcode( '[bartag foo="foo1" /]' );
     457        $this->assertEquals(
     458            array(
     459                'foo' => 'foo1',
     460                'baz' => 'default baz',
     461            ), $this->filter_atts_out
     462        );
     463        $this->assertEquals(
     464            array(
     465                'foo' => 'no foo',
     466                'baz' => 'default baz',
     467            ), $this->filter_atts_pairs
     468        );
    411469        $this->assertEquals( array( 'foo' => 'foo1' ), $this->filter_atts_atts );
    412470
     
    417475        add_filter( 'shortcode_atts_bartag', array( $this, '_filter_atts2' ), 10, 3 );
    418476
    419         $out = do_shortcode('[bartag foo="foo1" baz="baz1" /]');
     477        $out = do_shortcode( '[bartag foo="foo1" baz="baz1" /]' );
    420478        $this->assertEquals( array( 'foo' => 'no foo' ), $this->filter_atts_out );
    421479        $this->assertEquals( 'foo = no foo', $out );
    422480
    423         $out = do_shortcode('[bartag foo="foo2" /]');
     481        $out = do_shortcode( '[bartag foo="foo2" /]' );
    424482        $this->assertEquals( 'foo = foo2', $out );
    425483
     
    435493        $nbsp = "\xC2\xA0";
    436494
    437         $input  = array();
    438 
    439         $input[] = "<p>[gallery ids=\"37,15,11\"]</p>";
    440         $input[] = "<p> [gallery ids=\"37,15,11\"] </p>";
     495        $input = array();
     496
     497        $input[] = '<p>[gallery ids="37,15,11"]</p>';
     498        $input[] = '<p> [gallery ids="37,15,11"] </p>';
    441499        $input[] = "<p> {$nbsp}[gallery ids=\"37,15,11\"] {$nbsp}</p>";
    442         $input[] = "<p> &nbsp;[gallery ids=\"37,15,11\"] &nbsp;</p>";
    443 
    444         $output = "[gallery ids=\"37,15,11\"]";
    445 
    446         foreach($input as $in) {
     500        $input[] = '<p> &nbsp;[gallery ids="37,15,11"] &nbsp;</p>';
     501
     502        $output = '[gallery ids="37,15,11"]';
     503
     504        foreach ( $input as $in ) {
    447505            $this->assertEquals( $output, shortcode_unautop( $in ) );
    448506        }
     
    604662        add_shortcode( $input, '' );
    605663        $actual = shortcode_exists( $input );
    606         $test = $this->assertEquals( $expected, $actual );
    607         if ( $actual ) remove_shortcode( $input );
     664        $test   = $this->assertEquals( $expected, $actual );
     665        if ( $actual ) {
     666            remove_shortcode( $input );
     667        }
    608668        return $test;
    609669    }
     
    665725     */
    666726    function test_pcre_performance( $input ) {
    667         $regex = '/' . get_shortcode_regex() . '/';
     727        $regex  = '/' . get_shortcode_regex() . '/';
    668728        $result = benchmark_pcre_backtracking( $regex, $input, 'match_all' );
    669729        return $this->assertLessThan( 200, $result );
     
    677737    function test_php_and_js_shortcode_attribute_regexes_match() {
    678738
    679         $file = file_get_contents( ABSPATH . WPINC . '/js/shortcode.js' );
     739        $file    = file_get_contents( ABSPATH . WPINC . '/js/shortcode.js' );
    680740        $matched = preg_match( '|\s+pattern = (\/.+\/)g;|', $file, $matches );
    681         $php = get_shortcode_atts_regex();
     741        $php     = get_shortcode_atts_regex();
    682742
    683743        $this->assertSame( 1, $matched );
     
    694754     */
    695755    function test_unnamed_attribute() {
    696         $out = do_shortcode('[dumptag=https://wordpress.org/]');
     756        $out      = do_shortcode( '[dumptag=https://wordpress.org/]' );
    697757        $expected = "0 = =https://wordpress.org\n";
    698         $this->assertEquals($expected, $out);
     758        $this->assertEquals( $expected, $out );
    699759    }
    700760
     
    703763     */
    704764    function test_smilies_arent_converted() {
    705         $out = apply_filters( 'the_content', '[img alt="Hello :-) World"]' );
     765        $out      = apply_filters( 'the_content', '[img alt="Hello :-) World"]' );
    706766        $expected = "<img alt=\"Hello :-) World\" />\n";
    707767        $this->assertEquals( $expected, $out );
     
    730790        // pass arguments
    731791        $arr = array(
    732             'return'    => 'p11',
    733             'key'           => $str,
    734             'atts'      => array( 'a'=>'b', 'c'=>'d' ),
    735             'm'             => array(
     792            'return' => 'p11',
     793            'key'    => $str,
     794            'atts'   => array(
     795                'a' => 'b',
     796                'c' => 'd',
     797            ),
     798            'm'      => array(
    736799                "[{$str} a='b' c='d']",
    737                 "",
     800                '',
    738801                $str,
    739802                " a='b' c='d'",
    740                 "",
    741                 "",
    742                 "",
     803                '',
     804                '',
     805                '',
    743806            ),
    744807        );
     
    765828    }
    766829
    767     public function _filter_pre_do_shortcode_tag_attr( $return, $key, $atts, $m ){
     830    public function _filter_pre_do_shortcode_tag_attr( $return, $key, $atts, $m ) {
    768831        $arr = array(
    769832            'return' => $return,
     
    799862            'return' => 'foobar',
    800863            'key'    => $str,
    801             'atts'   => array( 'a' => 'b', 'c' => 'd' ),
     864            'atts'   => array(
     865                'a' => 'b',
     866                'c' => 'd',
     867            ),
    802868            'm'      => array(
    803869                "[{$str} a='b' c='d']",
    804                 "",
     870                '',
    805871                $str,
    806872                " a='b' c='d'",
    807                 "",
    808                 "",
    809                 "",
     873                '',
     874                '',
     875                '',
    810876            ),
    811877        );
     
    832898    }
    833899
    834     public function _filter_do_shortcode_tag_attr( $return, $key, $atts, $m ){
     900    public function _filter_do_shortcode_tag_attr( $return, $key, $atts, $m ) {
    835901        $arr = array(
    836902            'return' => $return,
     
    849915    function test_empty_single_quote_attribute() {
    850916        $out = do_shortcode( '[test-shortcode-tag a="foo" b=\'bar\' c=baz foo \'bar\' "baz" ]test empty atts[/test-shortcode-tag]' );
    851         $this->assertEquals( array( 'a' => 'foo', 'b' => 'bar', 'c' => 'baz', 0 => 'foo', 1 => 'bar', 2 => 'baz' ), $this->atts );
     917        $this->assertEquals(
     918            array(
     919                'a' => 'foo',
     920                'b' => 'bar',
     921                'c' => 'baz',
     922                0   => 'foo',
     923                1   => 'bar',
     924                2   => 'baz',
     925            ), $this->atts
     926        );
    852927    }
    853928
     
    858933        $out = do_shortcode( "[test-shortcode-tag 'something in quotes' 'something else']" );
    859934        $this->assertEquals( '', $out );
    860         $this->assertEquals( array( 0 => 'something in quotes', 1 => 'something else' ), $this->atts );
     935        $this->assertEquals(
     936            array(
     937                0 => 'something in quotes',
     938                1 => 'something else',
     939            ), $this->atts
     940        );
    861941        $this->assertEquals( 'test-shortcode-tag', $this->tagname );
    862942    }
     
    868948        $out = do_shortcode( "[test-shortcode-tag 'something in quotes' \"something else\" 123 foo bar='baz' example=\"test\" ]" );
    869949        $this->assertEquals( '', $out );
    870         $this->assertEquals( array( 0 => 'something in quotes', 1 => 'something else', 2 => '123', 3 => 'foo', 'bar' => 'baz', 'example' => 'test'), $this->atts );
     950        $this->assertEquals(
     951            array(
     952                0         => 'something in quotes',
     953                1         => 'something else',
     954                2         => '123',
     955                3         => 'foo',
     956                'bar'     => 'baz',
     957                'example' => 'test',
     958            ), $this->atts
     959        );
    871960        $this->assertEquals( 'test-shortcode-tag', $this->tagname );
    872961    }
Note: See TracChangeset for help on using the changeset viewer.