| 1 | <?php |
|---|
| 2 | require_once 'PHPUnit/Framework.php'; |
|---|
| 3 | |
|---|
| 4 | class ShortCodeTexturizing extends PHPUnit_Framework_TestCase |
|---|
| 5 | { |
|---|
| 6 | public function testShortcodesAreNotTexturized() |
|---|
| 7 | { |
|---|
| 8 | require_once('./wp-includes/formatting.php'); |
|---|
| 9 | require_once('./wp-includes/plugin.php'); |
|---|
| 10 | require_once('./wp-includes/shortcodes.php'); |
|---|
| 11 | |
|---|
| 12 | add_shortcode('shortcode', 'print_r'); |
|---|
| 13 | add_shortcode('shortcode_2', 'print_r'); |
|---|
| 14 | add_shortcode('shortcode_3', 'print_r'); |
|---|
| 15 | |
|---|
| 16 | $format = <<<EOS |
|---|
| 17 | 1 {y} |
|---|
| 18 | |
|---|
| 19 | [shortcode] |
|---|
| 20 | 2 {n} |
|---|
| 21 | [/shortcode] |
|---|
| 22 | |
|---|
| 23 | 3 {y} |
|---|
| 24 | |
|---|
| 25 | Escape shortcode like this: [[shortcode_2]] |
|---|
| 26 | |
|---|
| 27 | [shortcode_2] |
|---|
| 28 | |
|---|
| 29 | 4 {n} |
|---|
| 30 | [/shortcode_2][not a shortcode] |
|---|
| 31 | |
|---|
| 32 | 5 {y}[shortcode] |
|---|
| 33 | 6 {n}[/shortcode]7 {y} |
|---|
| 34 | |
|---|
| 35 | [not a shortcode] |
|---|
| 36 | |
|---|
| 37 | [shortcode_2 standalone /][[shortcode_2]] |
|---|
| 38 | |
|---|
| 39 | 8 {y} |
|---|
| 40 | |
|---|
| 41 | [shortcode_3 with_content] |
|---|
| 42 | 9 {n} |
|---|
| 43 | [/shortcode_3] |
|---|
| 44 | |
|---|
| 45 | [shortcode_3 standalone] |
|---|
| 46 | 10 {y} |
|---|
| 47 | |
|---|
| 48 | EOS; |
|---|
| 49 | |
|---|
| 50 | $search = array('{y}', '{n}'); |
|---|
| 51 | |
|---|
| 52 | $yes = '"This" text -- should be \'texturized\''; |
|---|
| 53 | $no = '"This" text -- should NOT be \'texturized\''; |
|---|
| 54 | $replace = array($yes, $no); |
|---|
| 55 | $input = str_replace($search, $replace, $format); |
|---|
| 56 | |
|---|
| 57 | $yes = '“This” text — should be ‘texturized’'; |
|---|
| 58 | $replace = array($yes, $no); |
|---|
| 59 | $expected = str_replace($search, $replace, $format); |
|---|
| 60 | |
|---|
| 61 | $result = wptexturize($input); |
|---|
| 62 | $this->assertEquals($expected, $result); |
|---|
| 63 | } |
|---|
| 64 | } |
|---|
| 65 | ?> |
|---|