1 | <?php |
||
18 | class ParserTest extends \PHPUnit_Framework_TestCase{ |
||
19 | |||
20 | /** |
||
21 | * @var \chillerlan\bbcode\Parser |
||
22 | */ |
||
23 | protected $parser; |
||
24 | |||
25 | /** |
||
26 | * @var \ReflectionClass |
||
27 | */ |
||
28 | protected $reflectionClass; |
||
29 | |||
30 | protected function setUp(){ |
||
31 | $this->reflectionClass = new ReflectionClass(Parser::class); |
||
32 | } |
||
33 | |||
34 | public function testInstance(){ |
||
35 | $this->parser = $this->reflectionClass->newInstance(); |
||
36 | $this->assertInstanceOf(Parser::class, $this->parser); |
||
37 | } |
||
38 | |||
39 | public function testGetAllowed(){ |
||
40 | $options = new ParserOptions; |
||
41 | $options->allowed_tags = ['noparse','code','img']; |
||
42 | |||
43 | $method = $this->reflectionClass->getMethod('getAllowed'); |
||
44 | $this->parser = $this->reflectionClass->newInstanceArgs([$options]); |
||
45 | $this->assertEquals(['code','img','noparse'], $method->invoke($this->parser)); |
||
46 | } |
||
47 | |||
48 | public function testGetNoparse(){ |
||
49 | $noparse_tags = ['code','css','html','js','json','noparse','nsis','php','pre','sql','xml']; |
||
50 | |||
51 | $method = $this->reflectionClass->getMethod('getNoparse'); |
||
52 | $this->parser = $this->reflectionClass->newInstance(); |
||
53 | $this->assertEquals($noparse_tags, $method->invoke($this->parser)); |
||
54 | } |
||
55 | |||
56 | public function testGetSingle(){ |
||
57 | $singletags = ['br','clear','col','hr']; |
||
58 | |||
59 | $method = $this->reflectionClass->getMethod('getSingle'); |
||
60 | $this->parser = $this->reflectionClass->newInstance(); |
||
61 | $this->assertEquals($singletags, $method->invoke($this->parser)); |
||
62 | } |
||
63 | |||
64 | } |