24 $this->assertEquals(preg_match($pattern,
'{namespace acme=Tx_AcmeMyPackage_Bla_blubb}'), 1,
'The SCAN_PATTERN_NAMESPACEDECLARATION pattern did not match a namespace declaration (1).');
25 $this->assertEquals(preg_match($pattern,
'{namespace acme=Tx_AcmeMyPackage_Bla_Blubb }'), 1,
'The SCAN_PATTERN_NAMESPACEDECLARATION pattern did not match a namespace declaration (2).');
26 $this->assertEquals(preg_match($pattern,
' {namespace foo = Tx_Foo_Bla3_Blubb } '), 1,
'The SCAN_PATTERN_NAMESPACEDECLARATION pattern did not match a namespace declaration (3).');
27 $this->assertEquals(preg_match($pattern,
' \\{namespace fblubb = Tx_Fluid_Bla3_Blubb }'), 0,
'The SCAN_PATTERN_NAMESPACEDECLARATION pattern did match a namespace declaration even if it was escaped. (1)');
28 $this->assertEquals(preg_match($pattern,
'\\{namespace typo3 = Tx_TYPO3_Bla3_Blubb }'), 0,
'The SCAN_PATTERN_NAMESPACEDECLARATION pattern did match a namespace declaration even if it was escaped. (2)');
36 $this->assertEquals(preg_match($pattern,
'{namespace acme=Acme.MyPackage\Bla\blubb}'), 1,
'The SCAN_PATTERN_NAMESPACEDECLARATION pattern did not match a namespace declaration (1).');
37 $this->assertEquals(preg_match($pattern,
'{namespace acme=Acme.MyPackage\Bla\Blubb }'), 1,
'The SCAN_PATTERN_NAMESPACEDECLARATION pattern did not match a namespace declaration (2).');
38 $this->assertEquals(preg_match($pattern,
' {namespace foo = Foo\Bla3\Blubb } '), 1,
'The SCAN_PATTERN_NAMESPACEDECLARATION pattern did not match a namespace declaration (3).');
39 $this->assertEquals(preg_match($pattern,
' \\{namespace fblubb = TYPO3.Fluid\Bla3\Blubb }'), 0,
'The SCAN_PATTERN_NAMESPACEDECLARATION pattern did match a namespace declaration even if it was escaped. (1)');
40 $this->assertEquals(preg_match($pattern,
'\\{namespace typo3 = TYPO3.TYPO3\Bla3\Blubb }'), 0,
'The SCAN_PATTERN_NAMESPACEDECLARATION pattern did match a namespace declaration even if it was escaped. (2)');
49 $source =
'<html><head> <f:a.testing /> <f:blablubb> {testing}</f4:blz> </t3:hi.jo>';
50 $expected = array(
'<html><head> ',
'<f:a.testing />',
' ',
'<f:blablubb>',
' {testing}</f4:blz> ',
'</t3:hi.jo>');
51 $this->assertEquals(preg_split($pattern, $source, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY), $expected,
'The SPLIT_PATTERN_DYNAMICTAGS pattern did not split the input string correctly with simple tags.');
53 $source =
'hi<f:testing attribute="Hallo>{yep}" nested:attribute="jup" />ja';
54 $expected = array(
'hi',
'<f:testing attribute="Hallo>{yep}" nested:attribute="jup" />',
'ja');
55 $this->assertEquals(preg_split($pattern, $source, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY), $expected,
'The SPLIT_PATTERN_DYNAMICTAGS pattern did not split the input string correctly with > inside an attribute.');
57 $source =
'hi<f:testing attribute="Hallo\\"{yep}" nested:attribute="jup" />ja';
58 $expected = array(
'hi',
'<f:testing attribute="Hallo\\"{yep}" nested:attribute="jup" />',
'ja');
59 $this->assertEquals(preg_split($pattern, $source, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY), $expected,
'The SPLIT_PATTERN_DYNAMICTAGS pattern did not split the input string correctly if a " is inside a double-quoted string.');
61 $source =
'hi<f:testing attribute=\'Hallo>{yep}\' nested:attribute="jup" />ja';
62 $expected = array(
'hi',
'<f:testing attribute=\'Hallo>{yep}\' nested:attribute="jup" />',
'ja');
63 $this->assertEquals(preg_split($pattern, $source, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY), $expected,
'The SPLIT_PATTERN_DYNAMICTAGS pattern did not split the input string correctly with single quotes as attribute delimiters.');
65 $source =
'hi<f:testing attribute=\'Hallo\\\'{yep}\' nested:attribute="jup" />ja';
66 $expected = array(
'hi',
'<f:testing attribute=\'Hallo\\\'{yep}\' nested:attribute="jup" />',
'ja');
67 $this->assertEquals(preg_split($pattern, $source, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY), $expected,
'The SPLIT_PATTERN_DYNAMICTAGS pattern did not split the input string correctly if \' is inside a single-quoted attribute.');
69 $source =
'Hallo <f:testing><![CDATA[<f:notparsed>]]></f:testing>';
70 $expected = array(
'Hallo ',
'<f:testing>',
'<![CDATA[<f:notparsed>]]>',
'</f:testing>');
71 $this->assertEquals(preg_split($pattern, $source, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY), $expected,
'The SPLIT_PATTERN_DYNAMICTAGS pattern did not split the input string correctly if there is a CDATA section the parser should ignore.');
73 $veryLongViewHelper =
'<f:form enctype="multipart/form-data" onsubmit="void(0)" onreset="void(0)" action="someAction" arguments="{arg1: \'val1\', arg2: \'val2\'}" controller="someController" package="YourCompanyName.somePackage" subpackage="YourCompanyName.someSubpackage" section="someSection" format="txt" additionalParams="{param1: \'val1\', param2: \'val2\'}" absolute="true" addQueryString="true" argumentsToBeExcludedFromQueryString="{0: \'foo\'}" />';
74 $source = $veryLongViewHelper .
'Begin' . $veryLongViewHelper .
'End';
75 $expected = array($veryLongViewHelper,
'Begin', $veryLongViewHelper,
'End');
76 $this->assertEquals(preg_split($pattern, $source, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY), $expected,
'The SPLIT_PATTERN_DYNAMICTAGS pattern did not split the input string correctly if the VH has lots of arguments.');
78 $source =
'<f:a.testing data-bar="foo"> <f:a.testing>';
79 $expected = array(
'<f:a.testing data-bar="foo">',
' ',
'<f:a.testing>');
80 $this->assertEquals(preg_split($pattern, $source, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY), $expected,
'The SPLIT_PATTERN_DYNAMICTAGS pattern did not split the input string correctly with data- attribute.');
88 $source =
'<f:crop attribute="Hallo">';
90 0 =>
'<f:crop attribute="Hallo">',
91 'NamespaceIdentifier' =>
'f',
93 'MethodIdentifier' =>
'crop',
95 'Attributes' =>
' attribute="Hallo"',
96 3 =>
' attribute="Hallo"',
100 preg_match($pattern, $source, $matches);
101 $this->assertEquals($expected, $matches,
'The SCAN_PATTERN_DYNAMICTAG does not match correctly.');
104 $source =
'<f:crop data-attribute="Hallo">';
106 0 =>
'<f:crop data-attribute="Hallo">',
107 'NamespaceIdentifier' =>
'f',
109 'MethodIdentifier' =>
'crop',
111 'Attributes' =>
' data-attribute="Hallo"',
112 3 =>
' data-attribute="Hallo"',
116 preg_match($pattern, $source, $matches);
117 $this->assertEquals($expected, $matches,
'The SCAN_PATTERN_DYNAMICTAG does not match correctly with data- attributes.');
119 $source =
'<f:base />';
122 'NamespaceIdentifier' =>
'f',
124 'MethodIdentifier' =>
'base',
128 'Selfclosing' =>
'/',
131 preg_match($pattern, $source, $matches);
132 $this->assertEquals($expected, $matches,
'The SCAN_PATTERN_DYNAMICTAG does not match correctly when there is a space before the self-closing tag.');
134 $source =
'<f:crop attribute="Ha\\"llo"/>';
136 0 =>
'<f:crop attribute="Ha\\"llo"/>',
137 'NamespaceIdentifier' =>
'f',
139 'MethodIdentifier' =>
'crop',
141 'Attributes' =>
' attribute="Ha\\"llo"',
142 3 =>
' attribute="Ha\\"llo"',
143 'Selfclosing' =>
'/',
146 preg_match($pattern, $source, $matches);
147 $this->assertEquals($expected, $matches,
'The SCAN_PATTERN_DYNAMICTAG does not match correctly with self-closing tags.');
149 $source =
'<f:link.uriTo complex:attribute="Ha>llo" a="b" c=\'d\'/>';
151 0 =>
'<f:link.uriTo complex:attribute="Ha>llo" a="b" c=\'d\'/>',
152 'NamespaceIdentifier' =>
'f',
154 'MethodIdentifier' =>
'link.uriTo',
156 'Attributes' =>
' complex:attribute="Ha>llo" a="b" c=\'d\'',
157 3 =>
' complex:attribute="Ha>llo" a="b" c=\'d\'',
158 'Selfclosing' =>
'/',
161 preg_match($pattern, $source, $matches);
162 $this->assertEquals($expected, $matches,
'The SCAN_PATTERN_DYNAMICTAG does not match correctly with complex attributes and > inside the attributes.');
170 $this->assertEquals(preg_match($pattern,
'</f:bla>'), 1,
'The SCAN_PATTERN_CLOSINGDYNAMICTAG does not match a tag it should match.');
171 $this->assertEquals(preg_match($pattern,
'</f:bla.a >'), 1,
'The SCAN_PATTERN_CLOSINGDYNAMICTAG does not match a tag (with spaces included) it should match.');
172 $this->assertEquals(preg_match($pattern,
'</t:bla>'), 0,
'The SCAN_PATTERN_CLOSINGDYNAMICTAG does match match a tag it should not match.');
180 $source =
' test="Hallo" argument:post="\'Web" other=\'Single"Quoted\' data-foo="bar"';
181 $this->assertEquals(preg_match_all($pattern, $source, $matches, PREG_SET_ORDER), 4,
'The SPLIT_PATTERN_TAGARGUMENTS does not match correctly.');
182 $this->assertEquals(
'data-foo', $matches[3][
'Argument']);
191 $source =
'some string{Object.bla}here as well';
192 $expected = array(
'some string',
'{Object.bla}',
'here as well');
193 $this->assertEquals(preg_split($pattern, $source, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY), $expected,
'The SPLIT_PATTERN_SHORTHANDSYNTAX pattern did not split the input string correctly with a simple example.');
195 $source =
'some {}string\\{Object.bla}here as well';
196 $expected = array(
'some {}string\\',
'{Object.bla}',
'here as well');
197 $this->assertEquals(preg_split($pattern, $source, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY), $expected,
'The SPLIT_PATTERN_SHORTHANDSYNTAX pattern did not split the input string correctly with an escaped example. (1)');
199 $source =
'some {f:viewHelper()} as well';
200 $expected = array(
'some ',
'{f:viewHelper()}',
' as well');
201 $this->assertEquals(preg_split($pattern, $source, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY), $expected,
'The SPLIT_PATTERN_SHORTHANDSYNTAX pattern did not split the input string correctly with an escaped example. (2)');
203 $source =
'abc {f:for(arg1: post)} def';
204 $expected = array(
'abc ',
'{f:for(arg1: post)}',
' def');
205 $this->assertEquals(preg_split($pattern, $source, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY), $expected,
'The SPLIT_PATTERN_SHORTHANDSYNTAX pattern did not split the input string correctly with an escaped example.(3)');
207 $source =
'abc {bla.blubb->f:for(param:42)} def';
208 $expected = array(
'abc ',
'{bla.blubb->f:for(param:42)}',
' def');
209 $this->assertEquals(preg_split($pattern, $source, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY), $expected,
'The SPLIT_PATTERN_SHORTHANDSYNTAX pattern did not split the input string correctly with an escaped example.(4)');
212 $source =
'abc {f:for(bla:"post{{")} def';
213 $expected = array(
'abc ',
'{f:for(bla:"post{{")}',
' def');
214 $this->assertEquals(preg_split($pattern, $source, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY), $expected,
'The SPLIT_PATTERN_SHORTHANDSYNTAX pattern did not split the input string correctly with an escaped example.(5)');
216 $source =
'abc {f:for(param:"abc\\"abc")} def';
217 $expected = array(
'abc ',
'{f:for(param:"abc\\"abc")}',
' def');
218 $this->assertEquals(preg_split($pattern, $source, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY), $expected,
'The SPLIT_PATTERN_SHORTHANDSYNTAX pattern did not split the input string correctly with an escaped example.(6)');
227 $source =
'f:for(each: bla)';
230 0 =>
'f:for(each: bla)',
232 'NamespaceIdentifier' =>
'f',
234 'MethodIdentifier' =>
'for',
236 'ViewHelperArguments' =>
'each: bla' 239 preg_match_all($pattern, $source, $matches, PREG_SET_ORDER);
240 $this->assertEquals($matches, $expected,
'The SPLIT_PATTERN_SHORTHANDSYNTAX_VIEWHELPER');
242 $source =
'f:for(each: bla)->g:bla(a:"b\\"->(f:a()", cd: {a:b})';
245 0 =>
'f:for(each: bla)',
247 'NamespaceIdentifier' =>
'f',
249 'MethodIdentifier' =>
'for',
251 'ViewHelperArguments' =>
'each: bla' 254 0 =>
'g:bla(a:"b\\"->(f:a()", cd: {a:b})',
256 'NamespaceIdentifier' =>
'g',
258 'MethodIdentifier' =>
'bla',
259 3 =>
'a:"b\\"->(f:a()", cd: {a:b}',
260 'ViewHelperArguments' =>
'a:"b\\"->(f:a()", cd: {a:b}' 263 preg_match_all($pattern, $source, $matches, PREG_SET_ORDER);
264 $this->assertEquals($matches, $expected,
'The SPLIT_PATTERN_SHORTHANDSYNTAX_VIEWHELPER');
272 $this->assertEquals(preg_match($pattern,
'{object}'), 1,
'Object accessor not identified!');
273 $this->assertEquals(preg_match($pattern,
'{oBject1}'), 1,
'Object accessor not identified if there is a number and capitals inside!');
274 $this->assertEquals(preg_match($pattern,
'{object.recursive}'), 1,
'Object accessor not identified if there is a dot inside!');
275 $this->assertEquals(preg_match($pattern,
'{object-with-dash.recursive_value}'), 1,
'Object accessor not identified if there is a _ or - inside!');
276 $this->assertEquals(preg_match($pattern,
'{f:for()}'), 1,
'Object accessor not identified if it contains only of a ViewHelper.');
277 $this->assertEquals(preg_match($pattern,
'{f:for()->f:for2()}'), 1,
'Object accessor not identified if it contains only of a ViewHelper (nested).');
278 $this->assertEquals(preg_match($pattern,
'{abc->f:for()}'), 1,
'Object accessor not identified if there is a ViewHelper inside!');
279 $this->assertEquals(preg_match($pattern,
'{bla-blubb.recursive_value->f:for()->f:for()}'), 1,
'Object accessor not identified if there is a recursive ViewHelper inside!');
280 $this->assertEquals(preg_match($pattern,
'{f:for(arg1:arg1value, arg2: "bla\\"blubb")}'), 1,
'Object accessor not identified if there is an argument inside!');
281 $this->assertEquals(preg_match($pattern,
'{dash:value}'), 0,
'Object accessor identified, but was array!');
290 $this->assertEquals(preg_match($pattern,
'{a:b}'), 1,
'Array syntax not identified!');
291 $this->assertEquals(preg_match($pattern,
'{a:b, c : d}'), 1,
'Array syntax not identified in case there are multiple properties!');
292 $this->assertEquals(preg_match($pattern,
'{a : 123}'), 1,
'Array syntax not identified when a number is passed as argument!');
293 $this->assertEquals(preg_match($pattern,
'{a:"String"}'), 1,
'Array syntax not identified in case of a double quoted string!');
294 $this->assertEquals(preg_match($pattern,
'{a:\'String\'}'), 1,
'Array syntax not identified in case of a single quoted string!');
296 $expected =
'{a:{bla:{x:z}, b: a}}';
297 preg_match($pattern, $expected, $match);
298 $this->assertEquals($match[0], $expected,
'If nested arrays appear, the string is not parsed correctly.');
300 $expected =
'{a:"{bla{{}"}';
301 preg_match($pattern, $expected, $match);
302 $this->assertEquals($match[0], $expected,
'If nested strings with {} inside appear, the string is not parsed correctly.');
311 $source =
'{a: b, e: {c:d, e:f}}';
312 preg_match_all($pattern, $source, $matches, PREG_SET_ORDER);
317 'ArrayPart' =>
'a: b',
321 'QuotedString' =>
'',
323 'VariableIdentifier' =>
'b',
327 0 =>
'e: {c:d, e:f}',
328 'ArrayPart' =>
'e: {c:d, e:f}',
329 1 =>
'e: {c:d, e:f}',
332 'QuotedString' =>
'',
334 'VariableIdentifier' =>
'',
338 'Subarray' =>
'c:d, e:f',
342 $this->assertEquals($matches, $expected,
'The regular expression splitting the array apart does not work!');
352 $this->assertEquals(preg_match($pattern,
'<!-- Test -->'), 0,
'The SCAN_PATTERN_CDATA matches a comment, but it should not.');
353 $this->assertEquals(preg_match($pattern,
'<![CDATA[This is some ]]>'), 1,
'The SCAN_PATTERN_CDATA does not match a simple CDATA string.');
354 $this->assertEquals(preg_match($pattern,
'<![CDATA[This is<bla:test> some ]]>'), 1,
'The SCAN_PATTERN_CDATA does not match a CDATA string with tags inside..');
365 return str_replace(
'NAMESPACE', implode(
'|', $namespace), $regularExpression);
static $SCAN_PATTERN_SHORTHANDSYNTAX_OBJECTACCESSORS
static $SPLIT_PATTERN_TAGARGUMENTS
testSPLIT_PATTERN_SHORTHANDSYNTAX()
testSPLIT_PATTERN_SHORTHANDSYNTAX_ARRAY_PARTS()
static $SCAN_PATTERN_SHORTHANDSYNTAX_ARRAYS
testSCAN_PATTERN_SHORTHANDSYNTAX_OBJECTACCESSORS()
const NAMESPACE_SEPARATOR
testSCAN_PATTERN_SHORTHANDSYNTAX_ARRAYS()
testSCAN_PATTERN_NAMESPACEDECLARATION()
static $SCAN_PATTERN_CDATA
testSPLIT_PATTERN_TAGARGUMENTS()
testSCAN_PATTERN_CLOSINGDYNAMICTAG()
testSPLIT_PATTERN_SHORTHANDSYNTAX_VIEWHELPER()
static $SPLIT_PATTERN_SHORTHANDSYNTAX_ARRAY_PARTS
const LEGACY_NAMESPACE_SEPARATOR
testSPLIT_PATTERN_DYNAMICTAGS()
testSCAN_PATTERN_LEGACYNAMESPACEDECLARATION()
testSCAN_PATTERN_DYNAMICTAG()
insertNamespaceIntoRegularExpression($regularExpression, $namespace)
static $SPLIT_PATTERN_SHORTHANDSYNTAX_VIEWHELPER