Ticket #17657: 17657-unit-tests.diff
File 17657-unit-tests.diff, 2.4 KB (added by , 14 years ago) |
---|
-
wp-testcase/test_shortcode.php
50 50 $this->atts = null; 51 51 $this->content = null; 52 52 $this->tagname = null; 53 53 54 54 } 55 55 56 56 function _shortcode_tag($atts, $content=NULL, $tagname=NULL) { 57 57 $this->atts = $atts; 58 58 $this->content = $content; 59 59 $this->tagname = $tagname; 60 60 } 61 61 62 62 function test_noatts() { 63 63 do_shortcode('[test-shortcode-tag /]'); 64 64 $this->assertEquals( '', $this->atts ); 65 65 $this->assertEquals( 'test-shortcode-tag', $this->tagname ); 66 66 } 67 67 68 68 function test_one_att() { 69 69 do_shortcode('[test-shortcode-tag foo="asdf" /]'); 70 70 $this->assertEquals( array('foo' => 'asdf'), $this->atts ); 71 71 $this->assertEquals( 'test-shortcode-tag', $this->tagname ); 72 72 } 73 73 74 74 function test_not_a_tag() { 75 75 $out = do_shortcode('[not-a-shortcode-tag]'); 76 76 $this->assertEquals( '[not-a-shortcode-tag]', $out ); 77 77 } 78 78 79 function test_tag_hyphen_not_tag() { 80 $out = do_shortcode('[dumptag-notreal]'); 81 $this->assertEquals( '[dumptag-notreal]', $out ); 82 } 83 84 function test_tag_underscore_not_tag() { 85 $out = do_shortcode('[dumptag_notreal]'); 86 $this->assertEquals( '[dumptag_notreal]', $out ); 87 } 88 89 function test_tag_not_tag() { 90 $out = do_shortcode('[dumptagnotreal]'); 91 $this->assertEquals( '[dumptagnotreal]', $out ); 92 } 93 79 94 function test_two_atts() { 80 95 do_shortcode('[test-shortcode-tag foo="asdf" bar="bing" /]'); 81 96 $this->assertEquals( array('foo' => 'asdf', 'bar' => 'bing'), $this->atts ); 82 97 $this->assertEquals( 'test-shortcode-tag', $this->tagname ); 83 98 } 84 99 85 100 function test_noatts_enclosing() { 86 101 do_shortcode('[test-shortcode-tag]content[/test-shortcode-tag]'); 87 102 $this->assertEquals( '', $this->atts ); 88 103 $this->assertEquals( 'content', $this->content ); 89 104 $this->assertEquals( 'test-shortcode-tag', $this->tagname ); 90 105 } 91 106 92 107 function test_one_att_enclosing() { 93 108 do_shortcode('[test-shortcode-tag foo="bar"]content[/test-shortcode-tag]'); 94 109 $this->assertEquals( array('foo' => 'bar'), $this->atts ); 95 110 $this->assertEquals( 'content', $this->content ); 96 111 $this->assertEquals( 'test-shortcode-tag', $this->tagname ); 97 112 } 98 113 99 114 function test_two_atts_enclosing() { 100 115 do_shortcode('[test-shortcode-tag foo="bar" baz="bing"]content[/test-shortcode-tag]'); 101 116 $this->assertEquals( array('foo' => 'bar', 'baz' => 'bing'), $this->atts );