| @@ 470-478 (lines=9) @@ | ||
| 467 | * |
|
| 468 | * @return void |
|
| 469 | */ |
|
| 470 | public function testMarkdown() |
|
| 471 | { |
|
| 472 | $filter = new CTextFilter(); |
|
| 473 | ||
| 474 | $html = "Header\n========="; |
|
| 475 | $exp = "<h1>Header</h1>\n"; |
|
| 476 | $res = $filter->doFilter($html, "markdown"); |
|
| 477 | $this->assertEquals($exp, $res, "Markdown <h1> failed: '$res'"); |
|
| 478 | } |
|
| 479 | ||
| 480 | ||
| 481 | ||
| @@ 487-495 (lines=9) @@ | ||
| 484 | * |
|
| 485 | * @return void |
|
| 486 | */ |
|
| 487 | public function testMarkdownAndBBCode() |
|
| 488 | { |
|
| 489 | $filter = new CTextFilter(); |
|
| 490 | ||
| 491 | $html = "Header[b]text[/b]\n========="; |
|
| 492 | $exp = "<h1>Header<strong>text</strong></h1>\n"; |
|
| 493 | $res = $filter->doFilter($html, "markdown, bbcode"); |
|
| 494 | $this->assertEquals($exp, $res, "Markdown <h1> failed: '$res'"); |
|
| 495 | } |
|
| 496 | ||
| 497 | ||
| 498 | ||
| @@ 504-512 (lines=9) @@ | ||
| 501 | * |
|
| 502 | * @return void |
|
| 503 | */ |
|
| 504 | public function testMarkdownAndBBCodeAsArray() |
|
| 505 | { |
|
| 506 | $filter = new CTextFilter(); |
|
| 507 | ||
| 508 | $html = "Header[b]text[/b]\n========="; |
|
| 509 | $exp = "<h1>Header<strong>text</strong></h1>\n"; |
|
| 510 | $res = $filter->doFilter($html, ["markdown", "bbcode"]); |
|
| 511 | $this->assertEquals($exp, $res, "Markdown <h1> failed: '$res'"); |
|
| 512 | } |
|
| 513 | ||
| 514 | ||
| 515 | ||
| @@ 521-529 (lines=9) @@ | ||
| 518 | * |
|
| 519 | * @return void |
|
| 520 | */ |
|
| 521 | public function testMarkdownArray() |
|
| 522 | { |
|
| 523 | $filter = new CTextFilter(); |
|
| 524 | ||
| 525 | $html = "Header\n========="; |
|
| 526 | $exp = "<h1>Header</h1>\n"; |
|
| 527 | $res = $filter->doFilter($html, ["markdown"]); |
|
| 528 | $this->assertEquals($exp, $res, "Markdown <h1> failed: '$res'"); |
|
| 529 | } |
|
| 530 | ||
| 531 | ||
| 532 | ||
| @@ 538-546 (lines=9) @@ | ||
| 535 | * |
|
| 536 | * @return void |
|
| 537 | */ |
|
| 538 | public function testUppercase() |
|
| 539 | { |
|
| 540 | $filter = new CTextFilter(); |
|
| 541 | ||
| 542 | $html = "Header\n========="; |
|
| 543 | $exp = "<h1>Header</h1>\n"; |
|
| 544 | $res = $filter->doFilter($html, "MARKDOWN"); |
|
| 545 | $this->assertEquals($exp, $res, "Markdown <h1> failed: '$res'"); |
|
| 546 | } |
|
| 547 | ||
| 548 | ||
| 549 | ||
| @@ 555-563 (lines=9) @@ | ||
| 552 | * |
|
| 553 | * @return void |
|
| 554 | */ |
|
| 555 | public function testBBCode() |
|
| 556 | { |
|
| 557 | $filter = new CTextFilter(); |
|
| 558 | ||
| 559 | $html = "[b]text[/b]"; |
|
| 560 | $exp = "<strong>text</strong>"; |
|
| 561 | $res = $filter->doFilter($html, "bbcode"); |
|
| 562 | $this->assertEquals($exp, $res, "BBCode [b] failed: '$res'"); |
|
| 563 | } |
|
| 564 | ||
| 565 | ||
| 566 | ||
| @@ 572-580 (lines=9) @@ | ||
| 569 | * |
|
| 570 | * @return void |
|
| 571 | */ |
|
| 572 | public function testClickable() |
|
| 573 | { |
|
| 574 | $filter = new CTextFilter(); |
|
| 575 | ||
| 576 | $html = "http://example.com/humans.txt"; |
|
| 577 | $exp = "<a href='$html'>$html</a>"; |
|
| 578 | $res = $filter->doFilter($html, "clickable"); |
|
| 579 | $this->assertEquals($exp, $res, "clickable failed: '$res'"); |
|
| 580 | } |
|
| 581 | ||
| 582 | ||
| 583 | ||
| @@ 589-597 (lines=9) @@ | ||
| 586 | * |
|
| 587 | * @return void |
|
| 588 | */ |
|
| 589 | public function testNl2Br() |
|
| 590 | { |
|
| 591 | $filter = new CTextFilter(); |
|
| 592 | ||
| 593 | $html = "hej\nhej"; |
|
| 594 | $exp = "hej<br />\nhej"; |
|
| 595 | $res = $filter->doFilter($html, "nl2br"); |
|
| 596 | $this->assertEquals($exp, $res, "nl2br failed: '$res'"); |
|
| 597 | } |
|
| 598 | ||
| 599 | ||
| 600 | ||