| @@ 364-372 (lines=9) @@ | ||
| 361 | * |
|
| 362 | * @return void |
|
| 363 | */ |
|
| 364 | public function testMarkdown() |
|
| 365 | { |
|
| 366 | $filter = new CTextFilter(); |
|
| 367 | ||
| 368 | $html = "Header\n========="; |
|
| 369 | $exp = "<h1>Header</h1>\n"; |
|
| 370 | $res = $filter->doFilter($html, "markdown"); |
|
| 371 | $this->assertEquals($exp, $res, "Markdown <h1> failed: '$res'"); |
|
| 372 | } |
|
| 373 | ||
| 374 | ||
| 375 | ||
| @@ 381-389 (lines=9) @@ | ||
| 378 | * |
|
| 379 | * @return void |
|
| 380 | */ |
|
| 381 | public function testMarkdownAndBBCode() |
|
| 382 | { |
|
| 383 | $filter = new CTextFilter(); |
|
| 384 | ||
| 385 | $html = "Header[b]text[/b]\n========="; |
|
| 386 | $exp = "<h1>Header<strong>text</strong></h1>\n"; |
|
| 387 | $res = $filter->doFilter($html, "markdown, bbcode"); |
|
| 388 | $this->assertEquals($exp, $res, "Markdown <h1> failed: '$res'"); |
|
| 389 | } |
|
| 390 | ||
| 391 | ||
| 392 | ||
| @@ 398-406 (lines=9) @@ | ||
| 395 | * |
|
| 396 | * @return void |
|
| 397 | */ |
|
| 398 | public function testMarkdownAndBBCodeAsArray() |
|
| 399 | { |
|
| 400 | $filter = new CTextFilter(); |
|
| 401 | ||
| 402 | $html = "Header[b]text[/b]\n========="; |
|
| 403 | $exp = "<h1>Header<strong>text</strong></h1>\n"; |
|
| 404 | $res = $filter->doFilter($html, ["markdown", "bbcode"]); |
|
| 405 | $this->assertEquals($exp, $res, "Markdown <h1> failed: '$res'"); |
|
| 406 | } |
|
| 407 | ||
| 408 | ||
| 409 | ||
| @@ 415-423 (lines=9) @@ | ||
| 412 | * |
|
| 413 | * @return void |
|
| 414 | */ |
|
| 415 | public function testMarkdownArray() |
|
| 416 | { |
|
| 417 | $filter = new CTextFilter(); |
|
| 418 | ||
| 419 | $html = "Header\n========="; |
|
| 420 | $exp = "<h1>Header</h1>\n"; |
|
| 421 | $res = $filter->doFilter($html, ["markdown"]); |
|
| 422 | $this->assertEquals($exp, $res, "Markdown <h1> failed: '$res'"); |
|
| 423 | } |
|
| 424 | ||
| 425 | ||
| 426 | ||
| @@ 432-440 (lines=9) @@ | ||
| 429 | * |
|
| 430 | * @return void |
|
| 431 | */ |
|
| 432 | public function testUppercase() |
|
| 433 | { |
|
| 434 | $filter = new CTextFilter(); |
|
| 435 | ||
| 436 | $html = "Header\n========="; |
|
| 437 | $exp = "<h1>Header</h1>\n"; |
|
| 438 | $res = $filter->doFilter($html, "MARKDOWN"); |
|
| 439 | $this->assertEquals($exp, $res, "Markdown <h1> failed: '$res'"); |
|
| 440 | } |
|
| 441 | ||
| 442 | ||
| 443 | ||
| @@ 449-457 (lines=9) @@ | ||
| 446 | * |
|
| 447 | * @return void |
|
| 448 | */ |
|
| 449 | public function testBBCode() |
|
| 450 | { |
|
| 451 | $filter = new CTextFilter(); |
|
| 452 | ||
| 453 | $html = "[b]text[/b]"; |
|
| 454 | $exp = "<strong>text</strong>"; |
|
| 455 | $res = $filter->doFilter($html, "bbcode"); |
|
| 456 | $this->assertEquals($exp, $res, "BBCode [b] failed: '$res'"); |
|
| 457 | } |
|
| 458 | ||
| 459 | ||
| 460 | ||
| @@ 466-474 (lines=9) @@ | ||
| 463 | * |
|
| 464 | * @return void |
|
| 465 | */ |
|
| 466 | public function testClickable() |
|
| 467 | { |
|
| 468 | $filter = new CTextFilter(); |
|
| 469 | ||
| 470 | $html = "http://example.com/humans.txt"; |
|
| 471 | $exp = "<a href='$html'>$html</a>"; |
|
| 472 | $res = $filter->doFilter($html, "clickable"); |
|
| 473 | $this->assertEquals($exp, $res, "clickable failed: '$res'"); |
|
| 474 | } |
|
| 475 | ||
| 476 | ||
| 477 | ||
| @@ 483-491 (lines=9) @@ | ||
| 480 | * |
|
| 481 | * @return void |
|
| 482 | */ |
|
| 483 | public function testNl2Br() |
|
| 484 | { |
|
| 485 | $filter = new CTextFilter(); |
|
| 486 | ||
| 487 | $html = "hej\nhej"; |
|
| 488 | $exp = "hej<br />\nhej"; |
|
| 489 | $res = $filter->doFilter($html, "nl2br"); |
|
| 490 | $this->assertEquals($exp, $res, "nl2br failed: '$res'"); |
|
| 491 | } |
|
| 492 | ||
| 493 | ||
| 494 | ||