-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathBbcodeExtensionTest.php
More file actions
212 lines (188 loc) · 6.83 KB
/
Copy pathBbcodeExtensionTest.php
File metadata and controls
212 lines (188 loc) · 6.83 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
<?php
namespace FM\BbcodeBundle\Tests\Templating;
use FM\BbcodeBundle\Tests\TwigBasedTestCase;
class BbcodeExtensionTest extends TwigBasedTestCase
{
/**
* @dataProvider dataDefaultTags
*/
public function testDefaultFilter($value, $expected)
{
$this->assertSame($expected,
$this->getTwig()->render('FunctionalTestBundle:filters:default.html.twig', array(
'value' => $value,
)));
}
public function dataDefaultTags()
{
return array(
array('[b]bold[/b]', "<strong>bold</strong>"),
array('[i]italic[/i]', "<em>italic</em>"),
array('[u]underline[/u]', "<u>underline</u>"),
array('[s]strikeout[/s]', "<del>strikeout</del>"),
array('[sub]subscript[/sub]', "<sub>subscript</sub>"),
array('[sup]superscript[/sup]', "<sup>superscript</sup>"),
array('[abbr="Object relational mapper"]ORM[/abbr]', '<abbr title="Object relational mapper">ORM</abbr>'),
);
}
/**
* @dataProvider dataUrlTags
*/
public function testUrlFilter($value, $expected)
{
$this->assertSame($expected,
$this->getTwig()->render('FunctionalTestBundle:filters:url.html.twig', array(
'value' => $value,
)));
}
public function dataUrlTags()
{
return array(
array('[url]http://example.org[/url]','<a href="http://example.org">http://example.org</a>'),
array('[url="http://example.com"]Example[/url]','<a href="http://example.com">Example</a>')
);
}
/**
* @dataProvider dataImgTags
*/
public function testImgFilter($value, $expected)
{
$this->assertSame($expected,
$this->getTwig()->render('FunctionalTestBundle:filters:image.html.twig', array(
'value' => $value,
)));
}
public function dataImgTags()
{
return array(
array('[img]http://github.com/picture.jpg[/img]','<img src="http://github.com/picture.jpg" alt="" />'),
array('[img width="500"]http://github.com/picture.jpg[/img]','<img width="500" src="http://github.com/picture.jpg" alt="" />')
);
}
/**
* @dataProvider dataQuoteTags
*/
public function testQuoteFilter($value, $expected)
{
$this->assertSame($expected,
$this->getTwig()->render('FunctionalTestBundle:filters:quote.html.twig', array(
'value' => $value,
)));
}
public function dataQuoteTags()
{
return array(
array('[quote]text[/quote]','text'),
);
}
/**
* @dataProvider dataStrict
*/
public function testStrict($value, $expected)
{
$this->assertSame($expected,
$this->getTwig()->render('FunctionalTestBundle:filters:strict_test.html.twig', array(
'value' => $value,
)));
}
public function dataStrict()
{
return array(
array('[url]http://example.org[/url]','<a href="http://example.org">http://example.org</a>'),
array('[url=http://example.com]Example[/url]','<a href="http://example.com">Example</a>')
);
}
/**
* @dataProvider dataDefaultTags
*/
public function testFooFilter($value, $expected)
{
$this->assertSame($expected,
$this->getTwig()->render('FunctionalTestBundle:filters:foo_filter.html.twig', array(
'value' => $value,
)));
}
/**
* @dataProvider dataDefaultTags
*/
public function testBarFilter($value, $expected)
{
$this->assertSame($expected,
$this->getTwig()->render('FunctionalTestBundle:filters:bar_filter.html.twig', array(
'value' => $value,
)));
}
/**
* @dataProvider dataClickableHook
*/
public function testFooHook($value, $expected)
{
$this->assertSame($expected,
$this->getTwig()->render('FunctionalTestBundle:filters:foo_hook.html.twig', array(
'value' => $value,
)));
}
/**
* @dataProvider dataClickableHook
*/
public function testBarHook($value, $expected)
{
$this->assertSame($expected,
$this->getTwig()->render('FunctionalTestBundle:filters:bar_hook.html.twig', array(
'value' => $value,
)));
}
public function dataClickableHook()
{
return array(
array('http://domain.com', '<a href="http://domain.com">http://domain.com</a>'),
);
}
/**
* @dataProvider dataDefaultFilterSet
*/
public function testDefaultFilterSet($value, $expected)
{
$this->assertSame($expected,
$this->getTwig()->render('FunctionalTestBundle:filters:default_filter_set.html.twig', array(
'value' => $value,
)));
}
public function dataDefaultFilterSet()
{
return array(
array('[b]Bold[/b]', "<b>Bold</b>"),
array('[i]Italic[/i]', "<i>Italic</i>"),
array('[u]Underline[/u]', "<u>Underline</u>"),
array('[s]strikeout[/s]', "<del>strikeout</del>"),
array('[sub]subscript[/sub]', "<sub>subscript</sub>"),
array('[sup]superscript[/sup]', "<sup>superscript</sup>"),
array('[abbr="Object relational mapper"]ORM[/abbr]', '<abbr title="Object relational mapper">ORM</abbr>'),
array('[url]http://example.org[/url]','<a href="http://example.org">http://example.org</a>'),
array('[url="http://example.com"]Example[/url]','<a href="http://example.com">Example</a>'),
array('[email]email@domain.com[/email]', '<a href="mailto:email@domain.com">email@domain.com</a>'),
);
}
/**
* @dataProvider dataEmoticonHook
*/
public function testEmoticonHook($value, $expected)
{
$this->assertSame($expected,
$this->getTwig()->render('FunctionalTestBundle:filters:emoticon.html.twig', array(
'value' => $value,
)));
}
public function dataEmoticonHook()
{
return array(
array(':)', ':)'),
array(':tester:', '<img src="/emoticons/tester.png" alt="" />'),
array(':url_tester:', '<img src="/foo.gif" alt="" />'),
array(':\\', ':\\'),
//array(':place_holder:', '<img src="/emoticons//foo.gif" alt="" />'), // FIXME Decoda Bug: result => <img src="/emoticons/tongue.png" alt="" />lace_holder:
array(':_lace_holder:', '<img src="/emoticons//foo.gif" alt="" />'),
array(':my_emoticon:', '<img src="/emoticons//my_emoticon.png" alt="" title="my_emoticon" />'),
);
}
}