-
Notifications
You must be signed in to change notification settings - Fork 34
/
TagMapperTest.php
62 lines (51 loc) · 1.58 KB
/
TagMapperTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
namespace tests;
use OfficeML\Processor\Lexer;
use OfficeML\Processor\TagMapper;
class TagMapperTest extends \PHPUnit_Framework_TestCase
{
/** @test */
public function it_parse_path_correctly()
{
$method = new \ReflectionMethod(
'PHPStamp\Processor\TagMapper', 'parsePath'
);
$method->setAccessible(true);
$lexer = new Lexer(array('[[', ']]'));
// case 0
$pathString = '';
$lexer->setInput($pathString);
$this->assertEquals(
array(), $method->invoke(new TagMapper, $lexer)
);
// case 1
$pathString = 'root';
$lexer->setInput($pathString);
$this->assertEquals(
array('root'), $method->invoke(new TagMapper, $lexer)
);
// case 2
$pathString = 'root.child';
$lexer->setInput($pathString);
$this->assertEquals(
array('root', 'child'), $method->invoke(new TagMapper, $lexer)
);
// case 3
$pathString = 'root-child';
$lexer->setInput($pathString);
$this->setExpectedException('PHPStamp\Exception\ProcessorException');
$result = $method->invoke(new TagMapper, $lexer);
}
/** @test */
public function it_works()
{
// prepare
$lexer = new Lexer(array('[[', ']]'));
$pathString = '[[root.child:function(arg1, arg2):function2(arg3, arg4, arg5)]]';
$lexer->setInput($pathString);
$mapper = new TagMapper();
while ($tag = $mapper->parse($lexer)) {
var_dump($tag);
}
}
}