1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Aiur\Cinema; |
4
|
|
|
|
5
|
|
|
use Anax\DI\DIMagic; |
6
|
|
|
use Anax\Response\ResponseUtility; |
7
|
|
|
use PHPUnit\Framework\TestCase; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Test the controller like it would be used from the router, |
11
|
|
|
* simulating the actual router paths and calling it directly. |
12
|
|
|
*/ |
13
|
|
|
class MyTextFilterTest extends TestCase |
14
|
|
|
{ |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Testing the parce |
18
|
|
|
* |
19
|
|
|
*/ |
20
|
|
|
public function testValueParse() |
21
|
|
|
{ |
22
|
|
|
$test = new MyTextFilter(); |
23
|
|
|
$text = "[b]Bold text[/b] http://www.google.com"; |
24
|
|
|
$filter = ["bbcode", "link"]; |
25
|
|
|
|
26
|
|
|
$res = $test->parse($text, $filter); |
27
|
|
|
$exp = "<strong>Bold text</strong> <a href=\'http://www.google.com\'>http://www.google.com</a>"; |
28
|
|
|
$this->assertEquals($exp, $res); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
|
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Testing the method bbcode |
35
|
|
|
* |
36
|
|
|
*/ |
37
|
|
|
public function testValuebbcode() |
38
|
|
|
{ |
39
|
|
|
$test = new MyTextFilter(); |
40
|
|
|
$text = "[b]Bold text[/b]"; |
41
|
|
|
|
42
|
|
|
$res = $test->bbcode2html($text); |
43
|
|
|
$exp = "<strong>Bold text</strong>"; |
44
|
|
|
$this->assertEquals($exp, $res); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Testing Makeclickable mathod |
49
|
|
|
* |
50
|
|
|
*/ |
51
|
|
|
public function testValueClickable() |
52
|
|
|
{ |
53
|
|
|
$test = new MyTextFilter(); |
54
|
|
|
$text = "http://www.google.com"; |
55
|
|
|
|
56
|
|
|
$res = $test->makeClickable($text); |
57
|
|
|
$exp = "<a href=\'http://www.google.com\'>http://www.google.com</a>"; |
58
|
|
|
$this->assertEquals($exp, $res); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Testing the method markdown |
63
|
|
|
* |
64
|
|
|
*/ |
65
|
|
|
public function testValueMarkdown() |
66
|
|
|
{ |
67
|
|
|
$test = new MyTextFilter(); |
68
|
|
|
$text = "### Header level 3"; |
69
|
|
|
|
70
|
|
|
$res = $test->markdown($text); |
71
|
|
|
$exp = "<h3>Header level 3</h3>\n"; |
72
|
|
|
$this->assertEquals($exp, $res); |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|