Make WordPress Core

Ticket #17657: 17657-unit-tests.2.diff

File 17657-unit-tests.2.diff, 2.1 KB (added by kovshenin, 13 years ago)
  • tests/shortcode.php

     
    1313                foreach ( $this->shortcodes as $shortcode )
    1414                        add_shortcode( $shortcode, array( $this, '_shortcode_' . $shortcode ) );
    1515
     16                add_shortcode( 'hyphen', array( $this, '_shortcode_hyphen' ) );
     17                add_shortcode( 'hyphen-foo', array( $this, '_shortcode_hyphen_foo' ) );
     18                add_shortcode( 'hyphen-foo-bar', array( $this, '_shortcode_hyphen_foo_bar' ) );
     19
    1620                $this->atts = null;
    1721                $this->content = null;
    1822                $this->tagname = null;
     
    6064                $this->tagname = $tagname;
    6165        }
    6266
     67        function _shortcode_hyphen() {
     68                return __FUNCTION__;
     69        }
     70
     71        function _shortcode_hyphen_foo() {
     72                return __FUNCTION__;
     73        }
     74
     75        function _shortcode_hyphen_foo_bar() {
     76                return __FUNCTION__;
     77        }
     78
    6379        function test_noatts() {
    6480                do_shortcode('[test-shortcode-tag /]');
    6581                $this->assertEquals( '', $this->atts );
     
    7793                $this->assertEquals( '[not-a-shortcode-tag]', $out );
    7894        }
    7995
     96        function test_tag_hyphen_not_tag() {
     97                $out = do_shortcode( '[dumptag-notreal]' );
     98                $this->assertEquals( '[dumptag-notreal]', $out );
     99        }
     100
     101        function test_tag_underscore_not_tag() {
     102                $out = do_shortcode( '[dumptag_notreal]' );
     103                $this->assertEquals( '[dumptag_notreal]', $out );
     104        }
     105
     106        function test_tag_not_tag() {
     107                $out = do_shortcode( '[dumptagnotreal]' );
     108                $this->assertEquals( '[dumptagnotreal]', $out );
     109        }
     110
     111        /**
     112         * @see #17657
     113         */
     114        function test_tag_hyphen() {
     115                $this->assertEquals( '_shortcode_hyphen', do_shortcode( '[hyphen]' ) );
     116                $this->assertEquals( '_shortcode_hyphen_foo', do_shortcode( '[hyphen-foo]' ) );
     117                $this->assertEquals( '_shortcode_hyphen_foo_bar', do_shortcode( '[hyphen-foo-bar]' ) );
     118                $this->assertEquals( '[hyphen-baz]', do_shortcode( '[hyphen-baz]' ) );
     119                $this->assertEquals( '[hyphen-foo-bar-baz]', do_shortcode( '[hyphen-foo-bar-baz]' ) );
     120        }
     121
    80122        function test_two_atts() {
    81123                do_shortcode('[test-shortcode-tag foo="asdf" bar="bing" /]');
    82124                $this->assertEquals( array('foo' => 'asdf', 'bar' => 'bing'), $this->atts );