Make WordPress Core

Ticket #17657: 17657-unit-tests.diff

File 17657-unit-tests.diff, 2.4 KB (added by aaroncampbell, 14 years ago)
  • wp-testcase/test_shortcode.php

     
    5050                $this->atts = null;
    5151                $this->content = null;
    5252                $this->tagname = null;
    53                
     53
    5454        }
    55        
     55
    5656        function _shortcode_tag($atts, $content=NULL, $tagname=NULL) {
    5757                $this->atts = $atts;
    5858                $this->content = $content;
    5959                $this->tagname = $tagname;
    6060        }
    61        
     61
    6262        function test_noatts() {
    6363                do_shortcode('[test-shortcode-tag /]');
    6464                $this->assertEquals( '', $this->atts );
    6565                $this->assertEquals( 'test-shortcode-tag', $this->tagname );
    6666        }
    67        
     67
    6868        function test_one_att() {
    6969                do_shortcode('[test-shortcode-tag foo="asdf" /]');
    7070                $this->assertEquals( array('foo' => 'asdf'), $this->atts );
    7171                $this->assertEquals( 'test-shortcode-tag', $this->tagname );
    7272        }
    73        
     73
    7474        function test_not_a_tag() {
    7575                $out = do_shortcode('[not-a-shortcode-tag]');
    7676                $this->assertEquals( '[not-a-shortcode-tag]', $out );
    7777        }
    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
    7994        function test_two_atts() {
    8095                do_shortcode('[test-shortcode-tag foo="asdf" bar="bing" /]');
    8196                $this->assertEquals( array('foo' => 'asdf', 'bar' => 'bing'), $this->atts );
    8297                $this->assertEquals( 'test-shortcode-tag', $this->tagname );
    8398        }
    84        
     99
    85100        function test_noatts_enclosing() {
    86101                do_shortcode('[test-shortcode-tag]content[/test-shortcode-tag]');
    87102                $this->assertEquals( '', $this->atts );
    88103                $this->assertEquals( 'content', $this->content );
    89104                $this->assertEquals( 'test-shortcode-tag', $this->tagname );
    90105        }
    91        
     106
    92107        function test_one_att_enclosing() {
    93108                do_shortcode('[test-shortcode-tag foo="bar"]content[/test-shortcode-tag]');
    94109                $this->assertEquals( array('foo' => 'bar'), $this->atts );
    95110                $this->assertEquals( 'content', $this->content );
    96111                $this->assertEquals( 'test-shortcode-tag', $this->tagname );
    97112        }
    98        
     113
    99114        function test_two_atts_enclosing() {
    100115                do_shortcode('[test-shortcode-tag foo="bar" baz="bing"]content[/test-shortcode-tag]');
    101116                $this->assertEquals( array('foo' => 'bar', 'baz' => 'bing'), $this->atts );