1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* |
4
|
|
|
* @filesource ParserTest.php |
5
|
|
|
* @created 09.02.2016 |
6
|
|
|
* @package chillerlan\BBCodeTest |
7
|
|
|
* @author Smiley <[email protected]> |
8
|
|
|
* @copyright 2015 Smiley |
9
|
|
|
* @license MIT |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace chillerlan\BBCodeTest\normal; |
13
|
|
|
|
14
|
|
|
use chillerlan\bbcode\Parser; |
15
|
|
|
use chillerlan\bbcode\ParserOptions; |
16
|
|
|
use ReflectionClass; |
17
|
|
|
|
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
|
|
|
} |