1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @group formatting |
5
|
|
|
*/ |
6
|
|
|
class Tests_Formatting_WPTexturize extends WP_UnitTestCase { |
7
|
|
|
function test_dashes() { |
8
|
|
|
$this->assertEquals('Hey — boo?', wptexturize('Hey -- boo?')); |
9
|
|
|
$this->assertEquals('<a href="http://xx--xx">Hey — boo?</a>', wptexturize('<a href="http://xx--xx">Hey -- boo?</a>')); |
10
|
|
|
} |
11
|
|
|
|
12
|
|
|
function test_disable() { |
13
|
|
|
$this->assertEquals('<pre>---&</pre>', wptexturize('<pre>---&</pre>')); |
14
|
|
|
$this->assertEquals('<pre><code></code>--&</pre>', wptexturize('<pre><code></code>--&</pre>')); |
15
|
|
|
|
16
|
|
|
$this->assertEquals( '<code>---&</code>', wptexturize( '<code>---&</code>' ) ); |
17
|
|
|
$this->assertEquals( '<kbd>---&</kbd>', wptexturize( '<kbd>---&</kbd>' ) ); |
18
|
|
|
$this->assertEquals( '<style>---&</style>', wptexturize( '<style>---&</style>' ) ); |
19
|
|
|
$this->assertEquals( '<script>---&</script>', wptexturize( '<script>---&</script>' ) ); |
20
|
|
|
$this->assertEquals( '<tt>---&</tt>', wptexturize( '<tt>---&</tt>' ) ); |
21
|
|
|
|
22
|
|
|
$this->assertEquals('<code>href="baba"</code> “baba”', wptexturize('<code>href="baba"</code> "baba"')); |
23
|
|
|
|
24
|
|
|
$enabled_tags_inside_code = '<code>curl -s <a href="http://x/">baba</a> | grep sfive | cut -d "\"" -f 10 > topmp3.txt</code>'; |
25
|
|
|
$this->assertEquals($enabled_tags_inside_code, wptexturize($enabled_tags_inside_code)); |
26
|
|
|
|
27
|
|
|
$double_nest = '<pre>"baba"<code>"baba"<pre></pre></code>"baba"</pre>'; |
28
|
|
|
$this->assertEquals($double_nest, wptexturize($double_nest)); |
29
|
|
|
|
30
|
|
|
$invalid_nest = '<pre></code>"baba"</pre>'; |
31
|
|
|
$this->assertEquals($invalid_nest, wptexturize($invalid_nest)); |
32
|
|
|
|
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
//WP Ticket #1418 |
36
|
|
|
function test_bracketed_quotes_1418() { |
37
|
|
|
$this->assertEquals('(“test”)', wptexturize('("test")')); |
38
|
|
|
$this->assertEquals('(‘test’)', wptexturize("('test')")); |
39
|
|
|
$this->assertEquals('(’twas)', wptexturize("('twas)")); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
//WP Ticket #3810 |
43
|
|
|
function test_bracketed_quotes_3810() { |
44
|
|
|
$this->assertEquals('A dog (“Hubertus”) was sent out.', wptexturize('A dog ("Hubertus") was sent out.')); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
//WP Ticket #4539 |
48
|
|
View Code Duplication |
function test_basic_quotes() { |
49
|
|
|
$this->assertEquals('test’s', wptexturize('test\'s')); |
50
|
|
|
|
51
|
|
|
$this->assertEquals('‘quoted’', wptexturize('\'quoted\'')); |
52
|
|
|
$this->assertEquals('“quoted”', wptexturize('"quoted"')); |
53
|
|
|
|
54
|
|
|
$this->assertEquals('space before ‘quoted’ space after', wptexturize('space before \'quoted\' space after')); |
55
|
|
|
$this->assertEquals('space before “quoted” space after', wptexturize('space before "quoted" space after')); |
56
|
|
|
|
57
|
|
|
$this->assertEquals('(‘quoted’)', wptexturize('(\'quoted\')')); |
58
|
|
|
$this->assertEquals('{“quoted”}', wptexturize('{"quoted"}')); |
59
|
|
|
|
60
|
|
|
$this->assertEquals('‘qu(ot)ed’', wptexturize('\'qu(ot)ed\'')); |
61
|
|
|
$this->assertEquals('“qu{ot}ed”', wptexturize('"qu{ot}ed"')); |
62
|
|
|
|
63
|
|
|
$this->assertEquals(' ‘test’s quoted’ ', wptexturize(' \'test\'s quoted\' ')); |
64
|
|
|
$this->assertEquals(' “test’s quoted” ', wptexturize(' "test\'s quoted" ')); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @ticket 4539 |
69
|
|
|
* @ticket 15241 |
70
|
|
|
*/ |
71
|
|
|
function test_full_sentences_with_unmatched_single_quotes() { |
72
|
|
|
$this->assertEquals( |
73
|
|
|
'That means every moment you’re working on something without it being in the public it’s actually dying.', |
74
|
|
|
wptexturize("That means every moment you're working on something without it being in the public it's actually dying.") |
75
|
|
|
); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @ticket 4539 |
80
|
|
|
*/ |
81
|
|
|
function test_quotes() { |
82
|
|
|
$this->assertEquals('“Quoted String”', wptexturize('"Quoted String"')); |
83
|
|
|
//$this->assertEquals('Here is “<a href="http://example.com">a test with a link</a>”', wptexturize('Here is "<a href="http://example.com">a test with a link</a>"')); |
84
|
|
|
//$this->assertEquals('Here is “<a href="http://example.com">a test with a link and a period</a>”.', wptexturize('Here is "<a href="http://example.com">a test with a link and a period</a>".')); |
85
|
|
|
$this->assertEquals('Here is “<a href="http://example.com">a test with a link</a>” and a space.', wptexturize('Here is "<a href="http://example.com">a test with a link</a>" and a space.')); |
86
|
|
|
$this->assertEquals('Here is “<a href="http://example.com">a test with a link</a> and some text quoted”', wptexturize('Here is "<a href="http://example.com">a test with a link</a> and some text quoted"')); |
87
|
|
|
//$this->assertEquals('Here is “<a href="http://example.com">a test with a link</a>”, and a comma.', wptexturize('Here is "<a href="http://example.com">a test with a link</a>", and a comma.')); |
88
|
|
|
//$this->assertEquals('Here is “<a href="http://example.com">a test with a link</a>”; and a semi-colon.', wptexturize('Here is "<a href="http://example.com">a test with a link</a>"; and a semi-colon.')); |
89
|
|
|
//$this->assertEquals('Here is “<a href="http://example.com">a test with a link</a>”- and a dash.', wptexturize('Here is "<a href="http://example.com">a test with a link</a>"- and a dash.')); |
90
|
|
|
//$this->assertEquals('Here is “<a href="http://example.com">a test with a link</a>”… and ellipses.', wptexturize('Here is "<a href="http://example.com">a test with a link</a>"... and ellipses.')); |
91
|
|
|
//$this->assertEquals('Here is “a test <a href="http://example.com">with a link</a>”.', wptexturize('Here is "a test <a href="http://example.com">with a link</a>".')); |
92
|
|
|
//$this->assertEquals('Here is “<a href="http://example.com">a test with a link</a>”and a work stuck to the end.', wptexturize('Here is "<a href="http://example.com">a test with a link</a>"and a work stuck to the end.')); |
93
|
|
|
$this->assertEquals('A test with a finishing number, “like 23”.', wptexturize('A test with a finishing number, "like 23".')); |
94
|
|
|
$this->assertEquals('A test with a number, “like 62”, is nice to have.', wptexturize('A test with a number, "like 62", is nice to have.')); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @ticket 4539 |
99
|
|
|
*/ |
100
|
|
|
function test_quotes_before_s() { |
101
|
|
|
$this->assertEquals('test’s', wptexturize("test's")); |
102
|
|
|
$this->assertEquals('‘test’s', wptexturize("'test's")); |
103
|
|
|
$this->assertEquals('‘test’s’', wptexturize("'test's'")); |
104
|
|
|
$this->assertEquals('‘string’', wptexturize("'string'")); |
105
|
|
|
$this->assertEquals('‘string’s’', wptexturize("'string's'")); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @ticket 4539 |
110
|
|
|
*/ |
111
|
|
|
function test_quotes_before_numbers() { |
112
|
|
|
$this->assertEquals('Class of ’99', wptexturize("Class of '99")); |
113
|
|
|
$this->assertEquals('Class of ’99’s', wptexturize("Class of '99's")); |
114
|
|
|
$this->assertEquals('‘Class of ’99’', wptexturize("'Class of '99'")); |
115
|
|
|
$this->assertEquals('‘Class of ’99’ ', wptexturize("'Class of '99' ")); |
116
|
|
|
$this->assertEquals('‘Class of ’99’.', wptexturize("'Class of '99'.")); |
117
|
|
|
$this->assertEquals('‘Class of ’99’, she said', wptexturize("'Class of '99', she said")); |
118
|
|
|
$this->assertEquals('‘Class of ’99’:', wptexturize("'Class of '99':")); |
119
|
|
|
$this->assertEquals('‘Class of ’99’;', wptexturize("'Class of '99';")); |
120
|
|
|
$this->assertEquals('‘Class of ’99’!', wptexturize("'Class of '99'!")); |
121
|
|
|
$this->assertEquals('‘Class of ’99’?', wptexturize("'Class of '99'?")); |
122
|
|
|
$this->assertEquals('‘Class of ’99’s’', wptexturize("'Class of '99's'")); |
123
|
|
|
$this->assertEquals('‘Class of ’99’s’', wptexturize("'Class of '99’s'")); |
124
|
|
|
$this->assertEquals('“Class of 99”', wptexturize("\"Class of 99\"")); |
125
|
|
|
$this->assertEquals('“Class of ’99”', wptexturize("\"Class of '99\"")); |
126
|
|
|
$this->assertEquals('{“Class of ’99”}', wptexturize("{\"Class of '99\"}")); |
127
|
|
|
$this->assertEquals(' “Class of ’99” ', wptexturize(" \"Class of '99\" ")); |
128
|
|
|
$this->assertEquals(' “Class of ’99”.', wptexturize(" \"Class of '99\".")); |
129
|
|
|
$this->assertEquals(' “Class of ’99”, she said', wptexturize(" \"Class of '99\", she said")); |
130
|
|
|
$this->assertEquals(' “Class of ’99”:', wptexturize(" \"Class of '99\":")); |
131
|
|
|
$this->assertEquals(' “Class of ’99”;', wptexturize(" \"Class of '99\";")); |
132
|
|
|
$this->assertEquals(' “Class of ’99”!', wptexturize(" \"Class of '99\"!")); |
133
|
|
|
$this->assertEquals(' “Class of ’99”?', wptexturize(" \"Class of '99\"?")); |
134
|
|
|
$this->assertEquals('}”Class of ’99″{', wptexturize("}\"Class of '99\"{")); // Not a quotation, may be between two other quotations. |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
function test_quotes_after_numbers() { |
138
|
|
|
$this->assertEquals('Class of ’99', wptexturize("Class of '99")); |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* @ticket 4539 |
143
|
|
|
* @ticket 15241 |
144
|
|
|
*/ |
145
|
|
|
function test_other_html() { |
146
|
|
|
$this->assertEquals('‘<strong>', wptexturize("'<strong>")); |
147
|
|
|
//$this->assertEquals('‘<strong>Quoted Text</strong>’,', wptexturize("'<strong>Quoted Text</strong>',")); |
148
|
|
|
//$this->assertEquals('“<strong>Quoted Text</strong>”,', wptexturize('"<strong>Quoted Text</strong>",')); |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
function test_x() { |
152
|
|
|
$this->assertEquals('14×24', wptexturize("14x24")); |
153
|
|
|
} |
154
|
|
|
|
155
|
|
View Code Duplication |
function test_minutes_seconds() { |
156
|
|
|
$this->assertEquals('9′', wptexturize('9\'')); |
157
|
|
|
$this->assertEquals('9″', wptexturize("9\"")); |
158
|
|
|
|
159
|
|
|
$this->assertEquals('a 9′ b', wptexturize('a 9\' b')); |
160
|
|
|
$this->assertEquals('a 9″ b', wptexturize("a 9\" b")); |
161
|
|
|
|
162
|
|
|
$this->assertEquals('“a 9′ b”', wptexturize('"a 9\' b"')); |
163
|
|
|
$this->assertEquals('‘a 9″ b’', wptexturize("'a 9\" b'")); |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* @ticket 8775 |
168
|
|
|
*/ |
169
|
|
|
function test_wptexturize_quotes_around_numbers() { |
170
|
|
|
$this->assertEquals('“12345”', wptexturize('"12345"')); |
171
|
|
|
$this->assertEquals('‘12345’', wptexturize('\'12345\'')); |
172
|
|
|
$this->assertEquals('“a 9′ plus a ‘9’, maybe a 9′ ‘9’”', wptexturize('"a 9\' plus a \'9\', maybe a 9\' \'9\'"')); |
173
|
|
|
$this->assertEquals('<p>’99<br />‘123’<br />’tis<br />‘s’</p>', wptexturize('<p>\'99<br />\'123\'<br />\'tis<br />\'s\'</p>')); |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
/** |
177
|
|
|
* @ticket 8912 |
178
|
|
|
*/ |
179
|
|
|
function test_wptexturize_html_comments() { |
180
|
|
|
$this->assertEquals('<!--[if !IE]>--><!--<![endif]-->', wptexturize('<!--[if !IE]>--><!--<![endif]-->')); |
181
|
|
|
$this->assertEquals('<!--[if !IE]>"a 9\' plus a \'9\', maybe a 9\' \'9\' "<![endif]-->', wptexturize('<!--[if !IE]>"a 9\' plus a \'9\', maybe a 9\' \'9\' "<![endif]-->')); |
182
|
|
|
$this->assertEquals('<ul><li>Hello.</li><!--<li>Goodbye.</li>--></ul>', wptexturize('<ul><li>Hello.</li><!--<li>Goodbye.</li>--></ul>')); |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
/** |
186
|
|
|
* @ticket 4539 |
187
|
|
|
* @ticket 15241 |
188
|
|
|
*/ |
189
|
|
|
function test_entity_quote_cuddling() { |
190
|
|
|
$this->assertEquals(' “Testing”', wptexturize(' "Testing"')); |
191
|
|
|
//$this->assertEquals('&“Testing”', wptexturize('&"Testing"')); |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
/** |
195
|
|
|
* @ticket 22823 |
196
|
|
|
*/ |
197
|
|
|
function test_apostrophes_before_primes() { |
198
|
|
|
$this->assertEquals( 'WordPress 3.5’s release date', wptexturize( "WordPress 3.5's release date" ) ); |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
/** |
202
|
|
|
* @ticket 23185 |
203
|
|
|
*/ |
204
|
|
|
function test_spaces_around_hyphens() { |
205
|
|
|
$nbsp = "\xC2\xA0"; |
206
|
|
|
|
207
|
|
|
$this->assertEquals( ' – ', wptexturize( ' - ' ) ); |
208
|
|
|
$this->assertEquals( ' – ', wptexturize( ' - ' ) ); |
209
|
|
|
$this->assertEquals( ' – ', wptexturize( ' - ' ) ); |
210
|
|
|
$this->assertEquals( ' – ', wptexturize( ' - ') ); |
211
|
|
|
$this->assertEquals( "$nbsp–$nbsp", wptexturize( "$nbsp-$nbsp" ) ); |
212
|
|
|
$this->assertEquals( " –$nbsp", wptexturize( " -$nbsp" ) ); |
213
|
|
|
$this->assertEquals( "$nbsp– ", wptexturize( "$nbsp- ") ); |
214
|
|
|
|
215
|
|
|
$this->assertEquals( ' — ', wptexturize( ' -- ' ) ); |
216
|
|
|
$this->assertEquals( ' — ', wptexturize( ' -- ' ) ); |
217
|
|
|
$this->assertEquals( ' — ', wptexturize( ' -- ' ) ); |
218
|
|
|
$this->assertEquals( ' — ', wptexturize( ' -- ') ); |
219
|
|
|
$this->assertEquals( "$nbsp—$nbsp", wptexturize( "$nbsp--$nbsp" ) ); |
220
|
|
|
$this->assertEquals( " —$nbsp", wptexturize( " --$nbsp" ) ); |
221
|
|
|
$this->assertEquals( "$nbsp— ", wptexturize( "$nbsp-- ") ); |
222
|
|
|
} |
223
|
|
|
|
224
|
|
|
/** |
225
|
|
|
* @ticket 31030 |
226
|
|
|
*/ |
227
|
|
View Code Duplication |
function test_hyphens_at_start_and_end() { |
228
|
|
|
$this->assertEquals( '– ', wptexturize( '- ' ) ); |
229
|
|
|
$this->assertEquals( '– –', wptexturize( '- -' ) ); |
230
|
|
|
$this->assertEquals( ' –', wptexturize( ' -' ) ); |
231
|
|
|
|
232
|
|
|
$this->assertEquals( '— ', wptexturize( '-- ' ) ); |
233
|
|
|
$this->assertEquals( '— —', wptexturize( '-- --' ) ); |
234
|
|
|
$this->assertEquals( ' —', wptexturize( ' --' ) ); |
235
|
|
|
} |
236
|
|
|
|
237
|
|
|
/** |
238
|
|
|
* Test spaces around quotes. |
239
|
|
|
* |
240
|
|
|
* These should never happen, even if the desired output changes some day. |
241
|
|
|
* |
242
|
|
|
* @ticket 22692 |
243
|
|
|
*/ |
244
|
|
|
function test_spaces_around_quotes_never() { |
245
|
|
|
$nbsp = "\xC2\xA0"; |
246
|
|
|
|
247
|
|
|
$problem_input = "$nbsp\"A"; |
248
|
|
|
$problem_output = "$nbsp”A"; |
249
|
|
|
|
250
|
|
|
$this->assertNotEquals( $problem_output, wptexturize( $problem_input ) ); |
251
|
|
|
} |
252
|
|
|
|
253
|
|
|
/** |
254
|
|
|
* Test spaces around quotes. |
255
|
|
|
* |
256
|
|
|
* These are desirable outputs for the current design. |
257
|
|
|
* |
258
|
|
|
* @ticket 22692 |
259
|
|
|
* @dataProvider data_spaces_around_quotes |
260
|
|
|
*/ |
261
|
|
|
function test_spaces_around_quotes( $input, $output ) { |
|
|
|
|
262
|
|
|
return $this->assertEquals( $output, wptexturize( $input ) ); |
263
|
|
|
} |
264
|
|
|
|
265
|
|
|
function data_spaces_around_quotes() { |
266
|
|
|
$nbsp = "\xC2\xA0"; |
267
|
|
|
$pi = "\xCE\xA0"; |
268
|
|
|
|
269
|
|
|
return array( |
270
|
|
|
array( |
271
|
|
|
"stop. $nbsp\"A quote after 2 spaces.\"", |
272
|
|
|
"stop. $nbsp“A quote after 2 spaces.”", |
273
|
|
|
), |
274
|
|
|
array( |
275
|
|
|
"stop.$nbsp$nbsp\"A quote after 2 spaces.\"", |
276
|
|
|
"stop.$nbsp$nbsp“A quote after 2 spaces.”", |
277
|
|
|
), |
278
|
|
|
array( |
279
|
|
|
"stop. $nbsp'A quote after 2 spaces.'", |
280
|
|
|
"stop. $nbsp‘A quote after 2 spaces.’", |
281
|
|
|
), |
282
|
|
|
array( |
283
|
|
|
"stop.$nbsp$nbsp'A quote after 2 spaces.'", |
284
|
|
|
"stop.$nbsp$nbsp‘A quote after 2 spaces.’", |
285
|
|
|
), |
286
|
|
|
array( |
287
|
|
|
"stop. \"A quote after 2 spaces.\"", |
288
|
|
|
"stop. “A quote after 2 spaces.”", |
289
|
|
|
), |
290
|
|
|
array( |
291
|
|
|
"stop. \"A quote after 2 spaces.\"", |
292
|
|
|
"stop. “A quote after 2 spaces.”", |
293
|
|
|
), |
294
|
|
|
array( |
295
|
|
|
"stop. 'A quote after 2 spaces.'", |
296
|
|
|
"stop. ‘A quote after 2 spaces.’", |
297
|
|
|
), |
298
|
|
|
array( |
299
|
|
|
"stop. 'A quote after 2 spaces.'", |
300
|
|
|
"stop. ‘A quote after 2 spaces.’", |
301
|
|
|
), |
302
|
|
|
array( |
303
|
|
|
"Contraction: $pi's", |
304
|
|
|
"Contraction: $pi’s", |
305
|
|
|
), |
306
|
|
|
); |
307
|
|
|
} |
308
|
|
|
|
309
|
|
|
/** |
310
|
|
|
* Apostrophe before a number always becomes ’ (apos); |
311
|
|
|
* |
312
|
|
|
* Checks all baseline patterns. If anything ever changes in wptexturize(), these tests may fail. |
313
|
|
|
* |
314
|
|
|
* @ticket 22692 |
315
|
|
|
* @dataProvider data_apos_before_digits |
316
|
|
|
*/ |
317
|
|
|
function test_apos_before_digits( $input, $output ) { |
|
|
|
|
318
|
|
|
return $this->assertEquals( $output, wptexturize( $input ) ); |
319
|
|
|
} |
320
|
|
|
|
321
|
|
View Code Duplication |
function data_apos_before_digits() { |
322
|
|
|
return array( |
323
|
|
|
array( |
324
|
|
|
"word '99 word", |
325
|
|
|
"word ’99 word", |
326
|
|
|
), |
327
|
|
|
array( |
328
|
|
|
"word'99 word", |
329
|
|
|
"word’99 word", |
330
|
|
|
), |
331
|
|
|
array( |
332
|
|
|
"word '99word", |
333
|
|
|
"word ’99word", |
334
|
|
|
), |
335
|
|
|
array( |
336
|
|
|
"word'99word", |
337
|
|
|
"word’99word", |
338
|
|
|
), |
339
|
|
|
array( |
340
|
|
|
"word '99’s word", // Appears as a separate but logically superfluous pattern in 3.8. |
341
|
|
|
"word ’99’s word", |
342
|
|
|
), |
343
|
|
|
array( |
344
|
|
|
"according to our source, '33 students scored less than 50' on the test.", // Apostrophes and primes have priority over quotes |
345
|
|
|
"according to our source, ’33 students scored less than 50′ on the test.", |
346
|
|
|
), |
347
|
|
|
); |
348
|
|
|
} |
349
|
|
|
|
350
|
|
|
/** |
351
|
|
|
* Apostrophe after a space or ([{<" becomes ‘ (opening_single_quote) |
352
|
|
|
* |
353
|
|
|
* Checks all baseline patterns. If anything ever changes in wptexturize(), these tests may fail. |
354
|
|
|
* |
355
|
|
|
* @ticket 22692 |
356
|
|
|
* @dataProvider data_opening_single_quote |
357
|
|
|
*/ |
358
|
|
|
function test_opening_single_quote( $input, $output ) { |
|
|
|
|
359
|
|
|
return $this->assertEquals( $output, wptexturize( $input ) ); |
360
|
|
|
} |
361
|
|
|
|
362
|
|
|
function data_opening_single_quote() { |
363
|
|
|
return array( |
364
|
|
|
array( |
365
|
|
|
"word 'word word", |
366
|
|
|
"word ‘word word", |
367
|
|
|
), |
368
|
|
|
array( |
369
|
|
|
"word ('word word", |
370
|
|
|
"word (‘word word", |
371
|
|
|
), |
372
|
|
|
array( |
373
|
|
|
"word ['word word", |
374
|
|
|
"word [‘word word", |
375
|
|
|
), |
376
|
|
|
array( |
377
|
|
|
"word <'word word", // Invalid HTML |
378
|
|
|
"word <'word word", |
379
|
|
|
), |
380
|
|
|
array( |
381
|
|
|
"word <'word word", // Valid HTML input makes curly quotes. |
382
|
|
|
"word <‘word word", |
383
|
|
|
), |
384
|
|
|
array( |
385
|
|
|
"word {'word word", |
386
|
|
|
"word {‘word word", |
387
|
|
|
), |
388
|
|
|
array( |
389
|
|
|
"word \"'word word", |
390
|
|
|
"word “‘word word", // Two opening quotes |
391
|
|
|
), |
392
|
|
|
array( |
393
|
|
|
"'word word", |
394
|
|
|
"‘word word", |
395
|
|
|
), |
396
|
|
|
array( |
397
|
|
|
"word('word word", |
398
|
|
|
"word(‘word word", |
399
|
|
|
), |
400
|
|
|
array( |
401
|
|
|
"word['word word", |
402
|
|
|
"word[‘word word", |
403
|
|
|
), |
404
|
|
|
array( |
405
|
|
|
"word<'word word", |
406
|
|
|
"word<'word word", |
407
|
|
|
), |
408
|
|
|
array( |
409
|
|
|
"word<'word word", |
410
|
|
|
"word<‘word word", |
411
|
|
|
), |
412
|
|
|
array( |
413
|
|
|
"word{'word word", |
414
|
|
|
"word{‘word word", |
415
|
|
|
), |
416
|
|
|
array( |
417
|
|
|
"word\"'word word", |
418
|
|
|
"word”‘word word", // Closing quote, then opening quote |
419
|
|
|
), |
420
|
|
|
array( |
421
|
|
|
"word ' word word", |
422
|
|
|
"word ‘ word word", |
423
|
|
|
), |
424
|
|
|
array( |
425
|
|
|
"word (' word word", |
426
|
|
|
"word (‘ word word", |
427
|
|
|
), |
428
|
|
|
array( |
429
|
|
|
"word [' word word", |
430
|
|
|
"word [‘ word word", |
431
|
|
|
), |
432
|
|
|
array( |
433
|
|
|
"word <' word word", |
434
|
|
|
"word <' word word", |
435
|
|
|
), |
436
|
|
|
array( |
437
|
|
|
"word <' word word", |
438
|
|
|
"word <‘ word word", |
439
|
|
|
), |
440
|
|
|
array( |
441
|
|
|
"word {' word word", |
442
|
|
|
"word {‘ word word", |
443
|
|
|
), |
444
|
|
|
array( |
445
|
|
|
"word \"' word word", |
446
|
|
|
"word “‘ word word", // Two opening quotes |
447
|
|
|
), |
448
|
|
|
array( |
449
|
|
|
"' word word", |
450
|
|
|
"‘ word word", |
451
|
|
|
), |
452
|
|
|
array( |
453
|
|
|
"word(' word word", |
454
|
|
|
"word(‘ word word", |
455
|
|
|
), |
456
|
|
|
array( |
457
|
|
|
"word[' word word", |
458
|
|
|
"word[‘ word word", |
459
|
|
|
), |
460
|
|
|
array( |
461
|
|
|
"word<' word word", |
462
|
|
|
"word<' word word", |
463
|
|
|
), |
464
|
|
|
array( |
465
|
|
|
"word<' word word", |
466
|
|
|
"word<‘ word word", |
467
|
|
|
), |
468
|
|
|
array( |
469
|
|
|
"word{' word word", |
470
|
|
|
"word{‘ word word", |
471
|
|
|
), |
472
|
|
|
array( |
473
|
|
|
"word\"' word word", |
474
|
|
|
"word”‘ word word", // Closing quote, then opening quote |
475
|
|
|
), |
476
|
|
|
); |
477
|
|
|
} |
478
|
|
|
|
479
|
|
|
/** |
480
|
|
|
* Double quote after a number becomes ″ (double_prime) |
481
|
|
|
* |
482
|
|
|
* Checks all baseline patterns. If anything ever changes in wptexturize(), these tests may fail. |
483
|
|
|
* |
484
|
|
|
* @ticket 22692 |
485
|
|
|
* @dataProvider data_double_prime |
486
|
|
|
*/ |
487
|
|
|
function test_double_prime( $input, $output ) { |
|
|
|
|
488
|
|
|
return $this->assertEquals( $output, wptexturize( $input ) ); |
489
|
|
|
} |
490
|
|
|
|
491
|
|
View Code Duplication |
function data_double_prime() { |
492
|
|
|
return array( |
493
|
|
|
array( |
494
|
|
|
'word 99" word', |
495
|
|
|
'word 99″ word', |
496
|
|
|
), |
497
|
|
|
array( |
498
|
|
|
'word 99"word', |
499
|
|
|
'word 99″word', |
500
|
|
|
), |
501
|
|
|
array( |
502
|
|
|
'word99" word', |
503
|
|
|
'word99″ word', |
504
|
|
|
), |
505
|
|
|
array( |
506
|
|
|
'word99"word', |
507
|
|
|
'word99″word', |
508
|
|
|
), |
509
|
|
|
); |
510
|
|
|
} |
511
|
|
|
|
512
|
|
|
/** |
513
|
|
|
* Apostrophe after a number becomes ′ (prime) |
514
|
|
|
* |
515
|
|
|
* Checks all baseline patterns. If anything ever changes in wptexturize(), these tests may fail. |
516
|
|
|
* |
517
|
|
|
* @ticket 22692 |
518
|
|
|
* @dataProvider data_single_prime |
519
|
|
|
*/ |
520
|
|
|
function test_single_prime( $input, $output ) { |
|
|
|
|
521
|
|
|
return $this->assertEquals( $output, wptexturize( $input ) ); |
522
|
|
|
} |
523
|
|
|
|
524
|
|
View Code Duplication |
function data_single_prime() { |
525
|
|
|
return array( |
526
|
|
|
array( |
527
|
|
|
"word 99' word", |
528
|
|
|
"word 99′ word", |
529
|
|
|
), |
530
|
|
|
array( |
531
|
|
|
"word 99'word", // Not a prime anymore. Apostrophes get priority. |
532
|
|
|
"word 99’word", |
533
|
|
|
), |
534
|
|
|
array( |
535
|
|
|
"word99' word", |
536
|
|
|
"word99′ word", |
537
|
|
|
), |
538
|
|
|
array( |
539
|
|
|
"word99'word", // Not a prime anymore. |
540
|
|
|
"word99’word", |
541
|
|
|
), |
542
|
|
|
); |
543
|
|
|
} |
544
|
|
|
|
545
|
|
|
/** |
546
|
|
|
* Apostrophe "in a word" becomes ’ (apos) |
547
|
|
|
* |
548
|
|
|
* Checks all baseline patterns. If anything ever changes in wptexturize(), these tests may fail. |
549
|
|
|
* |
550
|
|
|
* @ticket 22692 |
551
|
|
|
* @dataProvider data_contractions |
552
|
|
|
*/ |
553
|
|
|
function test_contractions( $input, $output ) { |
|
|
|
|
554
|
|
|
return $this->assertEquals( $output, wptexturize( $input ) ); |
555
|
|
|
} |
556
|
|
|
|
557
|
|
View Code Duplication |
function data_contractions() { |
558
|
|
|
return array( |
559
|
|
|
array( |
560
|
|
|
"word word's word", |
561
|
|
|
"word word’s word", |
562
|
|
|
), |
563
|
|
|
array( |
564
|
|
|
"word'[ word", // Apostrophes are never followed by opening punctuation. |
565
|
|
|
"word'[ word", |
566
|
|
|
), |
567
|
|
|
array( |
568
|
|
|
"word'( word", |
569
|
|
|
"word'( word", |
570
|
|
|
), |
571
|
|
|
array( |
572
|
|
|
"word'{ word", |
573
|
|
|
"word'{ word", |
574
|
|
|
), |
575
|
|
|
array( |
576
|
|
|
"word'< word", |
577
|
|
|
"word'< word", |
578
|
|
|
), |
579
|
|
|
array( |
580
|
|
|
"word'< word", // Invalid HTML input does trigger the apos pattern. |
581
|
|
|
"word’< word", |
582
|
|
|
), |
583
|
|
|
); |
584
|
|
|
} |
585
|
|
|
|
586
|
|
|
/** |
587
|
|
|
* Double quote after a space or ([-{< becomes “ (opening_quote) if not followed by spaces |
588
|
|
|
* |
589
|
|
|
* Checks all baseline patterns. If anything ever changes in wptexturize(), these tests may fail. |
590
|
|
|
* |
591
|
|
|
* @ticket 22692 |
592
|
|
|
* @dataProvider data_opening_quote |
593
|
|
|
*/ |
594
|
|
|
function test_opening_quote( $input, $output ) { |
|
|
|
|
595
|
|
|
return $this->assertEquals( $output, wptexturize( $input ) ); |
596
|
|
|
} |
597
|
|
|
|
598
|
|
View Code Duplication |
function data_opening_quote() { |
599
|
|
|
return array( |
600
|
|
|
array( |
601
|
|
|
'word "word word', |
602
|
|
|
'word “word word', |
603
|
|
|
), |
604
|
|
|
array( |
605
|
|
|
'word ("word word', |
606
|
|
|
'word (“word word', |
607
|
|
|
), |
608
|
|
|
array( |
609
|
|
|
'word ["word word', |
610
|
|
|
'word [“word word', |
611
|
|
|
), |
612
|
|
|
array( |
613
|
|
|
'word <"word word', // Invalid HTML |
614
|
|
|
'word <"word word', |
615
|
|
|
), |
616
|
|
|
array( |
617
|
|
|
'word <"word word', |
618
|
|
|
'word <“word word', |
619
|
|
|
), |
620
|
|
|
array( |
621
|
|
|
'word {"word word', |
622
|
|
|
'word {“word word', |
623
|
|
|
), |
624
|
|
|
array( |
625
|
|
|
'word -"word word', |
626
|
|
|
'word -“word word', |
627
|
|
|
), |
628
|
|
|
array( |
629
|
|
|
'word-"word word', |
630
|
|
|
'word-“word word', |
631
|
|
|
), |
632
|
|
|
array( |
633
|
|
|
'"word word', |
634
|
|
|
'“word word', |
635
|
|
|
), |
636
|
|
|
array( |
637
|
|
|
'word("word word', |
638
|
|
|
'word(“word word', |
639
|
|
|
), |
640
|
|
|
array( |
641
|
|
|
'word["word word', |
642
|
|
|
'word[“word word', |
643
|
|
|
), |
644
|
|
|
array( |
645
|
|
|
'word<"word word', |
646
|
|
|
'word<"word word', |
647
|
|
|
), |
648
|
|
|
array( |
649
|
|
|
'word<"word word', |
650
|
|
|
'word<“word word', |
651
|
|
|
), |
652
|
|
|
array( |
653
|
|
|
'word{"word word', |
654
|
|
|
'word{“word word', |
655
|
|
|
), |
656
|
|
|
array( |
657
|
|
|
'word "99 word', |
658
|
|
|
'word “99 word', |
659
|
|
|
), |
660
|
|
|
); |
661
|
|
|
} |
662
|
|
|
|
663
|
|
|
/** |
664
|
|
|
* Double quote becomes ” (closing_quote) unless it is already converted to double_prime or opening_quote. |
665
|
|
|
* |
666
|
|
|
* Checks all baseline patterns. If anything ever changes in wptexturize(), these tests may fail. |
667
|
|
|
* |
668
|
|
|
* @ticket 22692 |
669
|
|
|
* @dataProvider data_closing_quote |
670
|
|
|
*/ |
671
|
|
|
function test_closing_quote( $input, $output ) { |
|
|
|
|
672
|
|
|
return $this->assertEquals( $output, wptexturize( $input ) ); |
673
|
|
|
} |
674
|
|
|
|
675
|
|
View Code Duplication |
function data_closing_quote() { |
676
|
|
|
return array( |
677
|
|
|
array( |
678
|
|
|
'word word" word', |
679
|
|
|
'word word” word', |
680
|
|
|
), |
681
|
|
|
array( |
682
|
|
|
'word word") word', |
683
|
|
|
'word word”) word', |
684
|
|
|
), |
685
|
|
|
array( |
686
|
|
|
'word word"] word', |
687
|
|
|
'word word”] word', |
688
|
|
|
), |
689
|
|
|
array( |
690
|
|
|
'word word"} word', |
691
|
|
|
'word word”} word', |
692
|
|
|
), |
693
|
|
|
array( |
694
|
|
|
'word word"> word', // Invalid HTML input? |
695
|
|
|
'word word”> word', |
696
|
|
|
), |
697
|
|
|
array( |
698
|
|
|
'word word"> word', // Valid HTML should work |
699
|
|
|
'word word”> word', |
700
|
|
|
), |
701
|
|
|
array( |
702
|
|
|
'word word"', |
703
|
|
|
'word word”', |
704
|
|
|
), |
705
|
|
|
array( |
706
|
|
|
'word word"word', |
707
|
|
|
'word word”word', |
708
|
|
|
), |
709
|
|
|
array( |
710
|
|
|
'word"word"word', |
711
|
|
|
'word”word”word', |
712
|
|
|
), |
713
|
|
|
array( |
714
|
|
|
'test sentence".', |
715
|
|
|
'test sentence”.', |
716
|
|
|
), |
717
|
|
|
array( |
718
|
|
|
'test sentence",', |
719
|
|
|
'test sentence”,', |
720
|
|
|
), |
721
|
|
|
array( |
722
|
|
|
'test sentence":', |
723
|
|
|
'test sentence”:', |
724
|
|
|
), |
725
|
|
|
array( |
726
|
|
|
'test sentence";', |
727
|
|
|
'test sentence”;', |
728
|
|
|
), |
729
|
|
|
array( |
730
|
|
|
'test sentence"!', |
731
|
|
|
'test sentence”!', |
732
|
|
|
), |
733
|
|
|
array( |
734
|
|
|
'test sentence"?', |
735
|
|
|
'test sentence”?', |
736
|
|
|
), |
737
|
|
|
array( |
738
|
|
|
'test sentence."', |
739
|
|
|
'test sentence.”', |
740
|
|
|
), |
741
|
|
|
array( |
742
|
|
|
'test sentence". word', |
743
|
|
|
'test sentence”. word', |
744
|
|
|
), |
745
|
|
|
array( |
746
|
|
|
'test sentence." word', |
747
|
|
|
'test sentence.” word', |
748
|
|
|
), |
749
|
|
|
); |
750
|
|
|
} |
751
|
|
|
|
752
|
|
|
/** |
753
|
|
|
* Test that single quotes followed by a space or .,-)}]> become ’ (closing_single_quote) |
754
|
|
|
* |
755
|
|
|
* Checks all baseline patterns. If anything ever changes in wptexturize(), these tests may fail. |
756
|
|
|
* |
757
|
|
|
* @ticket 22692 |
758
|
|
|
* @dataProvider data_closing_single_quote |
759
|
|
|
*/ |
760
|
|
|
function test_closing_single_quote( $input, $output ) { |
|
|
|
|
761
|
|
|
return $this->assertEquals( $output, wptexturize( $input ) ); |
762
|
|
|
} |
763
|
|
|
|
764
|
|
View Code Duplication |
function data_closing_single_quote() { |
765
|
|
|
return array( |
766
|
|
|
array( |
767
|
|
|
"word word' word", |
768
|
|
|
"word word’ word", |
769
|
|
|
), |
770
|
|
|
array( |
771
|
|
|
"word word'. word", |
772
|
|
|
"word word’. word", |
773
|
|
|
), |
774
|
|
|
array( |
775
|
|
|
"word word'.word", |
776
|
|
|
"word word’.word", |
777
|
|
|
), |
778
|
|
|
array( |
779
|
|
|
"word word', she said", |
780
|
|
|
"word word’, she said", |
781
|
|
|
), |
782
|
|
|
array( |
783
|
|
|
"word word': word", |
784
|
|
|
"word word’: word", |
785
|
|
|
), |
786
|
|
|
array( |
787
|
|
|
"word word'; word", |
788
|
|
|
"word word’; word", |
789
|
|
|
), |
790
|
|
|
array( |
791
|
|
|
"word word'! word", |
792
|
|
|
"word word’! word", |
793
|
|
|
), |
794
|
|
|
array( |
795
|
|
|
"word word'? word", |
796
|
|
|
"word word’? word", |
797
|
|
|
), |
798
|
|
|
array( |
799
|
|
|
"word word'- word", |
800
|
|
|
"word word’- word", |
801
|
|
|
), |
802
|
|
|
array( |
803
|
|
|
"word word') word", |
804
|
|
|
"word word’) word", |
805
|
|
|
), |
806
|
|
|
array( |
807
|
|
|
"word word'} word", |
808
|
|
|
"word word’} word", |
809
|
|
|
), |
810
|
|
|
array( |
811
|
|
|
"word word'] word", |
812
|
|
|
"word word’] word", |
813
|
|
|
), |
814
|
|
|
array( |
815
|
|
|
"word word'> word", |
816
|
|
|
"word word’> word", |
817
|
|
|
), |
818
|
|
|
array( |
819
|
|
|
"word word'", |
820
|
|
|
"word word’", |
821
|
|
|
), |
822
|
|
|
array( |
823
|
|
|
"test sentence'.", |
824
|
|
|
"test sentence’.", |
825
|
|
|
), |
826
|
|
|
array( |
827
|
|
|
"test sentence.'", |
828
|
|
|
"test sentence.’", |
829
|
|
|
), |
830
|
|
|
array( |
831
|
|
|
"test sentence'. word", |
832
|
|
|
"test sentence’. word", |
833
|
|
|
), |
834
|
|
|
array( |
835
|
|
|
"test sentence.' word", |
836
|
|
|
"test sentence.’ word", |
837
|
|
|
), |
838
|
|
|
); |
839
|
|
|
} |
840
|
|
|
|
841
|
|
|
/** |
842
|
|
|
* Tests multiplication. |
843
|
|
|
* |
844
|
|
|
* Checks all baseline patterns. If anything ever changes in wptexturize(), these tests may fail. |
845
|
|
|
* |
846
|
|
|
* @ticket 22692 |
847
|
|
|
* @dataProvider data_multiplication |
848
|
|
|
*/ |
849
|
|
|
function test_multiplication( $input, $output ) { |
|
|
|
|
850
|
|
|
return $this->assertEquals( $output, wptexturize( $input ) ); |
851
|
|
|
} |
852
|
|
|
|
853
|
|
|
function data_multiplication() { |
854
|
|
|
return array( |
855
|
|
|
array( |
856
|
|
|
"9x9", |
857
|
|
|
"9×9", |
858
|
|
|
), |
859
|
|
|
array( |
860
|
|
|
"12x34", |
861
|
|
|
"12×34", |
862
|
|
|
), |
863
|
|
|
array( |
864
|
|
|
"-123x1=-123", |
865
|
|
|
"-123×1=-123", |
866
|
|
|
), |
867
|
|
|
// @ticket 30445 |
868
|
|
|
array( |
869
|
|
|
"-123x-1", |
870
|
|
|
"-123x-1", |
871
|
|
|
), |
872
|
|
|
array( |
873
|
|
|
"0.675x1=0.675", |
874
|
|
|
"0.675×1=0.675", |
875
|
|
|
), |
876
|
|
|
array( |
877
|
|
|
"9 x 9", |
878
|
|
|
"9 x 9", |
879
|
|
|
), |
880
|
|
|
array( |
881
|
|
|
"0x70", |
882
|
|
|
"0x70", |
883
|
|
|
), |
884
|
|
|
array( |
885
|
|
|
"3x2x1x0", |
886
|
|
|
"3x2x1x0", |
887
|
|
|
), |
888
|
|
|
); |
889
|
|
|
} |
890
|
|
|
|
891
|
|
|
/** |
892
|
|
|
* Test ampersands. & always becomes & unless it is followed by # or ; |
893
|
|
|
* |
894
|
|
|
* Checks all baseline patterns. If anything ever changes in wptexturize(), these tests may fail. |
895
|
|
|
* |
896
|
|
|
* @ticket 22692 |
897
|
|
|
* @dataProvider data_ampersand |
898
|
|
|
*/ |
899
|
|
|
function test_ampersand( $input, $output ) { |
|
|
|
|
900
|
|
|
return $this->assertEquals( $output, wptexturize( $input ) ); |
901
|
|
|
} |
902
|
|
|
|
903
|
|
View Code Duplication |
function data_ampersand() { |
904
|
|
|
return array( |
905
|
|
|
array( |
906
|
|
|
"word & word", |
907
|
|
|
"word & word", |
908
|
|
|
), |
909
|
|
|
array( |
910
|
|
|
"word&word", |
911
|
|
|
"word&word", |
912
|
|
|
), |
913
|
|
|
array( |
914
|
|
|
"word word", |
915
|
|
|
"word word", |
916
|
|
|
), |
917
|
|
|
array( |
918
|
|
|
"word & word", |
919
|
|
|
"word & word", |
920
|
|
|
), |
921
|
|
|
array( |
922
|
|
|
"word ઼ word", |
923
|
|
|
"word ઼ word", |
924
|
|
|
), |
925
|
|
|
array( |
926
|
|
|
"word Δ word", |
927
|
|
|
"word Δ word", |
928
|
|
|
), |
929
|
|
|
array( |
930
|
|
|
"word &# word", |
931
|
|
|
"word &# word", |
932
|
|
|
), |
933
|
|
|
array( |
934
|
|
|
"word &44; word", |
935
|
|
|
"word &44; word", |
936
|
|
|
), |
937
|
|
|
array( |
938
|
|
|
"word && word", |
939
|
|
|
"word && word", |
940
|
|
|
), |
941
|
|
|
array( |
942
|
|
|
"word &!amp; word", |
943
|
|
|
"word &!amp; word", |
944
|
|
|
), |
945
|
|
|
array( |
946
|
|
|
"word &#", |
947
|
|
|
"word &#", |
948
|
|
|
), |
949
|
|
|
array( |
950
|
|
|
"word &", |
951
|
|
|
"word &", |
952
|
|
|
), |
953
|
|
|
); |
954
|
|
|
} |
955
|
|
|
|
956
|
|
|
/** |
957
|
|
|
* Test "cockney" phrases, which begin with an apostrophe instead of an opening single quote. |
958
|
|
|
* |
959
|
|
|
* Checks all baseline patterns. If anything ever changes in wptexturize(), these tests may fail. |
960
|
|
|
* |
961
|
|
|
* @ticket 22692 |
962
|
|
|
* @dataProvider data_cockney |
963
|
|
|
*/ |
964
|
|
|
function test_cockney( $input, $output ) { |
|
|
|
|
965
|
|
|
return $this->assertEquals( $output, wptexturize( $input ) ); |
966
|
|
|
} |
967
|
|
|
|
968
|
|
View Code Duplication |
function data_cockney() { |
969
|
|
|
return array( |
970
|
|
|
array( |
971
|
|
|
"word 'tain't word", |
972
|
|
|
"word ’tain’t word", |
973
|
|
|
), |
974
|
|
|
array( |
975
|
|
|
"word 'twere word", |
976
|
|
|
"word ’twere word", |
977
|
|
|
), |
978
|
|
|
array( |
979
|
|
|
"word 'twas word", |
980
|
|
|
"word ’twas word", |
981
|
|
|
), |
982
|
|
|
array( |
983
|
|
|
"word 'tis word", |
984
|
|
|
"word ’tis word", |
985
|
|
|
), |
986
|
|
|
array( |
987
|
|
|
"word 'twill word", |
988
|
|
|
"word ’twill word", |
989
|
|
|
), |
990
|
|
|
array( |
991
|
|
|
"word 'til word", |
992
|
|
|
"word ’til word", |
993
|
|
|
), |
994
|
|
|
array( |
995
|
|
|
"word 'bout word", |
996
|
|
|
"word ’bout word", |
997
|
|
|
), |
998
|
|
|
array( |
999
|
|
|
"word 'nuff word", |
1000
|
|
|
"word ’nuff word", |
1001
|
|
|
), |
1002
|
|
|
array( |
1003
|
|
|
"word 'round word", |
1004
|
|
|
"word ’round word", |
1005
|
|
|
), |
1006
|
|
|
array( |
1007
|
|
|
"word 'cause word", |
1008
|
|
|
"word ’cause word", |
1009
|
|
|
), |
1010
|
|
|
array( |
1011
|
|
|
"word 'em word", |
1012
|
|
|
"word ’em word", |
1013
|
|
|
), |
1014
|
|
|
); |
1015
|
|
|
} |
1016
|
|
|
|
1017
|
|
|
/** |
1018
|
|
|
* Test smart dashes. |
1019
|
|
|
* |
1020
|
|
|
* Checks all baseline patterns. If anything ever changes in wptexturize(), these tests may fail. |
1021
|
|
|
* |
1022
|
|
|
* @ticket 22692 |
1023
|
|
|
* @dataProvider data_smart_dashes |
1024
|
|
|
*/ |
1025
|
|
|
function test_smart_dashes( $input, $output ) { |
|
|
|
|
1026
|
|
|
return $this->assertEquals( $output, wptexturize( $input ) ); |
1027
|
|
|
} |
1028
|
|
|
|
1029
|
|
|
function data_smart_dashes() { |
1030
|
|
|
return array( |
1031
|
|
|
array( |
1032
|
|
|
"word --- word", |
1033
|
|
|
"word — word", |
1034
|
|
|
), |
1035
|
|
|
array( |
1036
|
|
|
"word---word", |
1037
|
|
|
"word—word", |
1038
|
|
|
), |
1039
|
|
|
array( |
1040
|
|
|
"word -- word", |
1041
|
|
|
"word — word", |
1042
|
|
|
), |
1043
|
|
|
array( |
1044
|
|
|
"word--word", |
1045
|
|
|
"word–word", |
1046
|
|
|
), |
1047
|
|
|
array( |
1048
|
|
|
"word - word", |
1049
|
|
|
"word – word", |
1050
|
|
|
), |
1051
|
|
|
array( |
1052
|
|
|
"word-word", |
1053
|
|
|
"word-word", |
1054
|
|
|
), |
1055
|
|
|
array( |
1056
|
|
|
"word xn– word", |
1057
|
|
|
"word xn– word", |
1058
|
|
|
), |
1059
|
|
|
array( |
1060
|
|
|
"wordxn–word", |
1061
|
|
|
"wordxn–word", |
1062
|
|
|
), |
1063
|
|
|
array( |
1064
|
|
|
"wordxn--word", |
1065
|
|
|
"wordxn--word", |
1066
|
|
|
), |
1067
|
|
|
); |
1068
|
|
|
} |
1069
|
|
|
|
1070
|
|
|
/** |
1071
|
|
|
* Test miscellaneous static replacements. |
1072
|
|
|
* |
1073
|
|
|
* Checks all baseline patterns. If anything ever changes in wptexturize(), these tests may fail. |
1074
|
|
|
* |
1075
|
|
|
* @ticket 22692 |
1076
|
|
|
* @dataProvider data_misc_static_replacements |
1077
|
|
|
*/ |
1078
|
|
|
function test_misc_static_replacements( $input, $output ) { |
|
|
|
|
1079
|
|
|
return $this->assertEquals( $output, wptexturize( $input ) ); |
1080
|
|
|
} |
1081
|
|
|
|
1082
|
|
|
function data_misc_static_replacements() { |
1083
|
|
|
return array( |
1084
|
|
|
array( |
1085
|
|
|
"word ... word", |
1086
|
|
|
"word … word", |
1087
|
|
|
), |
1088
|
|
|
array( |
1089
|
|
|
"word...word", |
1090
|
|
|
"word…word", |
1091
|
|
|
), |
1092
|
|
|
array( |
1093
|
|
|
"word `` word", |
1094
|
|
|
"word “ word", |
1095
|
|
|
), |
1096
|
|
|
array( |
1097
|
|
|
"word``word", |
1098
|
|
|
"word“word", |
1099
|
|
|
), |
1100
|
|
|
array( |
1101
|
|
|
"word '' word", |
1102
|
|
|
"word ” word", |
1103
|
|
|
), |
1104
|
|
|
array( |
1105
|
|
|
"word''word", |
1106
|
|
|
"word”word", |
1107
|
|
|
), |
1108
|
|
|
array( |
1109
|
|
|
"word (tm) word", |
1110
|
|
|
"word ™ word", |
1111
|
|
|
), |
1112
|
|
|
array( |
1113
|
|
|
"word (tm)word", |
1114
|
|
|
"word ™word", |
1115
|
|
|
), |
1116
|
|
|
array( |
1117
|
|
|
"word(tm) word", |
1118
|
|
|
"word(tm) word", |
1119
|
|
|
), |
1120
|
|
|
array( |
1121
|
|
|
"word(tm)word", |
1122
|
|
|
"word(tm)word", |
1123
|
|
|
), |
1124
|
|
|
); |
1125
|
|
|
} |
1126
|
|
|
|
1127
|
|
|
/** |
1128
|
|
|
* Numbers inside of matching quotes get curly quotes instead of apostrophes and primes. |
1129
|
|
|
* |
1130
|
|
|
* @ticket 8775 |
1131
|
|
|
* @dataProvider data_quoted_numbers |
1132
|
|
|
*/ |
1133
|
|
|
function test_quoted_numbers( $input, $output ) { |
|
|
|
|
1134
|
|
|
return $this->assertEquals( $output, wptexturize( $input ) ); |
1135
|
|
|
} |
1136
|
|
|
|
1137
|
|
View Code Duplication |
function data_quoted_numbers() { |
1138
|
|
|
return array( |
1139
|
|
|
array( |
1140
|
|
|
'word "42.00" word', |
1141
|
|
|
'word “42.00” word', |
1142
|
|
|
), |
1143
|
|
|
array( |
1144
|
|
|
'word "42.00"word', |
1145
|
|
|
'word “42.00”word', |
1146
|
|
|
), |
1147
|
|
|
array( |
1148
|
|
|
"word '42.00' word", |
1149
|
|
|
"word ‘42.00’ word", |
1150
|
|
|
), |
1151
|
|
|
array( |
1152
|
|
|
"word '42.00'word", |
1153
|
|
|
"word ‘42.00’word", |
1154
|
|
|
), |
1155
|
|
|
array( |
1156
|
|
|
'word "42" word', |
1157
|
|
|
'word “42” word', |
1158
|
|
|
), |
1159
|
|
|
array( |
1160
|
|
|
'word "42,00" word', |
1161
|
|
|
'word “42,00” word', |
1162
|
|
|
), |
1163
|
|
|
array( |
1164
|
|
|
'word "4,242.00" word', |
1165
|
|
|
'word “4,242.00” word', |
1166
|
|
|
), |
1167
|
|
|
array( |
1168
|
|
|
"word '99's word", |
1169
|
|
|
"word ’99’s word", |
1170
|
|
|
), |
1171
|
|
|
array( |
1172
|
|
|
"word '99'samsonite", |
1173
|
|
|
"word ’99’samsonite", |
1174
|
|
|
), |
1175
|
|
|
); |
1176
|
|
|
} |
1177
|
|
|
|
1178
|
|
|
/** |
1179
|
|
|
* Quotations should be allowed to have dashes around them. |
1180
|
|
|
* |
1181
|
|
|
* @ticket 20342 |
1182
|
|
|
* @dataProvider data_quotes_and_dashes |
1183
|
|
|
*/ |
1184
|
|
|
function test_quotes_and_dashes( $input, $output ) { |
|
|
|
|
1185
|
|
|
return $this->assertEquals( $output, wptexturize( $input ) ); |
1186
|
|
|
} |
1187
|
|
|
|
1188
|
|
View Code Duplication |
function data_quotes_and_dashes() { |
1189
|
|
|
return array( |
1190
|
|
|
array( |
1191
|
|
|
'word---"quote"', |
1192
|
|
|
'word—“quote”', |
1193
|
|
|
), |
1194
|
|
|
array( |
1195
|
|
|
'word--"quote"', |
1196
|
|
|
'word–“quote”', |
1197
|
|
|
), |
1198
|
|
|
array( |
1199
|
|
|
'word-"quote"', |
1200
|
|
|
'word-“quote”', |
1201
|
|
|
), |
1202
|
|
|
array( |
1203
|
|
|
"word---'quote'", |
1204
|
|
|
"word—‘quote’", |
1205
|
|
|
), |
1206
|
|
|
array( |
1207
|
|
|
"word--'quote'", |
1208
|
|
|
"word–‘quote’", |
1209
|
|
|
), |
1210
|
|
|
array( |
1211
|
|
|
"word-'quote'", |
1212
|
|
|
"word-‘quote’", |
1213
|
|
|
), |
1214
|
|
|
array( |
1215
|
|
|
'"quote"---word', |
1216
|
|
|
'“quote”—word', |
1217
|
|
|
), |
1218
|
|
|
array( |
1219
|
|
|
'"quote"--word', |
1220
|
|
|
'“quote”–word', |
1221
|
|
|
), |
1222
|
|
|
array( |
1223
|
|
|
'"quote"-word', |
1224
|
|
|
'“quote”-word', |
1225
|
|
|
), |
1226
|
|
|
array( |
1227
|
|
|
"'quote'---word", |
1228
|
|
|
"‘quote’—word", |
1229
|
|
|
), |
1230
|
|
|
array( |
1231
|
|
|
"'quote'--word", |
1232
|
|
|
"‘quote’–word", |
1233
|
|
|
), |
1234
|
|
|
array( |
1235
|
|
|
"'quote'-word", |
1236
|
|
|
"‘quote’-word", |
1237
|
|
|
), |
1238
|
|
|
); |
1239
|
|
|
} |
1240
|
|
|
|
1241
|
|
|
/** |
1242
|
|
|
* Test HTML and shortcode avoidance. |
1243
|
|
|
* |
1244
|
|
|
* @ticket 12690 |
1245
|
|
|
* @dataProvider data_tag_avoidance |
1246
|
|
|
*/ |
1247
|
|
|
function test_tag_avoidance( $input, $output ) { |
|
|
|
|
1248
|
|
|
return $this->assertEquals( $output, wptexturize( $input ) ); |
1249
|
|
|
} |
1250
|
|
|
|
1251
|
|
|
function data_tag_avoidance() { |
1252
|
|
|
return array( |
1253
|
|
|
array( |
1254
|
|
|
'[ ... ]', |
1255
|
|
|
'[ … ]', |
1256
|
|
|
), |
1257
|
|
|
array( |
1258
|
|
|
'[ is it wise to <a title="allow user content ] here? hmm"> maybe </a> ]', |
1259
|
|
|
'[ is it wise to <a title="allow user content ] here? hmm"> maybe </a> ]', |
1260
|
|
|
), |
1261
|
|
|
array( |
1262
|
|
|
'[is it wise to <a title="allow user content ] here? hmm"> maybe </a> ]', |
1263
|
|
|
'[is it wise to <a title="allow user content ] here? hmm"> maybe </a> ]', |
1264
|
|
|
), |
1265
|
|
|
array( |
1266
|
|
|
'[caption - is it wise to <a title="allow user content ] here? hmm"> maybe </a> ]', |
1267
|
|
|
'[caption – is it wise to <a title="allow user content ] here? hmm"> maybe </a> ]', |
1268
|
|
|
), |
1269
|
|
|
array( |
1270
|
|
|
'[ photos by <a href="http://example.com/?a[]=1&a[]=2"> this guy & that guy </a> ]', |
1271
|
|
|
'[ photos by <a href="http://example.com/?a[]=1&a[]=2"> this guy & that guy </a> ]', |
1272
|
|
|
), |
1273
|
|
|
array( |
1274
|
|
|
'[photos by <a href="http://example.com/?a[]=1&a[]=2"> this guy & that guy </a>]', |
1275
|
|
|
'[photos by <a href="http://example.com/?a[]=1&a[]=2"> this guy & that guy </a>]', |
1276
|
|
|
), |
1277
|
|
|
array( |
1278
|
|
|
'& <script>&&</script>', |
1279
|
|
|
'& <script>&&</script>' |
1280
|
|
|
), |
1281
|
|
|
array( |
1282
|
|
|
'[gallery ...]', |
1283
|
|
|
'[gallery ...]', |
1284
|
|
|
), |
1285
|
|
|
array( |
1286
|
|
|
'[[gallery ...]', // This tag is still valid. |
1287
|
|
|
'[[gallery ...]', |
1288
|
|
|
), |
1289
|
|
|
array( |
1290
|
|
|
'[gallery ...]]', // This tag is also valid. |
1291
|
|
|
'[gallery ...]]', |
1292
|
|
|
), |
1293
|
|
|
array( |
1294
|
|
|
'[/gallery ...]', // This would actually be ignored by the shortcode system. The decision to not texturize it is intentional, if not correct. |
1295
|
|
|
'[/gallery ...]', |
1296
|
|
|
), |
1297
|
|
|
array( |
1298
|
|
|
'[[gallery]]...[[/gallery]]', // Shortcode parsing will ignore the inner ]...[ part and treat this as a single escaped shortcode. |
1299
|
|
|
'[[gallery]]…[[/gallery]]', |
1300
|
|
|
), |
1301
|
|
|
array( |
1302
|
|
|
'[[[gallery]]]...[[[/gallery]]]', // Again, shortcode parsing matches, but only the [[gallery] and [/gallery]] parts. |
1303
|
|
|
'[[[gallery]]]…[[[/gallery]]]', |
1304
|
|
|
), |
1305
|
|
|
array( |
1306
|
|
|
'[gallery ...', |
1307
|
|
|
'[gallery …', |
1308
|
|
|
), |
1309
|
|
|
array( |
1310
|
|
|
'[gallery <br ... /> ...]', // This tag is still valid. Shortcode 'attributes' are not considered in the initial parsing of shortcodes, and HTML is allowed. |
1311
|
|
|
'[gallery <br ... /> ...]', |
1312
|
|
|
), |
1313
|
|
|
array( |
1314
|
|
|
'<br [gallery ...] ... />', |
1315
|
|
|
'<br [gallery ...] ... />', |
1316
|
|
|
), |
1317
|
|
|
array( |
1318
|
|
|
'<br [gallery ...] ... /', |
1319
|
|
|
'<br [gallery ...] ... /', |
1320
|
|
|
), |
1321
|
|
|
array( |
1322
|
|
|
'<br ... />', |
1323
|
|
|
'<br ... />', |
1324
|
|
|
), |
1325
|
|
|
array( |
1326
|
|
|
'<br ... />...<br ... />', |
1327
|
|
|
'<br ... />…<br ... />', |
1328
|
|
|
), |
1329
|
|
|
array( |
1330
|
|
|
'[gallery ...]...[gallery ...]', |
1331
|
|
|
'[gallery ...]…[gallery ...]', |
1332
|
|
|
), |
1333
|
|
|
array( |
1334
|
|
|
'[[gallery ...]]', |
1335
|
|
|
'[[gallery ...]]', |
1336
|
|
|
), |
1337
|
|
|
array( |
1338
|
|
|
'[[gallery ...]', |
1339
|
|
|
'[[gallery ...]', |
1340
|
|
|
), |
1341
|
|
|
array( |
1342
|
|
|
'[gallery ...]]', |
1343
|
|
|
'[gallery ...]]', |
1344
|
|
|
), |
1345
|
|
|
array( |
1346
|
|
|
'[/gallery ...]]', |
1347
|
|
|
'[/gallery ...]]', |
1348
|
|
|
), |
1349
|
|
|
array( |
1350
|
|
|
'[[gallery <br ... /> ...]]', // This gets parsed as an escaped shortcode with embedded HTML. Brains may explode. |
1351
|
|
|
'[[gallery <br ... /> ...]]', |
1352
|
|
|
), |
1353
|
|
|
array( |
1354
|
|
|
'<br [[gallery ...]] ... />', |
1355
|
|
|
'<br [[gallery ...]] ... />', |
1356
|
|
|
), |
1357
|
|
|
array( |
1358
|
|
|
'<br [[gallery ...]] ... /', |
1359
|
|
|
'<br [[gallery ...]] ... /', |
1360
|
|
|
), |
1361
|
|
|
array( |
1362
|
|
|
'[[gallery ...]]...[[gallery ...]]', |
1363
|
|
|
'[[gallery ...]]…[[gallery ...]]', |
1364
|
|
|
), |
1365
|
|
|
array( |
1366
|
|
|
'[[gallery ...]...[/gallery]]', |
1367
|
|
|
'[[gallery ...]…[/gallery]]', |
1368
|
|
|
), |
1369
|
|
|
array( |
1370
|
|
|
'<!-- ... -->', |
1371
|
|
|
'<!-- ... -->', |
1372
|
|
|
), |
1373
|
|
|
array( |
1374
|
|
|
'<!--...-->', |
1375
|
|
|
'<!--...-->', |
1376
|
|
|
), |
1377
|
|
|
array( |
1378
|
|
|
'<!-- ... -- > ...', |
1379
|
|
|
'<!-- ... -- > ...', |
1380
|
|
|
), |
1381
|
|
|
array( |
1382
|
|
|
'<!-- ...', // An unclosed comment is still a comment. |
1383
|
|
|
'<!-- ...', |
1384
|
|
|
), |
1385
|
|
|
array( |
1386
|
|
|
'a<!-->b', // Browsers seem to allow this. |
1387
|
|
|
'a<!-->b', |
1388
|
|
|
), |
1389
|
|
|
array( |
1390
|
|
|
'a<!--->b', |
1391
|
|
|
'a<!--->b', |
1392
|
|
|
), |
1393
|
|
|
array( |
1394
|
|
|
'a<!---->b', |
1395
|
|
|
'a<!---->b', |
1396
|
|
|
), |
1397
|
|
|
array( |
1398
|
|
|
'a<!----->b', |
1399
|
|
|
'a<!----->b', |
1400
|
|
|
), |
1401
|
|
|
array( |
1402
|
|
|
'a<!-- c --->b', |
1403
|
|
|
'a<!-- c --->b', |
1404
|
|
|
), |
1405
|
|
|
array( |
1406
|
|
|
'a<!-- c -- d -->b', |
1407
|
|
|
'a<!-- c -- d -->b', |
1408
|
|
|
), |
1409
|
|
|
array( |
1410
|
|
|
'a<!-- <!-- c --> -->b<!-- close -->', |
1411
|
|
|
'a<!-- <!-- c --> –>b<!-- close -->', |
1412
|
|
|
), |
1413
|
|
|
array( |
1414
|
|
|
'<!-- <br /> [gallery] ... -->', |
1415
|
|
|
'<!-- <br /> [gallery] ... -->', |
1416
|
|
|
), |
1417
|
|
|
array( |
1418
|
|
|
'...<!-- ... -->...', |
1419
|
|
|
'…<!-- ... -->…', |
1420
|
|
|
), |
1421
|
|
|
array( |
1422
|
|
|
'[gallery ...]...<!-- ... -->...<br ... />', |
1423
|
|
|
'[gallery ...]…<!-- ... -->…<br ... />', |
1424
|
|
|
), |
1425
|
|
|
array( |
1426
|
|
|
'<ul><li>Hello.</li><!--<li>Goodbye.</li>--></ul>', |
1427
|
|
|
'<ul><li>Hello.</li><!--<li>Goodbye.</li>--></ul>', |
1428
|
|
|
), |
1429
|
|
|
array( |
1430
|
|
|
'word <img src="http://example.com/wp-content/uploads/2014/06/image-300x216.gif" /> word', // Ensure we are not corrupting image URLs. |
1431
|
|
|
'word <img src="http://example.com/wp-content/uploads/2014/06/image-300x216.gif" /> word', |
1432
|
|
|
), |
1433
|
|
|
array( |
1434
|
|
|
'[ do texturize "[quote]" here ]', |
1435
|
|
|
'[ do texturize “[quote]” here ]', |
1436
|
|
|
), |
1437
|
|
|
array( |
1438
|
|
|
'[ regex catches this <a href="[quote]">here</a> ]', |
1439
|
|
|
'[ regex catches this <a href="[quote]">here</a> ]', |
1440
|
|
|
), |
1441
|
|
|
array( |
1442
|
|
|
'[ but also catches the <b>styled "[quote]" here</b> ]', |
1443
|
|
|
'[ but also catches the <b>styled “[quote]” here</b> ]', |
1444
|
|
|
), |
1445
|
|
|
array( |
1446
|
|
|
'[Let\'s get crazy<input>[caption code="<a href=\'?a[]=100\'>hello</a>"]</input>world]', // caption shortcode is invalid here because it contains [] chars. |
1447
|
|
|
'[Let’s get crazy<input>[caption code=”<a href=\'?a[]=100\'>hello</a>“]</input>world]', |
1448
|
|
|
), |
1449
|
|
|
array( |
1450
|
|
|
'<> ... <>', |
1451
|
|
|
'<> … <>', |
1452
|
|
|
), |
1453
|
|
|
array( |
1454
|
|
|
'<> ... <> ... >', |
1455
|
|
|
'<> … <> … >', |
1456
|
|
|
), |
1457
|
|
|
array( |
1458
|
|
|
'<> ... < ... > ... <>', |
1459
|
|
|
'<> … < ... > … <>', |
1460
|
|
|
), |
1461
|
|
|
); |
1462
|
|
|
} |
1463
|
|
|
|
1464
|
|
|
/** |
1465
|
|
|
* Year abbreviations consist of exactly two digits. |
1466
|
|
|
* |
1467
|
|
|
* @ticket 26850 |
1468
|
|
|
* @dataProvider data_year_abbr |
1469
|
|
|
*/ |
1470
|
|
|
function test_year_abbr( $input, $output ) { |
|
|
|
|
1471
|
|
|
return $this->assertEquals( $output, wptexturize( $input ) ); |
1472
|
|
|
} |
1473
|
|
|
|
1474
|
|
View Code Duplication |
function data_year_abbr() { |
1475
|
|
|
return array( |
1476
|
|
|
array( |
1477
|
|
|
"word '99 word", |
1478
|
|
|
"word ’99 word", |
1479
|
|
|
), |
1480
|
|
|
array( |
1481
|
|
|
"word '99. word", |
1482
|
|
|
"word ’99. word", |
1483
|
|
|
), |
1484
|
|
|
array( |
1485
|
|
|
"word '99, word", |
1486
|
|
|
"word ’99, word", |
1487
|
|
|
), |
1488
|
|
|
array( |
1489
|
|
|
"word '99; word", |
1490
|
|
|
"word ’99; word", |
1491
|
|
|
), |
1492
|
|
|
array( |
1493
|
|
|
"word '99' word", // For this pattern, prime doesn't make sense. Should get apos and a closing quote. |
1494
|
|
|
"word ’99’ word", |
1495
|
|
|
), |
1496
|
|
|
array( |
1497
|
|
|
"word '99'. word", |
1498
|
|
|
"word ’99’. word", |
1499
|
|
|
), |
1500
|
|
|
array( |
1501
|
|
|
"word '99', word", |
1502
|
|
|
"word ’99’, word", |
1503
|
|
|
), |
1504
|
|
|
array( |
1505
|
|
|
"word '99.' word", |
1506
|
|
|
"word ’99.’ word", |
1507
|
|
|
), |
1508
|
|
|
array( |
1509
|
|
|
"word '99", |
1510
|
|
|
"word ’99", |
1511
|
|
|
), |
1512
|
|
|
array( |
1513
|
|
|
"'99 word", |
1514
|
|
|
"’99 word", |
1515
|
|
|
), |
1516
|
|
|
array( |
1517
|
|
|
"word '999 word", // Does not match the apos pattern, should be opening quote. |
1518
|
|
|
"word ‘999 word", |
1519
|
|
|
), |
1520
|
|
|
array( |
1521
|
|
|
"word '99% word", |
1522
|
|
|
"word ‘99% word", |
1523
|
|
|
), |
1524
|
|
|
array( |
1525
|
|
|
"word '9 word", |
1526
|
|
|
"word ‘9 word", |
1527
|
|
|
), |
1528
|
|
|
array( |
1529
|
|
|
"word '99.9 word", |
1530
|
|
|
"word ‘99.9 word", |
1531
|
|
|
), |
1532
|
|
|
array( |
1533
|
|
|
"word '999", |
1534
|
|
|
"word ‘999", |
1535
|
|
|
), |
1536
|
|
|
array( |
1537
|
|
|
"word '9", |
1538
|
|
|
"word ‘9", |
1539
|
|
|
), |
1540
|
|
|
array( |
1541
|
|
|
"in '4 years, 3 months,' Obama cut the deficit", |
1542
|
|
|
"in ‘4 years, 3 months,’ Obama cut the deficit", |
1543
|
|
|
), |
1544
|
|
|
array( |
1545
|
|
|
"testing's '4' through 'quotes'", |
1546
|
|
|
"testing’s ‘4’ through ‘quotes’", |
1547
|
|
|
), |
1548
|
|
|
); |
1549
|
|
|
} |
1550
|
|
|
|
1551
|
|
|
/** |
1552
|
|
|
* Make sure translation actually works. |
1553
|
|
|
* |
1554
|
|
|
* Also make sure apostrophes and closing quotes aren't being confused by default. |
1555
|
|
|
* |
1556
|
|
|
* @ticket 27426 |
1557
|
|
|
* @dataProvider data_translate |
1558
|
|
|
*/ |
1559
|
|
View Code Duplication |
function test_translate( $input, $output ) { |
|
|
|
|
1560
|
|
|
add_filter( 'gettext_with_context', array( $this, 'filter_translate' ), 10, 4 ); |
1561
|
|
|
|
1562
|
|
|
$result = wptexturize( $input, true ); |
1563
|
|
|
|
1564
|
|
|
remove_filter( 'gettext_with_context', array( $this, 'filter_translate' ), 10, 4 ); |
1565
|
|
|
wptexturize( 'reset', true ); |
1566
|
|
|
|
1567
|
|
|
return $this->assertEquals( $output, $result ); |
1568
|
|
|
} |
1569
|
|
|
|
1570
|
|
View Code Duplication |
function filter_translate( $translations, $text, $context, $domain ) { |
|
|
|
|
1571
|
|
|
switch ($text) { |
1572
|
|
|
case '–' : return '!endash!'; |
1573
|
|
|
case '—' : return '!emdash!'; |
1574
|
|
|
case '‘' : return '!openq1!'; |
1575
|
|
|
case '’' : |
1576
|
|
|
if ( 'apostrophe' == $context ) { |
1577
|
|
|
return '!apos!'; |
1578
|
|
|
} else { |
1579
|
|
|
return '!closeq1!'; |
1580
|
|
|
} |
1581
|
|
|
case '“' : return '!openq2!'; |
1582
|
|
|
case '”' : return '!closeq2!'; |
1583
|
|
|
case '′' : return '!prime1!'; |
1584
|
|
|
case '″' : return '!prime2!'; |
1585
|
|
|
case '’tain’t,’twere,’twas,’tis,’twill,’til,’bout,’nuff,’round,’cause,’em' : |
1586
|
|
|
return '!apos!tain!apos!t,!apos!twere,!apos!twas,!apos!tis,!apos!twill,!apos!til,!apos!bout,!apos!nuff,!apos!round,!apos!cause,!apos!em'; |
1587
|
|
|
default : return $translations; |
1588
|
|
|
} |
1589
|
|
|
} |
1590
|
|
|
|
1591
|
|
|
function data_translate() { |
1592
|
|
|
return array( |
1593
|
|
|
array( |
1594
|
|
|
"word '99 word", |
1595
|
|
|
"word !apos!99 word", |
1596
|
|
|
), |
1597
|
|
|
array( |
1598
|
|
|
"word'99 word", |
1599
|
|
|
"word!apos!99 word", |
1600
|
|
|
), |
1601
|
|
|
array( |
1602
|
|
|
"word 'test sentence' word", |
1603
|
|
|
"word !openq1!test sentence!closeq1! word", |
1604
|
|
|
), |
1605
|
|
|
array( |
1606
|
|
|
"'test sentence'", |
1607
|
|
|
"!openq1!test sentence!closeq1!", |
1608
|
|
|
), |
1609
|
|
|
array( |
1610
|
|
|
'word "test sentence" word', |
1611
|
|
|
'word !openq2!test sentence!closeq2! word', |
1612
|
|
|
), |
1613
|
|
|
array( |
1614
|
|
|
'"test sentence"', |
1615
|
|
|
'!openq2!test sentence!closeq2!', |
1616
|
|
|
), |
1617
|
|
|
array( |
1618
|
|
|
"word 'word word", |
1619
|
|
|
"word !openq1!word word", |
1620
|
|
|
), |
1621
|
|
|
array( |
1622
|
|
|
"word ('word word", |
1623
|
|
|
"word (!openq1!word word", |
1624
|
|
|
), |
1625
|
|
|
array( |
1626
|
|
|
"word ['word word", |
1627
|
|
|
"word [!openq1!word word", |
1628
|
|
|
), |
1629
|
|
|
array( |
1630
|
|
|
'word 99" word', |
1631
|
|
|
'word 99!prime2! word', |
1632
|
|
|
), |
1633
|
|
|
array( |
1634
|
|
|
'word 99"word', |
1635
|
|
|
'word 99!prime2!word', |
1636
|
|
|
), |
1637
|
|
|
array( |
1638
|
|
|
'word99" word', |
1639
|
|
|
'word99!prime2! word', |
1640
|
|
|
), |
1641
|
|
|
array( |
1642
|
|
|
'word99"word', |
1643
|
|
|
'word99!prime2!word', |
1644
|
|
|
), |
1645
|
|
|
array( |
1646
|
|
|
"word 99' word", |
1647
|
|
|
"word 99!prime1! word", |
1648
|
|
|
), |
1649
|
|
|
array( |
1650
|
|
|
"word99' word", |
1651
|
|
|
"word99!prime1! word", |
1652
|
|
|
), |
1653
|
|
|
array( |
1654
|
|
|
"word word's word", |
1655
|
|
|
"word word!apos!s word", |
1656
|
|
|
), |
1657
|
|
|
array( |
1658
|
|
|
"word word'. word", |
1659
|
|
|
"word word!closeq1!. word", |
1660
|
|
|
), |
1661
|
|
|
array( |
1662
|
|
|
"word ]'. word", |
1663
|
|
|
"word ]!closeq1!. word", |
1664
|
|
|
), |
1665
|
|
|
array( |
1666
|
|
|
'word "word word', |
1667
|
|
|
'word !openq2!word word', |
1668
|
|
|
), |
1669
|
|
|
array( |
1670
|
|
|
'word ("word word', |
1671
|
|
|
'word (!openq2!word word', |
1672
|
|
|
), |
1673
|
|
|
array( |
1674
|
|
|
'word ["word word', |
1675
|
|
|
'word [!openq2!word word', |
1676
|
|
|
), |
1677
|
|
|
array( |
1678
|
|
|
'word word" word', |
1679
|
|
|
'word word!closeq2! word', |
1680
|
|
|
), |
1681
|
|
|
array( |
1682
|
|
|
'word word") word', |
1683
|
|
|
'word word!closeq2!) word', |
1684
|
|
|
), |
1685
|
|
|
array( |
1686
|
|
|
'word word"] word', |
1687
|
|
|
'word word!closeq2!] word', |
1688
|
|
|
), |
1689
|
|
|
array( |
1690
|
|
|
'word word"', |
1691
|
|
|
'word word!closeq2!', |
1692
|
|
|
), |
1693
|
|
|
array( |
1694
|
|
|
'word word"word', |
1695
|
|
|
'word word!closeq2!word', |
1696
|
|
|
), |
1697
|
|
|
array( |
1698
|
|
|
'test sentence".', |
1699
|
|
|
'test sentence!closeq2!.', |
1700
|
|
|
), |
1701
|
|
|
array( |
1702
|
|
|
'test sentence."', |
1703
|
|
|
'test sentence.!closeq2!', |
1704
|
|
|
), |
1705
|
|
|
array( |
1706
|
|
|
'test sentence." word', |
1707
|
|
|
'test sentence.!closeq2! word', |
1708
|
|
|
), |
1709
|
|
|
array( |
1710
|
|
|
"word word' word", |
1711
|
|
|
"word word!closeq1! word", |
1712
|
|
|
), |
1713
|
|
|
array( |
1714
|
|
|
"word word'. word", |
1715
|
|
|
"word word!closeq1!. word", |
1716
|
|
|
), |
1717
|
|
|
array( |
1718
|
|
|
"word word'.word", |
1719
|
|
|
"word word!closeq1!.word", |
1720
|
|
|
), |
1721
|
|
|
array( |
1722
|
|
|
"word word'", |
1723
|
|
|
"word word!closeq1!", |
1724
|
|
|
), |
1725
|
|
|
array( |
1726
|
|
|
"test sentence'.", |
1727
|
|
|
"test sentence!closeq1!.", |
1728
|
|
|
), |
1729
|
|
|
array( |
1730
|
|
|
"test sentence.'", |
1731
|
|
|
"test sentence.!closeq1!", |
1732
|
|
|
), |
1733
|
|
|
array( |
1734
|
|
|
"test sentence'. word", |
1735
|
|
|
"test sentence!closeq1!. word", |
1736
|
|
|
), |
1737
|
|
|
array( |
1738
|
|
|
"test sentence.' word", |
1739
|
|
|
"test sentence.!closeq1! word", |
1740
|
|
|
), |
1741
|
|
|
array( |
1742
|
|
|
"word 'tain't word", |
1743
|
|
|
"word !apos!tain!apos!t word", |
1744
|
|
|
), |
1745
|
|
|
array( |
1746
|
|
|
"word 'twere word", |
1747
|
|
|
"word !apos!twere word", |
1748
|
|
|
), |
1749
|
|
|
array( |
1750
|
|
|
'word "42.00" word', |
1751
|
|
|
'word !openq2!42.00!closeq2! word', |
1752
|
|
|
), |
1753
|
|
|
array( |
1754
|
|
|
"word '42.00' word", |
1755
|
|
|
"word !openq1!42.00!closeq1! word", |
1756
|
|
|
), |
1757
|
|
|
array( |
1758
|
|
|
"word word'. word", |
1759
|
|
|
"word word!closeq1!. word", |
1760
|
|
|
), |
1761
|
|
|
array( |
1762
|
|
|
"word word'.word", |
1763
|
|
|
"word word!closeq1!.word", |
1764
|
|
|
), |
1765
|
|
|
array( |
1766
|
|
|
"word word', she said", |
1767
|
|
|
"word word!closeq1!, she said", |
1768
|
|
|
), |
1769
|
|
|
); |
1770
|
|
|
} |
1771
|
|
|
|
1772
|
|
|
/** |
1773
|
|
|
* Extra sanity checks for _wptexturize_pushpop_element() |
1774
|
|
|
* |
1775
|
|
|
* @ticket 28483 |
1776
|
|
|
* @dataProvider data_element_stack |
1777
|
|
|
*/ |
1778
|
|
|
function test_element_stack( $input, $output ) { |
|
|
|
|
1779
|
|
|
return $this->assertEquals( $output, wptexturize( $input ) ); |
1780
|
|
|
} |
1781
|
|
|
|
1782
|
|
View Code Duplication |
function data_element_stack() { |
1783
|
|
|
return array( |
1784
|
|
|
array( |
1785
|
|
|
'<span>hello</code>---</span>', |
1786
|
|
|
'<span>hello</code>—</span>', |
1787
|
|
|
), |
1788
|
|
|
array( |
1789
|
|
|
'</code>hello<span>---</span>', |
1790
|
|
|
'</code>hello<span>—</span>', |
1791
|
|
|
), |
1792
|
|
|
array( |
1793
|
|
|
'<code>hello</code>---</span>', |
1794
|
|
|
'<code>hello</code>—</span>', |
1795
|
|
|
), |
1796
|
|
|
array( |
1797
|
|
|
'<span>hello</span>---<code>', |
1798
|
|
|
'<span>hello</span>—<code>', |
1799
|
|
|
), |
1800
|
|
|
array( |
1801
|
|
|
'<span>hello<code>---</span>', |
1802
|
|
|
'<span>hello<code>---</span>', |
1803
|
|
|
), |
1804
|
|
|
array( |
1805
|
|
|
'<code>hello<span>---</span>', |
1806
|
|
|
'<code>hello<span>---</span>', |
1807
|
|
|
), |
1808
|
|
|
array( |
1809
|
|
|
'<code>hello</span>---</span>', |
1810
|
|
|
'<code>hello</span>---</span>', |
1811
|
|
|
), |
1812
|
|
|
array( |
1813
|
|
|
'<span><code>hello</code>---</span>', |
1814
|
|
|
'<span><code>hello</code>—</span>', |
1815
|
|
|
), |
1816
|
|
|
array( |
1817
|
|
|
'<code>hello</code>world<span>---</span>', |
1818
|
|
|
'<code>hello</code>world<span>—</span>', |
1819
|
|
|
), |
1820
|
|
|
); |
1821
|
|
|
} |
1822
|
|
|
|
1823
|
|
|
/** |
1824
|
|
|
* Test disabling shortcode texturization. |
1825
|
|
|
* |
1826
|
|
|
* @ticket 29557 |
1827
|
|
|
* @dataProvider data_unregistered_shortcodes |
1828
|
|
|
*/ |
1829
|
|
|
function test_unregistered_shortcodes( $input, $output ) { |
|
|
|
|
1830
|
|
|
add_filter( 'no_texturize_shortcodes', array( $this, 'filter_shortcodes' ), 10, 1 ); |
1831
|
|
|
|
1832
|
|
|
$output = $this->assertEquals( $output, wptexturize( $input ) ); |
1833
|
|
|
|
1834
|
|
|
remove_filter( 'no_texturize_shortcodes', array( $this, 'filter_shortcodes' ), 10, 1 ); |
1835
|
|
|
return $output; |
1836
|
|
|
} |
1837
|
|
|
|
1838
|
|
|
function filter_shortcodes( $disabled ) { |
1839
|
|
|
$disabled[] = 'audio'; |
1840
|
|
|
return $disabled; |
1841
|
|
|
} |
1842
|
|
|
|
1843
|
|
View Code Duplication |
function data_unregistered_shortcodes() { |
1844
|
|
|
return array( |
1845
|
|
|
array( |
1846
|
|
|
'[a]a--b[audio]---[/audio]a--b[/a]', |
1847
|
|
|
'[a]a–b[audio]---[/audio]a–b[/a]', |
1848
|
|
|
), |
1849
|
|
|
array( |
1850
|
|
|
'[code ...]...[/code]', // code is not a registered shortcode. |
1851
|
|
|
'[code …]…[/code]', |
1852
|
|
|
), |
1853
|
|
|
array( |
1854
|
|
|
'[hello ...]...[/hello]', // hello is not a registered shortcode. |
1855
|
|
|
'[hello …]…[/hello]', |
1856
|
|
|
), |
1857
|
|
|
array( |
1858
|
|
|
'[...]...[/...]', // These are potentially usable shortcodes. |
1859
|
|
|
'[…]…[/…]', |
1860
|
|
|
), |
1861
|
|
|
array( |
1862
|
|
|
'[gal>ery ...]', |
1863
|
|
|
'[gal>ery …]', |
1864
|
|
|
), |
1865
|
|
|
array( |
1866
|
|
|
'[randomthing param="test"]', |
1867
|
|
|
'[randomthing param=”test”]', |
1868
|
|
|
), |
1869
|
|
|
array( |
1870
|
|
|
'[[audio]...[/audio]...', // These are potentially usable shortcodes. Unfortunately, the meaning of [[audio] is ambiguous unless we run the entire shortcode regexp. |
1871
|
|
|
'[[audio]…[/audio]…', |
1872
|
|
|
), |
1873
|
|
|
array( |
1874
|
|
|
'[audio]...[/audio]]...', // These are potentially usable shortcodes. Unfortunately, the meaning of [/audio]] is ambiguous unless we run the entire shortcode regexp. |
1875
|
|
|
'[audio]...[/audio]]...', // This test would not pass in 3.9 because the extra brace was always ignored by texturize. |
1876
|
|
|
), |
1877
|
|
|
array( |
1878
|
|
|
'<span>hello[/audio]---</span>', |
1879
|
|
|
'<span>hello[/audio]—</span>', |
1880
|
|
|
), |
1881
|
|
|
array( |
1882
|
|
|
'[/audio]hello<span>---</span>', |
1883
|
|
|
'[/audio]hello<span>—</span>', |
1884
|
|
|
), |
1885
|
|
|
array( |
1886
|
|
|
'[audio]hello[/audio]---</span>', |
1887
|
|
|
'[audio]hello[/audio]—</span>', |
1888
|
|
|
), |
1889
|
|
|
array( |
1890
|
|
|
'<span>hello</span>---[audio]', |
1891
|
|
|
'<span>hello</span>—[audio]', |
1892
|
|
|
), |
1893
|
|
|
array( |
1894
|
|
|
'<span>hello[audio]---</span>', |
1895
|
|
|
'<span>hello[audio]---</span>', |
1896
|
|
|
), |
1897
|
|
|
array( |
1898
|
|
|
'[audio]hello<span>---</span>', |
1899
|
|
|
'[audio]hello<span>---</span>', |
1900
|
|
|
), |
1901
|
|
|
array( |
1902
|
|
|
'[audio]hello</span>---</span>', |
1903
|
|
|
'[audio]hello</span>---</span>', |
1904
|
|
|
), |
1905
|
|
|
); |
1906
|
|
|
} |
1907
|
|
|
|
1908
|
|
|
/** |
1909
|
|
|
* Ensure primes logic is not too greedy at the end of a quotation. |
1910
|
|
|
* |
1911
|
|
|
* @ticket 29256 |
1912
|
|
|
* @dataProvider data_primes_vs_quotes |
1913
|
|
|
*/ |
1914
|
|
|
function test_primes_vs_quotes( $input, $output ) { |
|
|
|
|
1915
|
|
|
return $this->assertEquals( $output, wptexturize( $input ) ); |
1916
|
|
|
} |
1917
|
|
|
|
1918
|
|
|
function data_primes_vs_quotes() { |
1919
|
|
|
return array( |
1920
|
|
|
array( |
1921
|
|
|
"George's porch is 99' long.", |
1922
|
|
|
"George’s porch is 99′ long.", |
1923
|
|
|
), |
1924
|
|
|
array( |
1925
|
|
|
'The best year "was that time in 2012" when everyone partied, he said.', |
1926
|
|
|
'The best year “was that time in 2012” when everyone partied, he said.', |
1927
|
|
|
), |
1928
|
|
|
array( |
1929
|
|
|
"I need 4 x 20' = 80' of trim.", // Works only with a space before the = char. |
1930
|
|
|
"I need 4 x 20′ = 80′ of trim.", |
1931
|
|
|
), |
1932
|
|
|
array( |
1933
|
|
|
'"Lorem ipsum dolor sit amet 1234"', |
1934
|
|
|
'“Lorem ipsum dolor sit amet 1234”', |
1935
|
|
|
), |
1936
|
|
|
array( |
1937
|
|
|
"'Etiam eu egestas dui 1234'", |
1938
|
|
|
"‘Etiam eu egestas dui 1234’", |
1939
|
|
|
), |
1940
|
|
|
array( |
1941
|
|
|
'according to our source, "33% of all students scored less than 50" on the test.', |
1942
|
|
|
'according to our source, “33% of all students scored less than 50” on the test.', |
1943
|
|
|
), |
1944
|
|
|
array( |
1945
|
|
|
"The doctor said, 'An average height is between 5' and 6' in study group 7'. He then produced a 6' chart of averages. A man of 7', incredibly, is very possible.", |
1946
|
|
|
"The doctor said, ‘An average height is between 5′ and 6′ in study group 7’. He then produced a 6′ chart of averages. A man of 7′, incredibly, is very possible.", |
1947
|
|
|
), |
1948
|
|
|
array( |
1949
|
|
|
'Pirates have voted on "The Expendables 3" with their clicks -- and it turns out the Sylvester Stallone-starrer hasn\'t been astoundingly popular among digital thieves, relatively speaking. |
1950
|
|
|
|
1951
|
|
|
As of Sunday, 5.12 million people worldwide had pirated "Expendables 3" since a high-quality copy hit torrent-sharing sites July 23, according to piracy-tracking firm Excipio. |
1952
|
|
|
|
1953
|
|
|
That likely contributed to the action movie\'s dismal box-office debut this weekend. But over the same July 23-Aug. 18 time period, the movie was No. 4 in downloads, after "Captain America: The Winter Soldier" (7.31 million), "Divergent" (6.29 million) and "The Amazing Spider-Man 2" (5.88 million). Moreover, that\'s despite "Expendables 3" becoming available more than three weeks prior to the film\'s U.S. theatrical debut. |
1954
|
|
|
|
1955
|
|
|
String with a number followed by a single quote \'Expendables 3\' vestibulum in arcu mi.', |
1956
|
|
|
|
1957
|
|
|
'Pirates have voted on “The Expendables 3” with their clicks — and it turns out the Sylvester Stallone-starrer hasn’t been astoundingly popular among digital thieves, relatively speaking. |
1958
|
|
|
|
1959
|
|
|
As of Sunday, 5.12 million people worldwide had pirated “Expendables 3” since a high-quality copy hit torrent-sharing sites July 23, according to piracy-tracking firm Excipio. |
1960
|
|
|
|
1961
|
|
|
That likely contributed to the action movie’s dismal box-office debut this weekend. But over the same July 23-Aug. 18 time period, the movie was No. 4 in downloads, after “Captain America: The Winter Soldier” (7.31 million), “Divergent” (6.29 million) and “The Amazing Spider-Man 2” (5.88 million). Moreover, that’s despite “Expendables 3” becoming available more than three weeks prior to the film’s U.S. theatrical debut. |
1962
|
|
|
|
1963
|
|
|
String with a number followed by a single quote ‘Expendables 3’ vestibulum in arcu mi.', |
1964
|
|
|
), |
1965
|
|
|
); |
1966
|
|
|
} |
1967
|
|
|
|
1968
|
|
|
/** |
1969
|
|
|
* Make sure translation actually works. |
1970
|
|
|
* |
1971
|
|
|
* Also make sure opening and closing quotes are allowed to be identical. |
1972
|
|
|
* |
1973
|
|
|
* @ticket 29256 |
1974
|
|
|
* @dataProvider data_primes_quotes_translation |
1975
|
|
|
*/ |
1976
|
|
View Code Duplication |
function test_primes_quotes_translation( $input, $output ) { |
|
|
|
|
1977
|
|
|
add_filter( 'gettext_with_context', array( $this, 'filter_translate2' ), 10, 4 ); |
1978
|
|
|
|
1979
|
|
|
$result = wptexturize( $input, true ); |
1980
|
|
|
|
1981
|
|
|
remove_filter( 'gettext_with_context', array( $this, 'filter_translate2' ), 10, 4 ); |
1982
|
|
|
wptexturize( 'reset', true ); |
1983
|
|
|
|
1984
|
|
|
return $this->assertEquals( $output, $result ); |
1985
|
|
|
} |
1986
|
|
|
|
1987
|
|
View Code Duplication |
function filter_translate2( $translations, $text, $context, $domain ) { |
|
|
|
|
1988
|
|
|
switch ($text) { |
1989
|
|
|
case '–' : return '!endash!'; |
1990
|
|
|
case '—' : return '!emdash!'; |
1991
|
|
|
case '‘' : return '!q1!'; |
1992
|
|
|
case '’' : |
1993
|
|
|
if ( 'apostrophe' == $context ) { |
1994
|
|
|
return '!apos!'; |
1995
|
|
|
} else { |
1996
|
|
|
return '!q1!'; |
1997
|
|
|
} |
1998
|
|
|
case '“' : return '!q2!'; |
1999
|
|
|
case '”' : return '!q2!'; |
2000
|
|
|
case '′' : return '!prime1!'; |
2001
|
|
|
case '″' : return '!prime2!'; |
2002
|
|
|
default : return $translations; |
2003
|
|
|
} |
2004
|
|
|
} |
2005
|
|
|
|
2006
|
|
|
function data_primes_quotes_translation() { |
2007
|
|
|
return array( |
2008
|
|
|
array( |
2009
|
|
|
"George's porch is 99' long.", |
2010
|
|
|
"George!apos!s porch is 99!prime1! long.", |
2011
|
|
|
), |
2012
|
|
|
array( |
2013
|
|
|
'The best year "was that time in 2012" when everyone partied, he said.', |
2014
|
|
|
'The best year !q2!was that time in 2012!q2! when everyone partied, he said.', |
2015
|
|
|
), |
2016
|
|
|
array( |
2017
|
|
|
"I need 4 x 20' = 80' of trim.", // Works only with a space before the = char. |
2018
|
|
|
"I need 4 x 20!prime1! = 80!prime1! of trim.", |
2019
|
|
|
), |
2020
|
|
|
array( |
2021
|
|
|
'"Lorem ipsum dolor sit amet 1234"', |
2022
|
|
|
'!q2!Lorem ipsum dolor sit amet 1234!q2!', |
2023
|
|
|
), |
2024
|
|
|
array( |
2025
|
|
|
"'Etiam eu egestas dui 1234'", |
2026
|
|
|
"!q1!Etiam eu egestas dui 1234!q1!", |
2027
|
|
|
), |
2028
|
|
|
array( |
2029
|
|
|
'according to our source, "33% of all students scored less than 50" on the test.', |
2030
|
|
|
'according to our source, !q2!33% of all students scored less than 50!q2! on the test.', |
2031
|
|
|
), |
2032
|
|
|
array( |
2033
|
|
|
"The doctor said, 'An average height is between 5' and 6' in study group 7'. He then produced a 6' chart of averages. A man of 7', incredibly, is very possible.", |
2034
|
|
|
"The doctor said, !q1!An average height is between 5!prime1! and 6!prime1! in study group 7!q1!. He then produced a 6!prime1! chart of averages. A man of 7!prime1!, incredibly, is very possible.", |
2035
|
|
|
), |
2036
|
|
|
array( |
2037
|
|
|
'Pirates have voted on "The Expendables 3" with their clicks -- and it turns out the Sylvester Stallone-starrer hasn\'t been astoundingly popular among digital thieves, relatively speaking. |
2038
|
|
|
|
2039
|
|
|
As of Sunday, 5.12 million people worldwide had pirated "Expendables 3" since a high-quality copy hit torrent-sharing sites July 23, according to piracy-tracking firm Excipio. |
2040
|
|
|
|
2041
|
|
|
That likely contributed to the action movie\'s dismal box-office debut this weekend. But over the same July 23-Aug. 18 time period, the movie was No. 4 in downloads, after "Captain America: The Winter Soldier" (7.31 million), "Divergent" (6.29 million) and "The Amazing Spider-Man 2" (5.88 million). Moreover, that\'s despite "Expendables 3" becoming available more than three weeks prior to the film\'s U.S. theatrical debut. |
2042
|
|
|
|
2043
|
|
|
String with a number followed by a single quote \'Expendables 3\' vestibulum in arcu mi.', |
2044
|
|
|
|
2045
|
|
|
'Pirates have voted on !q2!The Expendables 3!q2! with their clicks !emdash! and it turns out the Sylvester Stallone-starrer hasn!apos!t been astoundingly popular among digital thieves, relatively speaking. |
2046
|
|
|
|
2047
|
|
|
As of Sunday, 5.12 million people worldwide had pirated !q2!Expendables 3!q2! since a high-quality copy hit torrent-sharing sites July 23, according to piracy-tracking firm Excipio. |
2048
|
|
|
|
2049
|
|
|
That likely contributed to the action movie!apos!s dismal box-office debut this weekend. But over the same July 23-Aug. 18 time period, the movie was No. 4 in downloads, after !q2!Captain America: The Winter Soldier!q2! (7.31 million), !q2!Divergent!q2! (6.29 million) and !q2!The Amazing Spider-Man 2!q2! (5.88 million). Moreover, that!apos!s despite !q2!Expendables 3!q2! becoming available more than three weeks prior to the film!apos!s U.S. theatrical debut. |
2050
|
|
|
|
2051
|
|
|
String with a number followed by a single quote !q1!Expendables 3!q1! vestibulum in arcu mi.', |
2052
|
|
|
), |
2053
|
|
|
); |
2054
|
|
|
} |
2055
|
|
|
|
2056
|
|
|
/** |
2057
|
|
|
* Automated performance testing of the main regex. |
2058
|
|
|
* |
2059
|
|
|
* @dataProvider data_whole_posts |
2060
|
|
|
*/ |
2061
|
|
|
function test_pcre_performance( $input ) { |
|
|
|
|
2062
|
|
|
global $shortcode_tags; |
2063
|
|
|
|
2064
|
|
|
// With Shortcodes Disabled |
2065
|
|
|
$regex = _get_wptexturize_split_regex( ); |
2066
|
|
|
$result = benchmark_pcre_backtracking( $regex, $input, 'split' ); |
2067
|
|
|
$this->assertLessThan( 200, $result ); |
2068
|
|
|
|
2069
|
|
|
// With Shortcodes Enabled |
2070
|
|
|
$shortcode_regex = _get_wptexturize_shortcode_regex( array_keys( $shortcode_tags ) ); |
2071
|
|
|
$regex = _get_wptexturize_split_regex( $shortcode_regex ); |
2072
|
|
|
$result = benchmark_pcre_backtracking( $regex, $input, 'split' ); |
2073
|
|
|
return $this->assertLessThan( 200, $result ); |
2074
|
|
|
} |
2075
|
|
|
|
2076
|
|
|
/** |
2077
|
|
|
* Ensure that a trailing less-than symbol doesn't cause a PHP warning. |
2078
|
|
|
* |
2079
|
|
|
* @ticket 35864 |
2080
|
|
|
*/ |
2081
|
|
|
function test_trailing_less_than() { |
2082
|
|
|
$this->assertEquals( 'F–oo<', wptexturize( 'F--oo<', true ) ); |
2083
|
|
|
} |
2084
|
|
|
|
2085
|
|
|
function data_whole_posts() { |
2086
|
|
|
require_once( DIR_TESTDATA . '/formatting/whole-posts.php' ); |
2087
|
|
|
return data_whole_posts(); |
2088
|
|
|
} |
2089
|
|
|
} |
Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a
@return
annotation as described here.