Skip to content
This repository was archived by the owner on Apr 13, 2020. It is now read-only.

Commit 2a29ce7

Browse files
committed
3.1.12
1 parent 67f69a1 commit 2a29ce7

File tree

7 files changed

+342
-70
lines changed

7 files changed

+342
-70
lines changed

UnitTests/Compiler/Delimiter/DelimiterTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,14 @@ public function testDelimiter4()
6767
$this->assertEquals("hello world", $this->smarty->fetch($tpl));
6868
}
6969

70+
/**
71+
* test {= =} delimiter for conficts with option flags
72+
*/
73+
public function testDelimiter5()
74+
{
75+
$this->smarty->left_delimiter = '{=';
76+
$this->smarty->right_delimiter = '=}';
77+
$tpl = $this->smarty->createTemplate('eval:{=assign var=foo value="hello world" nocache=}{=$foo=}');
78+
$this->assertEquals("hello world", $this->smarty->fetch($tpl));
79+
}
7080
}

UnitTests/ResourceTests/File/FileResourceTest.php

Lines changed: 273 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,80 @@ public function testRelativeIncludeFailOtherDir()
235235
$this->fail('Exception for unknown relative filepath has not been raised.');
236236
}
237237

238+
/**
239+
*
240+
* @run InSeparateProcess
241+
* @preserveGlobalState disabled
242+
*
243+
*/
244+
public function testRelativeFetch()
245+
{
246+
$this->smarty->setTemplateDir(array(
247+
dirname(__FILE__) . '/does-not-exist/',
248+
dirname(__FILE__) . '/templates/sub/',
249+
));
250+
$this->smarty->security_policy = null;
251+
$this->assertEquals('hello world', $this->smarty->fetch('./relative.tpl'));
252+
}
253+
254+
/**
255+
*
256+
* @run InSeparateProcess
257+
* @preserveGlobalState disabled
258+
*
259+
*/
260+
public function testRelativeFetch2()
261+
{
262+
$this->smarty->setTemplateDir(array(
263+
dirname(__FILE__) . '/does-not-exist/',
264+
dirname(__FILE__) . '/templates/sub/',
265+
));
266+
$this->smarty->security_policy = null;
267+
$this->assertEquals('hello world', $this->smarty->fetch('../helloworld.tpl'));
268+
}
269+
270+
/**
271+
*
272+
* @run InSeparateProcess
273+
* @preserveGlobalState disabled
274+
*
275+
*/
276+
public function testRelativeFetchCwd()
277+
{
278+
$cwd = getcwd();
279+
chdir(dirname(__FILE__) . '/templates/sub/');
280+
$dn = dirname(__FILE__);
281+
$this->smarty->setCompileDir($dn . '/templates_c/');
282+
$this->smarty->setCacheDir($dn . '/cache/');
283+
$this->smarty->setTemplateDir(array(
284+
dirname(__FILE__) . '/does-not-exist/',
285+
));
286+
$this->smarty->security_policy = null;
287+
$this->assertEquals('hello world', $this->smarty->fetch('./relative.tpl'));
288+
chdir($cwd);
289+
}
290+
291+
/**
292+
*
293+
* @run InSeparateProcess
294+
* @preserveGlobalState disabled
295+
*
296+
*/
297+
public function testRelativeFetchCwd2()
298+
{
299+
$cwd = getcwd();
300+
chdir(dirname(__FILE__) . '/templates/sub/');
301+
$dn = dirname(__FILE__);
302+
$this->smarty->setCompileDir($dn . '/templates_c/');
303+
$this->smarty->setCacheDir($dn . '/cache/');
304+
$this->smarty->setTemplateDir(array(
305+
dirname(__FILE__) . '/does-not-exist/',
306+
));
307+
$this->smarty->security_policy = null;
308+
$this->assertEquals('hello world', $this->smarty->fetch('../helloworld.tpl'));
309+
chdir($cwd);
310+
}
311+
238312
protected function _relativeMap($map, $cwd = null)
239313
{
240314
foreach ($map as $file => $result) {
@@ -274,4 +348,203 @@ protected function _relativeMap($map, $cwd = null)
274348
chdir($cwd);
275349
}
276350
}
351+
352+
public function testRelativity()
353+
{
354+
$this->smarty->security_policy = null;
355+
356+
$cwd = getcwd();
357+
$dn = dirname(__FILE__);
358+
$this->smarty->setCompileDir($dn . '/templates_c/');
359+
$this->smarty->setCacheDir($dn . '/cache/');
360+
$this->smarty->setTemplateDir(array(
361+
$dn . '/templates/relativity/theory/',
362+
));
363+
364+
$map = array(
365+
'foo.tpl' => 'theory',
366+
'./foo.tpl' => 'theory',
367+
'././foo.tpl' => 'theory',
368+
'../foo.tpl' => 'relativity',
369+
'.././foo.tpl' => 'relativity',
370+
'./../foo.tpl' => 'relativity',
371+
'einstein/foo.tpl' => 'einstein',
372+
'./einstein/foo.tpl' => 'einstein',
373+
'../theory/einstein/foo.tpl' => 'einstein',
374+
'templates/relativity/relativity.tpl' => 'relativity',
375+
'./templates/relativity/relativity.tpl' => 'relativity',
376+
);
377+
378+
$this->_relativeMap($map);
379+
380+
$this->smarty->setTemplateDir(array(
381+
'templates/relativity/theory/',
382+
));
383+
384+
$map = array(
385+
'foo.tpl' => 'theory',
386+
'./foo.tpl' => 'theory',
387+
'././foo.tpl' => 'theory',
388+
'../foo.tpl' => 'relativity',
389+
'.././foo.tpl' => 'relativity',
390+
'./../foo.tpl' => 'relativity',
391+
'einstein/foo.tpl' => 'einstein',
392+
'./einstein/foo.tpl' => 'einstein',
393+
'../theory/einstein/foo.tpl' => 'einstein',
394+
'templates/relativity/relativity.tpl' => 'relativity',
395+
'./templates/relativity/relativity.tpl' => 'relativity',
396+
);
397+
398+
$this->_relativeMap($map);
399+
}
400+
401+
public function testRelativityCwd()
402+
{
403+
$this->smarty->security_policy = null;
404+
405+
$cwd = getcwd();
406+
$dn = dirname(__FILE__);
407+
408+
$this->smarty->setCompileDir($dn . '/templates_c/');
409+
$this->smarty->setCacheDir($dn . '/cache/');
410+
$this->smarty->setTemplateDir(array(
411+
$dn . '/templates/',
412+
));
413+
chdir($dn . '/templates/relativity/theory/');
414+
415+
$map = array(
416+
'foo.tpl' => 'theory',
417+
'./foo.tpl' => 'theory',
418+
'././foo.tpl' => 'theory',
419+
'../foo.tpl' => 'relativity',
420+
'.././foo.tpl' => 'relativity',
421+
'./../foo.tpl' => 'relativity',
422+
'einstein/foo.tpl' => 'einstein',
423+
'./einstein/foo.tpl' => 'einstein',
424+
'../theory/einstein/foo.tpl' => 'einstein',
425+
);
426+
427+
$this->_relativeMap($map, $cwd);
428+
}
429+
430+
public function testRelativityPrecedence()
431+
{
432+
$this->smarty->security_policy = null;
433+
434+
$cwd = getcwd();
435+
$dn = dirname(__FILE__);
436+
437+
$this->smarty->setCompileDir($dn . '/templates_c/');
438+
$this->smarty->setCacheDir($dn . '/cache/');
439+
$this->smarty->setTemplateDir(array(
440+
$dn . '/templates/relativity/theory/einstein/',
441+
));
442+
443+
$map = array(
444+
'foo.tpl' => 'einstein',
445+
'./foo.tpl' => 'einstein',
446+
'././foo.tpl' => 'einstein',
447+
'../foo.tpl' => 'theory',
448+
'.././foo.tpl' => 'theory',
449+
'./../foo.tpl' => 'theory',
450+
'../../foo.tpl' => 'relativity',
451+
);
452+
453+
chdir($dn . '/templates/relativity/theory/');
454+
$this->_relativeMap($map, $cwd);
455+
456+
$map = array(
457+
'../theory.tpl' => 'theory',
458+
'./theory.tpl' => 'theory',
459+
'../../relativity.tpl' => 'relativity',
460+
'../relativity.tpl' => 'relativity',
461+
'./einstein.tpl' => 'einstein',
462+
'einstein/einstein.tpl' => 'einstein',
463+
'./einstein/einstein.tpl' => 'einstein',
464+
);
465+
466+
chdir($dn . '/templates/relativity/theory/');
467+
$this->_relativeMap($map, $cwd);
468+
}
469+
470+
public function testRelativityRelRel()
471+
{
472+
$this->smarty->security_policy = null;
473+
474+
$cwd = getcwd();
475+
$dn = dirname(__FILE__);
476+
477+
$this->smarty->setCompileDir($dn . '/templates_c/');
478+
$this->smarty->setCacheDir($dn . '/cache/');
479+
$this->smarty->setTemplateDir(array(
480+
'../..',
481+
));
482+
483+
$map = array(
484+
'foo.tpl' => 'relativity',
485+
'./foo.tpl' => 'relativity',
486+
'././foo.tpl' => 'relativity',
487+
);
488+
489+
chdir($dn . '/templates/relativity/theory/einstein');
490+
$this->_relativeMap($map, $cwd);
491+
492+
$map = array(
493+
'relativity.tpl' => 'relativity',
494+
'./relativity.tpl' => 'relativity',
495+
'theory/theory.tpl' => 'theory',
496+
'./theory/theory.tpl' => 'theory',
497+
);
498+
499+
chdir($dn . '/templates/relativity/theory/einstein/');
500+
$this->_relativeMap($map, $cwd);
501+
502+
$map = array(
503+
'foo.tpl' => 'theory',
504+
'./foo.tpl' => 'theory',
505+
'theory.tpl' => 'theory',
506+
'./theory.tpl' => 'theory',
507+
'einstein/einstein.tpl' => 'einstein',
508+
'./einstein/einstein.tpl' => 'einstein',
509+
'../theory/einstein/einstein.tpl' => 'einstein',
510+
'../relativity.tpl' => 'relativity',
511+
'./../relativity.tpl' => 'relativity',
512+
'.././relativity.tpl' => 'relativity',
513+
);
514+
515+
$this->smarty->setTemplateDir(array(
516+
'..',
517+
));
518+
chdir($dn . '/templates/relativity/theory/einstein/');
519+
$this->_relativeMap($map, $cwd);
520+
}
521+
522+
public function testRelativityRelRel1()
523+
{
524+
$this->smarty->security_policy = null;
525+
526+
$cwd = getcwd();
527+
$dn = dirname(__FILE__);
528+
$this->smarty->setCompileDir($dn . '/templates_c/');
529+
$this->smarty->setCacheDir($dn . '/cache/');
530+
$this->smarty->setTemplateDir(array(
531+
'..',
532+
));
533+
534+
$map = array(
535+
'foo.tpl' => 'theory',
536+
'./foo.tpl' => 'theory',
537+
'theory.tpl' => 'theory',
538+
'./theory.tpl' => 'theory',
539+
'einstein/einstein.tpl' => 'einstein',
540+
'./einstein/einstein.tpl' => 'einstein',
541+
'../theory/einstein/einstein.tpl' => 'einstein',
542+
'../relativity.tpl' => 'relativity',
543+
'./../relativity.tpl' => 'relativity',
544+
'.././relativity.tpl' => 'relativity',
545+
);
546+
547+
chdir($dn . '/templates/relativity/theory/einstein/');
548+
$this->_relativeMap($map, $cwd);
549+
}
277550
}

