Changeset 47122 for trunk/tests/phpunit/tests/shortcode.php
- Timestamp:
- 01/29/2020 12:43:23 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/shortcode.php
r46586 r47122 294 294 $this->assertEquals( '[baztag foo="bar"]the content[/baztag]', $out ); 295 295 296 // double escaped296 // Double escaped. 297 297 $out = do_shortcode( '[[[footag]]] [[[bartag foo="bar"]]]' ); 298 298 $this->assertEquals( '[[footag]] [[bartag foo="bar"]]', $out ); … … 300 300 301 301 function test_tag_not_escaped() { 302 // these have square brackets on either end but aren't actually escaped302 // These have square brackets on either end but aren't actually escaped. 303 303 $out = do_shortcode( '[[footag] [bartag foo="bar"]]' ); 304 304 $this->assertEquals( '[foo = foo = bar]', $out ); … … 358 358 */ 359 359 function test_utf8_whitespace_1() { 360 // NO-BREAK SPACE: U+00A0 360 // NO-BREAK SPACE: U+00A0. 361 361 do_shortcode( "[test-shortcode-tag foo=\"bar\" \xC2\xA0baz=\"123\"]" ); 362 362 $this->assertEquals( … … 374 374 */ 375 375 function test_utf8_whitespace_2() { 376 // ZERO WIDTH SPACE: U+200B 376 // ZERO WIDTH SPACE: U+200B. 377 377 do_shortcode( "[test-shortcode-tag foo=\"bar\" \xE2\x80\x8Babc=\"def\"]" ); 378 378 $this->assertEquals( … … 390 390 */ 391 391 function test_shortcode_unautop() { 392 // a blank line is added at the end, so test with it already there392 // A blank line is added at the end, so test with it already there. 393 393 $test_string = "[footag]\n"; 394 394 $this->assertEquals( $test_string, shortcode_unautop( wpautop( $test_string ) ) ); … … 435 435 } 436 436 437 // Store passed in shortcode_atts_{$shortcode} args 437 // Store passed in shortcode_atts_{$shortcode} args. 438 438 function _filter_atts( $out, $pairs, $atts ) { 439 439 $this->filter_atts_out = $out; … … 443 443 } 444 444 445 // Filter shortcode atts in various ways 445 // Filter shortcode atts in various ways. 446 446 function _filter_atts2( $out, $pairs, $atts ) { 447 // If foo attribute equals "foo1", change it to be default value 447 // If foo attribute equals "foo1", change it to be default value. 448 448 if ( isset( $out['foo'] ) && 'foo1' === $out['foo'] ) { 449 449 $out['foo'] = $pairs['foo']; 450 450 } 451 451 452 // If baz attribute is set, remove it 452 // If baz attribute is set, remove it. 453 453 if ( isset( $out['baz'] ) ) { 454 454 unset( $out['baz'] ); … … 619 619 ), 620 620 array( 621 '<div [gallery]>', // Shortcodes will never be stripped inside elements.621 '<div [gallery]>', // Shortcodes will never be stripped inside elements. 622 622 '<div [gallery]>', 623 623 ), … … 782 782 */ 783 783 public function test_pre_do_shortcode_tag() { 784 // does nothing if no filters are set up784 // Does nothing if no filters are set up. 785 785 $str = 'pre_do_shortcode_tag'; 786 786 add_shortcode( $str, array( $this, '_shortcode_pre_do_shortcode_tag' ) ); … … 788 788 $this->assertSame( 'foo', $result_nofilter ); 789 789 790 // short-circuit with filter790 // Short-circuit with filter. 791 791 add_filter( 'pre_do_shortcode_tag', array( $this, '_filter_pre_do_shortcode_tag_bar' ) ); 792 792 $result_filter = do_shortcode( "[{$str}]" ); 793 793 $this->assertSame( 'bar', $result_filter ); 794 794 795 // respect priority795 // Respect priority. 796 796 add_filter( 'pre_do_shortcode_tag', array( $this, '_filter_pre_do_shortcode_tag_p11' ), 11 ); 797 797 $result_priority = do_shortcode( "[{$str}]" ); 798 798 $this->assertSame( 'p11', $result_priority ); 799 799 800 // pass arguments800 // Pass arguments. 801 801 $arr = array( 802 802 'return' => 'p11', … … 852 852 */ 853 853 public function test_do_shortcode_tag_filter() { 854 // does nothing if no filters are set up854 // Does nothing if no filters are set up. 855 855 $str = 'do_shortcode_tag'; 856 856 add_shortcode( $str, array( $this, '_shortcode_do_shortcode_tag' ) ); … … 858 858 $this->assertSame( 'foo', $result_nofilter ); 859 859 860 // modify output with filter860 // Modify output with filter. 861 861 add_filter( 'do_shortcode_tag', array( $this, '_filter_do_shortcode_tag_replace' ) ); 862 862 $result_filter = do_shortcode( "[{$str}]" ); 863 863 $this->assertSame( 'fee', $result_filter ); 864 864 865 // respect priority865 // Respect priority. 866 866 add_filter( 'do_shortcode_tag', array( $this, '_filter_do_shortcode_tag_generate' ), 11 ); 867 867 $result_priority = do_shortcode( "[{$str}]" ); 868 868 $this->assertSame( 'foobar', $result_priority ); 869 869 870 // pass arguments870 // Pass arguments. 871 871 $arr = array( 872 872 'return' => 'foobar',
Note: See TracChangeset
for help on using the changeset viewer.