mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
Update spacing tests
This commit is contained in:
@@ -26,67 +26,54 @@ class CommentsTest extends PHPUnit_Smarty
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test simple comments
|
* Test comments
|
||||||
|
*
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
* @dataProvider dataTestComments
|
||||||
*/
|
*/
|
||||||
public function testSimpleComment1()
|
public function testComments($code, $result, $testName, $testNumber)
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate("eval:{* this is a comment *}");
|
$name = empty($testName) ? $testNumber : $testName;
|
||||||
$this->assertEquals("", $this->smarty->fetch($tpl));
|
$file = "testComments_{$name}.tpl";
|
||||||
|
$this->makeTemplateFile($file, $code);
|
||||||
|
$this->smarty->template_dir = './templates_tmp';
|
||||||
|
$this->assertEquals($result,
|
||||||
|
$this->smarty->fetch($file),
|
||||||
|
$file);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSimpleComment2()
|
/*
|
||||||
{
|
* Data provider für testComments
|
||||||
$tpl = $this->smarty->createTemplate("eval:{* another \$foo comment *}");
|
|
||||||
$this->assertEquals("", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testSimpleComment3()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate("eval:{* another comment *}some in between{* another comment *}");
|
|
||||||
$this->assertEquals("some in between", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testSimpleComment4()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate("eval:{* multi line \n comment *}");
|
|
||||||
$this->assertEquals("", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testSimpleComment5()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate("eval:{* /* foo * / *}");
|
|
||||||
$this->assertEquals("", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* test comment text combinations
|
|
||||||
*/
|
*/
|
||||||
public function testTextComment1()
|
public function dataTestComments()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate("eval:A{* comment *}B\nC");
|
$i = 1;
|
||||||
$this->assertEquals("AB\nC", $this->smarty->fetch($tpl));
|
/*
|
||||||
|
* Code
|
||||||
|
* result
|
||||||
|
* test name
|
||||||
|
* test number
|
||||||
|
*/
|
||||||
|
return array(array('{* this is a comment *}', '', 'T1', $i++),
|
||||||
|
array('{* another $foo comment *}', '', 'T2', $i++),
|
||||||
|
array('{* another comment *}some in between{* another comment *}', 'some in between',
|
||||||
|
'T3', $i++),
|
||||||
|
array("{* multi line \n comment *}", '', 'T4', $i++),
|
||||||
|
array('{* /* foo * / *}', '', 'T5', $i++),
|
||||||
|
array("A{* comment *}B\nC", "AB\nC", 'T6', $i++),
|
||||||
|
array("D{* comment *}\n{* comment *}E\nF", "DE\nF", 'T7', $i++),
|
||||||
|
array("G{* multi \nline *}H", "GH", 'T8', $i++),
|
||||||
|
array("I{* multi \nline *}\nJ", "IJ", 'T9', $i++),
|
||||||
|
array("=\n{* comment *}\n{* comment *}\n b\n{* comment *}\n{* comment *}\n=", "=\n b\n=", 'T10', $i++),
|
||||||
|
array("=\na\n{* comment 1 *}\n{* comment 2 *}\n{* comment 3 *}\nb\n=", "=\na\nb\n=", 'T11', $i++),
|
||||||
|
array("=\na\n{* comment 1 *}\n {* comment 2 *}\n{* comment 3 *}\nb\n=", "=\na\n b\n=", 'T12', $i++),
|
||||||
|
array("=\na\n{* comment 1 *}\n{* comment 2 *} \n{* comment 3 *}\nb\n=", "=\na\n \nb\n=", 'T13', $i++),
|
||||||
|
array("=\na\n{* comment 1 *}\n {* comment 2 *} \n{* comment 3 *}\nb\n=", "=\na\n \nb\n=", 'T14', $i++),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testTextComment2()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate("eval:D{* comment *}\n{* comment *}E\nF");
|
|
||||||
$this->assertEquals("D\nE\nF", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testTextComment3()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate("eval:G{* multi \nline *}H");
|
|
||||||
$this->assertEquals("GH", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testTextComment4()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate("eval:I{* multi \nline *}\nJ");
|
|
||||||
$this->assertEquals("I\nJ", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
public function testTextComment5()
|
public function testTextComment5()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate("longcomment.tpl");
|
$this->assertEquals("IJ", $this->smarty->fetch("longcomment.tpl"), 'Comments longcomment.tpl');
|
||||||
$this->assertEquals("I\nJ", $this->smarty->fetch($tpl));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -35,14 +35,4 @@ class CompileSetfilterTest extends PHPUnit_Smarty
|
|||||||
$tpl->assign('foo', '<a@b.c>');
|
$tpl->assign('foo', '<a@b.c>');
|
||||||
$this->assertEquals("<a@b.c> <a@b.c> <a [AT] b [DOT] c> <a@b.c> <a@b.c>", $this->smarty->fetch($tpl));
|
$this->assertEquals("<a@b.c> <a@b.c> <a [AT] b [DOT] c> <a@b.c> <a@b.c>", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @runInSeparateProcess
|
|
||||||
* @preserveGlobalState disabled
|
|
||||||
*/
|
|
||||||
public function testNestedSetfilter2()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('string:{$foo}{setfilter htmlspecialchars} {$foo}{setfilter escape:"mail"} {$foo}{/setfilter} {$foo}{/setfilter} {$foo}');
|
|
||||||
$tpl->assign('foo', '<a@b.c>');
|
|
||||||
$this->assertEquals("<a@b.c> <a@b.c> <a [AT] b [DOT] c> <a@b.c> <a@b.c>", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,69 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Smarty PHPunit tests compiler errors
|
||||||
|
*
|
||||||
|
* @package PHPunit
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* class for compiler tests
|
||||||
|
*
|
||||||
|
* @runTestsInSeparateProcess
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
* @backupStaticAttributes enabled
|
||||||
|
*/
|
||||||
|
class NewlineSpacing extends PHPUnit_Smarty
|
||||||
|
{
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
$this->setUpSmarty(dirname(__FILE__));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testInit()
|
||||||
|
{
|
||||||
|
$this->cleanDirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test spacings
|
||||||
|
*
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
* @dataProvider dataTestSpacing
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*/
|
||||||
|
public function testSpacing($code, $result, $testName, $testNumber)
|
||||||
|
{
|
||||||
|
$name = empty($testName) ? $testNumber : $testName;
|
||||||
|
$file = "Spacing_{$name}.tpl";
|
||||||
|
$this->makeTemplateFile($file, $code);
|
||||||
|
$this->smarty->template_dir = './templates_tmp';
|
||||||
|
$this->smarty->assign('file', $file);
|
||||||
|
$this->smarty->assign('foo', 'bar');
|
||||||
|
$this->assertEquals($result,
|
||||||
|
$this->smarty->fetch($file),
|
||||||
|
$file);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Data provider für testSpacing
|
||||||
|
*/
|
||||||
|
public function dataTestSpacing()
|
||||||
|
{
|
||||||
|
$i = 1;
|
||||||
|
/*
|
||||||
|
* Code
|
||||||
|
* result
|
||||||
|
* test name
|
||||||
|
* test number
|
||||||
|
*/
|
||||||
|
return array(
|
||||||
|
array("=====================\n{if true}\n{foreach from=array(1) item='i'}\n <htmltag />\n{/foreach}\n{/if}\n=====================", "=====================\n <htmltag />\n=====================", 'T1', $i++),
|
||||||
|
array("=====================\n{if true}\n{if true}\n <htmltag />\n{/if}\n{/if}\n=====================", "=====================\n <htmltag />\n=====================", 'T2', $i++),
|
||||||
|
array("=====================\n{* comment *}\n{* comment *}\n <htmltag />\n{* comment *}\n{* comment *}\n=====================", "=====================\n <htmltag />\n=====================", 'T3', $i++),
|
||||||
|
array("=====================\na\n{* comment 1 *}\n{* comment 2 *}\n{* comment 3 *}\nb\n=====================", "=====================\na\nb\n=====================", 'T4', $i++),
|
||||||
|
array("=====================\na\nb{if true}\nd<span></span>\nf{/if}\nh\n=====================", "=====================\na\nbd<span></span>\nfh\n=====================", 'T5', $i++),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
1
tests/UnitTests/TemplateSource/_Issues/topic26878/cache/dummy.txt
vendored
Normal file
1
tests/UnitTests/TemplateSource/_Issues/topic26878/cache/dummy.txt
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
dummy
|
@@ -0,0 +1 @@
|
|||||||
|
dummy
|
@@ -0,0 +1 @@
|
|||||||
|
dummy
|
Reference in New Issue
Block a user