WordPress.org

Make WordPress Core

Ticket #6969: test_shortcode_texturize.php

File test_shortcode_texturize.php, 1.3 KB (added by mzizka, 5 years ago)

Updated test case

Line 
1<?php
2require_once 'PHPUnit/Framework.php';
3
4class 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
171 {y}
18
19[shortcode]
202 {n}
21[/shortcode]
22
233 {y}
24
25Escape shortcode like this: [[shortcode_2]]
26
27[shortcode_2]
28
294 {n}
30[/shortcode_2][not a shortcode]
31
325 {y}[shortcode]
336 {n}[/shortcode]7 {y}
34
35[not a shortcode]
36
37[shortcode_2 standalone /][[shortcode_2]]
38
398 {y}
40
41[shortcode_3 with_content]
429 {n}
43[/shortcode_3]
44
45[shortcode_3 standalone]
4610 {y}
47
48EOS;
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 = '&#8220;This&#8221; text &#8212; should be &#8216;texturized&#8217;';
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?>