| @@ 519-527 (lines=9) @@ | ||
| 516 | * |
|
| 517 | * @return void |
|
| 518 | */ |
|
| 519 | public function testMarkdown() |
|
| 520 | { |
|
| 521 | $filter = new CTextFilter(); |
|
| 522 | ||
| 523 | $html = "Header\n========="; |
|
| 524 | $exp = "<h1>Header</h1>\n"; |
|
| 525 | $res = $filter->doFilter($html, "markdown"); |
|
| 526 | $this->assertEquals($exp, $res, "Markdown <h1> failed: '$res'"); |
|
| 527 | } |
|
| 528 | ||
| 529 | ||
| 530 | ||
| @@ 536-544 (lines=9) @@ | ||
| 533 | * |
|
| 534 | * @return void |
|
| 535 | */ |
|
| 536 | public function testMarkdownAndBBCode() |
|
| 537 | { |
|
| 538 | $filter = new CTextFilter(); |
|
| 539 | ||
| 540 | $html = "Header[b]text[/b]\n========="; |
|
| 541 | $exp = "<h1>Header<strong>text</strong></h1>\n"; |
|
| 542 | $res = $filter->doFilter($html, "markdown, bbcode"); |
|
| 543 | $this->assertEquals($exp, $res, "Markdown <h1> failed: '$res'"); |
|
| 544 | } |
|
| 545 | ||
| 546 | ||
| 547 | ||
| @@ 553-561 (lines=9) @@ | ||
| 550 | * |
|
| 551 | * @return void |
|
| 552 | */ |
|
| 553 | public function testMarkdownAndBBCodeAsArray() |
|
| 554 | { |
|
| 555 | $filter = new CTextFilter(); |
|
| 556 | ||
| 557 | $html = "Header[b]text[/b]\n========="; |
|
| 558 | $exp = "<h1>Header<strong>text</strong></h1>\n"; |
|
| 559 | $res = $filter->doFilter($html, ["markdown", "bbcode"]); |
|
| 560 | $this->assertEquals($exp, $res, "Markdown <h1> failed: '$res'"); |
|
| 561 | } |
|
| 562 | ||
| 563 | ||
| 564 | ||
| @@ 570-578 (lines=9) @@ | ||
| 567 | * |
|
| 568 | * @return void |
|
| 569 | */ |
|
| 570 | public function testMarkdownArray() |
|
| 571 | { |
|
| 572 | $filter = new CTextFilter(); |
|
| 573 | ||
| 574 | $html = "Header\n========="; |
|
| 575 | $exp = "<h1>Header</h1>\n"; |
|
| 576 | $res = $filter->doFilter($html, ["markdown"]); |
|
| 577 | $this->assertEquals($exp, $res, "Markdown <h1> failed: '$res'"); |
|
| 578 | } |
|
| 579 | ||
| 580 | ||
| 581 | ||
| @@ 587-595 (lines=9) @@ | ||
| 584 | * |
|
| 585 | * @return void |
|
| 586 | */ |
|
| 587 | public function testUppercase() |
|
| 588 | { |
|
| 589 | $filter = new CTextFilter(); |
|
| 590 | ||
| 591 | $html = "Header\n========="; |
|
| 592 | $exp = "<h1>Header</h1>\n"; |
|
| 593 | $res = $filter->doFilter($html, "MARKDOWN"); |
|
| 594 | $this->assertEquals($exp, $res, "Markdown <h1> failed: '$res'"); |
|
| 595 | } |
|
| 596 | ||
| 597 | ||
| 598 | ||
| @@ 604-612 (lines=9) @@ | ||
| 601 | * |
|
| 602 | * @return void |
|
| 603 | */ |
|
| 604 | public function testBBCode() |
|
| 605 | { |
|
| 606 | $filter = new CTextFilter(); |
|
| 607 | ||
| 608 | $html = "[b]text[/b]"; |
|
| 609 | $exp = "<strong>text</strong>"; |
|
| 610 | $res = $filter->doFilter($html, "bbcode"); |
|
| 611 | $this->assertEquals($exp, $res, "BBCode [b] failed: '$res'"); |
|
| 612 | } |
|
| 613 | ||
| 614 | ||
| 615 | ||
| @@ 621-629 (lines=9) @@ | ||
| 618 | * |
|
| 619 | * @return void |
|
| 620 | */ |
|
| 621 | public function testClickable() |
|
| 622 | { |
|
| 623 | $filter = new CTextFilter(); |
|
| 624 | ||
| 625 | $html = "http://example.com/humans.txt"; |
|
| 626 | $exp = "<a href='$html'>$html</a>"; |
|
| 627 | $res = $filter->doFilter($html, "clickable"); |
|
| 628 | $this->assertEquals($exp, $res, "clickable failed: '$res'"); |
|
| 629 | } |
|
| 630 | ||
| 631 | ||
| 632 | ||
| @@ 638-646 (lines=9) @@ | ||
| 635 | * |
|
| 636 | * @return void |
|
| 637 | */ |
|
| 638 | public function testNl2Br() |
|
| 639 | { |
|
| 640 | $filter = new CTextFilter(); |
|
| 641 | ||
| 642 | $html = "hej\nhej"; |
|
| 643 | $exp = "hej<br />\nhej"; |
|
| 644 | $res = $filter->doFilter($html, "nl2br"); |
|
| 645 | $this->assertEquals($exp, $res, "nl2br failed: '$res'"); |
|
| 646 | } |
|
| 647 | ||
| 648 | ||
| 649 | ||