Make WordPress Core

Ticket #14993: TestMakeClickable.php

File TestMakeClickable.php, 11.4 KB (added by filosofo, 16 years ago)
Line 
1<?php
2include '../httpdocs/wp-includes/kses.php';
3include '../httpdocs/wp-includes/formatting.php';
4function apply_filters($ignore, $x )
5{
6 return $x;
7}
8function add_action() {}
9
10class TestMakeClickable extends PHPUnit_Framework_TestCase {
11
12 protected function setUp()
13 {
14 }
15
16 protected function tearDown()
17 {
18 }
19
20 /**
21 * @dataProvider provider__make_clickable
22 */
23 public function test__make_clickable( $orig_string, $accurately_clickable )
24 {
25 $this->assertEquals(
26 $accurately_clickable,
27 make_clickable( $orig_string )
28 );
29 }
30
31 public function provider__make_clickable()
32 {
33 return array(
34 array(
35 'There was a spoon named (http://wordpress.org)',
36 'There was a spoon named (<a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a>)',
37 ),
38
39 array(
40 'There was a spoon named (http://wordpress.org)x',
41 'There was a spoon named (<a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a>)x',
42 ),
43
44 array(
45 'blah blah blah http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software) blah blah',
46 'blah blah blah <a href="http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)" rel="nofollow">http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)</a> blah blah',
47 ),
48
49 array(
50 'blah blah blah http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)) blah blah',
51 'blah blah blah <a href="http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)" rel="nofollow">http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)</a>) blah blah',
52 ),
53
54 array(
55 'blah blah (http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)) blah blah',
56 'blah blah (<a href="http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)" rel="nofollow">http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)</a>) blah blah',
57 ),
58
59 array(
60 'blah blah http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software).) blah blah',
61 'blah blah <a href="http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)" rel="nofollow">http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)</a>.) blah blah',
62 ),
63
64 array(
65 'blah blah http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software).)moreurl blah blah',
66 'blah blah <a href="http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)" rel="nofollow">http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)</a>.)moreurl blah blah',
67 ),
68
69 array(
70 'blah blah There was a spoon named http://wordpress.org.',
71 'blah blah There was a spoon named <a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a>.',
72 ),
73
74 array(
75 'blah (blah There was a spoon named http://wordpress.org.) blah',
76 'blah (blah There was a spoon named <a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a>.) blah',
77 ),
78
79 array(
80 'blah blah There was a spoon named http://wordpress.org. [EOL char here]',
81 'blah blah There was a spoon named <a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a>. [EOL char here]',
82 ),
83
84 array(
85 'blah blah There was a spoon named http://wordpress.org.',
86 'blah blah There was a spoon named <a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a>.',
87 ),
88
89 array(
90 'blah blah There was a spoon named http://wordpress.org. blah blah',
91 'blah blah There was a spoon named <a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a>. blah blah',
92 ),
93
94 array(
95 'blah http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software) blah blah',
96 'blah <a href="http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)" rel="nofollow">http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)</a> blah blah',
97 ),
98
99 array(
100 'blah http://msdn.microsoft.com/en-us/library/aa752574(VS.85).aspx blah blah',
101 'blah <a href="http://msdn.microsoft.com/en-us/library/aa752574(VS.85).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/aa752574(VS.85).aspx</a> blah blah',
102 ),
103
104 array(
105 'blah My site (http://josephscott.org) blah blah',
106 'blah My site (<a href="http://josephscott.org" rel="nofollow">http://josephscott.org</a>) blah blah',
107 ),
108
109 array(
110 'blah My (http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)) article blah blah',
111 'blah My (<a href="http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)" rel="nofollow">http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)</a>) article blah blah',
112 ),
113
114 array(
115 'Example: WordPress, test (some text), I love example.com (http://example.org), it is brilliant',
116 'Example: WordPress, test (some text), I love example.com (<a href="http://example.org" rel="nofollow">http://example.org</a>), it is brilliant',
117 ),
118
119 array(
120 'http://twitter.com/#!/wordpress/status/25907440233',
121 '<a href="http://twitter.com/#!/wordpress/status/25907440233" rel="nofollow">http://twitter.com/#!/wordpress/status/25907440233</a>',
122 ),
123
124 // from the WP test suite:
125 array(
126 'http://wordpress.org/hello.html',
127 '<a href="http://wordpress.org/hello.html" rel="nofollow">http://wordpress.org/hello.html</a>',
128 ),
129
130 array(
131 'There was a spoon named http://wordpress.org. Alice!',
132 'There was a spoon named <a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a>. Alice!',
133 ),
134
135 array(
136 'There was a spoon named http://wordpress.org, said Alice.',
137 'There was a spoon named <a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a>, said Alice.',
138 ),
139
140 array(
141 'There was a spoon named http://wordpress.org; said Alice.',
142 'There was a spoon named <a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a>; said Alice.',
143 ),
144
145 array(
146 'There was a spoon named http://wordpress.org: said Alice.',
147 'There was a spoon named <a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a>: said Alice.',
148 ),
149
150 array(
151 'There was a spoon named (http://wordpress.org) said Alice.',
152 'There was a spoon named (<a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a>) said Alice.',
153 ),
154
155 array(
156 'http://wordpress.org/hello.html',
157 '<a href="http://wordpress.org/hello.html" rel="nofollow">http://wordpress.org/hello.html</a>',
158 ),
159
160 array(
161 'There was a spoon named http://wordpress.org.',
162 'There was a spoon named <a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a>.',
163 ),
164
165 array(
166 'There was a spoon named http://wordpress.org,',
167 'There was a spoon named <a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a>,',
168 ),
169
170 array(
171 'There was a spoon named http://wordpress.org;',
172 'There was a spoon named <a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a>;',
173 ),
174
175 array(
176 'There was a spoon named http://wordpress.org:',
177 'There was a spoon named <a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a>:',
178 ),
179
180 array(
181 'There was a spoon named (http://wordpress.org)',
182 'There was a spoon named (<a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a>)',
183 ),
184
185 array(
186 'www.wordpress.org',
187 '<a href="http://www.wordpress.org" rel="nofollow">http://www.wordpress.org</a>',
188 ),
189
190 array(
191 'There was a spoon named www.wordpress.org. Alice!',
192 'There was a spoon named <a href="http://www.wordpress.org" rel="nofollow">http://www.wordpress.org</a>. Alice!',
193 ),
194
195 array(
196 'There was a spoon named www.wordpress.org, said Alice.',
197 'There was a spoon named <a href="http://www.wordpress.org" rel="nofollow">http://www.wordpress.org</a>, said Alice.',
198 ),
199
200 array(
201 'There was a spoon named www.wordpress.org; said Alice.',
202 'There was a spoon named <a href="http://www.wordpress.org" rel="nofollow">http://www.wordpress.org</a>; said Alice.',
203 ),
204
205 array(
206 'There was a spoon named www.wordpress.org: said Alice.',
207 'There was a spoon named <a href="http://www.wordpress.org" rel="nofollow">http://www.wordpress.org</a>: said Alice.',
208 ),
209
210 array(
211 'There was a spoon named www.wordpress.org) said Alice.',
212 'There was a spoon named <a href="http://www.wordpress.org" rel="nofollow">http://www.wordpress.org</a>) said Alice.',
213 ),
214
215 array(
216 'www.wordpress.org',
217 '<a href="http://www.wordpress.org" rel="nofollow">http://www.wordpress.org</a>',
218 ),
219
220 array(
221 'There was a spoon named www.wordpress.org.',
222 'There was a spoon named <a href="http://www.wordpress.org" rel="nofollow">http://www.wordpress.org</a>.',
223 ),
224
225 array(
226 'There was a spoon named www.wordpress.org,',
227 'There was a spoon named <a href="http://www.wordpress.org" rel="nofollow">http://www.wordpress.org</a>,',
228 ),
229
230 array(
231 'There was a spoon named www.wordpress.org;',
232 'There was a spoon named <a href="http://www.wordpress.org" rel="nofollow">http://www.wordpress.org</a>;',
233 ),
234
235 array(
236 'There was a spoon named www.wordpress.org:',
237 'There was a spoon named <a href="http://www.wordpress.org" rel="nofollow">http://www.wordpress.org</a>:',
238 ),
239
240 array(
241 'There was a spoon named www.wordpress.org)',
242 'There was a spoon named <a href="http://www.wordpress.org" rel="nofollow">http://www.wordpress.org</a>)'
243 ),
244
245 array(
246 'http://www.詹姆斯.com/',
247 '<a href="http://www.詹姆斯.com/" rel="nofollow">http://www.詹姆斯.com/</a>',
248 ),
249 array(
250 'http://bg.wikipedia.org/Баба',
251 '<a href="http://bg.wikipedia.org/Баба" rel="nofollow">http://bg.wikipedia.org/Баба</a>',
252 ),
253
254 array(
255 'http://example.com/?a=баба&b=дядо',
256 '<a href="http://example.com/?a=баба&#038;b=дядо" rel="nofollow">http://example.com/?a=баба&#038;b=дядо</a>',
257 ),
258
259 array(
260 'http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)',
261 '<a href="http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)" rel="nofollow">http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)</a>',
262 ),
263 array(
264 '(http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software))',
265 '(<a href="http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)" rel="nofollow">http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)</a>)',
266 ),
267 array(
268 'blah http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software) blah',
269 'blah <a href="http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)" rel="nofollow">http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)</a> blah',
270 ),
271 array(
272 'blah (http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)) blah',
273 'blah (<a href="http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)" rel="nofollow">http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)</a>) blah',
274 ),
275 array(
276 'Example: WordPress, test (some text), I love example.com (http://example.org), it is brilliant',
277 'Example: WordPress, test (some text), I love example.com (<a href="http://example.org" rel="nofollow">http://example.org</a>), it is brilliant',
278 ),
279 array(
280 'Example: WordPress, test (some text), I love example.com (http://example.com), it is brilliant',
281 'Example: WordPress, test (some text), I love example.com (<a href="http://example.com" rel="nofollow">http://example.com</a>), it is brilliant',
282 ),
283 array(
284 'Some text followed by a bracketed link with a trailing elipsis (http://example.com)...',
285 'Some text followed by a bracketed link with a trailing elipsis (<a href="http://example.com" rel="nofollow">http://example.com</a>)...',
286 ),
287 );
288 }
289}