Make WordPress Core

Ticket #33134: 33134_test.diff

File 33134_test.diff, 1.1 KB (added by gitlost, 9 years ago)

Unit test.

  • tests/phpunit/tests/shortcode.php

     
    539539                $this->assertTrue( has_shortcode( $content_nested, 'gallery' ) );
    540540                remove_shortcode( 'foo' );
    541541        }
     542
     543        protected $state = 0;
     544
     545        function _short1_tag( $atts, $content ) {
     546                $this->state++;
     547                return do_shortcode( $content );
     548        }
     549
     550        function _short2_tag( $atts, $content ) {
     551                return $this->state;
     552        }
     553
     554        /**
     555         * @ticket 33134
     556         */
     557        function test_nested_left_to_right() {
     558                add_shortcode( 'short1', array( $this, '_short1_tag' ) );
     559                add_shortcode( 'short2', array( $this, '_short2_tag' ) );
     560                $content = '<a [short2]>[short2]</a>';
     561                $this->assertEquals( '<a 0>0</a>', wp_placeholder_restore( do_shortcode( wp_placeholder_shortcodes( $content ) ) ) );
     562                $content = '[short1]<a [short2]>[short2]</a>[/short1]';
     563                $this->assertEquals( '<a 1>1</a>', wp_placeholder_restore( do_shortcode( wp_placeholder_shortcodes( $content ) ) ) );
     564                remove_shortcode( 'short2' );
     565                remove_shortcode( 'short1' );
     566        }
    542567}