Ticket #17657: 17657-unit-tests.2.diff
File 17657-unit-tests.2.diff, 2.1 KB (added by , 13 years ago) |
---|
-
tests/shortcode.php
13 13 foreach ( $this->shortcodes as $shortcode ) 14 14 add_shortcode( $shortcode, array( $this, '_shortcode_' . $shortcode ) ); 15 15 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 16 20 $this->atts = null; 17 21 $this->content = null; 18 22 $this->tagname = null; … … 60 64 $this->tagname = $tagname; 61 65 } 62 66 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 63 79 function test_noatts() { 64 80 do_shortcode('[test-shortcode-tag /]'); 65 81 $this->assertEquals( '', $this->atts ); … … 77 93 $this->assertEquals( '[not-a-shortcode-tag]', $out ); 78 94 } 79 95 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 80 122 function test_two_atts() { 81 123 do_shortcode('[test-shortcode-tag foo="asdf" bar="bing" /]'); 82 124 $this->assertEquals( array('foo' => 'asdf', 'bar' => 'bing'), $this->atts );