Changeset 42343 for trunk/tests/phpunit/tests/shortcode.php
- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/shortcode.php
r41724 r42343 10 10 parent::setUp(); 11 11 12 foreach ( $this->shortcodes as $shortcode ) 12 foreach ( $this->shortcodes as $shortcode ) { 13 13 add_shortcode( $shortcode, array( $this, '_shortcode_' . str_replace( '-', '_', $shortcode ) ) ); 14 15 $this->atts = null; 14 } 15 16 $this->atts = null; 16 17 $this->content = null; 17 18 $this->tagname = null; … … 28 29 29 30 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; 34 35 $this->filter_atts_pairs = null; 35 $this->filter_atts_atts = null;36 $this->filter_atts_atts = null; 36 37 } 37 38 … … 43 44 // [bartag foo="bar"] 44 45 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 ); 49 54 50 55 return "foo = {$foo}"; … … 53 58 // [baztag]content[/baztag] 54 59 function _shortcode_baztag( $atts, $content = '' ) { 55 return 'content = ' .do_shortcode($content);60 return 'content = ' . do_shortcode( $content ); 56 61 } 57 62 58 63 function _shortcode_dumptag( $atts ) { 59 64 $out = ''; 60 foreach ( $atts as $k=>$v)65 foreach ( $atts as $k => $v ) { 61 66 $out .= "$k = $v\n"; 67 } 62 68 return $out; 63 69 } … … 90 96 91 97 function test_noatts() { 92 do_shortcode( '[test-shortcode-tag /]');98 do_shortcode( '[test-shortcode-tag /]' ); 93 99 $this->assertEquals( '', $this->atts ); 94 100 $this->assertEquals( 'test-shortcode-tag', $this->tagname ); … … 96 102 97 103 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 ); 100 106 $this->assertEquals( 'test-shortcode-tag', $this->tagname ); 101 107 } 102 108 103 109 function test_not_a_tag() { 104 $out = do_shortcode( '[not-a-shortcode-tag]');110 $out = do_shortcode( '[not-a-shortcode-tag]' ); 105 111 $this->assertEquals( '[not-a-shortcode-tag]', $out ); 106 112 } … … 128 134 */ 129 135 function test_tag_hyphen() { 130 131 132 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]' ) ); 133 139 $this->assertEquals( '[hyphen-baz]', do_shortcode( '[hyphen-baz]' ) ); 134 140 $this->assertEquals( '[hyphen-foo-bar-baz]', do_shortcode( '[hyphen-foo-bar-baz]' ) ); … … 139 145 */ 140 146 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" /]' ); 142 148 $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', 149 155 '-foo-bar-baz' => '-foo-bar-baz', 150 'foo--bar' => 'foo--bar',156 'foo--bar' => 'foo--bar', 151 157 ); 152 158 $this->assertEquals( $expected_attrs, $this->atts ); … … 154 160 155 161 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 ); 158 169 $this->assertEquals( 'test-shortcode-tag', $this->tagname ); 159 170 } 160 171 161 172 function test_noatts_enclosing() { 162 do_shortcode( '[test-shortcode-tag]content[/test-shortcode-tag]');173 do_shortcode( '[test-shortcode-tag]content[/test-shortcode-tag]' ); 163 174 $this->assertEquals( '', $this->atts ); 164 175 $this->assertEquals( 'content', $this->content ); … … 167 178 168 179 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 ); 171 182 $this->assertEquals( 'content', $this->content ); 172 183 $this->assertEquals( 'test-shortcode-tag', $this->tagname ); … … 174 185 175 186 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 ); 178 194 $this->assertEquals( 'content', $this->content ); 179 195 $this->assertEquals( 'test-shortcode-tag', $this->tagname ); … … 181 197 182 198 function test_unclosed() { 183 $out = do_shortcode( '[test-shortcode-tag]');199 $out = do_shortcode( '[test-shortcode-tag]' ); 184 200 $this->assertEquals( '', $out ); 185 201 $this->assertEquals( '', $this->atts ); … … 188 204 189 205 function test_positional_atts_num() { 190 $out = do_shortcode( '[test-shortcode-tag 123]');206 $out = do_shortcode( '[test-shortcode-tag 123]' ); 191 207 $this->assertEquals( '', $out ); 192 $this->assertEquals( array( 0=>'123'), $this->atts );208 $this->assertEquals( array( 0 => '123' ), $this->atts ); 193 209 $this->assertEquals( 'test-shortcode-tag', $this->tagname ); 194 210 } 195 211 196 212 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]' ); 198 214 $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 ); 200 216 $this->assertEquals( 'test-shortcode-tag', $this->tagname ); 201 217 } 202 218 203 219 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"]' ); 205 221 $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 ); 207 228 $this->assertEquals( 'test-shortcode-tag', $this->tagname ); 208 229 } 209 230 210 231 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]' ); 212 233 $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 ); 214 243 $this->assertEquals( 'test-shortcode-tag', $this->tagname ); 215 244 } 216 245 217 246 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"]' ); 219 248 $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 ); 221 257 $this->assertEquals( 'test-shortcode-tag', $this->tagname ); 222 258 } 223 259 224 260 function test_footag_default() { 225 $out = do_shortcode( '[footag]');226 $this->assertEquals( 'foo = ', $out);261 $out = do_shortcode( '[footag]' ); 262 $this->assertEquals( 'foo = ', $out ); 227 263 } 228 264 229 265 function test_footag_val() { 230 266 $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 ); 233 269 } 234 270 235 271 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]' ); 237 273 $expected = "content = abc = foo\ndef = 123\n0 = https://wordpress.org\n"; 238 $this->assertEquals( $expected, $out);274 $this->assertEquals( $expected, $out ); 239 275 } 240 276 … … 243 279 */ 244 280 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 ); 253 289 254 290 // 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 ); 257 293 } 258 294 259 295 function test_tag_not_escaped() { 260 296 // 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 ); 275 311 } 276 312 277 313 function test_mixed_tags() { 278 $in = <<<EOF314 $in = <<<EOF 279 315 So this is a post with [footag foo="some stuff"] and a bunch of tags. 280 316 … … 308 344 309 345 EOF; 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 ) ); 312 348 } 313 349 … … 317 353 function test_utf8_whitespace_1() { 318 354 // 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 ); 321 362 $this->assertEquals( '', $this->content ); 322 363 } … … 327 368 function test_utf8_whitespace_2() { 328 369 // 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 ); 331 377 $this->assertEquals( '', $this->content ); 332 378 } … … 383 429 // Store passed in shortcode_atts_{$shortcode} args 384 430 function _filter_atts( $out, $pairs, $atts ) { 385 $this->filter_atts_out = $out;431 $this->filter_atts_out = $out; 386 432 $this->filter_atts_pairs = $pairs; 387 $this->filter_atts_atts = $atts;433 $this->filter_atts_atts = $atts; 388 434 return $out; 389 435 } … … 392 438 function _filter_atts2( $out, $pairs, $atts ) { 393 439 // 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'] ) { 395 441 $out['foo'] = $pairs['foo']; 442 } 396 443 397 444 // If baz attribute is set, remove it 398 if ( isset( $out['baz'] ) ) 445 if ( isset( $out['baz'] ) ) { 399 446 unset( $out['baz'] ); 447 } 400 448 401 449 $this->filter_atts_out = $out; … … 406 454 add_filter( 'shortcode_atts_bartag', array( $this, '_filter_atts' ), 10, 3 ); 407 455 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 ); 411 469 $this->assertEquals( array( 'foo' => 'foo1' ), $this->filter_atts_atts ); 412 470 … … 417 475 add_filter( 'shortcode_atts_bartag', array( $this, '_filter_atts2' ), 10, 3 ); 418 476 419 $out = do_shortcode( '[bartag foo="foo1" baz="baz1" /]');477 $out = do_shortcode( '[bartag foo="foo1" baz="baz1" /]' ); 420 478 $this->assertEquals( array( 'foo' => 'no foo' ), $this->filter_atts_out ); 421 479 $this->assertEquals( 'foo = no foo', $out ); 422 480 423 $out = do_shortcode( '[bartag foo="foo2" /]');481 $out = do_shortcode( '[bartag foo="foo2" /]' ); 424 482 $this->assertEquals( 'foo = foo2', $out ); 425 483 … … 435 493 $nbsp = "\xC2\xA0"; 436 494 437 $input 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>'; 441 499 $input[] = "<p> {$nbsp}[gallery ids=\"37,15,11\"] {$nbsp}</p>"; 442 $input[] = "<p> [gallery ids=\"37,15,11\"] </p>";443 444 $output = "[gallery ids=\"37,15,11\"]";445 446 foreach ($input as $in) {500 $input[] = '<p> [gallery ids="37,15,11"] </p>'; 501 502 $output = '[gallery ids="37,15,11"]'; 503 504 foreach ( $input as $in ) { 447 505 $this->assertEquals( $output, shortcode_unautop( $in ) ); 448 506 } … … 604 662 add_shortcode( $input, '' ); 605 663 $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 } 608 668 return $test; 609 669 } … … 665 725 */ 666 726 function test_pcre_performance( $input ) { 667 $regex = '/' . get_shortcode_regex() . '/';727 $regex = '/' . get_shortcode_regex() . '/'; 668 728 $result = benchmark_pcre_backtracking( $regex, $input, 'match_all' ); 669 729 return $this->assertLessThan( 200, $result ); … … 677 737 function test_php_and_js_shortcode_attribute_regexes_match() { 678 738 679 $file = file_get_contents( ABSPATH . WPINC . '/js/shortcode.js' );739 $file = file_get_contents( ABSPATH . WPINC . '/js/shortcode.js' ); 680 740 $matched = preg_match( '|\s+pattern = (\/.+\/)g;|', $file, $matches ); 681 $php = get_shortcode_atts_regex();741 $php = get_shortcode_atts_regex(); 682 742 683 743 $this->assertSame( 1, $matched ); … … 694 754 */ 695 755 function test_unnamed_attribute() { 696 $out = do_shortcode('[dumptag=https://wordpress.org/]');756 $out = do_shortcode( '[dumptag=https://wordpress.org/]' ); 697 757 $expected = "0 = =https://wordpress.org\n"; 698 $this->assertEquals( $expected, $out);758 $this->assertEquals( $expected, $out ); 699 759 } 700 760 … … 703 763 */ 704 764 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"]' ); 706 766 $expected = "<img alt=\"Hello :-) World\" />\n"; 707 767 $this->assertEquals( $expected, $out ); … … 730 790 // pass arguments 731 791 $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( 736 799 "[{$str} a='b' c='d']", 737 "",800 '', 738 801 $str, 739 802 " a='b' c='d'", 740 "",741 "",742 "",803 '', 804 '', 805 '', 743 806 ), 744 807 ); … … 765 828 } 766 829 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 ) { 768 831 $arr = array( 769 832 'return' => $return, … … 799 862 'return' => 'foobar', 800 863 'key' => $str, 801 'atts' => array( 'a' => 'b', 'c' => 'd' ), 864 'atts' => array( 865 'a' => 'b', 866 'c' => 'd', 867 ), 802 868 'm' => array( 803 869 "[{$str} a='b' c='d']", 804 "",870 '', 805 871 $str, 806 872 " a='b' c='d'", 807 "",808 "",809 "",873 '', 874 '', 875 '', 810 876 ), 811 877 ); … … 832 898 } 833 899 834 public function _filter_do_shortcode_tag_attr( $return, $key, $atts, $m ) {900 public function _filter_do_shortcode_tag_attr( $return, $key, $atts, $m ) { 835 901 $arr = array( 836 902 'return' => $return, … … 849 915 function test_empty_single_quote_attribute() { 850 916 $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 ); 852 927 } 853 928 … … 858 933 $out = do_shortcode( "[test-shortcode-tag 'something in quotes' 'something else']" ); 859 934 $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 ); 861 941 $this->assertEquals( 'test-shortcode-tag', $this->tagname ); 862 942 } … … 868 948 $out = do_shortcode( "[test-shortcode-tag 'something in quotes' \"something else\" 123 foo bar='baz' example=\"test\" ]" ); 869 949 $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 ); 871 960 $this->assertEquals( 'test-shortcode-tag', $this->tagname ); 872 961 }
Note: See TracChangeset
for help on using the changeset viewer.