Changeset 930 in tests for trunk/tests/shortcode.php
- Timestamp:
- 07/20/2012 12:57:44 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/shortcode.php
r904 r930 5 5 class Tests_Shortcode extends WP_UnitTestCase { 6 6 7 protected $shortcodes = array( ' footag', 'bartag', 'baztag', 'dumptag' );7 protected $shortcodes = array( 'test-shortcode-tag', 'footag', 'bartag', 'baztag', 'dumptag', 'hyphen', 'hyphen-foo', 'hyphen-foo-bar' ); 8 8 9 9 function setUp() { 10 10 parent::setUp(); 11 add_shortcode('test-shortcode-tag', array(&$this, '_shortcode_tag'));12 11 13 12 foreach ( $this->shortcodes as $shortcode ) 14 add_shortcode( $shortcode, array( $this, '_shortcode_' . $shortcode) );13 add_shortcode( $shortcode, array( $this, '_shortcode_' . str_replace( '-', '_', $shortcode ) ) ); 15 14 16 15 $this->atts = null; … … 25 24 foreach ( $this->shortcodes as $shortcode ) 26 25 unset( $shortcode_tags[ $shortcode ] ); 27 unset( $shortcode_tags['test-shortcode-tag'] ); 26 } 27 28 function _shortcode_test_shortcode_tag( $atts, $content = null, $tagname = null ) { 29 $this->atts = $atts; 30 $this->content = $content; 31 $this->tagname = $tagname; 28 32 } 29 33 … … 55 59 } 56 60 57 function _shortcode_tag($atts, $content=NULL, $tagname=NULL) { 58 $this->atts = $atts; 59 $this->content = $content; 60 $this->tagname = $tagname; 61 function _shortcode_hyphen() { 62 return __FUNCTION__; 63 } 64 65 function _shortcode_hyphen_foo() { 66 return __FUNCTION__; 67 } 68 69 function _shortcode_hyphen_foo_bar() { 70 return __FUNCTION__; 61 71 } 62 72 … … 76 86 $out = do_shortcode('[not-a-shortcode-tag]'); 77 87 $this->assertEquals( '[not-a-shortcode-tag]', $out ); 88 } 89 90 /** 91 * @ticket 17657 92 */ 93 function test_tag_hyphen_not_tag() { 94 $out = do_shortcode( '[dumptag-notreal]' ); 95 $this->assertEquals( '[dumptag-notreal]', $out ); 96 } 97 98 function test_tag_underscore_not_tag() { 99 $out = do_shortcode( '[dumptag_notreal]' ); 100 $this->assertEquals( '[dumptag_notreal]', $out ); 101 } 102 103 function test_tag_not_tag() { 104 $out = do_shortcode( '[dumptagnotreal]' ); 105 $this->assertEquals( '[dumptagnotreal]', $out ); 106 } 107 108 /** 109 * @ticket 17657 110 */ 111 function test_tag_hyphen() { 112 $this->assertEquals( '_shortcode_hyphen', do_shortcode( '[hyphen]' ) ); 113 $this->assertEquals( '_shortcode_hyphen_foo', do_shortcode( '[hyphen-foo]' ) ); 114 $this->assertEquals( '_shortcode_hyphen_foo_bar', do_shortcode( '[hyphen-foo-bar]' ) ); 115 $this->assertEquals( '[hyphen-baz]', do_shortcode( '[hyphen-baz]' ) ); 116 $this->assertEquals( '[hyphen-foo-bar-baz]', do_shortcode( '[hyphen-foo-bar-baz]' ) ); 78 117 } 79 118
Note: See TracChangeset
for help on using the changeset viewer.