| @@ 250-258 (lines=9) @@ | ||
| 247 | * |
|
| 248 | * @return void |
|
| 249 | */ |
|
| 250 | public function testMarkdown() |
|
| 251 | { |
|
| 252 | $filter = new CTextFilter(); |
|
| 253 | ||
| 254 | $html = "Header\n========="; |
|
| 255 | $exp = "<h1>Header</h1>\n"; |
|
| 256 | $res = $filter->doFilter($html, "markdown"); |
|
| 257 | $this->assertEquals($exp, $res, "Markdown <h1> failed: '$res'"); |
|
| 258 | } |
|
| 259 | ||
| 260 | ||
| 261 | ||
| @@ 267-275 (lines=9) @@ | ||
| 264 | * |
|
| 265 | * @return void |
|
| 266 | */ |
|
| 267 | public function testMarkdownAndBBCode() |
|
| 268 | { |
|
| 269 | $filter = new CTextFilter(); |
|
| 270 | ||
| 271 | $html = "Header[b]text[/b]\n========="; |
|
| 272 | $exp = "<h1>Header<strong>text</strong></h1>\n"; |
|
| 273 | $res = $filter->doFilter($html, "markdown, bbcode"); |
|
| 274 | $this->assertEquals($exp, $res, "Markdown <h1> failed: '$res'"); |
|
| 275 | } |
|
| 276 | ||
| 277 | ||
| 278 | ||
| @@ 284-292 (lines=9) @@ | ||
| 281 | * |
|
| 282 | * @return void |
|
| 283 | */ |
|
| 284 | public function testMarkdownAndBBCodeAsArray() |
|
| 285 | { |
|
| 286 | $filter = new CTextFilter(); |
|
| 287 | ||
| 288 | $html = "Header[b]text[/b]\n========="; |
|
| 289 | $exp = "<h1>Header<strong>text</strong></h1>\n"; |
|
| 290 | $res = $filter->doFilter($html, ["markdown", "bbcode"]); |
|
| 291 | $this->assertEquals($exp, $res, "Markdown <h1> failed: '$res'"); |
|
| 292 | } |
|
| 293 | ||
| 294 | ||
| 295 | ||
| @@ 301-309 (lines=9) @@ | ||
| 298 | * |
|
| 299 | * @return void |
|
| 300 | */ |
|
| 301 | public function testMarkdownArray() |
|
| 302 | { |
|
| 303 | $filter = new CTextFilter(); |
|
| 304 | ||
| 305 | $html = "Header\n========="; |
|
| 306 | $exp = "<h1>Header</h1>\n"; |
|
| 307 | $res = $filter->doFilter($html, ["markdown"]); |
|
| 308 | $this->assertEquals($exp, $res, "Markdown <h1> failed: '$res'"); |
|
| 309 | } |
|
| 310 | ||
| 311 | ||
| 312 | ||
| @@ 318-326 (lines=9) @@ | ||
| 315 | * |
|
| 316 | * @return void |
|
| 317 | */ |
|
| 318 | public function testUppercase() |
|
| 319 | { |
|
| 320 | $filter = new CTextFilter(); |
|
| 321 | ||
| 322 | $html = "Header\n========="; |
|
| 323 | $exp = "<h1>Header</h1>\n"; |
|
| 324 | $res = $filter->doFilter($html, "MARKDOWN"); |
|
| 325 | $this->assertEquals($exp, $res, "Markdown <h1> failed: '$res'"); |
|
| 326 | } |
|
| 327 | ||
| 328 | ||
| 329 | ||
| @@ 335-343 (lines=9) @@ | ||
| 332 | * |
|
| 333 | * @return void |
|
| 334 | */ |
|
| 335 | public function testBBCode() |
|
| 336 | { |
|
| 337 | $filter = new CTextFilter(); |
|
| 338 | ||
| 339 | $html = "[b]text[/b]"; |
|
| 340 | $exp = "<strong>text</strong>"; |
|
| 341 | $res = $filter->doFilter($html, "bbcode"); |
|
| 342 | $this->assertEquals($exp, $res, "BBCode [b] failed: '$res'"); |
|
| 343 | } |
|
| 344 | ||
| 345 | ||
| 346 | ||
| @@ 352-360 (lines=9) @@ | ||
| 349 | * |
|
| 350 | * @return void |
|
| 351 | */ |
|
| 352 | public function testClickable() |
|
| 353 | { |
|
| 354 | $filter = new CTextFilter(); |
|
| 355 | ||
| 356 | $html = "http://example.com/humans.txt"; |
|
| 357 | $exp = "<a href='$html'>$html</a>"; |
|
| 358 | $res = $filter->doFilter($html, "clickable"); |
|
| 359 | $this->assertEquals($exp, $res, "clickable failed: '$res'"); |
|
| 360 | } |
|
| 361 | ||
| 362 | ||
| 363 | ||
| @@ 369-377 (lines=9) @@ | ||
| 366 | * |
|
| 367 | * @return void |
|
| 368 | */ |
|
| 369 | public function testNl2Br() |
|
| 370 | { |
|
| 371 | $filter = new CTextFilter(); |
|
| 372 | ||
| 373 | $html = "hej\nhej"; |
|
| 374 | $exp = "hej<br />\nhej"; |
|
| 375 | $res = $filter->doFilter($html, "nl2br"); |
|
| 376 | $this->assertEquals($exp, $res, "nl2br failed: '$res'"); |
|
| 377 | } |
|
| 378 | ||
| 379 | ||
| 380 | ||