|
1
|
|
|
<?php |
|
2
|
|
|
namespace Thunder\Shortcode\Tests; |
|
3
|
|
|
|
|
4
|
|
|
use Thunder\Shortcode\Syntax\Syntax; |
|
5
|
|
|
use Thunder\Shortcode\Syntax\CommonSyntax; |
|
6
|
|
|
use Thunder\Shortcode\Syntax\SyntaxBuilder; |
|
7
|
|
|
use Thunder\Shortcode\Syntax\SyntaxInterface; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* @author Tomasz Kowalczyk <[email protected]> |
|
11
|
|
|
*/ |
|
12
|
|
|
final class SyntaxTest extends AbstractTestCase |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* @dataProvider provideSyntaxes |
|
16
|
|
|
*/ |
|
17
|
|
|
public function testSyntax(SyntaxInterface $syntax, $open, $close, $slash, $parameter, $value) |
|
18
|
|
|
{ |
|
19
|
|
|
static::assertSame($open, $syntax->getOpeningTag()); |
|
20
|
|
|
static::assertSame($close, $syntax->getClosingTag()); |
|
21
|
|
|
static::assertSame($slash, $syntax->getClosingTagMarker()); |
|
22
|
|
|
static::assertSame($parameter, $syntax->getParameterValueSeparator()); |
|
23
|
|
|
static::assertSame($value, $syntax->getParameterValueDelimiter()); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
public function provideSyntaxes() |
|
27
|
|
|
{ |
|
28
|
|
|
return array( |
|
29
|
|
|
array(new Syntax(), '[', ']', '/', '=', '"'), |
|
30
|
|
|
array(new Syntax('[[', ']]', '//', '==', '""'), '[[', ']]', '//', '==', '""'), |
|
31
|
|
|
array(new CommonSyntax(), '[', ']', '/', '=', '"'), |
|
32
|
|
|
); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Note: do not merge this test with data provider above, code coverage |
|
37
|
|
|
* does not understand this and marks builder class as untested. |
|
38
|
|
|
*/ |
|
39
|
|
|
public function testBuilder() |
|
40
|
|
|
{ |
|
41
|
|
|
$builder = new SyntaxBuilder(); |
|
42
|
|
|
$this->testSyntax($builder->getSyntax(), '[', ']', '/', '=', '"'); |
|
43
|
|
|
|
|
44
|
|
|
$builder = new SyntaxBuilder(); |
|
45
|
|
|
$doubleBuiltSyntax = $builder |
|
46
|
|
|
->setOpeningTag('[[') |
|
47
|
|
|
->setClosingTag(']]') |
|
48
|
|
|
->setClosingTagMarker('//') |
|
49
|
|
|
->setParameterValueSeparator('==') |
|
50
|
|
|
->setParameterValueDelimiter('""') |
|
51
|
|
|
->getSyntax(); |
|
52
|
|
|
$this->testSyntax($doubleBuiltSyntax, '[[', ']]', '//', '==', '""'); |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|