| @@ 295-303 (lines=9) @@ | ||
| 292 | * |
|
| 293 | * @return void |
|
| 294 | */ |
|
| 295 | public function testMarkdown() |
|
| 296 | { |
|
| 297 | $filter = new CTextFilter(); |
|
| 298 | ||
| 299 | $html = "Header\n========="; |
|
| 300 | $exp = "<h1>Header</h1>\n"; |
|
| 301 | $res = $filter->doFilter($html, "markdown"); |
|
| 302 | $this->assertEquals($exp, $res, "Markdown <h1> failed: '$res'"); |
|
| 303 | } |
|
| 304 | ||
| 305 | ||
| 306 | ||
| @@ 312-320 (lines=9) @@ | ||
| 309 | * |
|
| 310 | * @return void |
|
| 311 | */ |
|
| 312 | public function testMarkdownAndBBCode() |
|
| 313 | { |
|
| 314 | $filter = new CTextFilter(); |
|
| 315 | ||
| 316 | $html = "Header[b]text[/b]\n========="; |
|
| 317 | $exp = "<h1>Header<strong>text</strong></h1>\n"; |
|
| 318 | $res = $filter->doFilter($html, "markdown, bbcode"); |
|
| 319 | $this->assertEquals($exp, $res, "Markdown <h1> failed: '$res'"); |
|
| 320 | } |
|
| 321 | ||
| 322 | ||
| 323 | ||
| @@ 329-337 (lines=9) @@ | ||
| 326 | * |
|
| 327 | * @return void |
|
| 328 | */ |
|
| 329 | public function testMarkdownAndBBCodeAsArray() |
|
| 330 | { |
|
| 331 | $filter = new CTextFilter(); |
|
| 332 | ||
| 333 | $html = "Header[b]text[/b]\n========="; |
|
| 334 | $exp = "<h1>Header<strong>text</strong></h1>\n"; |
|
| 335 | $res = $filter->doFilter($html, ["markdown", "bbcode"]); |
|
| 336 | $this->assertEquals($exp, $res, "Markdown <h1> failed: '$res'"); |
|
| 337 | } |
|
| 338 | ||
| 339 | ||
| 340 | ||
| @@ 346-354 (lines=9) @@ | ||
| 343 | * |
|
| 344 | * @return void |
|
| 345 | */ |
|
| 346 | public function testMarkdownArray() |
|
| 347 | { |
|
| 348 | $filter = new CTextFilter(); |
|
| 349 | ||
| 350 | $html = "Header\n========="; |
|
| 351 | $exp = "<h1>Header</h1>\n"; |
|
| 352 | $res = $filter->doFilter($html, ["markdown"]); |
|
| 353 | $this->assertEquals($exp, $res, "Markdown <h1> failed: '$res'"); |
|
| 354 | } |
|
| 355 | ||
| 356 | ||
| 357 | ||
| @@ 363-371 (lines=9) @@ | ||
| 360 | * |
|
| 361 | * @return void |
|
| 362 | */ |
|
| 363 | public function testUppercase() |
|
| 364 | { |
|
| 365 | $filter = new CTextFilter(); |
|
| 366 | ||
| 367 | $html = "Header\n========="; |
|
| 368 | $exp = "<h1>Header</h1>\n"; |
|
| 369 | $res = $filter->doFilter($html, "MARKDOWN"); |
|
| 370 | $this->assertEquals($exp, $res, "Markdown <h1> failed: '$res'"); |
|
| 371 | } |
|
| 372 | ||
| 373 | ||
| 374 | ||
| @@ 380-388 (lines=9) @@ | ||
| 377 | * |
|
| 378 | * @return void |
|
| 379 | */ |
|
| 380 | public function testBBCode() |
|
| 381 | { |
|
| 382 | $filter = new CTextFilter(); |
|
| 383 | ||
| 384 | $html = "[b]text[/b]"; |
|
| 385 | $exp = "<strong>text</strong>"; |
|
| 386 | $res = $filter->doFilter($html, "bbcode"); |
|
| 387 | $this->assertEquals($exp, $res, "BBCode [b] failed: '$res'"); |
|
| 388 | } |
|
| 389 | ||
| 390 | ||
| 391 | ||
| @@ 397-405 (lines=9) @@ | ||
| 394 | * |
|
| 395 | * @return void |
|
| 396 | */ |
|
| 397 | public function testClickable() |
|
| 398 | { |
|
| 399 | $filter = new CTextFilter(); |
|
| 400 | ||
| 401 | $html = "http://example.com/humans.txt"; |
|
| 402 | $exp = "<a href='$html'>$html</a>"; |
|
| 403 | $res = $filter->doFilter($html, "clickable"); |
|
| 404 | $this->assertEquals($exp, $res, "clickable failed: '$res'"); |
|
| 405 | } |
|
| 406 | ||
| 407 | ||
| 408 | ||
| @@ 414-422 (lines=9) @@ | ||
| 411 | * |
|
| 412 | * @return void |
|
| 413 | */ |
|
| 414 | public function testNl2Br() |
|
| 415 | { |
|
| 416 | $filter = new CTextFilter(); |
|
| 417 | ||
| 418 | $html = "hej\nhej"; |
|
| 419 | $exp = "hej<br />\nhej"; |
|
| 420 | $res = $filter->doFilter($html, "nl2br"); |
|
| 421 | $this->assertEquals($exp, $res, "nl2br failed: '$res'"); |
|
| 422 | } |
|
| 423 | ||
| 424 | ||
| 425 | ||