| @@ 16-24 (lines=9) @@ | ||
| 13 | * |
|
| 14 | * @return void |
|
| 15 | */ |
|
| 16 | public function testMarkdown() |
|
| 17 | { |
|
| 18 | $filter = new CTextFilter(); |
|
| 19 | ||
| 20 | $html = "Header\n========="; |
|
| 21 | $exp = "<h1>Header</h1>\n"; |
|
| 22 | $res = $filter->doFilter($html, "markdown"); |
|
| 23 | $this->assertEquals($exp, $res, "Markdown <h1> failed: '$res'"); |
|
| 24 | } |
|
| 25 | ||
| 26 | ||
| 27 | ||
| @@ 33-41 (lines=9) @@ | ||
| 30 | * |
|
| 31 | * @return void |
|
| 32 | */ |
|
| 33 | public function testMarkdownAndBBCode() |
|
| 34 | { |
|
| 35 | $filter = new CTextFilter(); |
|
| 36 | ||
| 37 | $html = "Header[b]text[/b]\n========="; |
|
| 38 | $exp = "<h1>Header<strong>text</strong></h1>\n"; |
|
| 39 | $res = $filter->doFilter($html, "markdown, bbcode"); |
|
| 40 | $this->assertEquals($exp, $res, "Markdown <h1> failed: '$res'"); |
|
| 41 | } |
|
| 42 | ||
| 43 | ||
| 44 | ||
| @@ 50-58 (lines=9) @@ | ||
| 47 | * |
|
| 48 | * @return void |
|
| 49 | */ |
|
| 50 | public function testMarkdownAndBBCodeAsArray() |
|
| 51 | { |
|
| 52 | $filter = new CTextFilter(); |
|
| 53 | ||
| 54 | $html = "Header[b]text[/b]\n========="; |
|
| 55 | $exp = "<h1>Header<strong>text</strong></h1>\n"; |
|
| 56 | $res = $filter->doFilter($html, ["markdown", "bbcode"]); |
|
| 57 | $this->assertEquals($exp, $res, "Markdown <h1> failed: '$res'"); |
|
| 58 | } |
|
| 59 | ||
| 60 | ||
| 61 | ||
| @@ 67-75 (lines=9) @@ | ||
| 64 | * |
|
| 65 | * @return void |
|
| 66 | */ |
|
| 67 | public function testMarkdownArray() |
|
| 68 | { |
|
| 69 | $filter = new CTextFilter(); |
|
| 70 | ||
| 71 | $html = "Header\n========="; |
|
| 72 | $exp = "<h1>Header</h1>\n"; |
|
| 73 | $res = $filter->doFilter($html, ["markdown"]); |
|
| 74 | $this->assertEquals($exp, $res, "Markdown <h1> failed: '$res'"); |
|
| 75 | } |
|
| 76 | ||
| 77 | ||
| 78 | ||
| @@ 84-92 (lines=9) @@ | ||
| 81 | * |
|
| 82 | * @return void |
|
| 83 | */ |
|
| 84 | public function testUppercase() |
|
| 85 | { |
|
| 86 | $filter = new CTextFilter(); |
|
| 87 | ||
| 88 | $html = "Header\n========="; |
|
| 89 | $exp = "<h1>Header</h1>\n"; |
|
| 90 | $res = $filter->doFilter($html, "MARKDOWN"); |
|
| 91 | $this->assertEquals($exp, $res, "Markdown <h1> failed: '$res'"); |
|
| 92 | } |
|
| 93 | ||
| 94 | ||
| 95 | ||
| @@ 101-109 (lines=9) @@ | ||
| 98 | * |
|
| 99 | * @return void |
|
| 100 | */ |
|
| 101 | public function testBBCode() |
|
| 102 | { |
|
| 103 | $filter = new CTextFilter(); |
|
| 104 | ||
| 105 | $html = "[b]text[/b]"; |
|
| 106 | $exp = "<strong>text</strong>"; |
|
| 107 | $res = $filter->doFilter($html, "bbcode"); |
|
| 108 | $this->assertEquals($exp, $res, "BBCode [b] failed: '$res'"); |
|
| 109 | } |
|
| 110 | ||
| 111 | ||
| 112 | ||
| @@ 118-126 (lines=9) @@ | ||
| 115 | * |
|
| 116 | * @return void |
|
| 117 | */ |
|
| 118 | public function testClickable() |
|
| 119 | { |
|
| 120 | $filter = new CTextFilter(); |
|
| 121 | ||
| 122 | $html = "http://example.com/humans.txt"; |
|
| 123 | $exp = "<a href='$html'>$html</a>"; |
|
| 124 | $res = $filter->doFilter($html, "clickable"); |
|
| 125 | $this->assertEquals($exp, $res, "clickable failed: '$res'"); |
|
| 126 | } |
|
| 127 | ||
| 128 | ||
| 129 | ||
| @@ 135-143 (lines=9) @@ | ||
| 132 | * |
|
| 133 | * @return void |
|
| 134 | */ |
|
| 135 | public function testNl2Br() |
|
| 136 | { |
|
| 137 | $filter = new CTextFilter(); |
|
| 138 | ||
| 139 | $html = "hej\nhej"; |
|
| 140 | $exp = "hej<br />\nhej"; |
|
| 141 | $res = $filter->doFilter($html, "nl2br"); |
|
| 142 | $this->assertEquals($exp, $res, "nl2br failed: '$res'"); |
|
| 143 | } |
|
| 144 | ||
| 145 | ||
| 146 | ||