UnitTests/TemplateSource/TagTests/BockExtend/CompileBlockExtendsTest.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,17 @@ public function testCompileBlockChildNestedHide_018()
202202
$this->assertNotContains('should be hidden', $result);
203203
}
204204

205+
/**
206+
* test nested child block with hide and auto_literal = false
207+
*/
208+
public function testCompileBlockChildNestedHideAutoLiteralFalse_019()
209+
{
210+
$this->smarty->setAutoLiteral(false);
211+
$result = $this->smarty->fetch('019_child_nested_hide_autoliteral.tpl');
212+
$this->assertContains('nested block', $result);
213+
$this->assertNotContains('should be hidden', $result);
214+
}
215+
205216
/**
206217
* test child/parent template chain starting in subtempates
207218
*/
@@ -321,7 +332,7 @@ public function testNotExistingChildBlock_024()
321332

322333
/**
323334
* @expectedException SmartyCompilerException
324-
* @expectedExceptionMessage Syntax Error in template ".\templates\025_parent.tpl"
335+
* @expectedExceptionMessage Syntax Error in template ".\templates\025_parent.tpl"
325336
* @expectedExceptionMessage {$smarty.block.child} used out of context
326337
* test {$this->smarty.block.child} outside {block]
327338
*/
@@ -332,7 +343,7 @@ public function testSmartyBlockChildOutsideBlock_025()
332343

333344
/**
334345
* @expectedException SmartyCompilerException
335-
* @expectedExceptionMessage Syntax Error in template ".\templates\026_parent.tpl"
346+
* @expectedExceptionMessage Syntax Error in template ".\templates\026_parent.tpl"
336347
* @expectedExceptionMessage $smarty.block is invalid
337348
* test {$this->smarty.block.parent} outside {block]
338349
*/
@@ -343,7 +354,7 @@ public function testSmartyBlockParentOutsideBlock_026()
343354

344355
/**
345356
* @expectedException SmartyCompilerException
346-
* @expectedExceptionMessage Syntax Error in template ".\templates\027_parent.tpl"
357+
* @expectedExceptionMessage Syntax Error in template ".\templates\027_parent.tpl"
347358
* @expectedExceptionMessage $smarty.block is invalid
348359
* test {$this->smarty.block.parent} in parent template
349360
*/

0 commit comments

Comments
 (0)