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

File 17657-unit-tests.2.diff, 2.1 KB (added by kovshenin, 10 months ago)
Line 
1Index: tests/shortcode.php
2===================================================================
3--- tests/shortcode.php (revision 929)
4+++ tests/shortcode.php (working copy)
5@@ -13,6 +13,10 @@
6                foreach ( $this->shortcodes as $shortcode )
7                        add_shortcode( $shortcode, array( $this, '_shortcode_' . $shortcode ) );
8 
9+               add_shortcode( 'hyphen', array( $this, '_shortcode_hyphen' ) );
10+               add_shortcode( 'hyphen-foo', array( $this, '_shortcode_hyphen_foo' ) );
11+               add_shortcode( 'hyphen-foo-bar', array( $this, '_shortcode_hyphen_foo_bar' ) );
12+
13                $this->atts = null;
14                $this->content = null;
15                $this->tagname = null;
16@@ -60,6 +64,18 @@
17                $this->tagname = $tagname;
18        }
19 
20+       function _shortcode_hyphen() {
21+               return __FUNCTION__;
22+       }
23+
24+       function _shortcode_hyphen_foo() {
25+               return __FUNCTION__;
26+       }
27+
28+       function _shortcode_hyphen_foo_bar() {
29+               return __FUNCTION__;
30+       }
31+
32        function test_noatts() {
33                do_shortcode('[test-shortcode-tag /]');
34                $this->assertEquals( '', $this->atts );
35@@ -77,6 +93,32 @@
36                $this->assertEquals( '[not-a-shortcode-tag]', $out );
37        }
38 
39+       function test_tag_hyphen_not_tag() {
40+               $out = do_shortcode( '[dumptag-notreal]' );
41+               $this->assertEquals( '[dumptag-notreal]', $out );
42+       }
43+
44+       function test_tag_underscore_not_tag() {
45+               $out = do_shortcode( '[dumptag_notreal]' );
46+               $this->assertEquals( '[dumptag_notreal]', $out );
47+       }
48+
49+       function test_tag_not_tag() {
50+               $out = do_shortcode( '[dumptagnotreal]' );
51+               $this->assertEquals( '[dumptagnotreal]', $out );
52+       }
53+
54+       /**
55+        * @see #17657
56+        */
57+       function test_tag_hyphen() {
58+               $this->assertEquals( '_shortcode_hyphen', do_shortcode( '[hyphen]' ) );
59+               $this->assertEquals( '_shortcode_hyphen_foo', do_shortcode( '[hyphen-foo]' ) );
60+               $this->assertEquals( '_shortcode_hyphen_foo_bar', do_shortcode( '[hyphen-foo-bar]' ) );
61+               $this->assertEquals( '[hyphen-baz]', do_shortcode( '[hyphen-baz]' ) );
62+               $this->assertEquals( '[hyphen-foo-bar-baz]', do_shortcode( '[hyphen-foo-bar-baz]' ) );
63+       }
64+
65        function test_two_atts() {
66                do_shortcode('[test-shortcode-tag foo="asdf" bar="bing" /]');
67                $this->assertEquals( array('foo' => 'asdf', 'bar' => 'bing'), $this->atts );