diff options
| author | Simon Wisselink <wisskid@users.noreply.github.com> | 2020-04-13 15:30:52 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-13 15:30:52 +0200 |
| commit | 17d4d43624f9cd183ae0395854f4409c410e3ce9 (patch) | |
| tree | e0e6e3a63b8012267e02240e259da56542e1a911 /tests/UnitTests/TemplateSource | |
| parent | 61e741280786d6dbe106fc14690a00d87019de96 (diff) | |
| download | smarty-17d4d43624f9cd183ae0395854f4409c410e3ce9.tar.gz smarty-17d4d43624f9cd183ae0395854f4409c410e3ce9.tar.bz2 smarty-17d4d43624f9cd183ae0395854f4409c410e3ce9.zip | |
Feature/merge smarty-phpunit into tests subfolder (#580)
* Removed unneeded files and replace dummy.txt with .gitignore files
* Synced unit tests with master codebase, noted TODO's, fixed phpunit scripts and travis config
* fix php7.4 deprecation and remove php7.4 from travis allow_failures since php7.4 is current stable
Co-authored-by: Uwe Tews <uwe.tews@googlemail.com>
Co-authored-by: Uwe Tews <uwe.tews@gmail.com>
Co-authored-by: AnrDaemon <anrdaemon@yandex.ru>
Diffstat (limited to 'tests/UnitTests/TemplateSource')
513 files changed, 14886 insertions, 0 deletions
diff --git a/tests/UnitTests/TemplateSource/Comments/CommentsTest.php b/tests/UnitTests/TemplateSource/Comments/CommentsTest.php new file mode 100644 index 00000000..281b5aec --- /dev/null +++ b/tests/UnitTests/TemplateSource/Comments/CommentsTest.php @@ -0,0 +1,79 @@ +<?php +/** + * Smarty PHPunit tests comments in templates + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for security test + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class CommentsTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * Test comments + * + * @preserveGlobalState disabled + * @dataProvider dataTestComments + */ + public function testComments($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "testComments_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->template_dir = './templates_tmp'; + $this->assertEquals($result, + $this->smarty->fetch($file), + $file); + } + + /* + * Data provider für testComments + */ + public function dataTestComments() + { + $i = 1; + /* + * 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 testTextComment5() + { + $this->assertEquals("IJ", $this->smarty->fetch("longcomment.tpl"), 'Comments longcomment.tpl'); + } +} diff --git a/tests/UnitTests/TemplateSource/Comments/cache/.gitignore b/tests/UnitTests/TemplateSource/Comments/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/Comments/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/Comments/templates/longcomment.tpl b/tests/UnitTests/TemplateSource/Comments/templates/longcomment.tpl new file mode 100644 index 00000000..8fa2edfc --- /dev/null +++ b/tests/UnitTests/TemplateSource/Comments/templates/longcomment.tpl @@ -0,0 +1,225 @@ +I{* + +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> +<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut diam diam. Aenean sodales ligula at tincidunt posuere. Curabitur pharetra hendrerit ligula quis consectetur. Pellentesque vehicula lorem tincidunt turpis porttitor, a adipiscing sem fermentum. Phasellus at vestibulum nisi. Nulla ut pretium eros. Aenean bibendum ante in quam tincidunt volutpat.</p> + +*} +J
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/Comments/templates_c/.gitignore b/tests/UnitTests/TemplateSource/Comments/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/Comments/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/Spacing/SpacingTest.php b/tests/UnitTests/TemplateSource/Spacing/SpacingTest.php new file mode 100644 index 00000000..bfcb7495 --- /dev/null +++ b/tests/UnitTests/TemplateSource/Spacing/SpacingTest.php @@ -0,0 +1,77 @@ +<?php +/** + * Smarty PHPunit tests spacing in template output + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for spacing test + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class SpacingTest 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('{$foo}', 'bar', 'T1', $i++), + array('{$foo}{$foo}', 'barbar', 'T2', $i++), + array('A{$foo}{$foo}B', 'AbarbarB', 'T3', $i++), + array('{$foo} {$foo}', 'bar bar', 'T4', $i++), + array('A{$foo}B', 'AbarB', 'T5', $i++), + array('A{counter}B', 'A1B', 'T6', $i++), + array('A {$foo}B', 'A barB', 'T7', $i++), + array('A{$foo} B', 'Abar B', 'T8', $i++), + array("A{\$foo}\nB", "Abar\nB", 'T9', $i++), + array("A{counter start=1}\nB", "A1\nB", 'T10', $i++), + array("A{\$foo}B\nC", "AbarB\nC", 'T11', $i++), + array("A{assign var=zoo value='blah'}B", "AB", 'T12', $i++), + array("A\n{assign var=zoo value='blah'}\nB", "A\nB", 'T13', $i++), + array("E{assign var=zoo value='blah'}\nF", "EF", 'T14', $i++), + array("G\n{assign var=zoo value='blah'}H", "G\nH", 'T15', $i++), + ); + } +} diff --git a/tests/UnitTests/TemplateSource/Spacing/cache/.gitignore b/tests/UnitTests/TemplateSource/Spacing/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/Spacing/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/Spacing/templates_c/.gitignore b/tests/UnitTests/TemplateSource/Spacing/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/Spacing/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/Spacing/templates_tmp/.gitignore b/tests/UnitTests/TemplateSource/Spacing/templates_tmp/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/Spacing/templates_tmp/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/StaticClass/StaticClassAccessTest.php b/tests/UnitTests/TemplateSource/StaticClass/StaticClassAccessTest.php new file mode 100644 index 00000000..42d9f0ce --- /dev/null +++ b/tests/UnitTests/TemplateSource/StaticClass/StaticClassAccessTest.php @@ -0,0 +1,136 @@ +<?php +/** + * Smarty PHPunit tests static class access to constants, variables and methods + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for static class access to constants, variables and methods tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class StaticClassAccessTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + $this->smarty->disableSecurity(); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test static class variable + */ + public function testStaticClassVariable() + { + $tpl = $this->smarty->createTemplate('eval:{mystaticclass::$static_var}'); + $this->assertEquals('5', $this->smarty->fetch($tpl)); + } + + /** + * test registered static class variable + */ + public function testStaticRegisteredClassVariable() + { + $this->smarty->registerClass('registeredclass', 'mystaticclass'); + $tpl = $this->smarty->createTemplate('eval:{registeredclass::$static_var}'); + $this->assertEquals('5', $this->smarty->fetch($tpl)); + } + + /** + * test static class constant + */ + public function testStaticClassConstant() + { + $tpl = $this->smarty->createTemplate('eval:{mystaticclass::STATIC_CONSTANT_VALUE}'); + $this->assertEquals('3', $this->smarty->fetch($tpl)); + } + + /** + * test static class constant + */ + public function testRegisteredStaticClassConstant() + { + $this->smarty->registerClass('registeredclass', 'mystaticclass'); + $tpl = $this->smarty->createTemplate('eval:{registeredclass::STATIC_CONSTANT_VALUE}'); + $this->assertEquals('3', $this->smarty->fetch($tpl)); + } + + /** + * test static class method + */ + public function testStaticClassmethod() + { + $tpl = $this->smarty->createTemplate('eval:{mystaticclass::square(5)}'); + $this->assertEquals('25', $this->smarty->fetch($tpl)); + } + + /** + * test static class method + */ + public function testRegisteredStaticClassmethod() + { + $this->smarty->registerClass('registeredclass', 'mystaticclass'); + $tpl = $this->smarty->createTemplate('eval:{registeredclass::square(5)}'); + $this->assertEquals('25', $this->smarty->fetch($tpl)); + } + + /** + * test static class variable method + */ + public function testStaticClassVariablemethod() + { + $tpl = $this->smarty->createTemplate('eval:{$foo=\'square\'}{mystaticclass::$foo(5)}'); + $this->assertEquals('25', $this->smarty->fetch($tpl)); + } + + /** + * test registered static class variable method + */ + public function testRegisteredStaticClassVariablemethod() + { + $this->smarty->registerClass('registeredclass', 'mystaticclass'); + $tpl = $this->smarty->createTemplate('eval:{$foo=\'square\'}{registeredclass::$foo(5)}'); + $this->assertEquals('25', $this->smarty->fetch($tpl)); + } + + /** + * test static class variable method + */ + public function testStaticClassVariablemethod2() + { + $tpl = $this->smarty->createTemplate('eval:{mystaticclass::$foo(5)}'); + $tpl->assign('foo', 'square'); + $this->assertEquals('25', $this->smarty->fetch($tpl)); + } + + /** + * test registered static class variable method + */ + public function testRegisteredStaticClassVariablemethod2() + { + $this->smarty->registerClass('registeredclass', 'mystaticclass'); + $tpl = $this->smarty->createTemplate('eval:{registeredclass::$foo(5)}'); + $tpl->assign('foo', 'square'); + $this->assertEquals('25', $this->smarty->fetch($tpl)); + } +} + +class mystaticclass +{ + const STATIC_CONSTANT_VALUE = 3; + static $static_var = 5; + + static function square($i) + { + return $i * $i; + } +} diff --git a/tests/UnitTests/TemplateSource/StaticClass/cache/.gitignore b/tests/UnitTests/TemplateSource/StaticClass/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/StaticClass/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/StaticClass/templates_c/.gitignore b/tests/UnitTests/TemplateSource/StaticClass/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/StaticClass/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Append/CompileAppendTest.php b/tests/UnitTests/TemplateSource/TagTests/Append/CompileAppendTest.php new file mode 100644 index 00000000..1c671f15 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Append/CompileAppendTest.php @@ -0,0 +1,149 @@ +<?php +/** + * Smarty PHPunit tests compilation of append tags + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for append tags tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class CompileAppendTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); + $this->smarty->addTemplateDir("../../../__shared/templates/"); + $this->smarty->addTemplateDir("./templates_tmp"); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * Test {append} tags + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestAppend + */ + public function testAppend($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Append_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->assignGlobal('file', $file); + $this->assertEquals($result, $this->smarty->fetch($file), "testAppend - {$code} - {$testName}"); + } + + /* + * Data provider für testAppend + */ + public function dataTestAppend() + { + $i = 0; + /* + * Code + * result + * test name + */ + return array(// old format + array('{$foo=1}{append var=foo value=2}{$foo|var_export:true}', var_export(array(0=>1,1=>2,),true), '', $i ++), + array('{$foo[\'i\']=1}{append var=foo value=2 index=\'j\'}{$foo|var_export:true}', var_export(array('i'=>1,'j'=>2,),true), '', $i ++), + array('{$bar=\'j\'}{$foo[\'i\']=1}{append var=foo value=2 index=$bar}{$foo|var_export:true}', var_export(array('i'=>1,'j'=>2,),true), '', $i ++), + array('{append var=foo value=2}{$foo|var_export:true}', var_export(array(0=>2,),true), '', $i ++), + array('{append foo value=3}{$foo|var_export:true}', var_export(array(0=>3,),true), '', $i ++), + array('{append foo 5}{$foo|var_export:true}', var_export(array(0=>5,),true), '', $i ++), // new format + array('{$foo[]=2}{$foo|var_export:true}', var_export(array(0=>2,),true), '', $i ++), + ); + } + + /** + * Test Assign spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestSpacing + * @runInSeparateProcess + */ + public function testAppendSpacing($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Spacing_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'bar'); + $this->assertEquals($result, + $this->smarty->fetch($file), + "testSpacing - {$file}"); + } + /** + * Test Append nocache spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestSpacing + * @runInSeparateProcess + */ + public function testAppendSpacingNocache($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Spacing_{$name}.tpl"; + $this->smarty->setCompileId('1'); + $this->smarty->setCaching(1); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'bar',true); + $this->assertEquals($result, + $this->smarty->fetch($file), + "testSpacing - {$file}"); + } + /** + * Test Append nocache spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestSpacing + * @runInSeparateProcess + */ + public function testAppendSpacingNocache2($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Spacing_{$name}.tpl"; + $this->smarty->setCompileId('1'); + $this->smarty->setCaching(1); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'foo',true); + $this->assertEquals(str_replace('bar','foo',$result), + $this->smarty->fetch($file), + "testSpacing - {$file}"); + } + + /* + * Data provider für testSpacing + */ + public function dataTestSpacing() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array( + array("A{append var=buh value=\$foo}B{\$buh[0]}", "ABbar", 'Text', $i++), + array("A\n{append var=buh value=\$foo}\nB{\$buh[0]}", "A\nBbar", 'Newline1', $i++), + array("E{append var=buh value=\$foo}\nF{\$buh[0]}", "EFbar", 'Newline2', $i++), + array("G\n{append var=buh value=\$foo}H{\$buh[0]}", "G\nHbar", 'Newline3', $i++), + array("A{\$buh[]=\$foo}B{\$buh[0]}", "ABbar", '2_Text', $i++), + array("A\n{\$buh[]=\$foo}\nB{\$buh[0]}", "A\nBbar", '2_Newline1', $i++), + array("E{\$buh[]=\$foo}\nF{\$buh[0]}", "EFbar", '2_Newline2', $i++), + array("G\n{\$buh[]=\$foo}H{\$buh[0]}", "G\nHbar", '2_Newline3', $i++), + ); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/Append/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Append/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Append/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Append/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Append/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Append/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Append/templates_tmp/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Append/templates_tmp/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Append/templates_tmp/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Assign/CompileAssignTest.php b/tests/UnitTests/TemplateSource/TagTests/Assign/CompileAssignTest.php new file mode 100644 index 00000000..b4301d59 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Assign/CompileAssignTest.php @@ -0,0 +1,168 @@ +<?php +/** + * Smarty PHPunit tests compilation of assign tags + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for assign tags tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class CompileAssignTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); + $this->smarty->addTemplateDir("../../../__shared/templates/"); + $this->smarty->addTemplateDir("./templates_tmp"); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * Test assign tags + * + * @not runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestAssign + */ + public function testAssign($code, $result, $testName, $testNumber) + { + $file = "Assign_{$testNumber}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->assignGlobal('file', $file); + $this->smarty->assign('bar', 'buh'); + $this->assertEquals($result, $this->smarty->fetch($file), "testAssign - {$code} - {$testName}"); + } + + /* + * Data provider für testAssign + */ + public function dataTestAssign() + { + $i = 1; + /* + * Code + * result + * test name + */ + return array(// old format + array('{assign var=foo value=1}{$foo}', '1', '', $i++), + array('{assign var=\'foo\' value=2}{$foo}', '2', '', $i++), + array('{assign var="foo" value=3}{$foo}', '3', '', $i++), + array('{assign var=foo value=$bar}{$foo}', 'buh', '', $i++), + array('{assign var=$bar value=11}{$buh}', '11', '', $i++), + array('{assign var=foo value=bar}{$foo}', 'bar', '', $i++), + array('{assign var=foo value=1+2}{$foo}', '3', '', $i++), + array('{assign var=foo value=strlen(\'barbuh\')}{$foo}', '6', '', $i++), + array('{assign var=foo value=\'barr\'|strlen}{$foo}', '4', '', $i++), + array('{assign var=foo value=[9,8,7,6]}{$foo|var_export:true}', + var_export(array(9, 8, 7, 6), true), '', $i++), + array( + '{assign var=foo value=[\'a\'=>9,\'b\'=>8,\'c\'=>7,\'d\'=>6]}{$foo|var_export:true}', + var_export(array('a' => 9, 'b' => 8, 'c' => 7, 'd' => 6,), true), '', $i++,), + array('{assign foo value=1}{$foo}', '1', '', $i++), + array('{assign foo 1}{$foo}', '1', '', $i++), + // new format + array('{$foo=1}{$foo}', '1', '', $i++), + array('{$foo =2}{$foo}', '2', '', $i++), + array('{$foo=bar}{$foo}', 'bar', '', $i++), + array('{$foo=1+2}{$foo}', '3', '', $i++), + array('{$foo = 1+3}{$foo}', '4', '', $i++), + array('{$foo = 1 + 4}{$foo}', '5', '', $i++), + array('{$foo=strlen(\'bar\')}{$foo}', '3', '', $i++), + array('{$foo=\'bar\'|strlen}{$foo}', '3', '', $i++), + array('{$foo[\'a\'][4]=1}{$foo[\'a\'][4]}', '1', '', $i++), + array('{$foo=[9,8,7,6]}{$foo|var_export:true}', var_export(array(9, 8, 7, 6), true), '', $i++), + array( + '{$foo=[\'a\'=>9,\'b\'=>8,\'c\'=>7,\'d\'=>6]}{$foo|var_export:true}', + var_export(array('a' => 9, 'b' => 8, 'c' => 7, 'd' => 6,), true), '', $i++), + ); + } + + /** + * Test Assign spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestSpacing + * @runInSeparateProcess + */ + public function testAssignSpacing($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Spacing_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'bar'); + $this->assertEquals($result, + $this->smarty->fetch($file), + "testSpacing - {$file}"); + } + /** + * Test Output nocache spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestSpacing + * @runInSeparateProcess + */ + public function testAssignSpacingNocache($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Spacing_{$name}.tpl"; + $this->smarty->setCompileId('1'); + $this->smarty->setCaching(1); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'bar',true); + $this->assertEquals($result, + $this->smarty->fetch($file), + "testSpacing - {$file}"); + } + /** + * Test Output nocache spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestSpacing + * @runInSeparateProcess + */ + public function testAssignSpacingNocache2($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Spacing_{$name}.tpl"; + $this->smarty->setCompileId('1'); + $this->smarty->setCaching(1); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'foo',true); + $this->assertEquals(str_replace('bar','foo',$result), + $this->smarty->fetch($file), + "testSpacing - {$file}"); + } + + /* + * Data provider für testSpacing + */ + public function dataTestSpacing() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array( + array("A{assign var=buh value=\$foo}B{\$buh}", "ABbar", 'Text1', $i++), + array("A\n{assign var=buh value=\$foo}\nB{\$buh}", "A\nBbar", 'Newline1', $i++), + array("E{assign var=buh value=\$foo}\nF{\$buh}", "EFbar", 'Newline2', $i++), + array("G\n{assign var=buh value=\$foo}H{\$buh}", "G\nHbar", 'Newline3', $i++), + ); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/Assign/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Assign/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Assign/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Assign/templates/test_scope_assignbar.tpl b/tests/UnitTests/TemplateSource/TagTests/Assign/templates/test_scope_assignbar.tpl new file mode 100644 index 00000000..c0be3a40 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Assign/templates/test_scope_assignbar.tpl @@ -0,0 +1 @@ +{$foo = $bar scope=global}{checkvar var=foo nocache}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Assign/templates/test_scope_assignnocache.tpl b/tests/UnitTests/TemplateSource/TagTests/Assign/templates/test_scope_assignnocache.tpl new file mode 100644 index 00000000..4bde90af --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Assign/templates/test_scope_assignnocache.tpl @@ -0,0 +1 @@ +{$foo = $buh scope=global nocache}{checkvar var=foo nocache}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Assign/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Assign/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Assign/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Assign/templates_tmp/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Assign/templates_tmp/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Assign/templates_tmp/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/CompileBlockPluginTest.php b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/CompileBlockPluginTest.php new file mode 100644 index 00000000..c6a2eee4 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/CompileBlockPluginTest.php @@ -0,0 +1,531 @@ +<?php +/** + * Smarty PHPunit tests compilation of block plugins + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for block plugin tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class CompileBlockPluginTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + $this->smarty->addPluginsDir("./PHPunitplugins/"); + $this->smarty->disableSecurity(); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * test block plugin tag + * + */ + public function testBlockPluginNoAssign() + { + $this->assertEquals("hello world", $this->smarty->fetch('no_assign.tpl')); + } + + /** + * test block plugin tag with assign attribute + * + */ + public function testBlockPluginAssign() + { + $this->assertEquals("hello world", $this->smarty->fetch('assign.tpl')); + } + + /** + * test unknown block plugin tag + * + * @expectedException SmartyCompilerException + * @expectedExceptionMessage unknown tag 'bar' + * + */ + public function testBlockPluginUnknown() + { + $this->assertEquals("hello world", $this->smarty->fetch('unknown.tpl')); + } + + /** + * test block plugin function definition in script + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testBlockPluginRegisteredFunction() + { + $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'blockplugintest', 'myblockplugintest'); + $this->assertEquals('block test', $this->smarty->fetch('registered.tpl')); + } + + /** + * test block plugin function definition in script + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @expectedException SmartyException + * @expectedExceptionMessage block tag 'blockplugintest' not callable + * + */ + public function testBlockPluginRegisteredFunction2() + { + $this->assertEquals('block test', $this->smarty->fetch('registered.tpl')); + } + + /** + * test block plugin static method + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testBlockPluginRegisteredStatic() + { + $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'blockpluginstatic', array('myblockclass1', 'staticfunc')); + $this->assertEquals('static block test', $this->smarty->fetch('registered_static.tpl')); + } + + /** + * test block plugin static method failure + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @expectedException SmartyException + * @expectedExceptionMessage block tag 'blockpluginstatic' not callable + * + */ + public function testBlockPluginRegisteredStatic2() + { + $this->assertEquals('static block test', $this->smarty->fetch('registered_static.tpl')); + } + + /** + * test block plugin object method + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testBlockPluginRegisteredMethod() + { + $object = new myblockclass1(); + $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'blockpluginmethod', array($object, 'methodfunc')); + $this->assertEquals('method block test', $this->smarty->fetch('registered_method.tpl')); + } + + /** + * test block plugin object method failure + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @expectedException SmartyException + * @expectedExceptionMessage block tag 'blockpluginmethod' not callable + * + */ + public function testBlockPluginRegisteredMethod2() + { + $this->assertEquals('method block test', $this->smarty->fetch('registered_method.tpl')); + } + + /** + * test block plugin registered object + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testBlockPluginRegisteredObject() + { + $object = new myblockclass1(); + $this->smarty->registerObject('myobject', $object, array(), true, array('objectfunc')); + $this->assertEquals('object block test', $this->smarty->fetch('registered_object.tpl')); + } + + /** + * test block plugin registered object failure + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @expectedException SmartyException + * @expectedExceptionMessage block tag 'myobject' not callable + * + */ + public function testBlockPluginRegisteredObject2() + { + $this->assertEquals('object block test', $this->smarty->fetch('registered_object.tpl')); + } + + /** + * test block plugin repeat function + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testBlockPluginRepeat() + { + $this->assertEquals('12345', $this->smarty->fetch('repeat.tpl')); + } + + /** + * test block plugin repeat function with modifier + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testBlockPluginRepeatModidier1() + { + $this->assertEquals('11111', $this->smarty->fetch('repeat_modifier.tpl')); + } + + /** + * test block plugin repeat function with modifier list + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testBlockPluginRepeatModidier2() + { + $this->assertEquals('11111', $this->smarty->fetch('repeat_modifier_2.tpl')); + } + + /** + * test block plugin with no output + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testBlockPluginNoOutput() + { + $this->assertEquals('default', $this->smarty->fetch('nooutput.tpl')); + } + + /** + * test nested block plugin + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testBlockPluginNested() + { + $this->assertEquals('hello world12345', $this->smarty->fetch('nested.tpl')); + } + + /** + * test default block plugin + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testBlockPluginDefault1() + { + $this->smarty->registerDefaultPluginHandler('my_block_plugin_handler'); + $this->assertEquals('scriptblock hello world', $this->smarty->fetch('default1.tpl')); + } + + /** + * test default block plugin + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testBlockPluginDefault2() + { + $this->smarty->registerDefaultPluginHandler('my_block_plugin_handler'); + $this->assertEquals('defaultblock hello world', $this->smarty->fetch('default2.tpl')); + } + + /** + * test tag stack + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testBlockPluginTagStack() + { + $this->assertEquals('noop-teststack', $this->smarty->fetch('tag_stack.tpl')); + $this->assertEmpty($this->smarty->_cache[ '_tag_stack' ]); + } + + /** + * Test caching + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + * + */ + public function testCache($isCached, + $caching, + $cachable, + $testNumber, + $compileTestNumber, + $renderTestNumber, + $resultNumber, + $nocache, + $compileid, + $testName) + { + $this->smarty->registerFilter('pre', array($this, 'prefilterTest')); + $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'cachetest', 'myblockplugintest2', $cachable); + $this->smarty->compile_id = $compileid; + $this->smarty->caching = $caching; + $this->smarty->cache_lifetime = 1000; + $this->smarty->assign('test', $testNumber); + $this->smarty->assign('var', $testNumber, $nocache); + $tpl = $this->smarty->createTemplate('caching.tpl', null, null, $this->smarty); + if (isset($isCached)) { + $this->assertEquals($isCached, $tpl->isCached(), $testName . ' - isCached()'); + } + $result = $this->smarty->fetch($tpl); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", + $result, + $testName . ' - fetch() failure test number'); + $this->assertContains("block test{$resultNumber}", $result, $testName . ' - fetch() failure result'); + } + + public function data() + { + return array(array(false, false, false, 1, 1, 1, 1, false, 0, 'no cacheing'), + array(false, false, false, 2, 1, 2, 2, false, 0, 'no cacheing'), + array(false, false, true, 3, 3, 3, 3, false, 1, 'cacheable'), + array(false, true, true, 4, 4, 4, 4, false, 1, 'cachable Caching'), + array(true, true, true, 5, 4, 4, 4, false, 1, 'cachable isCached'), + array(true, true, true, 6, 4, 4, 4, false, 1, 'cachable isCached'), + array(false, true, false, 7, 7, 7, 7, false, 2, 'not cachable'), + array(true, true, false, 8, 7, 7, 8, false, 2, 'not cachable isCached'), + array(true, true, false, 9, 7, 7, 9, false, 2, 'not cachable isCached'), + array(false, true, true, 10, 10, 10, 10, true, 3, 'not cachable nocache var'), + array(true, true, true, 11, 10, 10, 11, true, 3, 'not cachable isCached'), + array(true, true, true, 12, 10, 10, 12, true, 3, 'not cachable isCached'),); + } + + /** + * Test spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestSpacing + * @runInSeparateProcess + */ + public function testSpacing($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "testSpacing_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'bar'); + $this->assertEquals($result, + $this->smarty->fetch($file), + "testSpacing - {$file}"); + } + + /* + * Data provider für testSpacing + */ + public function dataTestSpacing() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array(array("A{noop}\nB{/noop}C", "ABC", 'Newline1', $i++), + array("A{noop}\nB\n{/noop}C", "AB\nC", 'Newline2', $i++), + array("A{noop}\nB{/noop}\nC", "ABC", 'Newline3', $i++), + array("A\n{noop}\nB\n{/noop}\nC", "A\nB\nC", 'Newline4', $i++), + array("A{noop}\n{\$foo}{/noop}C", "AbarC", 'Var1', $i++), + array("A{noop}\n{\$foo}\n{/noop}C", "Abar\nC", 'Var2', $i++), + array("A{noop}\n{\$foo}{/noop}\nC", "AbarC", 'Var3', $i++), + array("A\n{noop}\n{\$foo}\n{/noop}\nC", "A\nbar\nC", 'Var4', $i++), + ); + } + /** + * Test spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestDefaultSpacing + * @runInSeparateProcess + */ + public function testSpacingDefault($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "testSpacing_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->registerDefaultPluginHandler('my_block_plugin_handler'); + $this->smarty->compile_id='default'; + $this->smarty->assign('foo', 'bar'); + $this->assertEquals($result, + $this->smarty->fetch($file), + "testSpacing - {$file}"); + } + + /* + * Data provider für testSpacing + */ + public function dataTestDefaultSpacing() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array(array("A{scriptblock}\nB{/scriptblock}C", "Ascriptblock BC", 'Newline1', $i++), + array("A{scriptblock}\nB\n{/scriptblock}C", "Ascriptblock B\nC", 'Newline2', $i++), + array("A{scriptblock}\nB{/scriptblock}\nC", "Ascriptblock BC", 'Newline3', $i++), + array("A\n{scriptblock}\nB\n{/scriptblock}\nC", "A\nscriptblock B\nC", 'Newline4', $i++), + array("A{scriptblock}\n{\$foo}{/scriptblock}C", "Ascriptblock barC", 'Var1', $i++), + array("A{scriptblock}\n{\$foo}\n{/scriptblock}C", "Ascriptblock bar\nC", 'Var2', $i++), + array("A{scriptblock}\n{\$foo}{/scriptblock}\nC", "Ascriptblock barC", 'Var3', $i++), + array("A\n{scriptblock}\n{\$foo}\n{/scriptblock}\nC", "A\nscriptblock bar\nC", 'Var4', $i++), + ); + } + + /** + * Test nocache block spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestNocacheSpacing + * @runInSeparateProcess + */ + public function testBlockNocache($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Nocache_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->setCompileId('nocache'); + $this->smarty->setCaching(1); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('bar', 'bar',true); + $this->assertEquals($result, + $this->smarty->fetch($file), + "testNocache - {$file}"); + } + /** + * Test nocache block spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestNocacheSpacing + * @runInSeparateProcess + */ + public function testBlockNocache2($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Nocache_{$name}.tpl"; + $this->smarty->setCompileId('nocache'); + $this->smarty->setCaching(1); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('bar', 'foo',true); + $this->assertEquals(str_replace('bar','foo',$result), + $this->smarty->fetch($file), + "testNocache2 - {$file}"); + } + + /* + * Data provider für testSpacing + */ + public function dataTestNocacheSpacing() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array(array("A{testparameter value=\$bar}\n{\$foo}{/testparameter}C", "AbarC", 'Var1', $i++), + array("A{testparameter value=\$bar}\n{\$foo}\n{/testparameter}C", "Abar\nC", 'Var2', $i++), + array("A{testparameter value=\$bar}\n{\$foo}{/testparameter}\nC", "AbarC", 'Var3', $i++), + array("A\n{testparameter value=\$bar}\n{\$foo}\n{/testparameter}\nC", "A\nbar\nC", 'Var4', $i++), + ); + } + +} +function myblockplugintest($params, $content, &$smarty_tpl, &$repeat) +{ + if (!$repeat) { + $output = str_replace('hello world', 'block test', $content); + + return $output; + } +} + +function myblockplugintest2($params, $content, &$smarty_tpl, &$repeat) +{ + if (!$repeat) { + $output = str_replace('hello world', "block test{$params['var']}", $content); + + return $output; + } +} + +class myblockclass1 +{ + static function staticfunc($params, $content, &$smarty_tpl, &$repeat) + { + if (!$repeat) { + $output = str_replace('hello world', 'static block test', $content); + return $output; + } + } + + public function methodfunc($params, $content, &$smarty_tpl, &$repeat) + { + if (!$repeat) { + $output = str_replace('hello world', 'method block test', $content); + return $output; + } + } + + public function objectfunc($params, $content, &$smarty_tpl, &$repeat) + { + if (!$repeat) { + $output = str_replace('hello world', 'object block test', $content); + return $output; + } + } +} + +function my_block_plugin_handler($tag, $type, $template, &$callback, &$script, &$cachable) +{ + switch ($type) { + case Smarty::PLUGIN_BLOCK: + switch ($tag) { + case 'scriptblock': + $script = './scripts/script_block_tag.php'; + $callback = 'default_script_block_tag'; + + return true; + default: + $script = './scripts/other_block_tag.php'; + $callback = 'default_block_tag'; + return true; + } + default: + return false; + } +} + diff --git a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/PHPunitplugins/block.noop.php b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/PHPunitplugins/block.noop.php new file mode 100644 index 00000000..0e163e59 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/PHPunitplugins/block.noop.php @@ -0,0 +1,24 @@ +<?php +/** + * Smarty plugin for testing block plugins + * + * @package Smarty + * @subpackage PHPunitPlugin + */ + +/** + * Smarty {noop}{/noop} block plugin + * + * @param array $params parameter array + * @param string $content contents of the block + * @param object $template template object + * @param bool $repeat flag + * + * @return string content re-formatted + */ +function smarty_block_noop($params, $content, $template, &$repeat) +{ + if (isset($content)) { + return $content; + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/PHPunitplugins/block.nooutput.php b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/PHPunitplugins/block.nooutput.php new file mode 100644 index 00000000..398c9a3b --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/PHPunitplugins/block.nooutput.php @@ -0,0 +1,24 @@ +<?php +/** + * Smarty plugin for testing block plugins + * + * @package Smarty + * @subpackage PHPunitPlugin + */ + +/** + * Smarty {nooutput}{/nooutput} block plugin + * + * @param array $params parameter array + * @param string $content contents of the block + * @param object $template template object + * @param bool $repeat flag + * + * @return string content re-formatted + */ +function smarty_block_nooutput($params, $content, $template, &$repeat) +{ + if (isset($content)) { + $repeat = false; + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/PHPunitplugins/block.testblock.php b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/PHPunitplugins/block.testblock.php new file mode 100644 index 00000000..63f1108a --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/PHPunitplugins/block.testblock.php @@ -0,0 +1,33 @@ +<?php +/** + * Smarty plugin for testing block plugins + * + * @package Smarty + * @subpackage PHPunitPlugin + */ + +/** + * Smarty {testblock}{/testblock} block plugin + * + * @param array $params parameter array + * @param string $content contents of the block + * @param object $template template object + * @param bool $repeat flag + * + * @return string content re-formatted + */ +function smarty_block_testblock($params, $content, $template, &$repeat) +{ + static $loop = 0; + if (isset($content)) { + $loop ++; + if ($loop < 5) { + $repeat = true; + } else { + $repeat = false; + } + return $loop; + } else { + $loop = 0; + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/PHPunitplugins/block.testparameter.php b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/PHPunitplugins/block.testparameter.php new file mode 100644 index 00000000..bdac3291 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/PHPunitplugins/block.testparameter.php @@ -0,0 +1,25 @@ +<?php +/** + * Smarty plugin for testing block plugins + * + * @package Smarty + * @subpackage PHPunitPlugin + */ +/** + * Smarty {testparameter}{/testparameter} block plugin + * + * @param array $params parameter array + * @param string $content contents of the block + * @param \Smarty_Internal_Template $template template object + * @param bool $repeat flag + * + * @return string content re-formatted + */ +function smarty_block_testparameter($params, $content, Smarty_Internal_Template $template, &$repeat) +{ + if (isset($content)) { + return $content; + } else { + $template->assign('foo', $params[ 'value' ]); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/PHPunitplugins/block.teststack.php b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/PHPunitplugins/block.teststack.php new file mode 100644 index 00000000..f1eef38d --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/PHPunitplugins/block.teststack.php @@ -0,0 +1,25 @@ +<?php +/** + * Smarty plugin for testing block plugins + * + * @package Smarty + * @subpackage PHPunitPlugin + */ + +/** + * Smarty {teststack}{/teststack} block plugin + * + * @param array $params parameter array + * @param string $content contents of the block + * @param object $template template object + * @param bool $repeat flag + * + * @return string content re-formatted + */ +function smarty_block_teststack($params, $content, $template, &$repeat) +{ + if (isset($content)) { + $stack = $template->smarty->_cache['_tag_stack']; + return $stack[0][0] . '-' . $stack[1][0]; + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/scripts/other_block_tag.php b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/scripts/other_block_tag.php new file mode 100644 index 00000000..29cf94b4 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/scripts/other_block_tag.php @@ -0,0 +1,7 @@ +<?php +function default_block_tag($params, $content, $template, &$repeat) +{ + if (isset($content)) { + return 'defaultblock ' . $content; + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/scripts/script_block_tag.php b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/scripts/script_block_tag.php new file mode 100644 index 00000000..a61f14d6 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/scripts/script_block_tag.php @@ -0,0 +1,7 @@ +<?php +function default_script_block_tag($params, $content, $template, &$repeat) +{ + if (isset($content)) { + return 'scriptblock ' . $content; + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/assign.tpl b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/assign.tpl new file mode 100644 index 00000000..48273727 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/assign.tpl @@ -0,0 +1 @@ +{textformat assign=foo}hello world{/textformat}{$foo}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/caching.tpl b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/caching.tpl new file mode 100644 index 00000000..4384230d --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/caching.tpl @@ -0,0 +1 @@ +#test#{cachetest var=$var}hello world{/cachetest}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/default1.tpl b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/default1.tpl new file mode 100644 index 00000000..e4c3aa88 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/default1.tpl @@ -0,0 +1 @@ +{scriptblock}hello world{/scriptblock}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/default2.tpl b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/default2.tpl new file mode 100644 index 00000000..63e069f1 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/default2.tpl @@ -0,0 +1 @@ +{foo}hello world{/foo}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/nested.tpl b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/nested.tpl new file mode 100644 index 00000000..ab13b77b --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/nested.tpl @@ -0,0 +1 @@ +{textformat assign=foo}hello world{testblock}{/testblock}{/textformat}{$foo}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/no_assign.tpl b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/no_assign.tpl new file mode 100644 index 00000000..4137bdf1 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/no_assign.tpl @@ -0,0 +1 @@ +{textformat}hello world{/textformat}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/nooutput.tpl b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/nooutput.tpl new file mode 100644 index 00000000..f287b5aa --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/nooutput.tpl @@ -0,0 +1 @@ +{nooutput}{/nooutput|default:'default'}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/registered.tpl b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/registered.tpl new file mode 100644 index 00000000..e7822da9 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/registered.tpl @@ -0,0 +1 @@ +{blockplugintest}hello world{/blockplugintest}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/registered_method.tpl b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/registered_method.tpl new file mode 100644 index 00000000..6334e244 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/registered_method.tpl @@ -0,0 +1 @@ +{blockpluginmethod}hello world{/blockpluginmethod}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/registered_object.tpl b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/registered_object.tpl new file mode 100644 index 00000000..8de8a168 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/registered_object.tpl @@ -0,0 +1 @@ +{myobject->objectfunc}hello world{/myobject->objectfunc}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/registered_static.tpl b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/registered_static.tpl new file mode 100644 index 00000000..b9d83c83 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/registered_static.tpl @@ -0,0 +1 @@ +{blockpluginstatic}hello world{/blockpluginstatic}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/repeat.tpl b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/repeat.tpl new file mode 100644 index 00000000..32c39c0c --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/repeat.tpl @@ -0,0 +1 @@ +{testblock}{/testblock}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/repeat_modifier.tpl b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/repeat_modifier.tpl new file mode 100644 index 00000000..831c95a5 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/repeat_modifier.tpl @@ -0,0 +1 @@ +{testblock}{/testblock|strlen}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/repeat_modifier_2.tpl b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/repeat_modifier_2.tpl new file mode 100644 index 00000000..33031924 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/repeat_modifier_2.tpl @@ -0,0 +1 @@ +{testblock}{/testblock|strlen|default:''}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/tag_stack.tpl b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/tag_stack.tpl new file mode 100644 index 00000000..6cbc1404 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/tag_stack.tpl @@ -0,0 +1 @@ +{noop}{teststack}{/teststack}{/noop}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/unknown.tpl b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/unknown.tpl new file mode 100644 index 00000000..d6820019 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates/unknown.tpl @@ -0,0 +1 @@ +{bar}hello world{/bar}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates_tmp/.gitignore b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates_tmp/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/templates_tmp/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/CompileBlockExtendsTest.php b/tests/UnitTests/TemplateSource/TagTests/BockExtend/CompileBlockExtendsTest.php new file mode 100644 index 00000000..0f3eb406 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/CompileBlockExtendsTest.php @@ -0,0 +1,1382 @@ +<?php +/** + * Smarty PHPunit tests for Block Extends + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for block extends compiler tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class CompileBlockExtendsTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + //$this->smarty->setMergeCompiledIncludes(true); + } + + public function compiledPrefilter($text, Smarty_Internal_Template $tpl) + { + return str_replace('#', $tpl->getTemplateVars('test'), $text); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * test block default outout + */ + public function testBlockDefault_000_1() + { + $result = $this->smarty->fetch('string:{block name=test}-- block default --{/block}'); + $this->assertEquals('-- block default --', $result); + } + + public function testBlockDefault_000_2() + { + $this->smarty->assign('foo', 'another'); + $result = $this->smarty->fetch('string:{block name=test}-- {$foo} block default --{/block}'); + $this->assertEquals('-- another block default --', $result); + } + + /** + * test just call of parent template, no blocks predefined + */ + public function testCompileBlockParent_001() + { + $this->smarty->assign('parent', 'parent'); + $result = $this->smarty->fetch('001_parent.tpl'); + $this->assertContains('(parent|b)content parent b(parent|/b)', $result); + } + + /** + * test child/parent template chain + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockChild_002($caching, $merge, $testNumber, $compileTestNumber, $renderTestNumber, + $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->assign('parent', 'parent', true); + $this->smarty->assign('child', 'child', true); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('002_child.tpl'); + $this->assertContains('(child|b)content child b(child|/b)', $result, $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + /** + * test child/parent template chain with prepend + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockChildPrepend_003($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->assign('parent', 'parent', true); + $this->smarty->assign('child', 'child', true); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('003_child.tpl'); + $this->assertContains('(child|b)content child b(child|/b)(parent|b)content parent b(parent|/b)', $result, + $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + /** + * test child/parent template chain with prepend + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockGrandPrepend_003($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->assign('parent', 'parent', true); + $this->smarty->assign('child', 'child', true); + $this->smarty->assign('grand', 'grand', true); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('003_grand.tpl'); + $this->assertContains('(grand|b)content grand b(grand|/b)(child|b)content child b(child|/b)(parent|b)content parent b(parent|/b)', + $result, $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + /** + * test child/parent template chain with apppend + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockChildAppend_004($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->assign('parent', 'parent', true); + $this->smarty->assign('child', 'child', true); + $this->smarty->assign('grand', 'grand', true); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('004_child.tpl'); + $this->assertContains('(parent|b)content parent b(parent|/b)(child|b)content child b(child|/b)', $result, + $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + /** + * test grandchild/parent template chain with apppend + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockGrandAppend_004($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->assign('parent', 'parent', true); + $this->smarty->assign('child', 'child', true); + $this->smarty->assign('grand', 'grand', true); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('004_grand.tpl'); + $this->assertContains('(parent|b)content parent b(parent|/b)(child|b)content child b(child|/b)(grand|b)content grand b(grand|/b)', + $result, $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + /** + * test grandchild/parent template chain with apppend + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockGrandAppendPrepend_004($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->assign('parent', 'parent', true); + $this->smarty->assign('child', 'child', true); + $this->smarty->assign('grand', 'grand', true); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('004_grand2.tpl'); + $this->assertContains('(parent|b)content parent b(parent|/b)(grand|b)content grand b(grand|/b)(child|b)content child b(child|/b)(grand|b)content grand b(grand|/b)', + $result, $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + /** + * test child/parent template chain with apppend and shorttags + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockChildAppendShortag_005($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->assign('parent', 'parent', true); + $this->smarty->assign('child', 'child', true); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('005_child.tpl'); + $this->assertContains('(parent|b)content parent b(parent|/b)(child|b)content child b(child|/b)', $result, + $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + /** + * test child/parent template chain with {$this->smarty.block.child) + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockChildSmartyChild_006($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->assign('parent', 'parent', true); + $this->smarty->assign('child', 'child', true); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('006_child.tpl'); + $this->assertContains('(parent|b)content (child|b)content child b(child|/b) b(parent|/b)', $result, + $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + /** + * test child/parent template chain with {$this->smarty.block.parent) + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockChildSmartyParent_007($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->assign('parent', 'parent', true); + $this->smarty->assign('child', 'child', true); + $this->smarty->assign('grand', 'grand', true); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('007_child.tpl'); + $this->assertContains('(child|b)content (parent|b)content parent b(parent|/b) b(child|/b)', $result, + $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + /** + * test grandchild/child/parent template chain with {$this->smarty.block.parent) + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockChildSmartyParent_007_2($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->assign('parent', 'parent', true); + $this->smarty->assign('child', 'child', true); + $this->smarty->assign('grand', 'grand', true); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('007_grand.tpl'); + $this->assertContains('(grand|b)content (child|b)content (parent|b)content parent b(parent|/b) b(child|/b) b(grand|/b)', + $result, $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + /** + * test child/parent template chain loading plugin + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockChildPlugin_008($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->assign('parent', 'parent', true); + $this->smarty->assign('child', 'child', true); + $this->smarty->assign('grand', 'grand', true); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('008_child.tpl'); + $this->assertContains('(child|b)content escaped <text> child 1 b(child|/b', $result, + $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + /** + * test parent template with nested blocks + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockParentNested_009($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->assign('parent', 'parent', true); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('009_parent.tpl'); + $this->assertContains('(parent|b)content (parent|c)content parent c(parent|/c) b(parent|/b)', $result, + $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + /** + * test child/parent template chain with nested block + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockChildNested_010($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->assign('parent', 'parent', true); + $this->smarty->assign('child', 'child', true); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('010_child.tpl'); + $this->assertContains('(parent|b)content (parent|c)content child c(parent|/c) b(parent|/b)', $result, + $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + /** + * test child/parent template chain with nested block and include + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockChildNestedInclude_011($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->assign('parent', 'parent', true); + $this->smarty->assign('child', 'child', true); + $this->smarty->assign('grand', 'grand', true); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('011_grand.tpl'); + $this->assertContains('(child|b)content(child|c)content(child|n)content(include)content child i(/include)n(child|/n)c(child|/c)(grand|c)content grand c(grand|\c)b(child|/b)', + $result, $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + /** + * test template chain with nested block level test + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockChildNestedInclude_012($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->assign('parent', 'parent', true); + $this->smarty->assign('child', 'child', true); + $this->smarty->assign('grand', 'grand', true); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('012_grandgrand.tpl'); + $this->assertContains('(grand|b)content (grandgrand|c)content c(grandgrand|\c)(grand|c)content c(grand|\c) b(grand|/b)', + $result, $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + /** + * test nested child block with hide + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockChildNestedHide_018($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('018_child.tpl'); + $this->assertContains('(child|b)content(child|c)content child c(child|/c)b(child|/b)', $result, + $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + /** + * test nested grand/child block with hide + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockChildNestedHide_018_2($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('018_grand.tpl'); + $this->assertContains('(child|b)content(child|c)content child c(child|/c)(child|d)content (grand|d)content grand d(grand|/d) d(child|/d)b(child|/b)', + $result, $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + /** + * test nested grandgrand/grand/child block with hide + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockChildNestedHide_018_3($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('018_grandgrand.tpl'); + $this->assertContains('(child|b)content(grand|c)content (grandgrand|c)content grandgrand c(grandgrand|/c) c(grand|/c)(child|d)content (grandgrand|d)content grandgrand d(grandgrand|/d) d(child|/d)b(child|/b)', + $result, $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + /** + * test child/parent template chain starting in subtempates + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockStartSubTemplates_020($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('020_include_root.tpl'); + $this->assertContains('(include1)(include1|p)content 1 p(include1|\p)(include1|b)content 1 b(include1|\b)(\include1)', + $result, $testName . ' - include 1'); + $this->assertContains('(include2)(include2|p)content 2 p(include2|\p)(include2|b)content 2 b(include2|\b)(\include2)', + $result, $testName . ' - include 1'); + $this->assertContains('(include3)(include3|p)content 3 p(include3|\p)(include3|b)content 3 b(include3|\b)(\include3)', + $result, $testName . ' - include 1'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + /** + * test grandchild/child/parent dependency test1 + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testCompileBlockGrandChildMustCompile_021_1() + { + $this->smarty->assign('parent', 'parent'); + $this->smarty->assign('child', 'child', true); + $this->smarty->assign('grand', 'grand', true); + $this->smarty->setCompileDir('./templates_c/mustcompile'); + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $tpl = $this->smarty->createTemplate('021_grand.tpl', $this->smarty); + $this->assertFalse($tpl->isCached()); + $result = $this->smarty->fetch($tpl); + $this->assertContains('(grand|b)content grand b(grand|/b)(child|b)content child b(child|/b)(parent|b)content parent b(parent|/b)', + $result); + $this->smarty->_clearTemplateCache(); + $this->smarty->assign('parent', 'parent2'); + $this->smarty->assign('child', 'child2', true); + $this->smarty->assign('grand', 'grand2', true); + $tpl2 = $this->smarty->createTemplate('021_grand.tpl', $this->smarty); + $this->assertTrue($tpl2->isCached()); + $result = $this->smarty->fetch($tpl2); + $this->assertContains('(grand|b)content grand2 b(grand|/b)(child|b)content child2 b(child|/b)(parent|b)content parent b(parent|/b)', + $result); + } + + /** + * test grandchild/child/parent dependency test1 + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testCompileBlockGrandChildMustCompile_021_12() + { + $this->smarty->setCompileDir('./templates_c/mustcompile'); + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $this->smarty->assign('parent', 'parent3'); + $this->smarty->assign('child', 'child3', true); + $this->smarty->assign('grand', 'grand3', true); + $tpl2 = $this->smarty->createTemplate('021_grand.tpl', $this->smarty); + $this->assertTrue($tpl2->isCached()); + $result = $this->smarty->fetch($tpl2); + $this->assertContains('(grand|b)content grand3 b(grand|/b)(child|b)content child3 b(child|/b)(parent|b)content parent b(parent|/b)', + $result); + } + + /** + * test grandchild/child/parent dependency test2 + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testCompileBlockGrandChildMustCompile_021_2() + { + $this->smarty->assign('parent', 'parent4'); + $this->smarty->assign('child', 'child4', true); + $this->smarty->assign('grand', 'grand4', true); + $this->smarty->setCompileDir('./templates_c/mustcompile'); + sleep(2); + touch($this->smarty->getTemplateDir(0) . '021_grand.tpl'); + clearstatcache(); + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $tpl = $this->smarty->createTemplate('021_grand.tpl', $this->smarty); + $this->assertFalse($tpl->isCached()); + $result = $this->smarty->fetch($tpl); + $this->assertContains('(grand|b)content grand4 b(grand|/b)(child|b)content child4 b(child|/b)(parent|b)content parent4 b(parent|/b)', + $result); + $this->smarty->_clearTemplateCache(); + $this->smarty->assign('parent', 'parent5'); + $this->smarty->assign('child', 'child5', true); + $this->smarty->assign('grand', 'grand5', true); + $this->smarty->setCompileDir('./templates_c/mustcompile'); + $tpl2 = $this->smarty->createTemplate('021_grand.tpl', $this->smarty); + $this->assertTrue($tpl2->isCached()); + $result = $this->smarty->fetch($tpl2); + $this->assertContains('(grand|b)content grand5 b(grand|/b)(child|b)content child5 b(child|/b)(parent|b)content parent4 b(parent|/b)', + $result); + } + + /** + * test grandchild/child/parent dependency test3 + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testCompileBlockGrandChildMustCompile_021_3() + { + $this->smarty->assign('parent', 'parent6'); + $this->smarty->assign('child', 'child6', true); + $this->smarty->assign('grand', 'grand6', true); + $this->smarty->setCompileDir('./templates_c/mustcompile'); + sleep(2); + touch($this->smarty->getTemplateDir(0) . '021_child.tpl'); + clearstatcache(); + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $tpl = $this->smarty->createTemplate('021_grand.tpl', $this->smarty); + $this->assertFalse($tpl->isCached()); + $result = $this->smarty->fetch($tpl); + $this->assertContains('(grand|b)content grand6 b(grand|/b)(child|b)content child6 b(child|/b)(parent|b)content parent6 b(parent|/b)', + $result); + } + + /** + * test grandchild/child/parent dependency test3 + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testCompileBlockGrandChildMustCompile_021_32() + { + $this->smarty->assign('parent', 'parent7'); + $this->smarty->assign('child', 'child7', true); + $this->smarty->assign('grand', 'grand7', true); + $this->smarty->setCompileDir('./templates_c/mustcompile'); + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $tpl2 = $this->smarty->createTemplate('021_grand.tpl', $this->smarty); + $this->assertTrue($tpl2->isCached()); + $result = $this->smarty->fetch($tpl2); + $this->assertContains('(grand|b)content grand7 b(grand|/b)(child|b)content child7 b(child|/b)(parent|b)content parent6 b(parent|/b)', + $result); + } + + /** + * test grandchild/child/parent dependency test4 + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testCompileBlockGrandChildMustCompile_021_4() + { + $this->smarty->assign('parent', 'parent8'); + $this->smarty->assign('child', 'child8', true); + $this->smarty->assign('grand', 'grand8', true); + $this->smarty->setCompileDir('./templates_c/mustcompile'); + sleep(2); + touch($this->smarty->getTemplateDir(0) . '021_parent.tpl'); + clearstatcache(); + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $tpl = $this->smarty->createTemplate('021_grand.tpl', $this->smarty); + $this->assertFalse($tpl->isCached()); + $result = $this->smarty->fetch($tpl); + $this->assertContains('(grand|b)content grand8 b(grand|/b)(child|b)content child8 b(child|/b)(parent|b)content parent8 b(parent|/b)', + $result); + } + + /** + * test grandchild/child/parent dependency test4 + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testCompileBlockGrandChildMustCompile_021_42() + { + $this->smarty->assign('parent', 'parent9'); + $this->smarty->assign('child', 'child9', true); + $this->smarty->assign('grand', 'grand9', true); + $this->smarty->setCompileDir('./templates_c/mustcompile'); + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $tpl2 = $this->smarty->createTemplate('021_grand.tpl', $this->smarty); + $this->assertTrue($tpl2->isCached()); + $result = $this->smarty->fetch($tpl2); + $this->assertContains('(grand|b)content grand9 b(grand|/b)(child|b)content child9 b(child|/b)(parent|b)content parent8 b(parent|/b)', + $result); + } + + /** + * test dirt in child templates + */ + public function testDirt_022() + { + $result = $this->smarty->fetch('022_child.tpl'); + $this->assertEquals('Page Title', $result); + } + + /** + * test {$this->smarty.block.child} for not existing child {block] + */ + public function testNotExistingChildBlock_024() + { + $result = $this->smarty->fetch('024_parent.tpl'); + $this->assertContains('no >< child', $result); + } + + /** + * @expectedException SmartyCompilerException + * @expectedExceptionMessage '{$smarty.block.child}' used outside {block} tags + * test {$this->smarty.block.child} outside {block] + */ + public function testSmartyBlockChildOutsideBlock_025() + { + $this->smarty->fetch('025_parent.tpl'); + } + + /** + * @expectedException SmartyCompilerException + * @expectedExceptionMessage '{$smarty.block.parent}' used outside {block} tags + * test {$this->smarty.block.parent} outside {block] + */ + public function testSmartyBlockParentOutsideBlock_026() + { + $this->smarty->fetch('026_child.tpl'); + } + + /** + * @expectedException SmartyException + * @expectedExceptionMessage illegal '{$smarty.block.parent}' + * test {$this->smarty.block.parent} in parent template + */ + public function testSmartyBlockParentInParent_027() + { + $result = $this->smarty->fetch('027_parent.tpl'); + } + + /** + * test child/parent template chain + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testSmartyBlockVariablePartentInclude_28($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + $this->smarty->setCompileId(10); + if ($merge) { + $this->smarty->setCompileId(11); + } + $this->smarty->assign('foo', '028_parent_include1.tpl'); + $result = $this->smarty->fetch('028_child.tpl'); + $this->assertContains('b1-include-1--b1', $result, $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + /** + * test child/parent template chain + * + * @dataProvider data + */ + public function testSmartyBlockVariablePartentInclude_282($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $this->smarty->assign('foo', '028_parent_include2.tpl'); + $result = $this->smarty->fetch('028_child.tpl'); + $this->assertContains('b1-child-i2-include-2--b1', $result, $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + /** + * test grandchild/child/parent template chain with nested {$this->smarty.block.child} and {include nocache} + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockGrandChildNested_030($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('030_grandchild_nested.tpl'); + $this->assertContains('child pre -grandchild content- child post', $result, $testName . ' - content'); + $this->assertContains('include:' . $testNumber, $result, $testName . ' - content 2'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + /** + * test grandchild/child/parent template chain with nested {$this->smarty.block.child} and {include nocache} + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockGrandChildNestedRelative_030($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('sub/030_grandchild_nested_rel.tpl'); + $this->assertContains('child pre -grandchild content- child post', $result, $testName . ' - content'); + $this->assertContains('include:' . $testNumber, $result, $testName . ' - content 2'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + /** + * test grandchild/child/parent template chain with nested {$this->smarty.block.child} and {include nocache} + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockSmartyBlockParent_034_1($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('034_1child.tpl'); + $this->assertContains('parent b1', $result, $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + /** + * test grandchild/child/parent template chain with nested {$this->smarty.block.child} and {include nocache} + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockSmartyBlockParent_034_2($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('034_2child.tpl'); + $this->assertContains('parent b1', $result, $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + /** + * test grandchild/child/parent template chain with nested {$this->smarty.block.child} and {include nocache} + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockSmartyBlockParent_034_3($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('034_3child.tpl'); + $this->assertContains('parent b1', $result, $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + /** + * test grandchild/child/parent template chain with nested {$this->smarty.block.child} and {include nocache} + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockSmartyBlockParent_034_4($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('034_4child.tpl'); + $this->assertContains('parent b1', $result, $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + /** + * test child/parent template chain with {$this->smarty.block.child) + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockSmartyBlockChild_035_1($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->assign('parenttpl', '035_1parent.tpl'); + $this->smarty->assign('parent', 'parent', true); + $this->smarty->assign('child', 'child', true); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('035_child.tpl'); + $this->assertContains('(parent|b)content (child|b)content child b(child|/b) b(parent|/b)', $result, + $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + /** + * test child/parent template chain with {$this->smarty.block.child) + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockSmartyBlockChild_035_2($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->assign('parenttpl', '035_2parent.tpl'); + $this->smarty->assign('parent', 'parent', true); + $this->smarty->assign('child', 'child', true); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('035_child.tpl'); + $this->assertContains('(parent|b)content (child|b)content child b(child|/b) b(parent|/b)', $result, + $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + /** + * test child/parent template chain with {$this->smarty.block.child) + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockSmartyBlockChild_035_3($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->assign('parenttpl', '035_3parent.tpl'); + $this->smarty->assign('parent', 'parent', true); + $this->smarty->assign('child', 'child', true); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('035_child.tpl'); + $this->assertContains('(parent|b)content (child|b)content child b(child|/b) b(parent|/b)', $result, + $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + /** + * test child/parent template chain with {$this->smarty.block.child) + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockSmartyBlockChild_035_4($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->assign('parenttpl', '035_4parent.tpl'); + $this->smarty->assign('parent', 'parent', true); + $this->smarty->assign('child', 'child', true); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('035_child.tpl'); + $this->assertContains('(parent|b)content (child|b)content child b(child|/b) b(parent|/b)', $result, + $testName . ' - content'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + + + + public function data() + { + return array(/* + * caching + * merging + * test nr + * result compile nr + * result render nr + * text + */ + array(false, false, 1, 1, 1, 'no caching, no merge - new'), + array(false, false, 2, 1, 2, 'no caching, no merge - exits'), + array(true, false, 3, 3, 3, 'caching, no merge - new'), + array(true, false, 4, 3, 3, 'caching, no merge - exits'), + array(false, true, 5, 5, 5, 'no caching, merge - new'), + array(false, true, 6, 5, 6, 'no caching, merge - exits'), + array(true, true, 7, 7, 7, 'caching, merge - new'), + array(true, true, 8, 7, 7, 'caching, merge - exits'),); + } + + /* + * Test post filter on {block} + */ + public function testPostFilter_031() + { + function smarty_postfilter_test031($compiled, Smarty_Internal_Template $template) + { + return str_replace("'foo'", "'bar'", $compiled); + } + + $this->smarty->loadFilter('post', 'test031'); + $this->smarty->assign('foo', 'foo'); + $this->smarty->assign('bar', 'bar'); + $this->assertContains('bar', $this->smarty->fetch('031_post_filter.tpl')); + } + /* + * Test new inheritance root in outermost include + */ + public function testInclude_032() + { + $result = $this->smarty->fetch('032_child.tpl'); + $this->assertContains('foo in 032_child.tpl', $result); + $this->assertContains('bar in 032_included_child.tpl', $result); + $this->assertContains('foo in 032_included_parent.tpl', $result); + $this->assertNotContains('bar in 032_included_parent.tpl', $result); + $this->assertNotContains('foo in 032_parent.tpl', $result); + } + /** + * test relative includes in {block} + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + */ + public function testCompileBlockRelativeIncludes_033($caching, $merge, $testNumber, $compileTestNumber, + $renderTestNumber, $testName) + { + $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); + $this->smarty->assign('test', $testNumber); + $this->smarty->setCaching($caching); + $this->smarty->setMergeCompiledIncludes($merge); + if ($merge) { + $this->smarty->setCompileId(1); + } + $result = $this->smarty->fetch('033_grandchild.tpl'); + $this->assertContains('include grand:content include grand', $result, $testName . ' - grand'); + $this->assertContains('include child:content include child', $result, $testName . ' - grand'); + $this->assertContains('include parent:content include parent', $result, $testName . ' - grand'); + $this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, + $testName . ' - fetch() failure'); + } + /** + * + * test smarty.block.foo + * + * @expectedException SmartyCompilerException + * @expectedExceptionMessage $smarty.block is not defined + */ + public function testSmartyBlockWrongBlockName_036() + { + $this->smarty->fetch('036_parent.tpl'); + } + /** + * + * test '{$smarty.block.parent}' + * + * @expectedException SmartyException + * @expectedExceptionMessage inheritance: illegal '{$smarty.block.parent}' used in child template + */ + public function testSmartyParentBlockCalledInParent_036_1() + { + $this->smarty->fetch('036_1_parent.tpl'); + } + /** + * + * test {block_parent} + * + * @expectedException SmartyException + * @expectedExceptionMessage inheritance: illegal '{block_parent}' used in child template + */ + public function testSmartyParentBlockCalledInParent_036_2() + { + $this->smarty->fetch('036_2_parent.tpl'); + } + /** + * + * test {block_parent} + * + * @expectedException SmartyException + * @expectedExceptionMessage inheritance: illegal '{parent}' used in child template + */ + public function testSmartyParentBlockCalledInParent_036_3() + { + $this->smarty->fetch('036_3_parent.tpl'); + } + + /** + * + * test smarty.block + * + * @expectedException SmartyCompilerException + * @expectedExceptionMessage $smarty.block is not defined + */ + public function testSmartyBlockMissigBlockName_037() + { + $this->smarty->fetch('037_parent.tpl'); + } + + /** + * 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->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'bar'); + $this->assertEquals($result, + $this->smarty->fetch($file), + "testSpacing - {$file}"); + } + /** + * Test Output nocache spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestSpacing + * @runInSeparateProcess + */ + public function testBlockSpacingNocache($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Spacing_{$name}.tpl"; + $this->smarty->setCompileId('VarNocache'); + $this->smarty->setCaching(1); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'bar',true); + $this->assertEquals($result, + $this->smarty->fetch($file), + "testVarNocache - {$file}"); + } + /** + * Test Output nocache spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestSpacing + * @runInSeparateProcess + */ + public function testBlockSpacingNocache2($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Spacing_{$name}.tpl"; + $this->smarty->setCompileId('VarNocache'); + $this->smarty->setCaching(1); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'foo',true); + $this->assertEquals(str_replace('bar','foo',$result), + $this->smarty->fetch($file), + "testVarNocache1 - {$file}"); + } + + /* + * Data provider für testSpacing + */ + public function dataTestSpacing() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array(array("A{block name='a'}{\$foo}{/block}C", "AbarC", 'Var0', $i++), + array("A{block name='a'}\n{\$foo}{/block}C", "A\nbarC", 'Var1', $i++), + array("A{block name='a'}\n{\$foo}\n{/block}C", "A\nbar\nC", 'Var2', $i++), + array("A{block name='a'}\n{\$foo}{/block}\nC", "A\nbar\nC", 'Var3', $i++), + array("A\n{block name='a'}\n{\$foo}\n{/block}\nC", "A\n\nbar\n\nC", 'Var4', $i++), + ); + } + /** + * Test spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestChildSpacing + * @runInSeparateProcess + */ + public function testChildSpacing($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Spacing_Parent{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $child = "{extends file='$file'}\n"; + $child .= preg_replace(array('/A/','/C/','/[$]foo/','/\s*[{][$]smarty[.]block[.]child[}]\s*/'),array('G','H','$bar','{$bar}'),$code); + $file = "Spacing_Child{$name}.tpl"; + $this->makeTemplateFile($file, $child); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'foo'); + $this->smarty->assign('bar', 'bar'); + $this->assertEquals($result, + $this->smarty->fetch($file), + "testChildSpacing - {$file}"); + } + + /* + * Data provider für testSpacing + */ + public function dataTestChildSpacing() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array(array("A{block name='a'}{\$foo}{/block}C", "AbarC", 'Var0', $i++), + array("A{block name='a'}\n{\$foo}{/block}C", "A\nbarC", 'Var1', $i++), + array("A{block name='a'}\n{\$foo}\n{/block}C", "A\nbar\nC", 'Var2', $i++), + array("A{block name='a'}\n{\$foo}{/block}\nC", "A\nbar\nC", 'Var3', $i++), + array("A\n{block name='a'}\n{\$foo}\n{/block}\nC", "A\n\nbar\n\nC", 'Var4', $i++), + array("A{block name='a'}{\$smarty.block.child}{/block}C", "AbarC", 'BlockChild0', $i++), + array("A{block name='a'}\n{\$smarty.block.child}{/block}C", "A\nbarC", 'BlockChild1', $i++), + array("A{block name='a'}\n{\$smarty.block.child}\n{/block}C", "A\nbar\nC", 'BlockChild2', $i++), + array("A{block name='a'}\n{\$smarty.block.child}{/block}\nC", "A\nbar\nC", 'BlockChild3', $i++), + array("A\n{block name='a'}\n{\$smarty.block.child}\n{/block}\nC", "A\n\nbar\n\nC", 'BlockChild4', $i++), + ); + } + + /** + * Test Block nocache spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestBlockNocache + * @runInSeparateProcess + */ + public function testBlockNocacheSpacing($code, $result, $name, $testNumber) + { + $file = "blockNocache_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->setCompileId('BlockNocache'); + $this->smarty->setCaching(1); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'bar'); + $this->assertEquals($result, + $this->smarty->fetch($file), + "blockNocache - {$file}"); + } + /** + * Test Block nocache spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestBlockNocache + * @runInSeparateProcess + */ + public function testBlockNocacheSpacing2($code, $result, $name, $testNumber) + { + $file = "blockNocache_{$name}.tpl"; + $this->smarty->setCompileId('BlockNocache'); + $this->smarty->setCaching(1); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'foo'); + $this->assertEquals(str_replace('bar','foo',$result), + $this->smarty->fetch($file), + "blockNocache - {$file}"); + } + /* + * Data provider für TestBlockNocache + */ + public function dataTestBlockNocache() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array(array("A{nocache}{block name='a'}{\$foo}{/block}{/nocache}C", "AbarC", 'Var0', $i++), + array("A{nocache}{block name='a'}\n{\$foo}{/block}{/nocache}C", "A\nbarC", 'Var1', $i++), + array("A{nocache}{block name='a'}\n{\$foo}\n{/block}{/nocache}C", "A\nbar\nC", 'Var2', $i++), + array("A{nocache}{block name='a'}\n{\$foo}{/block}\n{/nocache}C", "A\nbar\nC", 'Var3', $i++), + array("A{nocache}\n{block name='a'}\n{\$foo}\n{/block}\n{/nocache}C", "A\n\nbar\n\nC", 'Var4', $i++), + ); + } + +} diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/BockExtend/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/001_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/001_parent.tpl new file mode 100644 index 00000000..9905f864 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/001_parent.tpl @@ -0,0 +1 @@ +{block name='b'}(parent|b)content {$parent} b(parent|/b){/block} diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/002_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/002_child.tpl new file mode 100644 index 00000000..b17c2973 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/002_child.tpl @@ -0,0 +1,2 @@ +{extends file='002_parent.tpl'} +{block name='b'}(child|b)content {$child} b(child|/b){/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/002_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/002_parent.tpl new file mode 100644 index 00000000..07bb4259 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/002_parent.tpl @@ -0,0 +1,2 @@ +test:{$test nocache} compiled:# rendered:{$test} +{block name='b'}(parent|b)content {$parent} b(parent|/b){/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/003_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/003_child.tpl new file mode 100644 index 00000000..db178929 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/003_child.tpl @@ -0,0 +1,2 @@ +{extends file='003_parent.tpl'} +{block name='b' prepend}(child|b)content {$child} b(child|/b){/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/003_grand.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/003_grand.tpl new file mode 100644 index 00000000..2a4cfa83 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/003_grand.tpl @@ -0,0 +1,2 @@ +{extends file='003_child.tpl'} +{block name='b' prepend}(grand|b)content {$grand} b(grand|/b){/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/003_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/003_parent.tpl new file mode 100644 index 00000000..36ae8965 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/003_parent.tpl @@ -0,0 +1,3 @@ +test:{$test nocache} compiled:# rendered:{$test} +{block name='b'}(parent|b)content {$parent} b(parent|/b){/block} + diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/004_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/004_child.tpl new file mode 100644 index 00000000..f887fb2a --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/004_child.tpl @@ -0,0 +1,2 @@ +{extends file='004_parent.tpl'} +{block name='b' append}(child|b)content {$child} b(child|/b){/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/004_grand.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/004_grand.tpl new file mode 100644 index 00000000..5a15ef4c --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/004_grand.tpl @@ -0,0 +1,2 @@ +{extends file='004_child.tpl'} +{block name='b' append}(grand|b)content {$grand} b(grand|/b){/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/004_grand2.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/004_grand2.tpl new file mode 100644 index 00000000..adfa4c27 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/004_grand2.tpl @@ -0,0 +1,2 @@ +{extends file='004_child.tpl'} +{block name='b' append prepend}(grand|b)content {$grand} b(grand|/b){/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/004_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/004_parent.tpl new file mode 100644 index 00000000..07bb4259 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/004_parent.tpl @@ -0,0 +1,2 @@ +test:{$test nocache} compiled:# rendered:{$test} +{block name='b'}(parent|b)content {$parent} b(parent|/b){/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/005_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/005_child.tpl new file mode 100644 index 00000000..3d822c28 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/005_child.tpl @@ -0,0 +1,2 @@ +{extends '005_parent.tpl'} +{block 'b' append}(child|b)content {$child} b(child|/b){/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/005_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/005_parent.tpl new file mode 100644 index 00000000..093ed256 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/005_parent.tpl @@ -0,0 +1,2 @@ +test:{$test nocache} compiled:# rendered:{$test} +{block 'b'}(parent|b)content {$parent} b(parent|/b){/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/006_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/006_child.tpl new file mode 100644 index 00000000..43a47504 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/006_child.tpl @@ -0,0 +1,2 @@ +{extends file='006_parent.tpl'} +{block name='b'}(child|b)content {$child} b(child|/b){/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/006_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/006_parent.tpl new file mode 100644 index 00000000..9774ebb4 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/006_parent.tpl @@ -0,0 +1,2 @@ +test:{$test nocache} compiled:# rendered:{$test} +{block name='b'}(parent|b)content {$smarty.block.child} b(parent|/b){/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/007_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/007_child.tpl new file mode 100644 index 00000000..4ac41f82 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/007_child.tpl @@ -0,0 +1,2 @@ +{extends file='007_parent.tpl'} +{block name='b'}(child|b)content {$smarty.block.parent} b(child|/b){/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/007_grand.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/007_grand.tpl new file mode 100644 index 00000000..83dba9fe --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/007_grand.tpl @@ -0,0 +1,2 @@ +{extends file='007_child.tpl'} +{block name='b'}(grand|b)content {$smarty.block.parent} b(grand|/b){/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/007_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/007_parent.tpl new file mode 100644 index 00000000..602e45fe --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/007_parent.tpl @@ -0,0 +1,2 @@ +test:{$test nocache} compiled:# rendered:{$test} +{block name='b'}(parent|b)content {$parent} b(parent|/b){/block} diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/008_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/008_child.tpl new file mode 100644 index 00000000..8f7312bd --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/008_child.tpl @@ -0,0 +1,2 @@ +{extends file='008_parent.tpl'} +{block name='b'}(child|b)content {'escaped <text>'|escape} {$child} {counter start=1} b(child|/b){/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/008_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/008_parent.tpl new file mode 100644 index 00000000..07bb4259 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/008_parent.tpl @@ -0,0 +1,2 @@ +test:{$test nocache} compiled:# rendered:{$test} +{block name='b'}(parent|b)content {$parent} b(parent|/b){/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/009_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/009_parent.tpl new file mode 100644 index 00000000..0323dde5 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/009_parent.tpl @@ -0,0 +1,2 @@ +test:{$test nocache} compiled:# rendered:{$test} +{block name='b'}(parent|b)content {block name='c'}(parent|c)content {$parent} c(parent|/c){/block} b(parent|/b){/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/010_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/010_child.tpl new file mode 100644 index 00000000..9db0214e --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/010_child.tpl @@ -0,0 +1,2 @@ +{extends file='010_parent.tpl'} +{block name='c'}(parent|c)content {$child} c(parent|/c){/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/010_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/010_parent.tpl new file mode 100644 index 00000000..0323dde5 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/010_parent.tpl @@ -0,0 +1,2 @@ +test:{$test nocache} compiled:# rendered:{$test} +{block name='b'}(parent|b)content {block name='c'}(parent|c)content {$parent} c(parent|/c){/block} b(parent|/b){/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/011_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/011_child.tpl new file mode 100644 index 00000000..98f3eb3d --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/011_child.tpl @@ -0,0 +1,12 @@ +{extends file='011_parent.tpl'} +{strip} +{block name='b'}(child|b)content + {block name='c'}(child|c)content + {block name='n'}(child|n)content + {include file='011_include.tpl'} + n(child|/n) + {/block} + c(child|/c) + {/block} + b(child|/b) +{/block} diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/011_grand.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/011_grand.tpl new file mode 100644 index 00000000..a93a4143 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/011_grand.tpl @@ -0,0 +1,5 @@ +{extends file='011_child.tpl'} +{strip} +{block name='c' append} + (grand|c)content {$grand} c(grand|\c) +{/block} diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/011_include.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/011_include.tpl new file mode 100644 index 00000000..704ca492 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/011_include.tpl @@ -0,0 +1 @@ +(include)content {$child} i(/include)
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/011_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/011_parent.tpl new file mode 100644 index 00000000..07bb4259 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/011_parent.tpl @@ -0,0 +1,2 @@ +test:{$test nocache} compiled:# rendered:{$test} +{block name='b'}(parent|b)content {$parent} b(parent|/b){/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/012_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/012_child.tpl new file mode 100644 index 00000000..6f95ae50 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/012_child.tpl @@ -0,0 +1,2 @@ +{extends file='012_parent.tpl'} +{block name='c' prepend}(child|c)content {$child} c(child|/c){/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/012_grand.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/012_grand.tpl new file mode 100644 index 00000000..00b98f3a --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/012_grand.tpl @@ -0,0 +1,2 @@ +{extends file='012_child.tpl'} +{block name='b'}(grand|b)content {block name='c'}(grand|c)content c(grand|\c){/block} b(grand|/b){/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/012_grandgrand.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/012_grandgrand.tpl new file mode 100644 index 00000000..1312dfc9 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/012_grandgrand.tpl @@ -0,0 +1,2 @@ +{extends file='012_grand.tpl'} +{block name='c' prepend}(grandgrand|c)content c(grandgrand|\c){/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/012_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/012_parent.tpl new file mode 100644 index 00000000..602e45fe --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/012_parent.tpl @@ -0,0 +1,2 @@ +test:{$test nocache} compiled:# rendered:{$test} +{block name='b'}(parent|b)content {$parent} b(parent|/b){/block} diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/018_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/018_child.tpl new file mode 100644 index 00000000..b0def3a7 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/018_child.tpl @@ -0,0 +1,9 @@ +{extends file="018_parent.tpl"} +{strip} +{block name='b'}(child|b)content + {block name='c'}(child|c)content child c(child|/c) + {/block} + {block name='d' hide}(child|d)content {$smarty.block.child} d(child|/d) + {/block} + b(child|/b) +{/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/018_grand.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/018_grand.tpl new file mode 100644 index 00000000..867e317c --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/018_grand.tpl @@ -0,0 +1,6 @@ +{extends file="018_child.tpl"} +{strip} +{block name='c' hide}(grand|c)content {$smarty.block.child} c(grand|/c) +{/block} +{block name='d'}(grand|d)content grand d(grand|/d) +{/block} diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/018_grandgrand.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/018_grandgrand.tpl new file mode 100644 index 00000000..fa7035fa --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/018_grandgrand.tpl @@ -0,0 +1,6 @@ +{extends file="018_grand.tpl"} +{strip} +{block name='c'}(grandgrand|c)content grandgrand c(grandgrand|/c) +{/block} +{block name='d'}(grandgrand|d)content grandgrand d(grandgrand|/d) +{/block} diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/018_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/018_parent.tpl new file mode 100644 index 00000000..4fa37768 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/018_parent.tpl @@ -0,0 +1,2 @@ +test:{$test nocache} compiled:# rendered:{$test} +{block name='b'}(parent|b)content parent b(parent|/b){/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/020_include_1.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/020_include_1.tpl new file mode 100644 index 00000000..be9a8b68 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/020_include_1.tpl @@ -0,0 +1,5 @@ +{extends file='020_include_parent.tpl'} + +{block name="p"}(include1|p)content 1 p(include1|\p){/block} + +{block name="b"}(include1|b)content 1 b(include1|\b){/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/020_include_2.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/020_include_2.tpl new file mode 100644 index 00000000..ffa41c6c --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/020_include_2.tpl @@ -0,0 +1,5 @@ +{extends file='020_include_parent.tpl'} + +{block name="p"}(include2|p)content 2 p(include2|\p){/block} + +{block name="b"}(include2|b)content 2 b(include2|\b){/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/020_include_3.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/020_include_3.tpl new file mode 100644 index 00000000..629e2cac --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/020_include_3.tpl @@ -0,0 +1,5 @@ +{extends file='020_include_parent.tpl'} + +{block name="p"}(include3|p)content 3 p(include3|\p){/block} + +{block name="b"}(include3|b)content 3 b(include3|\b){/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/020_include_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/020_include_parent.tpl new file mode 100644 index 00000000..c9a605b9 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/020_include_parent.tpl @@ -0,0 +1,5 @@ +{strip} +{block name="p"} {/block} +{block name='dummy'} + {include file='020_include_subtemplate.tpl'} +{/block} diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/020_include_root.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/020_include_root.tpl new file mode 100644 index 00000000..2090d4b1 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/020_include_root.tpl @@ -0,0 +1,5 @@ +test:{$test nocache} compiled:# rendered:{$test} +(include1){include file='020_include_1.tpl'}(\include1) +(include2){include file='020_include_2.tpl'}(\include2) +(include3){include file='020_include_3.tpl'}(\include3) + diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/020_include_subtemplate.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/020_include_subtemplate.tpl new file mode 100644 index 00000000..21a4d317 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/020_include_subtemplate.tpl @@ -0,0 +1 @@ +{block name="b"}-dummy-{/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/021_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/021_child.tpl new file mode 100644 index 00000000..9c1dcc09 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/021_child.tpl @@ -0,0 +1,2 @@ +{extends file='021_parent.tpl'} +{block name='b' prepend}(child|b)content {$child} b(child|/b){/block} diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/021_grand.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/021_grand.tpl new file mode 100644 index 00000000..7182c6df --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/021_grand.tpl @@ -0,0 +1,2 @@ +{extends file='021_child.tpl'} +{block name='b' prepend}(grand|b)content {$grand} b(grand|/b){/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/021_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/021_parent.tpl new file mode 100644 index 00000000..70ed9c0a --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/021_parent.tpl @@ -0,0 +1 @@ +{block name='b'}(parent|b)content {$parent} b(parent|/b){/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/022_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/022_child.tpl new file mode 100644 index 00000000..305d805b --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/022_child.tpl @@ -0,0 +1,4 @@ +{extends file='022_parent.tpl'} +{block name='title'}Page Title{/block} + + diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/022_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/022_parent.tpl new file mode 100644 index 00000000..b5ba7602 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/022_parent.tpl @@ -0,0 +1 @@ +{block name='title'}{/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/023_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/023_child.tpl new file mode 100644 index 00000000..69f554f9 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/023_child.tpl @@ -0,0 +1,8 @@ +{extends file="023_parent.tpl"} +{strip} + {block name="strip"} + <div> + Demo + </div> + {/block} +{/strip} diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/023_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/023_parent.tpl new file mode 100644 index 00000000..028e456f --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/023_parent.tpl @@ -0,0 +1,9 @@ +{strip} + <div id="header"> + {block name="strip"} + <div> + Content is stripped + </div> + {/block} + </div> +{/strip}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/024_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/024_parent.tpl new file mode 100644 index 00000000..ba6d010b --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/024_parent.tpl @@ -0,0 +1 @@ +{block 'b1'}no >{$smarty.block.child}< child{/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/025_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/025_parent.tpl new file mode 100644 index 00000000..345cff01 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/025_parent.tpl @@ -0,0 +1 @@ +{$smarty.block.child}{block 'b1'}{/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/026_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/026_child.tpl new file mode 100644 index 00000000..88cbbe41 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/026_child.tpl @@ -0,0 +1,2 @@ +{extends '026_parent.tpl'} +{$smarty.block.parent}{block 'b1'}{/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/026_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/026_parent.tpl new file mode 100644 index 00000000..d046a177 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/026_parent.tpl @@ -0,0 +1 @@ +{$smarty.block.parent}{block 'b1'}{/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/027_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/027_parent.tpl new file mode 100644 index 00000000..580bc737 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/027_parent.tpl @@ -0,0 +1 @@ +{block 'b1'}this {$smarty.block.parent} is illegal{/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/028_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/028_child.tpl new file mode 100644 index 00000000..ccfca614 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/028_child.tpl @@ -0,0 +1,4 @@ +{extends '028_parent.tpl'} +{block 'i2'}-i2-{/block} +{block 'n1'}-1-{/block} +{block 'n2'}-2-{/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/028_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/028_parent.tpl new file mode 100644 index 00000000..1d8cee2f --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/028_parent.tpl @@ -0,0 +1,2 @@ +test:{$test nocache} compiled:# rendered:{$test} +{block 'b1'}b1-{include $foo}-b1{/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/028_parent_include1.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/028_parent_include1.tpl new file mode 100644 index 00000000..0e21a57d --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/028_parent_include1.tpl @@ -0,0 +1 @@ +{block 'i1'}include{block 'n1'}{/block}{/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/028_parent_include2.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/028_parent_include2.tpl new file mode 100644 index 00000000..27ce8563 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/028_parent_include2.tpl @@ -0,0 +1 @@ +{block 'i2'}child{$smarty.block.child}include{block 'n2'}{/block}{/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/029_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/029_child.tpl new file mode 100644 index 00000000..671c92cc --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/029_child.tpl @@ -0,0 +1,4 @@ +{extends $foo} + +{block 'p2'}2{/block} +{block 'p1'}1{/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/029_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/029_parent.tpl new file mode 100644 index 00000000..cd6579dc --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/029_parent.tpl @@ -0,0 +1 @@ +{block 'b1'}parent{block 'p1'}{/block}{/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/029_parent2.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/029_parent2.tpl new file mode 100644 index 00000000..4ec5d97f --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/029_parent2.tpl @@ -0,0 +1 @@ +{block 'b1'}parent{block 'p2'}{/block}{/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_child.tpl new file mode 100644 index 00000000..9f9a8c35 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_child.tpl @@ -0,0 +1,23 @@ +{extends '030_parent.tpl'} +{strip} +{block 'b3'} + [b3 child b3={$b3} b3] +{/block} +{block 'b4'} + [b4 child b4={$b4} block.child={$smarty.block.child} b4] +{/block} +{block 'b5' nocache} + [b5-nocache child b5={$b5} block.child={$smarty.block.child} b5-nocache] +{/block} +{block 'b61'} + [b61 child b6={$b6} include={include '030_include.tpl'} b61] +{/block} +{block 'b62' nocache} + [b62-nocache child b6={$b6} include={include '030_include.tpl'} b62-nocache] +{/block} +{block 'b63'} + [b63 child b6={$b6} include_2={include '030_include_2.tpl'} b63] +{/block} +{block 'b64'} + [b64 child b6={$b6} include-nocache={include '030_include.tpl' nocache} b64] +{/block} diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_child_nested.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_child_nested.tpl new file mode 100644 index 00000000..92d60419 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_child_nested.tpl @@ -0,0 +1,6 @@ +{extends file='030_parent.tpl'} +{block name='content1'} + {block name='content2'} + child pre {$smarty.block.child} child post {include file='030_include.tpl' nocache} + {/block} +{/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_grandchild.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_grandchild.tpl new file mode 100644 index 00000000..2fba50d6 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_grandchild.tpl @@ -0,0 +1,14 @@ +{extends '030_child.tpl'} +{strip} +{block 'b3'} + [b3 grandchild b3={$b3} include={include '030_include.tpl'} b3] +{/block} +{block 'b4' nocache} + [b4-nocache grandchild b4={$b4} b4-nocache] +{/block} +{block 'b5'} + [b5 grandchild b5={$b5} b5] +{/block} +{block 'b6'} + [b6 grandchild b6={$b6} b6] +{/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_grandchild_nested.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_grandchild_nested.tpl new file mode 100644 index 00000000..8e219545 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_grandchild_nested.tpl @@ -0,0 +1,2 @@ +{extends file='030_child_nested.tpl'} +{block name='content2'}-grandchild content-{/block} diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_include.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_include.tpl new file mode 100644 index 00000000..a2848d8e --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_include.tpl @@ -0,0 +1 @@ +include:{$test nocache} diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_include_2.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_include_2.tpl new file mode 100644 index 00000000..b3738594 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_include_2.tpl @@ -0,0 +1,6 @@ +{strip} +[include_2 +{block 'b6' nocache} + [b6-nocache include_2 b6={$b6} b6-nocache] +{/block} +include_2]
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_parent.tpl new file mode 100644 index 00000000..70c36693 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/030_parent.tpl @@ -0,0 +1,2 @@ +test:{$test nocache} compiled:# rendered:{$test} +{block name='content1'}Default content{/block} diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/031_post_filter.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/031_post_filter.tpl new file mode 100644 index 00000000..bfbcb272 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/031_post_filter.tpl @@ -0,0 +1 @@ +{block name='title'}{$foo}{/block} diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/032_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/032_child.tpl new file mode 100644 index 00000000..9ec7d00b --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/032_child.tpl @@ -0,0 +1,3 @@ +{extends "032_parent.tpl"} + +{block "foo"}foo in 032_child.tpl{/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/032_included_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/032_included_child.tpl new file mode 100644 index 00000000..471ec2a6 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/032_included_child.tpl @@ -0,0 +1,3 @@ +{extends file="032_included_parent.tpl"} + +{block "bar"}bar in 032_included_child.tpl{/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/032_included_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/032_included_parent.tpl new file mode 100644 index 00000000..db12e3c6 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/032_included_parent.tpl @@ -0,0 +1,2 @@ +{block "bar"}bar in 032_included_parent.tpl{/block} +{block "foo"}foo in 032_included_parent.tpl{/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/032_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/032_parent.tpl new file mode 100644 index 00000000..f55f6e7a --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/032_parent.tpl @@ -0,0 +1,2 @@ +{include file="032_included_child.tpl"} +{block "foo"}foo in 032_parent.tpl{/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/033_grandchild.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/033_grandchild.tpl new file mode 100644 index 00000000..88d9ec73 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/033_grandchild.tpl @@ -0,0 +1,2 @@ +{extends "./child/033_child.tpl"} +{block 'grand'}{include './include/include.tpl'}{/block} diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/034_1child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/034_1child.tpl new file mode 100644 index 00000000..58501aec --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/034_1child.tpl @@ -0,0 +1,2 @@ +{extends '034_parent.tpl'} +{block 'b1'}{$smarty.block.parent}{/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/034_2child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/034_2child.tpl new file mode 100644 index 00000000..07ff346b --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/034_2child.tpl @@ -0,0 +1,2 @@ +{extends '034_parent.tpl'} +{block 'b1'}{parent assign='foo'}{$foo}{/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/034_3child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/034_3child.tpl new file mode 100644 index 00000000..a4e701b0 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/034_3child.tpl @@ -0,0 +1,2 @@ +{extends '034_parent.tpl'} +{block 'b1'}{parent}{/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/034_4child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/034_4child.tpl new file mode 100644 index 00000000..431145fd --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/034_4child.tpl @@ -0,0 +1,2 @@ +{extends '034_parent.tpl'} +{block 'b1'}{block_parent}{/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/034_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/034_parent.tpl new file mode 100644 index 00000000..1f3bc7f5 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/034_parent.tpl @@ -0,0 +1,2 @@ +test:{$test nocache} compiled:# rendered:{$test} +{block 'b1'}parent b1{/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/035_1parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/035_1parent.tpl new file mode 100644 index 00000000..9774ebb4 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/035_1parent.tpl @@ -0,0 +1,2 @@ +test:{$test nocache} compiled:# rendered:{$test} +{block name='b'}(parent|b)content {$smarty.block.child} b(parent|/b){/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/035_2parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/035_2parent.tpl new file mode 100644 index 00000000..06fed627 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/035_2parent.tpl @@ -0,0 +1,2 @@ +test:{$test nocache} compiled:# rendered:{$test} +{block name='b'}(parent|b)content {child assign='foo'}{$foo} b(parent|/b){/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/035_3parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/035_3parent.tpl new file mode 100644 index 00000000..1ada9dfa --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/035_3parent.tpl @@ -0,0 +1,2 @@ +test:{$test nocache} compiled:# rendered:{$test} +{block name='b'}(parent|b)content {child} b(parent|/b){/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/035_4parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/035_4parent.tpl new file mode 100644 index 00000000..9cea0612 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/035_4parent.tpl @@ -0,0 +1,2 @@ +test:{$test nocache} compiled:# rendered:{$test} +{block name='b'}(parent|b)content {block_child} b(parent|/b){/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/035_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/035_child.tpl new file mode 100644 index 00000000..d0435049 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/035_child.tpl @@ -0,0 +1,2 @@ +{extends file=$parenttpl} +{block name='b'}(child|b)content {$child} b(child|/b){/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/036_1_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/036_1_parent.tpl new file mode 100644 index 00000000..b1432cf2 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/036_1_parent.tpl @@ -0,0 +1 @@ +{block name='b'}{$smarty.block.parent}{/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/036_2_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/036_2_parent.tpl new file mode 100644 index 00000000..f96cb679 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/036_2_parent.tpl @@ -0,0 +1 @@ +{block name='b'}{block_parent}{/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/036_3_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/036_3_parent.tpl new file mode 100644 index 00000000..6c8516f2 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/036_3_parent.tpl @@ -0,0 +1 @@ +{block name='b'}{parent}{/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/036_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/036_parent.tpl new file mode 100644 index 00000000..8e3ed9da --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/036_parent.tpl @@ -0,0 +1 @@ +{block name='b'}{$smarty.block.foo}{/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/037_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/037_parent.tpl new file mode 100644 index 00000000..96a2a583 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/037_parent.tpl @@ -0,0 +1 @@ +{block name='b'}{$smarty.block}{/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/child/033_child.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/child/033_child.tpl new file mode 100644 index 00000000..6ed3943f --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/child/033_child.tpl @@ -0,0 +1,2 @@ +{extends "./parent/033_parent.tpl"} +{block 'child'}{include './include/include.tpl'}{/block} diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/child/include/include.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/child/include/include.tpl new file mode 100644 index 00000000..3360d880 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/child/include/include.tpl @@ -0,0 +1 @@ +include child:{include './include/include.tpl'}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/child/include/include/include.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/child/include/include/include.tpl new file mode 100644 index 00000000..021312d2 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/child/include/include/include.tpl @@ -0,0 +1 @@ +content include child
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/child/parent/033_parent.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/child/parent/033_parent.tpl new file mode 100644 index 00000000..cbb08821 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/child/parent/033_parent.tpl @@ -0,0 +1,4 @@ +test:{$test nocache} compiled:# rendered:{$test} +{block 'grand'}{include './include/include.tpl'}{/block} +{block 'child'}{include './include/include.tpl'}{/block} +{block 'parent'}{include './include/include.tpl'}{/block} diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/child/parent/include/include.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/child/parent/include/include.tpl new file mode 100644 index 00000000..25e7b985 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/child/parent/include/include.tpl @@ -0,0 +1 @@ +include parent:{include './include/include.tpl'}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/child/parent/include/include/include.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/child/parent/include/include/include.tpl new file mode 100644 index 00000000..3ed97ea1 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/child/parent/include/include/include.tpl @@ -0,0 +1 @@ +content include parent
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/helloworld.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/helloworld.tpl new file mode 100644 index 00000000..95d09f2b --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/helloworld.tpl @@ -0,0 +1 @@ +hello world
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/include/include.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/include/include.tpl new file mode 100644 index 00000000..1d72045b --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/include/include.tpl @@ -0,0 +1 @@ +include grand:{include './include/include.tpl'}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/include/include/include.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/include/include/include.tpl new file mode 100644 index 00000000..e560a2ad --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/include/include/include.tpl @@ -0,0 +1 @@ +content include grand
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/sub/030_child_nested_rel.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/sub/030_child_nested_rel.tpl new file mode 100644 index 00000000..7a56aa37 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/sub/030_child_nested_rel.tpl @@ -0,0 +1,6 @@ +{extends file='../030_parent.tpl'} +{block name='content1'} + {block name='content2'} + child pre {$smarty.block.child} child post {include file='../030_include.tpl' nocache} + {/block} +{/block}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/sub/030_grandchild_nested_rel.tpl b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/sub/030_grandchild_nested_rel.tpl new file mode 100644 index 00000000..79060995 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates/sub/030_grandchild_nested_rel.tpl @@ -0,0 +1,2 @@ +{extends file='./030_child_nested_rel.tpl'} +{block name='content2'}-grandchild content-{/block} diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates_c/mustcompile/.gitignore b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates_c/mustcompile/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates_c/mustcompile/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates_tmp/.gitignore b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates_tmp/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/templates_tmp/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Capture/CompileCaptureTest.php b/tests/UnitTests/TemplateSource/TagTests/Capture/CompileCaptureTest.php new file mode 100644 index 00000000..b76b5f7d --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Capture/CompileCaptureTest.php @@ -0,0 +1,149 @@ +<?php +/** + * Smarty PHPunit tests compilation of capture tags + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for capture tags tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class CompileCaptureTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + $this->smarty->addTemplateDir("./templates_tmp"); + } + + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * Test capture tags + * + * @not runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestCapture + */ + public function testCapture($code, $result, $testName, $testNumber) + { + $file = "testCapture{$testNumber}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->assignGlobal('file', $file); + $this->assertEquals($result, $this->smarty->fetch($file), "testCapture - {$code} - {$testName}"); + } + + /* + * Data provider für testCapture + */ + public function dataTestCapture() + { + $i = 1; + /* + * Code + * result + * test name + */ + return array(// old format + array('{assign var=foo value=bar}{capture assign=foo}hello world{/capture}{$foo}', 'hello world', '', $i ++), + array('{capture name=foo}hello world{/capture}{$smarty.capture.foo}', 'hello world', '', $i ++), + array('{capture name=foo assign=bar}hello world{/capture}{$smarty.capture.foo} {$bar}', 'hello world hello world', '', $i ++), + array('{capture}hello world{/capture}{$smarty.capture.default}', 'hello world', '', $i ++), + array('{capture short}hello shorttag{/capture}{$smarty.capture.short}', 'hello shorttag', '', $i ++), + array('{capture append=foo}hello{/capture}bar{capture append=foo}world{/capture}{foreach $foo item} {$item@key} {$item}{/foreach}', 'bar 0 hello 1 world', '', $i ++), + array('{capture assign=foo}hello {capture assign=bar}this is my {/capture}world{/capture}{$foo} {$bar}', 'hello world this is my ', '', $i ++), + array('{capture name=foo}hello world{/capture}{capture name=Foo}Smarty 3{/capture}{$smarty.capture.foo} {$smarty.capture.Foo}', 'hello world Smarty 3', '', $i ++), + ); + } + /* + * Test that capture results are global + */ + public function testCapture9() + { + $result = $this->smarty->fetch('009_capture.tpl'); + $this->assertContains('-->hello world<--', $result); + $this->assertContains('-->hello world2<--', $result); + } + + public function testCompileCaptureNocache1() + { + $this->smarty->assign('foo', 1); + $this->smarty->caching = 1; + $this->assertContains('foo 1', $this->smarty->fetch('test_capture_nocache.tpl')); + } + + /** + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testCompileCaptureNocache2() + { + $this->smarty->assign('foo', 2); + $this->smarty->caching = 1; + $this->assertTrue($this->smarty->isCached('test_capture_nocache.tpl')); + $this->assertContains('foo 2', $this->smarty->fetch('test_capture_nocache.tpl')); + } + /* + * Test capture buffer names with uppercase + */ + public function testCapture10() + { + $result = $this->smarty->fetch('010_capture.tpl'); + $this->assertContains('lowercase', $result); + $this->assertContains('uppercase', $result); + } + + /** + * 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->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'bar'); + $this->assertEquals($result, + $this->smarty->fetch($file), + "Spacing - {$file}"); + } + + /* + * Data provider für testSpacing + */ + public function dataTestSpacing() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array(array("A{capture}B{/capture}C{\$smarty.capture.default}", "ACB", 'Newline1', $i++), + array("A{capture}\nB{/capture}C{\$smarty.capture.default}", "ACB", 'Newline2', $i++), + array("A{capture}B\n{/capture}C{\$smarty.capture.default}", "ACB\n", 'Newline3', $i++), + array("A\n{capture}\nB\n{/capture}C{\$smarty.capture.default}", "A\nCB\n", 'Newline4', $i++), + array("{capture}B{/capture}A{\$smarty.capture.default}C", "ABC", 'Newline5', $i++), + array("{capture}B{/capture}A\n{\$smarty.capture.default}C", "A\nBC", 'Newline6', $i++), + array("{capture}B{/capture}A{\$smarty.capture.default}\nC", "AB\nC", 'Newline7', $i++), + array("{capture}B{/capture}A\n{\$smarty.capture.default}\nC", "A\nB\nC", 'Newline8', $i++), + ); + } + +} diff --git a/tests/UnitTests/TemplateSource/TagTests/Capture/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Capture/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Capture/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Capture/templates/009_capture.tpl b/tests/UnitTests/TemplateSource/TagTests/Capture/templates/009_capture.tpl new file mode 100644 index 00000000..00c7fecf --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Capture/templates/009_capture.tpl @@ -0,0 +1,3 @@ +{capture name='test'}hello world{/capture} +{include '009_capture_include.tpl'} +-->{$smarty.capture.test2}<--
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Capture/templates/009_capture_include.tpl b/tests/UnitTests/TemplateSource/TagTests/Capture/templates/009_capture_include.tpl new file mode 100644 index 00000000..b37f029a --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Capture/templates/009_capture_include.tpl @@ -0,0 +1,2 @@ +-->{$smarty.capture.test}<-- +{capture name='test2'}hello world2{/capture}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Capture/templates/010_capture.tpl b/tests/UnitTests/TemplateSource/TagTests/Capture/templates/010_capture.tpl new file mode 100644 index 00000000..56bc97cf --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Capture/templates/010_capture.tpl @@ -0,0 +1,4 @@ +{capture name='testname'}lowercase{/capture} +{capture name='testName'}uppercase{/capture} +{$smarty.capture.testname} +{$smarty.capture.testName} diff --git a/tests/UnitTests/TemplateSource/TagTests/Capture/templates/test_capture_nocache.tpl b/tests/UnitTests/TemplateSource/TagTests/Capture/templates/test_capture_nocache.tpl new file mode 100644 index 00000000..f34f731a --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Capture/templates/test_capture_nocache.tpl @@ -0,0 +1,2 @@ +{capture assign=bar nocache}foo {$foo}{/capture} +{$bar nocache}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Capture/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Capture/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Capture/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Capture/templates_tmp/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Capture/templates_tmp/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Capture/templates_tmp/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/CompilerPluginTest.php b/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/CompilerPluginTest.php new file mode 100644 index 00000000..eca3d1a3 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/CompilerPluginTest.php @@ -0,0 +1,36 @@ +<?php +/** + * Smarty PHPunit tests compiler plugin + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for compiler plugin tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class CompilerPluginTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test compiler plugin + */ + public function testCompilerPlugin() + { + $this->smarty->addPluginsDir(dirname(__FILE__) . "/PHPunitplugins/"); + $this->assertEquals('test output', $this->smarty->fetch('eval:{test data="test output"}{/test}')); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/PHPunitplugins/compiler.test.php b/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/PHPunitplugins/compiler.test.php new file mode 100644 index 00000000..615e0413 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/PHPunitplugins/compiler.test.php @@ -0,0 +1,28 @@ +<?php + +// compiler.test.php +class smarty_compiler_test extends Smarty_Internal_CompileBase +{ + public function compile($args, $compiler) + { + $this->required_attributes = array('data'); + + $_attr = $this->getAttributes($compiler, $args); + + $this->openTag($compiler, 'test'); + + return "<?php echo 'test output'; ?>"; + } +} + +// compiler.testclose.php +class smarty_compiler_testclose extends Smarty_Internal_CompileBase +{ + public function compile($args, $compiler) + { + + $this->closeTag($compiler, 'test'); + + return ''; + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/PHPunitplugins/compiler.testclose.php b/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/PHPunitplugins/compiler.testclose.php new file mode 100644 index 00000000..bd751f06 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/PHPunitplugins/compiler.testclose.php @@ -0,0 +1,13 @@ +<?php + +// compiler.testclose.php +class smarty_compiler_testclose extends Smarty_Internal_CompileBase +{ + public function execute($args, $compiler) + { + + $this->closeTag($compiler, 'test'); + + return ''; + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/CompileConfigLoadTest.php b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/CompileConfigLoadTest.php new file mode 100644 index 00000000..50a8a321 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/CompileConfigLoadTest.php @@ -0,0 +1,172 @@ +<?php +/** + * Smarty PHPunit tests of the {config_load} tag + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for config variable tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class CompileConfigLoadTest extends PHPUnit_Smarty +{ + /** + * Sets up the fixture + * This method is called before a test is executed. + * + */ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); + $this->smarty->addTemplateDir("../../../__shared/templates/"); + $this->smarty->addTemplateDir("./templates_tmp"); + } + + /** + * empty template_c and cache folders + */ + public function testInit() + { + $this->cleanDirs(); + } + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * + * test {load_config} loading section2 + */ + public function testConfigVariableSection2Template_001() + { + $this->assertEquals("Welcome to Smarty! Global Section1 Hello Section2", $this->smarty->fetch('001_section2.tpl')); + } + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * + * test {load_config} loading section2 + */ + public function testConfigVariableSection2Template_0012() + { + $this->smarty->caching = true; + $this->assertEquals("Welcome to Smarty! Global Section1 Hello Section2", $this->smarty->fetch('001_section2.tpl')); + } + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * + * test {load_config} loading section2 + */ + public function testConfigVariableInclude_003() + { + $this->assertEquals("Welcome to Smarty! Global Section1 Hello Section2", $this->smarty->fetch('003_section2.tpl')); + } + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * + * test {load_config} loading section2 shorttags + */ + public function testConfigVariableSection2TemplateShorttags() + { + $this->assertEquals("Welcome to Smarty! Global Section1 Hello Section2", $this->smarty->fetch('002_section2.tpl')); + } + + /** + * test config varibales loading all sections from template + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testConfigVariableAllSectionsTemplate_004() + { + $this->smarty->setConfigOverwrite(true); + $this->assertEquals("Welcome to Smarty! Global Section1 Global Section2", $this->smarty->fetch('004_allsection.tpl')); + } + + /** + * test config varibales overwrite + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testConfigVariableOverwrite_005() + { + $this->assertEquals("Overwrite2", $this->smarty->fetch('005_overwrite.tpl')); + } + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testConfigVariableOverwrite_006() + { + $this->assertEquals("Welcome to Smarty! Overwrite3", $this->smarty->fetch('006_overwrite.tpl')); + } + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testConfigVariableOverwrite_0061() + { + $this->smarty->configLoad('test.conf', 'default'); + $this->smarty->configLoad('test2.conf', 'default'); + $this->assertEquals('Welcome to overwrite test! this overwitten', $this->smarty->fetch('0061_overwrite.tpl')); + } + + /** + * test config varibales overwrite false + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testConfigVariableOverwrite_007() + { + $this->smarty->setConfigOverwrite(false); + $this->assertEquals("Overwrite1 Overwrite2 Overwrite3 ", $this->smarty->fetch('007_overwrite.tpl')); + } + + /** + * test config varibales booleanize on + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testConfigVariableBooleanizeOn_008() + { + $this->smarty->setConfigBooleanize(true); + $this->smarty->assign('expected', true); + $this->assertEquals("passed", $this->smarty->fetch('008_booleanize.tpl')); + } + + /** + * test config varibales booleanize off + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testConfigVariableBooleanizeOff_008() + { + $this->smarty->setConfigBooleanize(false); + $this->smarty->assign('expected', 'on'); + $this->assertEquals("passed", $this->smarty->fetch('008_booleanize.tpl')); + } + + /** + * @expectedException SmartyCompilerException + * @expectedExceptionMessage Syntax error in config file + * test config file syntax error + */ + public function testConfigSyntaxError_009() + { + $this->smarty->fetch('009_error.tpl'); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/configs/data.conf b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/configs/data.conf new file mode 100644 index 00000000..c9349c71 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/configs/data.conf @@ -0,0 +1 @@ +foo = data diff --git a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/configs/smarty.conf b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/configs/smarty.conf new file mode 100644 index 00000000..d65d1fd0 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/configs/smarty.conf @@ -0,0 +1 @@ +foo = smarty diff --git a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/configs/template.conf b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/configs/template.conf new file mode 100644 index 00000000..303000d4 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/configs/template.conf @@ -0,0 +1 @@ +foo = newvar diff --git a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/configs/test.conf b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/configs/test.conf new file mode 100644 index 00000000..cd5cd4dd --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/configs/test.conf @@ -0,0 +1,53 @@ +title = Welcome to Smarty! + +overwrite = Overwrite1 +overwrite = Overwrite2 + +booleanon = on + +Intro = """This is a value that spans more + than one line. you must enclose + it in triple quotes.""" + +Number = 123.4 + +text = 123bvc + +line = 123 This is a line + +sec1 = Global Section1 + +sec2 = Global Section2 + +sec = Global char +[/] +sec = special char + +[foo/bar] +sec = section foo/bar + +[section1] +sec1 = Hello Section1 + +[default] +title = Welcome to overwrite test! +over = shall not show + +[section2] +sec2 = 'Hello Section2' + +[.hidden] +hiddentext = Hidden Section + +#Comment +# Comment with a space first line first + #Comment line starting with space + # Space before and after # +#The line below only contains a # +# +# +# title = This is not the correct title + +#[section1] +#sec1 = Wrong text + diff --git a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/configs/test2.conf b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/configs/test2.conf new file mode 100644 index 00000000..94f31bc4 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/configs/test2.conf @@ -0,0 +1,5 @@ + +overwrite = Overwrite3 + +[default] +over = this overwitten
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/configs/test_error.conf b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/configs/test_error.conf new file mode 100644 index 00000000..586e0c75 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/configs/test_error.conf @@ -0,0 +1,15 @@ +title = Welcome to Smarty! + +overwrite = Overwrite1 +overwrite = Overwrite2 + +[section1=]] +# Here is an error +sec1 = "Hello Section1" + +[section2] +sec2 = 'Hello Section2' + +[.hidden] +hiddentext = Hidden Section + diff --git a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/001_section2.tpl b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/001_section2.tpl new file mode 100644 index 00000000..c8c7baf9 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/001_section2.tpl @@ -0,0 +1 @@ +{config_load file='test.conf' section='section2'}{#title#} {#sec1#} {#sec2#}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/002_section2.tpl b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/002_section2.tpl new file mode 100644 index 00000000..3de3b450 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/002_section2.tpl @@ -0,0 +1 @@ +{config_load 'test.conf' 'section2'}{#title#} {#sec1#} {#sec2#}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/003_include.tpl b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/003_include.tpl new file mode 100644 index 00000000..694aecb5 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/003_include.tpl @@ -0,0 +1 @@ +{#sec2#}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/003_section2.tpl b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/003_section2.tpl new file mode 100644 index 00000000..8155c48f --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/003_section2.tpl @@ -0,0 +1 @@ +{config_load file='test.conf' section='section2'}{#title#} {#sec1#} {include '003_include.tpl'}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/004_allsection.tpl b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/004_allsection.tpl new file mode 100644 index 00000000..bb3a8783 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/004_allsection.tpl @@ -0,0 +1 @@ +{config_load 'test.conf'}{#title#} {#sec1#} {#sec2#}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/005_overwrite.tpl b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/005_overwrite.tpl new file mode 100644 index 00000000..d58fcdb4 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/005_overwrite.tpl @@ -0,0 +1 @@ +{config_load 'test.conf'}{#overwrite#}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/0061_overwrite.tpl b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/0061_overwrite.tpl new file mode 100644 index 00000000..e82e5c74 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/0061_overwrite.tpl @@ -0,0 +1 @@ +{#title#} {#over#}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/006_overwrite.tpl b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/006_overwrite.tpl new file mode 100644 index 00000000..5f5abfbf --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/006_overwrite.tpl @@ -0,0 +1 @@ +{config_load 'test.conf'}{config_load 'test2.conf'}{#title#} {#overwrite#}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/007_overwrite.tpl b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/007_overwrite.tpl new file mode 100644 index 00000000..093ea298 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/007_overwrite.tpl @@ -0,0 +1 @@ +{config_load 'test.conf'}{config_load 'test2.conf'}{foreach #overwrite# as $over}{$over} {/foreach}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/008_booleanize.tpl b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/008_booleanize.tpl new file mode 100644 index 00000000..bc59712f --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/008_booleanize.tpl @@ -0,0 +1 @@ +{config_load 'test.conf'}{if #booleanon# === $expected}passed{/if}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/009_error.tpl b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/009_error.tpl new file mode 100644 index 00000000..e97c16b6 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates/009_error.tpl @@ -0,0 +1 @@ +{config_load 'test_error.conf'}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Delimiter/CompileDelimiterTest.php b/tests/UnitTests/TemplateSource/TagTests/Delimiter/CompileDelimiterTest.php new file mode 100644 index 00000000..16ae980f --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Delimiter/CompileDelimiterTest.php @@ -0,0 +1,55 @@ +<?php +/** + * Smarty PHPunit tests compilation of delimiter tags + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for delimiter tags tests + * + * @run TestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class CompileDelimiterTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * test delimiter tag test + */ + public function testLeftDelimiter() + { + $tpl = $this->smarty->createTemplate('string:x{ldelim}x'); + $this->assertEquals('x{x', $this->smarty->fetch($tpl)); + } + + public function testRightDelimiter() + { + $tpl = $this->smarty->createTemplate('string:x{rdelim}x'); + $this->assertEquals('x}x', $this->smarty->fetch($tpl)); + } + + /** + * @expectedException SmartyCompilerException + * @expectedExceptionMessage nocache option not allowed + */ + public function testLeftDelimiterError() + { + $tpl = $this->smarty->createTemplate('string:x{ldelim nocache}x'); + $this->assertEquals('x{x', $this->smarty->fetch($tpl)); + } + + +} diff --git a/tests/UnitTests/TemplateSource/TagTests/Delimiter/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Delimiter/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Delimiter/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Delimiter/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Delimiter/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Delimiter/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Eval/CompileEvalTest.php b/tests/UnitTests/TemplateSource/TagTests/Eval/CompileEvalTest.php new file mode 100644 index 00000000..5053e42d --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Eval/CompileEvalTest.php @@ -0,0 +1,48 @@ +<?php +/** + * Smarty PHPunit tests compilation of {eval} tag + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for {eval} tag tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class CompileEvalTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test eval tag + */ + public function testEval1() + { + $tpl = $this->smarty->createTemplate("string:{eval var='hello world'}"); + $this->assertEquals("hello world", $this->smarty->fetch($tpl)); + } + + public function testEval2() + { + $tpl = $this->smarty->createTemplate("string:{eval var='hello world' assign=foo}{\$foo}"); + $this->assertEquals("hello world", $this->smarty->fetch($tpl)); + } + + public function testEval3() + { + $tpl = $this->smarty->createTemplate("string:{eval var='hello world' assign=foo}"); + $this->assertEquals("", $this->smarty->fetch($tpl)); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/Eval/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Eval/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Eval/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Eval/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Eval/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Eval/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/For/CompileForTest.php b/tests/UnitTests/TemplateSource/TagTests/For/CompileForTest.php new file mode 100644 index 00000000..0a1c5d9d --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/For/CompileForTest.php @@ -0,0 +1,200 @@ +<?php +/** + * Smarty PHPunit tests compilation of {for} tag + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for {for} tag tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class CompileForTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * Test For + * + * @preserveGlobalState disabled + * @dataProvider dataTestFor + * @runInSeparateProcess + */ + public function testFor($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "For_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->assertEquals($result, + $this->smarty->fetch($file), + $file); + } + + /* + * Data provider für testFor + */ + public function dataTestFor() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array( + array('{for $x=0;$x<10;$x++}{$x}{/for}', '0123456789', 'T1', $i++), + array('{for $x=0; $x<10; $x++}{$x}{forelse}else{/for}', '0123456789', 'T2', $i++), + array('{for $x=10;$x<10;$x++}{$x}{forelse}else{/for}', 'else', 'T3', $i++), + array('{for $x=9;$x>=0;$x--}{$x}{forelse}else{/for}', '9876543210', 'T4', $i++), + array('{for $x=-1;$x>=0;$x--}{$x}{forelse}else{/for}', 'else', 'T5', $i++), + array('{for $x=0,$y=10;$x<$y;$x++}{$x}{forelse}else{/for}', '0123456789', 'T6', $i++), + array('{for $x=0;$x<10;$x=$x+2}{$x}{/for}', '02468', 'T7', $i++), + array('{for $x=0 to 8}{$x}{/for}', '012345678', 'T8', $i++), + array('{for $x=0 to 8 step=2}{$x}{/for}', '02468', 'T9', $i++), + array('{for $x=0 to 8 step=2}{if $x@first}{$x} {$x@total}{/if}{/for}', '0 5', 'T10', $i++), + array('{for $x=0 to 8 step=2}{if $x@last}{$x} {$x@iteration}{/if}{/for}', '8 5', 'T11', $i++), + array('{for $x=8 to 0 step=-2}{$x}{/for}', '86420', 'T12', $i++), + array('{for $x=8 to 0 step=2}{$x}{forelse}step error{/for}', 'step error', 'T13', $i++), + array('{for $x=8 to 0 step -1 max=3}{$x}{/for}', '876', 'T14', $i++), + ); + } + + + + /* + * test for and nocache + */ + public function testForNocacheVar1() + { + $this->smarty->caching = true; + $tpl = $this->smarty->createTemplate('string:{for $x=$foo to 5}{$x} {/for}'); + $tpl->assign('foo', 1, true); + $this->assertFalse($this->smarty->isCached($tpl)); + $this->assertEquals("1 2 3 4 5 ", $this->smarty->fetch($tpl)); + } + + /** + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testForNocacheVar2() + { + $this->smarty->caching = true; + $tpl = $this->smarty->createTemplate('string:{for $x=$foo to 5}{$x} {/for}'); + $tpl->assign('foo', 4, true); + $this->assertTrue($this->smarty->isCached($tpl)); + $this->assertEquals("4 5 ", $this->smarty->fetch($tpl)); + } + + public function testForNocacheTag1() + { + $this->smarty->caching = true; + $tpl = $this->smarty->createTemplate('string:{for $x=$foo to 5 nocache}{$x} {/for}'); + $tpl->assign('foo', 1); + $this->assertFalse($this->smarty->isCached($tpl)); + $this->assertEquals("1 2 3 4 5 ", $this->smarty->fetch($tpl)); + } + + /** + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testForNocacheTag2() + { + $this->smarty->caching = true; + $tpl = $this->smarty->createTemplate('string:{for $x=$foo to 5 nocache}{$x} {/for}'); + $tpl->assign('foo', 4); + $this->assertTrue($this->smarty->isCached($tpl)); + $this->assertEquals("4 5 ", $this->smarty->fetch($tpl)); + } + + public function testForCache1() + { + $this->smarty->caching = true; + $tpl = $this->smarty->createTemplate('string:{for $x=$foo to 2}{$x} {/for}'); + $tpl->assign('foo', 1); + $this->assertFalse($this->smarty->isCached($tpl)); + $this->assertEquals("1 2 ", $this->smarty->fetch($tpl)); + } + + /** + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testForCache2() + { + $this->smarty->caching = true; + $tpl = $this->smarty->createTemplate('string:{for $x=$foo to 2}{$x} {/for}'); + $tpl->assign('foo', 6); + $this->assertTrue($this->smarty->isCached($tpl)); + $this->assertEquals("1 2 ", $this->smarty->fetch($tpl)); + } + /** + * 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->setTemplateDir('./templates_tmp'); + $this->smarty->assign('buh', 'buh'); + $this->assertEquals($result, + $this->smarty->fetch($file), + "Spacing - {$file}"); + } + + /* + * Data provider für testSpacing + */ + public function dataTestSpacing() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array(array("A{for \$bar = 1 to 2}{\$bar}{/for}C", "A12C", 'T1', $i++), + array("A{for \$bar = 1 to 2}\n{\$bar}{/for}C", "A12C", 'T2', $i++), + array("A{for \$bar = 1 to 2}{\$bar}\n{/for}C", "A1\n2\nC", 'T3', $i++), + array("A{for \$bar = 1 to 2}\n{\$bar}\n{/for}C", "A1\n2\nC", 'T4', $i++), + array("A\n{for \$bar = 1 to 2}{\$bar}{/for}C", "A\n12C", 'T5', $i++), + array("A{for \$bar = 1 to 2}{\$bar}{/for}\nC", "A12C", 'T6', $i++), + array("A{for \$bar = 1 to 2}{\$bar}{forelse}D{/for}C", "A12C", 'T7', $i++), + array("A{for \$bar = 1 to 2}{\$bar}\n{forelse}D{/for}C", "A1\n2\nC", 'T8', $i++), + array("{for \$x=-1;\$x>=0;\$x--}{\$x}{forelse}A{\$buh}B{/for}", "AbuhB", 'T9', $i++), + array("{for \$x=-1;\$x>=0;\$x--}{\$x}{forelse}\nA{\$buh}B{/for}", "AbuhB", 'T10', $i++), + array("{for \$x=-1;\$x>=0;\$x--}{\$x}{forelse}A{\$buh}\nB{/for}", "Abuh\nB", 'T11', $i++), + array("{for \$x=-1;\$x>=0;\$x--}{\$x}{forelse}\nA{\$buh}\nB{/for}", "Abuh\nB", 'T12', $i++), + array("{for \$x=-1;\$x>=0;\$x--}{\$x}{forelse}{\$buh}\nB{/for}", "buh\nB", 'T13', $i++), + array("{for \$x=-1;\$x>=0;\$x--}{\$x}{forelse}{\$buh}{/for}", "buh", 'T14', $i++), + ); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/For/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/For/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/For/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/For/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/For/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/For/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/For/templates_tmp/.gitignore b/tests/UnitTests/TemplateSource/TagTests/For/templates_tmp/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/For/templates_tmp/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Foreach/CompileForeachTest.php b/tests/UnitTests/TemplateSource/TagTests/Foreach/CompileForeachTest.php new file mode 100644 index 00000000..ac186b58 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Foreach/CompileForeachTest.php @@ -0,0 +1,389 @@ +<?php +/** + * Smarty PHPunit tests compilation of {foreach} tag + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for {foreach} tag tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class CompileForeachTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); + $this->smarty->addTemplateDir("./templates_tmp"); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * Test foreach tags + * + * + * @preserveGlobalState disabled + * @dataProvider dataTestForeach + */ + public function testForeach($code, $foo, $result, $testName, $testNumber) + { + $file = "testForeach_{$testNumber}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->assign('x', 'x'); + $this->smarty->assign('y', 'y'); + if ($foo !== null) { + $this->smarty->assign('foo', $foo); + } else { + // unassigned $from parameter + $this->smarty->setErrorReporting(error_reporting() & ~(E_NOTICE | E_USER_NOTICE)); + } + + $this->assertEquals($result, $this->smarty->fetch($file), "testForeach - {$code} - {$testName}"); + } + + /* + * Data provider für testForeach + */ + public function dataTestForeach() + { + $i = 0; + /* + * Code + * $foo value + * result + * test name + */ + return array( + array('{foreach item=x from=$foo}{$x}{/foreach}', array(1,2,3), '123', '', $i ++), + array('{foreach $foo as $x}{$x}{/foreach}', array(1,2,3), '123', '', $i ++), + array('{foreach item=x from=$foo}{if $x == 2}{break}{/if}{$x}{/foreach}', array(0,1,2,3,4), '01', '', $i ++), + array('{foreach item=x from=$foo}{if $x == 2}{continue}{/if}{$x}{/foreach}', array(0,1,2,3,4), '0134', '', $i ++), + array('{foreach item=x from=$foo}{$x}{foreachelse}else{/foreach}', array(1,2,3), '123', '', $i ++), + array('{foreach item=x from=$foo}{$x}{foreachelse}else{/foreach}', array(), 'else', '', $i ++), + array('{foreach item=x from=$foo}{$x}{foreachelse}else{/foreach}', null, 'else', '', $i ++), + array('{foreach item=x key=y from=$foo}{$y}=>{$x},{foreachelse}else{/foreach}', array(1,2,3), '0=>1,1=>2,2=>3,', '', $i ++), + array('{foreach $foo as $y => $x}{$y}=>{$x},{foreachelse}else{/foreach}', array(1,2,3), '0=>1,1=>2,2=>3,', '', $i ++), + array('{foreach $foo as $y => $x}{$y}=>{$x},{/foreach}-{$x}-{$y}', array(1,2,3), '0=>1,1=>2,2=>3,-x-y', 'saved loop variables', $i ++), + array('{foreach $foo as $y => $x}{$y}=>{$x},{foreachelse}else{/foreach}-{$x}-{$y}', array(1,2,3), '0=>1,1=>2,2=>3,-x-y', 'saved loop variables', $i ++), + array('{foreach $foo as $y => $x}{$y}=>{$x},{foreachelse}else{/foreach}-{$x}-{$y}', array(), 'else-x-y', 'saved loop variables', $i ++), + array('{foreach $foo as $x}{$x@key}=>{$x},{foreachelse}else{/foreach}', array(1,2,3), '0=>1,1=>2,2=>3,', '', $i ++), + array('{foreach item=x name=foo from=$foo}{$x}{foreachelse}else{/foreach}total{$smarty.foreach.foo.total}', array(1,2,3), '123total3', '', $i ++), + array('{foreach item=x from=$foo}{$x}{foreachelse}else{/foreach}total{$x@total}', array(1,2,3), '123total3', '', $i ++), + array('{foreach item=x name=foo from=$foo}{$smarty.foreach.foo.index}.{$x},{/foreach}', array(9,10,11), '0.9,1.10,2.11,', '', $i ++), + array('{foreach item=x from=$foo}{$x@index}.{$x},{/foreach}', array(9,10,11), '0.9,1.10,2.11,', '', $i ++), + array('{foreach item=x name=foo from=$foo}{$smarty.foreach.foo.iteration}.{$x},{/foreach}', array(9,10,11), '1.9,2.10,3.11,', '', $i ++), + array('{foreach item=x from=$foo}{$x@iteration}.{$x},{/foreach}', array(9,10,11), '1.9,2.10,3.11,', '', $i ++), + array('{foreach item=x from=$foo}{$x@iteration}.{$x}-{$x=\'foo\'}{$x},{/foreach}', array(9,10,11), '1.9-foo,2.10-foo,3.11-foo,', '', $i ++), + array('{foreach item=x name=foo from=$foo}{if $smarty.foreach.foo.first}first{/if}{$x},{/foreach}', array(9,10,11), 'first9,10,11,', '', $i ++), + array('{foreach item=x from=$foo}{if $x@first}first{/if}{$x},{/foreach}', array(9,10,11), 'first9,10,11,', '', $i ++), + array('{foreach item=x name=foo from=$foo}{if $smarty.foreach.foo.last}last{/if}{$x},{/foreach}', array(9,10,11), '9,10,last11,', '', $i ++), + array('{foreach item=x name=foo from=$foo}{if $smarty.foreach.foo.last}last{/if}{$smarty.foreach.foo.iteration}.{$x},{/foreach}', array(9,10,11), '1.9,2.10,last3.11,', '', $i ++), + array('{foreach item=x from=$foo}{if $x@last}last{/if}{$x},{/foreach}', array(9,10,11), '9,10,last11,', '', $i ++), + array('{foreach item=x name=foo from=$foo}{$x}{foreachelse}else{/foreach}{if $smarty.foreach.foo.show}-show{else}-noshow{/if}', array(9,10,11), '91011-show', '', $i ++), + array('{foreach item=x name=foo from=$foo}{$x}{foreachelse}else{/foreach}{if $smarty.foreach.foo.show}-show{else}-noshow{/if}', array(), 'else-noshow', '', $i ++), + array('{foreach item=x from=$foo}{$x}{foreachelse}else{/foreach}{if $x@show}-show{else}-noshow{/if}', array(9,10,11), '91011-show', '', $i ++), + array('{foreach item=x from=$foo}{$x}{foreachelse}else{/foreach}{if $x@show}-show{else}-noshow{/if}', array(), 'else-noshow', '', $i ++), + array('{foreach $foo x y foo}{$y}.{$x},{foreachelse}else{/foreach}total{$smarty.foreach.foo.total}', array(9,10,11), '0.9,1.10,2.11,total3', '', $i ++), + array('{$x = "hallo"}{$bar=[1,2,3]}{foreach $foo as $x}outer={$x@index}.{$x}#{foreach $bar as $x}inner={$x@index}.{$x}{/foreach}##{/foreach}###{$x}', array(9,10,11), 'outer=0.9#inner=0.1inner=1.2inner=2.3##outer=1.10#inner=0.1inner=1.2inner=2.3##outer=2.11#inner=0.1inner=1.2inner=2.3#####hallo', '', $i ++), + array('{foreach $foo as $x}{$x}{foreachelse}else{/foreach}', null, 'else', '', $i ++), + array('{foreach $foo as $x}{$x}{foreachelse}else{/foreach}', [], 'else', '', $i ++), + array('{foreach $foo as $x}{$x}{foreachelse}else{/foreach}', new \ArrayIterator(), 'else', '', $i ++), + ); + } + + + /** + * Test foreach tags caching + * + * + * @preserveGlobalState disabled + * @dataProvider dataTestForeachNocache + */ + public function testForeachCaching($code, $new, $assignNocache, $foo, $result, $testName, $testNumber) + { + $this->smarty->caching = true; + $file = "testForeachNocache_{$testNumber}.tpl"; + if ($new) { + $this->makeTemplateFile($file, $code); + } + if ($foo !== null) { + $this->smarty->assign('foo', $foo, $assignNocache); + } else { + // unassigned $from parameter + $this->smarty->setErrorReporting(error_reporting() & ~(E_NOTICE | E_USER_NOTICE)); + } + + $this->assertEquals($result, $this->smarty->fetch($file), "testForeach - {$code} - {$testName}"); + } + + /* + * Data provider für testForeachNocache + */ + public function dataTestForeachNocache() + { + $i = 0; + /* + * Code + * new name new file + * assign nocache + * $foo value + * result + * test name + */ + return array( + array('{foreach item=x from=$foo}{$x}{/foreach}', true, true, array(1, 2, 3), '123', '', $i), + array('{foreach item=x from=$foo}{$x}{/foreach}', false, true, array(4, 5, 6), '456', '', $i ++), + array('{foreach item=x from=$foo}{$x}{/foreach}', true, false, array(1, 2, 3), '123', '', $i), + array('{foreach item=x from=$foo}{$x}{/foreach}', false, false, array(4, 5, 6), '123', '', $i ++), + array('{nocache}{foreach item=x from=$foo}{$x}{/foreach}{/nocache}', true, false, array(1, 2, 3), '123', '', $i), + array('{nocache}{foreach item=x from=$foo}{$x}{/foreach}{/nocache}', false, false, array(4, 5, 6), '456', '', $i ++), + ); + } + /* + * test foreach and nocache + * + * @runInSeparateProcess + * @preserveGlobalState disabled + + */ + public function testForeachNocacheVar1_024() + { + $this->smarty->caching = true; + $this->smarty->assign('foo', array(1, 2), true); + $this->assertFalse($this->smarty->isCached('024_foreach.tpl')); + $this->assertEquals("1 2 ", $this->smarty->fetch('024_foreach.tpl')); + } + + /** + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testForeachNocacheVar2_024() + { + $this->smarty->caching = true; + $this->smarty->assign('foo', array(9, 8), true); + $this->assertTrue($this->smarty->isCached('024_foreach.tpl')); + $this->assertEquals("9 8 ", $this->smarty->fetch('024_foreach.tpl')); + } + + /** + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testForeachNocacheTag1_025() + { + $this->smarty->caching = true; + $this->smarty->assign('foo', array(1, 2)); + $this->assertFalse($this->smarty->isCached('025_foreach.tpl')); + $this->assertEquals("1 2 ", $this->smarty->fetch('025_foreach.tpl')); + } + + /** + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testForeachNocacheTag2_25() + { + $this->smarty->caching = true; + $this->smarty->assign('foo', array(9, 8)); + $this->assertTrue($this->smarty->isCached('025_foreach.tpl')); + $this->assertEquals("9 8 ", $this->smarty->fetch('025_foreach.tpl')); + } + + /** + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testForeachCache1_26() + { + $this->smarty->caching = true; + $this->smarty->assign('foo', array(1, 2)); + $this->assertFalse($this->smarty->isCached('026_foreach.tpl')); + $this->assertEquals("1 2 ", $this->smarty->fetch('026_foreach.tpl')); + } + + /** + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testForeachCache2_26() + { + $this->smarty->caching = true; + $this->smarty->assign('foo', array(9, 8)); + $this->assertTrue($this->smarty->isCached('026_foreach.tpl')); + $this->assertEquals("1 2 ", $this->smarty->fetch('026_foreach.tpl')); + } + + public function testForeachNested_27() + { + $this->smarty->assign('foo', array(9, 8)); + $this->smarty->assign('bar', array(4, 10)); + $this->assertEquals("outer=0#9inner=0#4inner=1#10##outer=1#8inner=0#4inner=1#10#####hallo", + $this->smarty->fetch('027_foreach.tpl')); + } + + public function testForeachNestedNamed_28() + { + $this->smarty->assign('foo', array(9, 8)); + $this->smarty->assign('bar', array(4, 10)); + $this->assertEquals("outer=0#0-9inner=1#0-4inner=2#0-10##outer=1#1-8inner=1#1-4inner=2#1-10#####hallo", + $this->smarty->fetch('028_foreach.tpl')); + } + + public function testForeachBreak_29() + { + $this->assertEquals("12", + $this->smarty->fetch('029_foreach.tpl')); + } + + public function testForeachBreak_30() + { + $this->assertEquals("a1a2b1b2for20a1a2b1b2for21", + $this->smarty->fetch('030_foreach.tpl')); + } + + public function testForeachBreak_31() + { + $this->assertEquals("a1a2for20a1a2for21", + $this->smarty->fetch('031_foreach.tpl')); + } + + public function testForeachContinue_32() + { + $this->assertEquals("1245", + $this->smarty->fetch('032_foreach.tpl')); + } + + public function testForeachContinue_33() + { + $this->assertEquals("a1a2a4a5b1b2b4b5for20a1a2a4a5b1b2b4b5for21", + $this->smarty->fetch('033_foreach.tpl')); + } + + public function testForeachContinue_34() + { + $this->assertEquals("a1a2b1b2for20a1a2b1b2for21", + $this->smarty->fetch('034_foreach.tpl')); + } + + public function testForeachContinue_35() + { + $this->assertEquals("a1a2a1a2", + $this->smarty->fetch('035_foreach.tpl')); + } + public function testForeachIsset_36() + { + $this->assertEquals("false", + $this->smarty->fetch('036_foreach.tpl')); + } + public function testForeachIsset_37() + { + $this->assertEquals("false", + $this->smarty->fetch('037_foreach.tpl')); + } + /** + * 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->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', array(1,2)); + $this->assertEquals($result, + $this->smarty->fetch($file), + "Spacing - {$file}"); + } + + /* + * Data provider für testSpacing + */ + public function dataTestSpacing() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array(array("A{foreach from=\$foo item='bar'}{\$bar}{/foreach}C", "A12C", 'Newline1', $i++), + array("A{foreach from=\$foo item='bar'}\n{\$bar}{/foreach}C", "A12C", 'Newline2', $i++), + array("A{foreach from=\$foo item='bar'}{\$bar}\n{/foreach}C", "A1\n2\nC", 'Newline3', $i++), + array("A{foreach from=\$foo item='bar'}\n{\$bar}\n{/foreach}C", "A1\n2\nC", 'Newline4', $i++), + array("A\n{foreach from=\$foo item='bar'}{\$bar}{/foreach}C", "A\n12C", 'Newline5', $i++), + array("A{foreach from=\$foo item='bar'}{\$bar}{/foreach}\nC", "A12C", 'Newline6', $i++), + array("A{foreach from=\$foo item='bar'}{\$bar}{foreachelse}D{/foreach}C", "A12C", 'Newline7', $i++), + array("A{foreach from=\$foo item='bar'}{\$bar}\n{foreachelse}D{/foreach}C", "A1\n2\nC", 'Newline8', $i++), + array("{foreach from=\$foo item='bar' name='buh'}{\$bar}{/foreach}A{\$smarty.foreach.buh.total}C", "12A2C", 'Newline9', $i++), + array("{foreach from=\$foo item='bar' name='buh'}{\$bar}{/foreach}A\n{\$smarty.foreach.buh.total}C", "12A\n2C", 'Newline10', $i++), + array("{foreach from=\$foo item='bar' name='buh'}{\$bar}{/foreach}A{\$smarty.foreach.buh.total}\nC", "12A2\nC", 'Newline11', $i++), + ); + } + /** + * Test spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestElseSpacing + * @runInSeparateProcess + */ + public function testElseSpacing($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Spacing_Else_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', array()); + $this->smarty->assign('buh', 'buh'); + $this->assertEquals($result, + $this->smarty->fetch($file), + "Spacing - {$file}"); + } + + /* + * Data provider für testSpacing + */ + public function dataTestElseSpacing() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array( + array("{foreach from=\$foo item='bar'}{\$bar}{foreachelse}A{\$buh}B{/foreach}", "AbuhB", 'Newline1', $i++), + array("{foreach from=\$foo item='bar'}{\$bar}{foreachelse}\nA{\$buh}B{/foreach}", "AbuhB", 'Newline2', $i++), + array("{foreach from=\$foo item='bar'}{\$bar}{foreachelse}A{\$buh}\nB{/foreach}", "Abuh\nB", 'Newline3', $i++), + array("{foreach from=\$foo item='bar'}{\$bar}{foreachelse}\nA{\$buh}\nB{/foreach}", "Abuh\nB", 'Newline4', $i++), + array("{foreach from=\$foo item='bar'}{\$bar}{foreachelse}{\$buh}\nB{/foreach}", "buh\nB", 'Newline5', $i++), + array("{foreach from=\$foo item='bar'}{\$bar}{foreachelse}{\$buh}{/foreach}", "buh", 'Newline6', $i++), + ); + } + +} diff --git a/tests/UnitTests/TemplateSource/TagTests/Foreach/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Foreach/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Foreach/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/024_foreach.tpl b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/024_foreach.tpl new file mode 100644 index 00000000..44f3cb37 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/024_foreach.tpl @@ -0,0 +1 @@ +{foreach $foo as $x}{$x} {/foreach}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/025_foreach.tpl b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/025_foreach.tpl new file mode 100644 index 00000000..fe5193af --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/025_foreach.tpl @@ -0,0 +1 @@ +{foreach $foo as $x nocache}{$x} {/foreach}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/026_foreach.tpl b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/026_foreach.tpl new file mode 100644 index 00000000..9a2b698b --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/026_foreach.tpl @@ -0,0 +1 @@ +{foreach $foo as $x name=bar}{$x} {/foreach}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/027_foreach.tpl b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/027_foreach.tpl new file mode 100644 index 00000000..ad2fe7cf --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/027_foreach.tpl @@ -0,0 +1,9 @@ +{strip} +{$x = "hallo"} +{foreach $foo as $x} + outer={$x@index}#{$x} +{foreach $bar as $x} + inner={$x@index}#{$x} +{/foreach}## +{/foreach} +###{$x}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/028_foreach.tpl b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/028_foreach.tpl new file mode 100644 index 00000000..8d1c07f9 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/028_foreach.tpl @@ -0,0 +1,9 @@ +{strip} +{$x = 'hallo'} +{foreach from=$foo item=x key=y name='b'} + outer={$smarty.foreach.b.index}#{$y}-{$x} +{foreach from=$bar item=x name='b'} + inner={$smarty.foreach.b.iteration}#{$y}-{$x} +{/foreach}## +{/foreach} +###{$x}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/029_foreach.tpl b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/029_foreach.tpl new file mode 100644 index 00000000..afae1b27 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/029_foreach.tpl @@ -0,0 +1,5 @@ +{strip} +{foreach [1,2,3,4,5] as $i} + {if $i == 3}{break}{/if} + {$i} +{/foreach}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/030_foreach.tpl b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/030_foreach.tpl new file mode 100644 index 00000000..45feb6f3 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/030_foreach.tpl @@ -0,0 +1,9 @@ +{strip} +{for $i=20;$i<22;$i++} +{foreach ['a','b'] as $a} +{foreach [1,2,3,4,5] as $i} + {if $i == 3}{break}{/if} + {$a}{$i} +{/foreach} +{/foreach} +for{$i}{/for}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/031_foreach.tpl b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/031_foreach.tpl new file mode 100644 index 00000000..70a2859b --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/031_foreach.tpl @@ -0,0 +1,9 @@ +{strip} +{for $i=20;$i<22;$i++} +{foreach ['a','b'] as $a} +{foreach [1,2,3,4,5] as $i} + {if $i == 3}{break 2}{/if} + {$a}{$i} +{/foreach} +{/foreach} +for{$i}{/for}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/032_foreach.tpl b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/032_foreach.tpl new file mode 100644 index 00000000..c0bae38b --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/032_foreach.tpl @@ -0,0 +1,5 @@ +{strip} +{foreach [1,2,3,4,5] as $i} + {if $i == 3}{continue}{/if} + {$i} +{/foreach}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/033_foreach.tpl b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/033_foreach.tpl new file mode 100644 index 00000000..c2ade6d5 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/033_foreach.tpl @@ -0,0 +1,9 @@ +{strip} +{for $i=20;$i<22;$i++} +{foreach ['a','b'] as $a} +{foreach [1,2,3,4,5] as $i} + {if $i == 3}{continue}{/if} + {$a}{$i} +{/foreach} +{/foreach} +for{$i}{/for}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/034_foreach.tpl b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/034_foreach.tpl new file mode 100644 index 00000000..ad256a96 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/034_foreach.tpl @@ -0,0 +1,9 @@ +{strip} +{for $i=20;$i<22;$i++} +{foreach ['a','b'] as $a} +{foreach [1,2,3,4,5] as $i} + {if $i == 3}{continue 2}{/if} + {$a}{$i} +{/foreach} +{/foreach} +for{$i}{/for}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/035_foreach.tpl b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/035_foreach.tpl new file mode 100644 index 00000000..dd61dd28 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/035_foreach.tpl @@ -0,0 +1,9 @@ +{strip} +{for $i=20;$i<22;$i++} +{foreach ['a','b'] as $a} +{foreach [1,2,3,4,5] as $i} + {if $i == 3}{continue 3}{/if} + {$a}{$i} +{/foreach} +{/foreach} +for{$i}{/for}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/036_foreach.tpl b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/036_foreach.tpl new file mode 100644 index 00000000..9aa2865c --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/036_foreach.tpl @@ -0,0 +1 @@ +{if !isset($smarty.foreach.name.index)}false{/if}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/037_foreach.tpl b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/037_foreach.tpl new file mode 100644 index 00000000..81ba1e51 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/037_foreach.tpl @@ -0,0 +1 @@ +{if false}no{elseif !isset($smarty.foreach.name.index)}false{/if}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Foreach/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Foreach/templates_tmp/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates_tmp/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates_tmp/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/FunctionPlugin/CompileFunctionPluginTest.php b/tests/UnitTests/TemplateSource/TagTests/FunctionPlugin/CompileFunctionPluginTest.php new file mode 100644 index 00000000..4622e578 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/FunctionPlugin/CompileFunctionPluginTest.php @@ -0,0 +1,62 @@ +<?php +/** + * Smarty PHPunit tests compilation of function plugins + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for function plugin tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class CompileFunctionPluginTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); + } + + public function testInit() + { + $this->cleanDirs(); + } + + + /** + * test function plugin tag in compiled template file + */ + public function testFunctionPluginFromCompiledTemplateFile() + { + $this->smarty->setForceCompile(false); + $tpl = $this->smarty->createTemplate('functionplugintest.tpl', $this->smarty); + $this->assertEquals("10", $this->smarty->fetch($tpl)); + } + + /** + * test function plugin function definition in script + */ + public function testFunctionPluginRegisteredFunction() + { + $this->smarty->registerPlugin(Smarty::PLUGIN_FUNCTION, 'plugintest', 'myplugintest'); + $tpl = $this->smarty->createTemplate('string:{plugintest foo=bar}', $this->smarty); + $this->assertEquals("plugin test called bar", $this->smarty->fetch($tpl)); + } + + /** + * test muiltiline tags + */ + public function testMultiLineTags() + { + $this->assertEquals("10", $this->smarty->fetch("string:{counter\n\tstart=10}")); + } +} + +function myplugintest($params, $smarty) +{ + return "plugin test called $params[foo]"; +} diff --git a/tests/UnitTests/TemplateSource/TagTests/FunctionPlugin/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/FunctionPlugin/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/FunctionPlugin/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/FunctionPlugin/templates/functionplugintest.tpl b/tests/UnitTests/TemplateSource/TagTests/FunctionPlugin/templates/functionplugintest.tpl new file mode 100644 index 00000000..8faa5d5f --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/FunctionPlugin/templates/functionplugintest.tpl @@ -0,0 +1 @@ +{counter start=10 name=tpl}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/FunctionPlugin/templates/functionplugintestnocache.tpl b/tests/UnitTests/TemplateSource/TagTests/FunctionPlugin/templates/functionplugintestnocache.tpl new file mode 100644 index 00000000..9134519a --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/FunctionPlugin/templates/functionplugintestnocache.tpl @@ -0,0 +1 @@ +{getvar var=foo nocache}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/FunctionPlugin/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/FunctionPlugin/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/FunctionPlugin/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/If/CompileIfTest.php b/tests/UnitTests/TemplateSource/TagTests/If/CompileIfTest.php new file mode 100644 index 00000000..1eb7bd30 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/If/CompileIfTest.php @@ -0,0 +1,261 @@ +<?php +/** + * Smarty PHPunit tests compilation of {if} tag + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for {if} tag tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class CompileIfTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); + $this->smarty->addTemplateDir("../../../__shared/templates/"); + $this->smarty->addTemplateDir("./templates_tmp"); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * Test if tags + * + * @not runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestIf + */ + public function testIf($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "testIf_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->assignGlobal('file', $file); + $this->smarty->assign('bar', 'buh'); + $this->assertEquals($result, $this->smarty->fetch($file), + "testIf - {$code} - {$name}"); + } + + /* + * Data provider für testIf + */ + public function dataTestIf() + { + $i = 1; + /* + * Code + * result + * test name + */ + return array(array('{if 0<1}yes{/if}', 'yes', '', $i ++), + array('{if false}false{elseif 0<1}yes{/if}', 'yes', '', $i ++), + array('{if 2<1}yes{else}no{/if}', 'no', '', $i ++), + array('{if 2<1}yes{elseif 4<5}yes1{else}no{/if}', 'yes1', '', $i ++), + array('{if 2<1}yes{elseif 6<5}yes1{else}no{/if}', 'no', '', $i ++), + array('{if false}false{elseif true}yes{else}no{/if}', 'yes', '', $i ++), + array('{if false}yes{else}no{/if}', 'no', '', $i ++), + array('{if !(1<2)}yes{else}no{/if}', 'no', '', $i ++), + array('{if not (true)}yes{else}no{/if}', 'no', '', $i ++), + array('{if 1 == 1}yes{else}no{/if}', 'yes', '', $i ++), + array('{if 1 EQ 1}yes{else}no{/if}', 'yes', '', $i ++), + array('{if 1 eq 1}yes{else}no{/if}', 'yes', '', $i ++), + array('{$foo=true}{if $foo===true}yes{else}no{/if}', 'yes', '', $i ++), + array('{$foo=true}{if $foo!==true}yes{else}no{/if}', 'no', '', $i ++), + array('{if 1 > 0}yes{else}no{/if}', 'yes', '', $i ++), + array('{if $x=1}yes{else}no{/if}{$x}', 'yes1', '', $i ++), + array('{$x=0}{if $x++}yes{else}no{/if} {$x}', 'no 1', '', $i ++), + array('{$x=[1,2]}{if $x[] = 7}{$x|var_export:true}{else}no{/if}', var_export(array(0=>1,1=>2,2=>7,),true), '', + $i ++), + array('{$x=[1,2]}{if $x[][\'a\'] = 7}{$x|var_export:true}{else}no{/if}', + var_export(array(0=>1,1=>2,2=>array('a'=>7,),),true), '', $i ++), + array('{$foo=\'foo\'}{$bar=\'bar\'}{if $bar = "new_{$foo|default:\'\'}"}yes-{else}no{/if}{$bar}', + 'yes-new_foo', '', $i ++), + array('{$foo=\'foo\'}{$bar=\'bar\'}{if false}false{elseif $bar = "new_{$foo|default:\'\'}"}yes-{else}no{/if}{$bar}', + 'yes-new_foo', '', $i ++), + array('{$foo=\'foo\'}{$bar=\'bar\'}{if false}false{elseif $bar[3] = "new_{$foo|default:\'\'}"}yes-{else}no{/if}{$bar[0]}-{$bar[3]}', + 'yes-bar-new_foo', '', $i ++), + + array('{$x=0}{if $x}yes{else}no{/if}', 'no', 'AssignVar', $i ++), + array('{$x=0}{if $x++}yes{else}no{/if} {$x}', 'no 1', 'IncVar', $i ++), + array('{$x=1}{if $x}yes{else}no{/if}', 'yes', 'SimpleVar', $i ++), + array('{if $x=true}yes{else}no{/if}', 'yes', 'AssignTrue', $i ++), + array('{if $x=false}yes{else}no{/if}', 'no', 'AssignFalse', $i ++), + array('{if 3 ge strlen("foo")}yes{else}no{/if}', 'yes', 'CmpWithFunc', $i ++), + array('{if isset($foo)}yes{else}no{/if}', 'no', 'NotIsset', $i ++), + array('{$foo=1}{if isset($foo)}yes{else}no{/if}', 'yes', 'Isset', $i ++), + array('{$foo=1}{if !isset($foo)}yes{else}no{/if}', 'no', 'IssetNegate', $i ++), + array('{$foo=\'\'}{if empty($foo)}yes{else}no{/if}', 'yes', 'Empty', $i ++), + array('{$foo=\'foo\'}{if empty($foo)}yes{else}no{/if}', 'no', 'NotEmpty', $i ++), + array('{if 6 is div by 3}yes{else}no{/if}', 'yes', 'IsDivBy', $i ++), + array('{if 6 is not div by 3}yes{else}no{/if}', 'no', 'IsNotDivBye', $i ++), + array('{if 6 is even}yes{else}no{/if}', 'yes', 'IsEven', $i ++), + array('{if 6 is not even}yes{else}no{/if}', 'no', 'IsNotEven', $i ++), + array('{if 3 is odd}yes{else}no{/if}', 'yes', 'IsOdd', $i ++), + array('{if 3 is not odd}yes{else}no{/if}', 'no', 'IsNotOdd', $i ++), + array('{$foo=3}{if 3 is odd by $foo}yes{else}no{/if}', 'yes', 'IsOddByVar', $i ++), + array('{$foo=3}{$bar=6}{if $bar is not odd by $foo}yes{else}no{/if}', 'yes', 'IsNotOddByVar', $i ++), + array('{$foo=3}{$bar=3}{if 3+$bar is not odd by $foo}yes{else}no{/if}', 'yes', 'ExprIsNotOddByVar', $i ++), + array('{$foo=2}{$bar=6}{if (3+$bar) is not odd by ($foo+1)}yes{else}no{/if}', 'no', 'ExprIsNotOddByExpr', $i ++), + array('{if strlen("hello world") === 11}yes{else}no{/if}', 'yes', 'FuncCmp', $i ++), + array('{if 0>1}yes{else}no{/if}', 'no', 'GT2', $i ++), + array('{if 1 GT 0}yes{else}no{/if}', 'yes', 'GT3', $i ++), + array('{if 0 gt 1}yes{else}no{/if}', 'no', 'GT4', $i ++), + array('{if 1 >= 0}yes{else}no{/if}', 'yes', 'GE1', $i ++), + array('{if 1>=1}yes{else}no{/if}', 'yes', 'GE2', $i ++), + array('{if 1 GE 1}yes{else}no{/if}', 'yes', 'GE3', $i ++), + array('{if 0 ge 1}yes{else}no{/if}', 'no', 'GE4', $i ++), + array('{if 0 < 0}yes{else}no{/if}', 'no', 'LT1', $i ++), + array('{if 0<1}yes{else}no{/if}', 'yes', 'LT2', $i ++), + array('{if 0 <= 0}yes{else}no{/if}', 'yes', 'LE1', $i ++), + array('{if 0<=1}yes{else}no{/if}', 'yes', 'LE2', $i ++), + array('{if 1 LE 0}yes{else}no{/if}', 'no', 'LE3', $i ++), + array('{if 0 le 1}yes{else}no{/if}', 'yes', 'LE4', $i ++), + array('{if 1 != 1}yes{else}no{/if}', 'no', 'NE1', $i ++), + array('{if 1!=2}yes{else}no{/if}', 'yes', 'NE2', $i ++), + array('{if 1 NE 1}yes{else}no{/if}', 'no', 'NE3', $i ++), + array('{if 1 ne 2}yes{else}no{/if}', 'yes', 'NE4', $i ++), + array('{if 1 === "1"}yes{else}no{/if}', 'no', 'Ident1', $i ++), + array('{if "1" === "1"}yes{else}no{/if}', 'yes', 'Ident2', $i ++), + array('{if 1 > 0 && 5 < 6}yes{else}no{/if}', 'yes', 'And1', $i ++), + array('{if 1 > 0&&5 < 6}yes{else}no{/if}', 'yes', 'And2', $i ++), + array('{if 1 > 0 AND 5 > 6}yes{else}no{/if}', 'no', 'And3', $i ++), + array('{if (1 > 0) and (5 < 6)}yes{else}no{/if}', 'yes', 'And4', $i ++), + array('{if 1 > 0 || 7 < 6}yes{else}no{/if}', 'yes', 'Or1', $i ++), + array('{if 1 > 0||5 < 6}yes{else}no{/if}', 'yes', 'Or2', $i ++), + array('{if 1 > 0 OR 5 > 6}yes{else}no{/if}', 'yes', 'Or3', $i ++), + array('{if (0 > 0) or (9 < 6)}yes{else}no{/if}', 'no', 'Or4', $i ++), + array('{if ((7>8)||(1 > 0)) and (5 < 6)}yes{else}no{/if}', 'yes', 'AndOr1', $i ++), + array('{if {counter start=1} == 1}yes{else}no{/if}', 'yes', 'Tag1', $i ++), + array('{if false}false{elseif {counter start=1} == 1}yes{else}no{/if}', 'yes', 'Tag2', $i ++), + array('{if {counter start=1} == 0}false{elseif {counter} == 2}yes{else}no{/if}', 'yes', 'Tag3', $i ++), + ); + } + + + + + /** + * Test if nocache tags + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestIfNocache + */ + public function testIfNocache($var, $value, $code, $result, $testName, $testNumber, $file = null) + { + if (!isset($file)) { + $file = "testIfNoCache_{$testNumber}.tpl"; + } + if ($code) { + $this->makeTemplateFile($file, $code); + } + $this->smarty->setCaching(true); + $this->smarty->assign('file', $file, true); + $this->smarty->assign($var, $value, true); + $this->smarty->assign($var . '2', $value); + $this->assertEquals($result, $this->strip($this->smarty->fetch('run_code_caching.tpl')), + "testIfNocahe - {$code} - {$testName}"); + } + + /* + * Data provider für testIfNocache + */ + public function dataTestIfNocache() + { + $i = 1; + /* + * var + * value + * Code + * result + * test name + */ + return array(array('foo', true, '{if $foo}yes{else}no{/if}', 'yes', '', $i ++, 'testIfNoCache_Var1.tpl'), + array('foo', true, false, 'yes', '', $i ++, 'testIfNoCache_Var1.tpl'), + array('foo', false, false, 'no', '', $i ++, 'testIfNoCache_Var1.tpl'), + array('foo', false, false, 'no', '', $i ++, 'testIfNoCache_Var1.tpl'), + array('foo', true, '{$bar=$foo}{if $bar}yes{else}no{/if}', 'yes', '', $i ++, + 'testIfNoCache_Var2.tpl'), + array('foo', true, false, 'yes', '', $i ++, 'testIfNoCache_Var2.tpl'), + array('foo', false, false, 'no', '', $i ++, 'testIfNoCache_Var2.tpl'), + array('foo', false, false, 'no', '', $i ++, 'testIfNoCache_Var2.tpl'), + array('foo', 1, '{if $bar=$foo}yes{else}no{/if}{$bar}', 'yes1', '', $i ++, + 'testIfNoCache_Var3.tpl'), + array('foo', 1, false, 'yes1', '', $i ++, 'testIfNoCache_Var3.tpl'), + array('foo', 0, false, 'no0', '', $i ++, 'testIfNoCache_Var3.tpl'), + array('foo', 0, false, 'no0', '', $i ++, 'testIfNoCache_Var3.tpl'), + array('bar', 4, '{if $bar2=$bar+3}yes{else}no{/if}{$bar2}', 'yes7', '', $i ++, + 'testIfNoCache_Var4.tpl'), + array('bar', 4, false, 'yes7', '', $i ++, 'testIfNoCache_Var4.tpl'), + array('bar', 0, false, 'yes3', '', $i ++, 'testIfNoCache_Var4.tpl'), + array('bar', 0, false, 'yes3', '', $i ++, 'testIfNoCache_Var4.tpl'),); + } + + /** + * 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->setTemplateDir('./templates_tmp'); + $this->smarty->assign('bar', '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("A{if false}false{elseif true}{\$bar}{/if}C", "AbarC", 'T1', $i++), + array("A{if false}false{elseif true}\n{\$bar}{/if}C", "AbarC", 'T2', $i++), + array("A{if false}false{elseif true}{\$bar}\n{/if}C", "Abar\nC", 'T3', $i++), + array("A{if false}false{elseif true}\n{\$bar}\n{/if}C", "Abar\nC", 'T4', $i++), + array("A\n{if false}false{elseif true}{\$bar}{/if}C", "A\nbarC", 'T5', $i++), + array("A{if false}false{elseif true}{\$bar}{/if}\nC", "AbarC", 'T6', $i++), + array("A{if false}false{elseif true}{\$bar}{else}D{/if}C", "AbarC", 'T7', $i++), + array("A{if false}false{elseif true}{\$bar}\n{else}D{/if}C", "Abar\nC", 'T8', $i++), + array("{if false}false{else}A{\$bar}B{/if}", "AbarB", 'T9', $i++), + array("{if false}false{else}\nA{\$bar}B{/if}", "AbarB", 'T10', $i++), + array("{if false}false{else}A{\$bar}\nB{/if}", "Abar\nB", 'T11', $i++), + array("{if false}false{else}\nA{\$bar}\nB{/if}", "Abar\nB", 'T12', $i++), + array("{if false}false{else}{\$bar}\nB{/if}", "bar\nB", 'T13', $i++), + array("{if false}false{else}{\$bar}{/if}", "bar", 'T14', $i++), + array("A{if false}false{elseif true}{\$bar}{/if}C", "AbarC", 'T15', $i++), + array("A{if false}false{elseif true}\n{\$bar}{/if}C", "AbarC", 'T16', $i++), + array("A{if false}false{elseif true}{\$bar}\n{/if}C", "Abar\nC", 'T17', $i++), + array("A{if false}false{elseif true}\n{\$bar}\n{/if}C", "Abar\nC", 'T18', $i++), + array("A\n{if false}false{elseif true}{\$bar}{/if}C", "A\nbarC", 'T19', $i++), + array("A{if false}false{elseif true}{\$bar}{/if}\nC", "AbarC", 'T20', $i++), + array("A{if false}false{elseif true}{\$bar}{else}D{/if}C", "AbarC", 'T21', $i++), + array("A{if false}false{elseif true}{\$bar}\n{else}D{/if}C", "Abar\nC", 'T22', $i++), + ); + } + + + } diff --git a/tests/UnitTests/TemplateSource/TagTests/If/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/If/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/If/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/If/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/If/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/If/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/If/templates_tmp/.gitignore b/tests/UnitTests/TemplateSource/TagTests/If/templates_tmp/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/If/templates_tmp/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/CompileIncludeTest.php b/tests/UnitTests/TemplateSource/TagTests/Include/CompileIncludeTest.php new file mode 100644 index 00000000..830089ae --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/CompileIncludeTest.php @@ -0,0 +1,327 @@ +<?php +/** + * Smarty PHPunit tests compilation of the {include} tag + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for {include} tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class CompileIncludeTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); + $this->smarty->addTemplateDir("./templates_tmp"); + } + + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * test spacing + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider includeProviderCaching + */ + public function testSpacing_001($merge, $caching, $text) + { + $this->smarty->setCaching($caching); + if ($merge) { + $this->smarty->setCacheId('1'); + } + $this->smarty->setMergeCompiledIncludes($merge); + $content = $this->smarty->fetch('test_include_001.tpl'); + $this->assertEquals('I1I2I3', $content, $text); + } + + /** + * test spacing + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider includeProviderCaching + */ + public function testSpacing_001V2($merge, $caching, $text) + { + $this->smarty->setCaching($caching); + if ($merge) { + $this->smarty->setCacheId('1'); + } + $this->smarty->setMergeCompiledIncludes($merge); + $content = $this->smarty->fetch('test_include_001V2.tpl'); + $this->assertEquals('I1I2I3', $content, $text); + } + + /** + * test spacing + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider includeProviderCaching + */ + public function testSpacing_001V3($merge, $caching, $text) + { + $this->smarty->setCaching($caching); + if ($merge) { + $this->smarty->setCacheId('1'); + } + $this->smarty->setMergeCompiledIncludes($merge); + $content = $this->smarty->fetch('test_include_001V3.tpl'); + $this->assertEquals('I1I2I3', $content, $text); + } + + /** + * test standard output + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider includeProvider + */ + public function testIncludeStandard_001($merge, $text) + { + $this->smarty->setMergeCompiledIncludes($merge); + $tpl = $this->smarty->createTemplate('test_include_standard.tpl'); + $content = $this->smarty->fetch($tpl); + $this->assertEquals("hello world", $content, $text); + } + + /** + * test standard output var + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider includeProvider + */ + public function testIncludeStandardNocacheVar($merge, $text) + { + $this->smarty->setMergeCompiledIncludes(false); + $this->smarty->caching = true; + $this->smarty->assign('foo', 'foo', true); + $tpl = $this->smarty->createTemplate('test_include_standard_nocache_var.tpl', $this->smarty); + $content = $this->smarty->fetch($tpl); + $this->assertEquals("foo\n\nhello world", $content, $text); + } + + /** + * Test that assign attribute does not create standard output + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider includeProvider + */ + public function testIncludeAssign1($merge, $text) + { + $this->smarty->setMergeCompiledIncludes($merge); + $tpl = $this->smarty->createTemplate('test_include_assign1.tpl'); + $this->assertEquals("", $this->smarty->fetch($tpl), $text); + } + + /** + * Test that assign attribute does load variable + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider includeProvider + */ + public function testIncludeAssign2($merge, $text) + { + $this->smarty->setMergeCompiledIncludes($merge); + $tpl = $this->smarty->createTemplate('test_include_assign2.tpl'); + $this->assertEquals("hello world", $this->smarty->fetch($tpl), $text); + } + + /** + * Test passing local vars eval + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider includeProvider + */ + public function testIncludePassVars($merge, $text) + { + //$this->smarty->caching = true; + $this->smarty->setMergeCompiledIncludes($merge); + $tpl = $this->smarty->createTemplate('test_include_pass_vars.tpl'); + $this->assertEquals("12", $this->smarty->fetch($tpl), $text); + } + + /** + * Test passing local vars include + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider includeProvider + */ + public function testIncludePassVars2($merge, $text) + { + $this->smarty->setMergeCompiledIncludes($merge); + $tpl = $this->smarty->createTemplate('test_include_pass_vars2.tpl'); + $this->assertEquals("12", $this->smarty->fetch($tpl), $text); + } + + + + + /** + * Test recursive includes + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider includeProvider + */ + public function testRecursiveIncludes1($merge, $text) + { + $this->smarty->setMergeCompiledIncludes($merge); + $this->smarty->assign('foo', 1); + $this->smarty->assign('bar', 'bar'); + $content = $this->smarty->fetch('test_recursive_includes.tpl'); + $this->assertContains("before 1 bar<br>\nbefore 2 bar<br>\nbefore 3 bar<br>\nafter 3 bar<br>\nafter 2 bar<br>\nafter 1 bar<br>", $content, $text); + } + + /** + * Test recursive includes 2 + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider includeProvider + */ + public function testRecursiveIncludes2($merge, $text) + { + $this->smarty->setMergeCompiledIncludes($merge); + $this->smarty->assign('foo', 1); + $this->smarty->assign('bar', 'bar'); + $content = $this->smarty->fetch('test_recursive_includes2.tpl'); + $this->assertContains("before 1 bar<br>\nbefore 3 bar<br>\nbefore 5 bar<br>\nafter 5 bar<br>\nafter 3 bar<br>\nafter 1 bar<br>", $content, $text); + } + + /** + * Include data provider + */ + public function includeProvider() + { + return array( + array(false, 'normal'), + array(true, 'merged'), + ); + } + + /** + * Include data provider caching + * + * @dataProvider fileProvider + */ + public function includeProviderCaching($file) + { + return array( + array(false, false, 'normal'), + array(true, false, 'merged'), + array(false, true, 'normal cached 1'), + array(false, true, 'normal cached 2'), + array(true, true, 'merged cached 1'), + array(true, true, 'merged cached 2'), + ); + } + + public function fileProvider() + { + return array( + array('normal'), + array('merged'), + ); + } + /** + * Test Include spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestSpacing + * @runInSeparateProcess + */ + public function testIncludeSpacing($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Spacing_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->addTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'bar'); + $this->assertEquals($result, + $this->smarty->fetch($file), + "testSpacing - {$file}"); + } + /** + * Test Output spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestSpacing + * @runInSeparateProcess + */ + public function testIncludeSpacingNocache($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Spacing_{$name}.tpl"; + $this->smarty->setCompileId('1'); + $this->smarty->setCaching(1); + $this->smarty->addTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'bar',true); + $this->assertEquals($result, + $this->smarty->fetch($file), + "testSpacing - {$file}"); + } + /** + * Test Output spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestSpacing + * @runInSeparateProcess + */ + public function testIncludeSpacingNocache2($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Spacing_{$name}.tpl"; + $this->smarty->setCompileId('1'); + $this->smarty->setCaching(1); + $this->smarty->addTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'foo',true); + $this->assertEquals(str_replace('bar','foo',$result), + $this->smarty->fetch($file), + "testSpacing - {$file}"); + } + + /* + * Data provider für testSpacing + */ + public function dataTestSpacing() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array(array('A{include file=\'include_spacing2.tpl\'}B', 'A barB', '2_Text1', $i++), + array('A {include file=\'include_spacing2.tpl\'}B', 'A barB', '2_Text2', $i++), + array('A{include file=\'include_spacing2.tpl\'}B', 'A barB', '2_Text3', $i++), + array("A{include file='include_spacing2.tpl'}\nB", "A barB", '2_Newline1', $i++), + array("A\n{include file='include_spacing2.tpl'}\nB", "A\n barB", '2_Newline2', $i++), + array("A{include file='include_spacing2.tpl'}B\nC", "A barB\nC", '2_Newline3', $i++), + array('A{include file=\'include_spacing3.tpl\'}B', "AbarB", '3_Text1', $i++), + array('A {include file=\'include_spacing3.tpl\'}B', "A barB", '3_Text2', $i++), + array('A{include file=\'include_spacing3.tpl\'}B', "AbarB", '3_Text3', $i++), + array("A{include file='include_spacing3.tpl'}\nB", "AbarB", '3_Newline1', $i++), + array("A\n{include file='include_spacing3.tpl'}\nB", "A\nbarB", '3_Newline2', $i++), + array("A{include file='include_spacing3.tpl'}B\nC", "AbarB\nC", '3_Newline3', $i++), + ); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Include/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/helloworld.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/helloworld.tpl new file mode 100644 index 00000000..95d09f2b --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/helloworld.tpl @@ -0,0 +1 @@ +hello world
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/include_spacing1.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/include_spacing1.tpl new file mode 100644 index 00000000..ba0e162e --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/include_spacing1.tpl @@ -0,0 +1 @@ +bar
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/include_spacing2.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/include_spacing2.tpl new file mode 100644 index 00000000..2f9aec39 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/include_spacing2.tpl @@ -0,0 +1 @@ + {$foo}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/include_spacing3.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/include_spacing3.tpl new file mode 100644 index 00000000..b9490d3b --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/include_spacing3.tpl @@ -0,0 +1 @@ +{$foo}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_001.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_001.tpl new file mode 100644 index 00000000..8dd11b1e --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_001.tpl @@ -0,0 +1 @@ +I1{include file='test_include_001_2.tpl'}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_001V2.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_001V2.tpl new file mode 100644 index 00000000..49d4a5bb --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_001V2.tpl @@ -0,0 +1 @@ +I1{include file='test_include_001_2.tpl' cache_lifetime=30}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_001V3.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_001V3.tpl new file mode 100644 index 00000000..a1eee482 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_001V3.tpl @@ -0,0 +1 @@ +I1{include file='test_include_001_2V3.tpl' cache_lifetime=30}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_001_2.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_001_2.tpl new file mode 100644 index 00000000..c2a6f309 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_001_2.tpl @@ -0,0 +1 @@ +I2{include file='test_include_001_3.tpl'}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_001_2V3.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_001_2V3.tpl new file mode 100644 index 00000000..64bf6c17 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_001_2V3.tpl @@ -0,0 +1 @@ +I2{include file='test_include_001_3.tpl' nocache}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_001_3.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_001_3.tpl new file mode 100644 index 00000000..ebf6bc50 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_001_3.tpl @@ -0,0 +1 @@ +I3
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_assign1.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_assign1.tpl new file mode 100644 index 00000000..6021362f --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_assign1.tpl @@ -0,0 +1 @@ +{include file="helloworld.tpl" assign=foo}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_assign2.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_assign2.tpl new file mode 100644 index 00000000..aee9b8ad --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_assign2.tpl @@ -0,0 +1 @@ +{assign var=foo value=bar}{include file="helloworld.tpl" assign=foo}{$foo}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_pass_vars.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_pass_vars.tpl new file mode 100644 index 00000000..0cf974d1 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_pass_vars.tpl @@ -0,0 +1 @@ +{include file='test_include_pass_vars2_sub.tpl' myvar1=1 myvar2=2}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_pass_vars2.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_pass_vars2.tpl new file mode 100644 index 00000000..0cf974d1 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_pass_vars2.tpl @@ -0,0 +1 @@ +{include file='test_include_pass_vars2_sub.tpl' myvar1=1 myvar2=2}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_pass_vars2_sub.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_pass_vars2_sub.tpl new file mode 100644 index 00000000..e2b94437 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_pass_vars2_sub.tpl @@ -0,0 +1 @@ +{$myvar1}{$myvar2}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_standard.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_standard.tpl new file mode 100644 index 00000000..9837d596 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_standard.tpl @@ -0,0 +1 @@ +{include file='helloworld.tpl'}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_standard_nocache_var.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_standard_nocache_var.tpl new file mode 100644 index 00000000..8a545348 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_include_standard_nocache_var.tpl @@ -0,0 +1,3 @@ +{$foo} + +{include file="helloworld.tpl"}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_recursive_includes.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_recursive_includes.tpl new file mode 100644 index 00000000..344c0dd6 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_recursive_includes.tpl @@ -0,0 +1,2 @@ +before {$foo} {$bar}<br> +{if $foo < 3}{include 'test_recursive_includes.tpl' foo=$foo+1}{/if}after {$foo} {$bar}<br> diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_recursive_includes2.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_recursive_includes2.tpl new file mode 100644 index 00000000..f550809e --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_recursive_includes2.tpl @@ -0,0 +1,2 @@ +before {$foo} {$bar}<br> +{if $foo < 4}{include 'test_recursive_includes_pass.tpl' foo=$foo+1}{/if}after {$foo} {$bar}<br> diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_recursive_includes_pass.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_recursive_includes_pass.tpl new file mode 100644 index 00000000..eb31fc18 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_recursive_includes_pass.tpl @@ -0,0 +1 @@ +{include 'test_recursive_includes2.tpl' foo=$foo+1}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_scope.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_scope.tpl new file mode 100644 index 00000000..bfb1e6cb --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_scope.tpl @@ -0,0 +1 @@ +{include $file} diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_scope_assign.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_scope_assign.tpl new file mode 100644 index 00000000..ae7268d8 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_scope_assign.tpl @@ -0,0 +1 @@ +{$foo = 'newvar'}{checkvar var=foo}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_scope_pluginassign.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_scope_pluginassign.tpl new file mode 100644 index 00000000..e19a560a --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/test_scope_pluginassign.tpl @@ -0,0 +1 @@ +{pluginassign var=foo value='newvar'}{checkvar var=foo}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Include/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates_tmp/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Include/templates_tmp/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates_tmp/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/IncludePhp/CompileIncludePhpTest.php b/tests/UnitTests/TemplateSource/TagTests/IncludePhp/CompileIncludePhpTest.php new file mode 100644 index 00000000..acdd1429 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/IncludePhp/CompileIncludePhpTest.php @@ -0,0 +1,74 @@ +<?php +/** + * Smarty PHPunit tests compilation of the {include_php} tag + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for {include_php} tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class CompileIncludePhpTest extends PHPUnit_Smarty +{ + public $loadSmartyBC = true; + public $loadSmarty = false; + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + $this->smartyBC->setForceCompile(true); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test include_php string file_name function + */ + public function testIncludePhpStringFileName() + { + $this->smartyBC->disableSecurity(); + $tpl = $this->smartyBC->createTemplate('include_php.tpl'); + $result = $this->smartyBC->fetch($tpl); + $this->assertContains("test include php", $result); + } + + /** + * test include_php from trusted dir + */ + public function testIncludePhpTrusted() + { + $this->smartyBC->enableSecurity(); + $this->smartyBC->security_policy->trusted_dir = '.\\scripts\\'; + $tpl = $this->smartyBC->createTemplate('include_php_trusted.tpl'); + $result = $this->smartyBC->fetch($tpl); + $this->assertContains("test include php", $result); + } + + /** + * test include_php string file_name function + */ + public function testIncludePhpVariableFileName() + { + $this->smartyBC->disableSecurity(); + $tpl = $this->smartyBC->createTemplate('string:start {include_php file=$filename once=false} end'); + $tpl->assign('filename', 'scripts/test_include_php.php'); + $result = $this->smartyBC->fetch($tpl); + $this->assertContains("test include php", $result); + } + + public function testIncludePhpVariableFileNameShortag() + { + $this->smartyBC->disableSecurity(); + $tpl = $this->smartyBC->createTemplate('string:start {include_php $filename once=false} end'); + $tpl->assign('filename', 'scripts/test_include_php.php'); + $result = $this->smartyBC->fetch($tpl); + $this->assertContains("test include php", $result); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/IncludePhp/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/IncludePhp/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/IncludePhp/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/IncludePhp/scripts/test_include_php.php b/tests/UnitTests/TemplateSource/TagTests/IncludePhp/scripts/test_include_php.php new file mode 100644 index 00000000..2bb96d8a --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/IncludePhp/scripts/test_include_php.php @@ -0,0 +1,2 @@ +<?php +echo 'test include php'; diff --git a/tests/UnitTests/TemplateSource/TagTests/IncludePhp/templates/include_php.tpl b/tests/UnitTests/TemplateSource/TagTests/IncludePhp/templates/include_php.tpl new file mode 100644 index 00000000..f8fbe555 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/IncludePhp/templates/include_php.tpl @@ -0,0 +1 @@ +start {include_php file='scripts/test_include_php.php'} end diff --git a/tests/UnitTests/TemplateSource/TagTests/IncludePhp/templates/include_php_trusted.tpl b/tests/UnitTests/TemplateSource/TagTests/IncludePhp/templates/include_php_trusted.tpl new file mode 100644 index 00000000..55c5865d --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/IncludePhp/templates/include_php_trusted.tpl @@ -0,0 +1 @@ +start {include_php file='test_include_php.php' once=false} end diff --git a/tests/UnitTests/TemplateSource/TagTests/IncludePhp/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/IncludePhp/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/IncludePhp/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Insert/CompileInsertTest.php b/tests/UnitTests/TemplateSource/TagTests/Insert/CompileInsertTest.php new file mode 100644 index 00000000..61e8835c --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Insert/CompileInsertTest.php @@ -0,0 +1,268 @@ +<?php +/** + * Smarty PHPunit tests compilation of the {insert} tag + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for {insert} tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class CompileInsertTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + $this->smarty->addPluginsDir(dirname(__FILE__) . "/PHPunitplugins/"); + $this->smarty->enableSecurity(); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * Test For + * + * @preserveGlobalState disabled + * @dataProvider dataTestInsert + * @runInSeparateProcess + */ + public function testInsert($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Insert_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->assign('variable', 'test'); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->assertEquals($result, + $this->smarty->fetch($file), + $file); + } + + /* + * Data provider für testInsert + */ + public function dataTestInsert() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array( + array('start {insert name=\'test\' foo=\'bar\'} end', 'start insert function parameter value bar end', 'T1', $i++), + array('start {insert name="test" foo=\'bar\'} end', 'start insert function parameter value bar end', 'T2', $i++), + array('start {insert name=$variable foo=\'bar\'} end', 'start insert function parameter value bar end', 'T3', $i++), + array("start {insert name='test' foo='bar' assign=blar} end {\$blar}", 'start end insert function parameter value bar', 'T4', $i++), + array("start {insert name='test' foo='bar' assign=blar} end", 'start end', 'T5', $i++), + ); + } + + + + + /** + * test insert plugin + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testInsertPlugin1() + { + global $insertglobal; + $insertglobal = 'global'; + $tpl = $this->smarty->createTemplate('insertplugintest.tpl'); + $tpl->assign('foo', 'bar'); + $this->assertEquals('param foo bar globalvar global', $this->smarty->fetch($tpl)); + } + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * test insert plugin + */ + public function testInsertPlugin2() + { + global $insertglobal; + $insertglobal = 'global 2'; + $tpl = $this->smarty->createTemplate('insertplugintest.tpl'); + $tpl->assign('foo', 'buh'); + $this->assertEquals('param foo buh globalvar global 2', $this->smarty->fetch($tpl)); + } + + /** + * test insert plugin caching + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testInsertPluginCaching1_1() + { + global $insertglobal; + $insertglobal = 'global'; + $this->smarty->caching = true; + $tpl = $this->smarty->createTemplate('insertplugintest.tpl'); + $tpl->assign('foo', 'bar', true); + $this->assertEquals('param foo bar globalvar global', $this->smarty->fetch($tpl)); + } + + /** + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testInsertPluginCaching1_2() + { + $this->smarty->addPluginsDir(dirname(__FILE__) . "/PHPunitplugins/"); + global $insertglobal; + $insertglobal = 'changed global 2'; + $this->smarty->caching = 1; + $tpl = $this->smarty->createTemplate('insertplugintest.tpl'); + $tpl->assign('foo', 'buh', true); +// $this->assertTrue($tpl->isCached()); + $this->assertEquals('param foo buh globalvar changed global 2', $this->smarty->fetch($tpl)); + } + + /** + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testInsertPluginCaching1_3() + { + $this->smarty->addPluginsDir(dirname(__FILE__) . "/PHPunitplugins/"); + global $insertglobal; + $insertglobal = 'changed global'; + $this->smarty->caching = 1; +// $this->smarty->setForceCompile(true); + $this->smarty->assign('foo', 'bar', true); + $this->assertEquals('param foo bar globalvar changed global', $this->smarty->fetch('insertplugintest.tpl')); + } + + /** + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testInsertPluginCaching1_4() + { + global $insertglobal; + $this->smarty->addPluginsDir(dirname(__FILE__) . "/PHPunitplugins/"); + $insertglobal = 'changed global 4'; + $this->smarty->caching = 1; + $this->smarty->assign('foo', 'buh', true); + $this->assertTrue($this->smarty->isCached('insertplugintest.tpl')); + $this->assertEquals('param foo buh globalvar changed global 4', $this->smarty->fetch('insertplugintest.tpl')); + } + /** + * test insert plugin caching 2 + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testInsertPluginCaching2_1() + { + global $insertglobal; + $insertglobal = 'global'; + $this->smarty->caching = true; + $this->smarty->compile_id = 1; + $tpl = $this->smarty->createTemplate('insertplugintest.tpl'); + $tpl->assign('foo', 'bar'); + $this->assertEquals('param foo bar globalvar global', $this->smarty->fetch($tpl)); + } + + /** + * test insert plugin caching 2 + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testInsertPluginCaching2_2() + { + global $insertglobal; + $insertglobal = 'global 2'; + $this->smarty->caching = true; + $this->smarty->compile_id = 1; + $tpl = $this->smarty->createTemplate('insertplugintest.tpl'); + $tpl->assign('foo', 'buh'); + $this->assertContains('param foo bar globalvar global 2', $this->smarty->fetch($tpl)); + } + /** + * test insert plugin caching 3 + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testInsertPluginCaching3_1() + { + $this->smarty->caching = true; + $this->smarty->assign('insert',$t=time()); + $this->assertContains($t.'Inner template', $this->smarty->fetch('insertplugintest2.tpl')); + } + + /** + * test insert plugin caching 2 + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testInsertPluginCaching3_2() + { + sleep(2); + $this->smarty->caching = true; + $this->smarty->assign('insert',$t=time()); + $this->assertContains($t.'Inner template', $this->smarty->fetch('insertplugintest2.tpl')); + } + + + /** + * test inserted function none existing function + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testInsertFunctionNoneExistingFunction() + { + $tpl = $this->smarty->createTemplate("eval:start {insert name='mustfail' foo='bar' assign=blar} end {\$blar}"); + try { + $this->smarty->fetch($tpl); + } + catch (Exception $e) { + $this->assertContains("{insert} no function or plugin found for 'mustfail'", $e->getMessage()); + + return; + } + $this->fail('Exception for "function is not callable" has not been raised.'); + } + + /** + * test inserted function none existing script + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testInsertFunctionNoneExistingScript() + { + $tpl = $this->smarty->createTemplate("eval:{insert name='mustfail' foo='bar' script='nofile.php'}"); + try { + $this->smarty->fetch($tpl); + } + catch (Exception $e) { + $this->assertContains('missing script file', $e->getMessage()); + + return; + } + $this->fail('Exception for "missing file" has not been raised.'); + } +} + +/** + * test function + */ +function insert_test($params, $template) +{ + return "insert function parameter value $params[foo]"; +} diff --git a/tests/UnitTests/TemplateSource/TagTests/Insert/PHPunitplugins/insert.insertplugintest.php b/tests/UnitTests/TemplateSource/TagTests/Insert/PHPunitplugins/insert.insertplugintest.php new file mode 100644 index 00000000..cd2e27cd --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Insert/PHPunitplugins/insert.insertplugintest.php @@ -0,0 +1,7 @@ +<?php +function smarty_insert_insertplugintest($params, $template) +{ + global $insertglobal; + + return 'param foo ' . $params['foo'] . ' globalvar ' . $insertglobal; +} diff --git a/tests/UnitTests/TemplateSource/TagTests/Insert/PHPunitplugins/insert.test2.php b/tests/UnitTests/TemplateSource/TagTests/Insert/PHPunitplugins/insert.test2.php new file mode 100644 index 00000000..bfc35e12 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Insert/PHPunitplugins/insert.test2.php @@ -0,0 +1,6 @@ +<?php + +function smarty_insert_test2($params, $smarty) { + + return $smarty->tpl_vars[$params['var']]->value; +} diff --git a/tests/UnitTests/TemplateSource/TagTests/Insert/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Insert/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Insert/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Insert/templates/inner.tpl b/tests/UnitTests/TemplateSource/TagTests/Insert/templates/inner.tpl new file mode 100644 index 00000000..e5f67304 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Insert/templates/inner.tpl @@ -0,0 +1 @@ +Inner template diff --git a/tests/UnitTests/TemplateSource/TagTests/Insert/templates/insertplugintest.tpl b/tests/UnitTests/TemplateSource/TagTests/Insert/templates/insertplugintest.tpl new file mode 100644 index 00000000..579f2548 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Insert/templates/insertplugintest.tpl @@ -0,0 +1 @@ +{insert name='insertplugintest' foo=$foo}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Insert/templates/insertplugintest2.tpl b/tests/UnitTests/TemplateSource/TagTests/Insert/templates/insertplugintest2.tpl new file mode 100644 index 00000000..a1834ab0 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Insert/templates/insertplugintest2.tpl @@ -0,0 +1,2 @@ +{insert name='test2' var='insert'} +{include 'inner.tpl'}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Insert/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Insert/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Insert/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Insert/templates_tmp/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Insert/templates_tmp/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Insert/templates_tmp/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Literal/LiteralTest.php b/tests/UnitTests/TemplateSource/TagTests/Literal/LiteralTest.php new file mode 100644 index 00000000..972f9e25 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Literal/LiteralTest.php @@ -0,0 +1,67 @@ +<?php +/** + * Smarty PHPunit tests appendByRef method + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for appendByRef tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class LiteralTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /* + * Test literal tag + */ + public function testLiteralTag() + { + $tpl = $this->smarty->createTemplate("string:{literal} {\$foo} {/literal}"); + $this->assertEquals(' {$foo} ', $this->smarty->fetch($tpl)); + } + + /* + * Test auto literal space + */ + public function testAutoLiteralSpace() + { + $tpl = $this->smarty->createTemplate("string: { \$foo} "); + $tpl->assign('foo', 'literal'); + $this->assertEquals(' { $foo} ', $this->smarty->fetch($tpl)); + } + + /* + * Test auto literal line break + */ + public function testAutoLiteralLineBreak() + { + $tpl = $this->smarty->createTemplate("string: {\n\$foo} "); + $tpl->assign('foo', 'literal'); + $this->assertEquals(" {\n\$foo} ", $this->smarty->fetch($tpl)); + } + + /* + * Test auto literal disabled + */ + public function testAutoLiteralDisabled() + { + $this->smarty->setAutoLiteral(false); + $tpl = $this->smarty->createTemplate("string: { \$foo} "); + $tpl->assign('foo', 'literal'); + $this->assertEquals(' literal ', $this->smarty->fetch($tpl)); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/Literal/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Literal/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Literal/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Literal/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Literal/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Literal/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/MakeNocache/CompileMakeNocacheTest.php b/tests/UnitTests/TemplateSource/TagTests/MakeNocache/CompileMakeNocacheTest.php new file mode 100644 index 00000000..718c7313 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/MakeNocache/CompileMakeNocacheTest.php @@ -0,0 +1,309 @@ +<?php +/** + * Smarty PHPunit tests compilation of {make_nocache} tags + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for {make_nocache} tags tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class CompileMakeNocacheTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); + $this->smarty->addTemplateDir("../../../__shared/templates/"); + $this->smarty->addTemplateDir("./templates_tmp"); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * Test {make_nocache} tags caching disabled + * + * @not runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestMakeNocache001 + */ + public function testMakeNocache_001($foo, $result) + { + if ($foo) { + $this->smarty->assign('foo', $foo); + } + $this->assertEquals($result, $this->smarty->fetch('001_test_foo.tpl'), + "foo = {$foo}"); + } + + /* + * Data provider für testMakeNocache_001 + */ + public function dataTestMakeNocache001() + { + + /* + * $foo + * result + * + */ + return array(array(1, '#001_test_foo.tpl:$foo =1'), array(2, '#001_test_foo.tpl:$foo =2'), + array(null, '#001_test_foo.tpl:$foo =>unassigned<'),); + } + + /** + * Test {make_nocache} cached tags + * + * @not runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestMakeNocache001_1 + */ + public function testMakeNocache_001_1($foo, $result) + { + $this->smarty->setCaching(true); + if ($foo) { + $this->smarty->assign('foo', $foo); + } + $this->assertEquals($result, $this->smarty->fetch('001_test_foo.tpl'), + "foo = {$foo}"); + } + + /* + * Data provider für testMakeNocache_001_1 + */ + public function dataTestMakeNocache001_1() + { + + /* + * $foo + * result + * + */ + return array(array(1, '#001_test_foo.tpl:$foo =1'), array(2, '#001_test_foo.tpl:$foo =1'), + array(null, '#001_test_foo.tpl:$foo =1'),); + } + + /** + * Test {make_nocache} cached tags existing nocahe variable + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestMakeNocache001_2 + */ + public function testMakeNocache_001_2($foo, $result) + { + $this->smarty->setCaching(true); + if ($foo) { + $this->smarty->assign('foo', $foo, true); + } + $this->assertEquals($result, $this->smarty->fetch('001_test_foo.tpl'), + "foo = {$foo}"); + } + + /* + * Data provider für testMakeNocache_001_2 + */ + public function dataTestMakeNocache001_2() + { + + /* + * $foo + * result + * + */ + return array(array(1, '#001_test_foo.tpl:$foo =1'), array(2, '#001_test_foo.tpl:$foo =2'), + array(null, '#001_test_foo.tpl:$foo =1'),); + } + + /** + * Test {make_nocache} cached tags reassign + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestMakeNocache001_3 + */ + public function testMakeNocache_001_3($foo, $result) + { + $this->smarty->setCaching(true); + if ($foo) { + $this->smarty->assign('foo', $foo); + } + $this->smarty->assign('bar', $foo + 4, true); + $this->assertEquals($result, $this->smarty->fetch('001_test_foo_assign.tpl'), + "foo = {$foo}"); + } + + /* + * Data provider für testMakeNocache_001_3 + */ + public function dataTestMakeNocache001_3() + { + + /* + * $foo + * result + * + */ + return array(array(1, '#001_test_foo_assign.tpl:$foo =5'), array(2, '#001_test_foo_assign.tpl:$foo =6'), + array(null, '#001_test_foo_assign.tpl:$foo =4'),); + } + + /** + * Test {make_nocache} cached tags {if} + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestMakeNocache001_4 + */ + public function testMakeNocache_001_4($foo, $bar, $result) + { + $this->smarty->setCaching(true); + $this->smarty->assign('foo', $foo); + $this->smarty->assign('bar', $bar); + $this->assertEquals($result, $this->smarty->fetch('001_test_foo_if.tpl'), + "foo = {$foo}"); + } + + /* + * Data provider für testMakeNocache_001_4 + */ + public function dataTestMakeNocache001_4() + { + /* + * $foo + * $bar + * result + * + */ + return array(array(10, 9, 'greater'), array(9, 10, 'greater'),); + } + + /** + * Test {make_nocache} cached tags {if} nocache + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestMakeNocache001_5 + */ + public function testMakeNocache_001_5($foo, $bar, $result) + { + $this->smarty->setCaching(true); + $this->smarty->compile_id = 1; + if ($foo) { + $this->smarty->assign('foo', $foo); + } + $this->smarty->assign('bar', $bar, true); + $this->assertEquals($result, $this->smarty->fetch('001_test_foo_if.tpl'), + "foo = {$foo}"); + } + + /* + * Data provider für testMakeNocache_001_5 + */ + public function dataTestMakeNocache001_5() + { + /* + * $foo + * $bar + * result + * + */ + return array(array(10, 9, 'greater'), array(9, 10, 'not greater'), array(null, 11, 'not greater'), + array(null, 2, 'greater'),); + } + + /** + * Test {make_nocache} cached tags {foreach} + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestMakeNocache001_6 + */ + public function testMakeNocache_001_6($foo, $bar, $result) + { + $this->smarty->setCaching(true); + $this->smarty->assign('foo', $foo, true); + $this->smarty->assign('bar', $bar); + $this->assertEquals($result, $this->smarty->fetch('001_test_foo_foreach.tpl'), + "foo = {$foo}"); + } + + /* + * Data provider für testMakeNocache_001_6 + */ + public function dataTestMakeNocache001_6() + { + + /* + * $foo + * $bar + * result + * + */ + return array(array(2, array(1, 2, 3, 4), ' 1 2match 3 4'), array(3, array(7, 8, 9), ' 1 2 3match 4'),); + } + + /** + * Test {make_nocache} cached tags {foreach} nocache + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestMakeNocache001_7 + */ + public function testMakeNocache_001_7($foo, $bar, $result) + { + $this->smarty->setCaching(true); + $this->smarty->compile_id = 1; + $this->smarty->assign('foo', $foo, true); + $this->smarty->assign('bar', $bar, true); + $this->assertEquals($result, $this->smarty->fetch('001_test_foo_foreach.tpl'), + "foo = {$foo}"); + } + + /* + * Data provider für testMakeNocache_001_7 + */ + public function dataTestMakeNocache001_7() + { + + /* + * $foo + * $bar + * result + * + */ + return array(array(2, array(1, 2, 3, 4), ' 1 2match 3 4'), array(7, array(7, 8, 9), ' 7match 8 9'),); + } + /** + * Test {make_nocache} with values containing '\' + * + * @preserveGlobalState disabled + */ + public function testMakeNocache_002() + { + $this->smarty->setCaching(true); + $this->smarty->assign('foo', 'uwe\'s'); + $this->assertEquals($this->strip('uwe\'s'), $this->smarty->fetch('002_test_backslash.tpl')); + } + + /** + * Test {make_nocache} with values containing spaces + * + * @preserveGlobalState disabled + */ + public function testMakeNocache_003() + { + $this->smarty->setCaching(true); + $this->smarty->assign('foo', 'the Smarty template engine'); + $this->assertEquals('the Smarty template engine', $this->smarty->fetch('003_test_spaces.tpl')); + } + +} diff --git a/tests/UnitTests/TemplateSource/TagTests/MakeNocache/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/MakeNocache/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/MakeNocache/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates/001_test_foo.tpl b/tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates/001_test_foo.tpl new file mode 100644 index 00000000..4253b8dd --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates/001_test_foo.tpl @@ -0,0 +1 @@ +{make_nocache $foo}{checkvar var=foo types='template' nocache}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates/001_test_foo_assign.tpl b/tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates/001_test_foo_assign.tpl new file mode 100644 index 00000000..7042daf3 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates/001_test_foo_assign.tpl @@ -0,0 +1 @@ +{make_nocache $foo}{$foo=$bar nocache}{checkvar var=foo types='template' nocache}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates/001_test_foo_foreach.tpl b/tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates/001_test_foo_foreach.tpl new file mode 100644 index 00000000..326fa569 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates/001_test_foo_foreach.tpl @@ -0,0 +1,3 @@ +{foreach $bar as $i} + {$i}{make_nocache $i}{if $i == $foo}match{/if} +{/foreach}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates/001_test_foo_if.tpl b/tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates/001_test_foo_if.tpl new file mode 100644 index 00000000..fe2c88e1 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates/001_test_foo_if.tpl @@ -0,0 +1 @@ +{make_nocache $foo}{if $foo > $bar}greater{else}not greater{/if}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates/002_test_backslash.tpl b/tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates/002_test_backslash.tpl new file mode 100644 index 00000000..ab21fba8 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates/002_test_backslash.tpl @@ -0,0 +1 @@ +{make_nocache $foo}{$foo nocache}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates/003_test_spaces.tpl b/tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates/003_test_spaces.tpl new file mode 100644 index 00000000..ab21fba8 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates/003_test_spaces.tpl @@ -0,0 +1 @@ +{make_nocache $foo}{$foo nocache}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/MakeNocache/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Nocache/CompileNocacheTest.php b/tests/UnitTests/TemplateSource/TagTests/Nocache/CompileNocacheTest.php new file mode 100644 index 00000000..a0a7e373 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Nocache/CompileNocacheTest.php @@ -0,0 +1,75 @@ +<?php +/** + * Smarty PHPunit tests compilation of {nocache} tag + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for {nocache} tag tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class CompileNocacheTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test nocache tag caching disabled + */ + public function testNocacheCachingNo() + { + $this->smarty->caching = 0; + $this->smarty->assign('foo', 0); + $this->smarty->assign('bar', 'A'); + $content = $this->smarty->fetch('test_nocache_tag.tpl'); + $this->assertContains("root 2A", $content); + $this->assertContains("include 4A", $content); + $this->smarty->assign('foo', 2); + $this->smarty->assign('bar', 'B'); + $content = $this->smarty->fetch('test_nocache_tag.tpl'); + $this->assertContains("root 4B", $content); + $this->assertContains("include 6B", $content); + } + + /** + * test nocache tag caching enabled + */ + public function testNocacheCachingYes1() + { + $this->smarty->caching = 1; + $this->smarty->assign('foo', 0); + $this->smarty->assign('bar', 'A'); + $content = $this->smarty->fetch('test_nocache_tag.tpl'); + $this->assertContains("root 2A", $content); + $this->assertContains("include 4A", $content); + + } + + /** + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * + */ + public function testNocacheCachingYes2() + { + $this->smarty->caching = 1; + $this->smarty->assign('foo', 2); + $this->smarty->assign('bar', 'B'); + $content = $this->smarty->fetch('test_nocache_tag.tpl'); + $this->assertContains("root 4A", $content); + $this->assertContains("include 6A", $content); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/Nocache/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Nocache/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Nocache/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Nocache/templates/test_nocache_tag.tpl b/tests/UnitTests/TemplateSource/TagTests/Nocache/templates/test_nocache_tag.tpl new file mode 100644 index 00000000..fed2d1fa --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Nocache/templates/test_nocache_tag.tpl @@ -0,0 +1,2 @@ +<br>root {nocache}{$foo + 2}{/nocache}{$bar} +{include file='test_nocache_tag_include.tpl'}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Nocache/templates/test_nocache_tag_include.tpl b/tests/UnitTests/TemplateSource/TagTests/Nocache/templates/test_nocache_tag_include.tpl new file mode 100644 index 00000000..6ef97be7 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Nocache/templates/test_nocache_tag_include.tpl @@ -0,0 +1 @@ +<br>include {nocache}{$foo + 4}{/nocache}{$bar}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Nocache/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Nocache/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Nocache/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Php/CompilePhpTest.php b/tests/UnitTests/TemplateSource/TagTests/Php/CompilePhpTest.php new file mode 100644 index 00000000..fb34e9f4 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Php/CompilePhpTest.php @@ -0,0 +1,198 @@ +<?php +/** + * Smarty PHPunit tests compilation of {php} and <?php...?> tag + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for {php} and <?php...?> tag tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class CompilePhpTest extends PHPUnit_Smarty +{ + public $loadSmartyBC = true; + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + $this->smarty->setUseSubDirs(true); + $this->smartyBC->setUseSubDirs(true); + $this->smartyBC->disableSecurity(); + $this->smarty->disableSecurity(); + $this->smarty->setCompileId($this->getName()); + $this->smartyBC->setCompileId($this->getName()); + } + + public function testInit() + { + $this->cleanDirs(); + } + + + /** + * Test + * @run InSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + * + */ + public function testPHP($phpHandling, $templateFile, $result, $testName) + { + $result = str_replace("\r", '', $result); + $this->smartyBC->force_compile = true; + $this->smartyBC->php_handling = $phpHandling; + $this->smartyBC->compile_id = $testName.$this->smartyBC->php_handling ; + $tpl = $this->smartyBC->createTemplate($templateFile); + if ($phpHandling == Smarty::PHP_PASSTHRU || $phpHandling == Smarty::PHP_QUOTE) { + $result = str_replace("\r", '', $tpl->source->getContent()); + } + if ($phpHandling == Smarty::PHP_QUOTE) { + $result = preg_replace_callback('#(<\?(?:php|=)?)|(<%)|(<script\s+language\s*=\s*["\']?\s*php\s*["\']?\s*>)|(\?>)|(%>)|(<\/script>)#i', array($this, 'quote'), $result); + } + $content = $tpl->fetch(); + $this->assertEquals($result, $content, $testName); + } /** + * Test + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider data + * + */ + public function testPHPcaching($phpHandling, $templateFile, $result, $testName) + { + $result = str_replace("\r", '', $result); + $this->smartyBC->php_handling = $phpHandling; + $this->smartyBC->compile_id = $testName.$this->smartyBC->php_handling ; + $this->smartyBC->caching = true; + $this->smartyBC->force_cache = true; + $tpl = $this->smartyBC->createTemplate($templateFile); + if ($phpHandling == Smarty::PHP_PASSTHRU || $phpHandling == Smarty::PHP_QUOTE) { + $result = str_replace("\r", '', $tpl->source->getContent()); + } + if ($phpHandling == Smarty::PHP_QUOTE) { + $result = preg_replace_callback('#(<\?(?:php|=)?)|(<%)|(<script\s+language\s*=\s*["\']?\s*php\s*["\']?\s*>)|(\?>)|(%>)|(<\/script>)#i', array($this, 'quote'), $result); + } + $content = $tpl->fetch(); + $this->assertEquals($result, $content, $testName); + } + /** + * @expectedException SmartyCompilerException + * @expectedExceptionMessage $smarty->php_handling PHP_ALLOW not allowed. Use SmartyBC to enable it + */ + + public function testPHP_ALLOW_error() + { + $this->smarty->setPhpHandling(Smarty::PHP_ALLOW); + $content = $this->smarty->fetch("string:aa <?php echo 'hallo'; ?> ae"); + } + + /** + * test {php nocache}{/php} tag + */ + public function testPHP_Tag_Nocache1() + { + $this->smartyBC->caching = 1; + $this->smartyBC->assign('foo', 'foo'); + $this->smartyBC->compile_id = 'Tag nocache' ; + $content = $this->smartyBC->fetch('phptag_nocache.tpl'); + $this->assertEquals('-->foo<--', $content,'Tag nocache 1'); + } + + public function testPHP_Tag_Nocache2() + { + $this->smartyBC->caching = 1; + $this->smartyBC->assign('foo', 'bar'); + $this->smartyBC->compile_id = 'Tag nocache' ; + $content = $this->smartyBC->fetch('phptag_nocache.tpl'); + $this->assertEquals('-->bar<--', $content,'Tag nocache 2'); + } + /** + * test {php no cache}illegal option + * @expectedException SmartyCompilerException + * @expectedExceptionMessage illegal value of option flag 'no cache' + * + */ + public function testPHP_Tag_IllegalOption() + { + $content = $this->smartyBC->fetch("string:aa {php no cache} echo 'hallo'; {/php} ae"); + } + + /** + * Test regression that plugin names starting with 'php' do work + */ + public function testPHPfooPlugin() + { + $this->smarty->addPluginsDir("./PHPunitplugins/"); + $this->smartyBC->compile_id = 'Tag nocache' ; + $this->assertEquals('phptest okay', $this->smarty->fetch('string:{phptest}'),'testPHPfooPlugin'); + } + + public function data() + { + $shortTag = ini_get('short_open_tag') == 1; + $aspTag = ini_get('asp_tags') == 1; + + $data = array( + /* + * php_handling + * template file + * result + * text + */ + array(Smarty::PHP_REMOVE, 'php.tpl', '--><--', 'PHP_REMOVE, \'php.tpl\''), + array(Smarty::PHP_PASSTHRU, 'php.tpl', '', 'PHP_PASSTHRU, \'php.tpl\''), + array(Smarty::PHP_QUOTE, 'php.tpl', '', 'PHP_QUOTE, \'php.tpl\''), + array(Smarty::PHP_ALLOW, 'php.tpl', '--> hello world <?php ?> <--', 'PHP_ALLOW, \'php.tpl\''), + array(Smarty::PHP_REMOVE, 'php_line_comment.tpl', '--><--', 'PHP_REMOVE, \'php_line_comment.tpl\''), + array(Smarty::PHP_PASSTHRU, 'php_line_comment.tpl', '', 'PHP_PASSTHRU, \'php_line_comment.tpl\''), + array(Smarty::PHP_QUOTE, 'php_line_comment.tpl', '', 'PHP_QUOTE, \'php_line_comment.tpl\''), + array(Smarty::PHP_ALLOW, 'php_line_comment.tpl', '--> hello world <?php ?> <--', 'PHP_ALLOW, \'php_line_comment.tpl\''), + array(Smarty::PHP_REMOVE, 'php_block_comment.tpl', '--><--', 'PHP_REMOVE, \'php_block_comment.tpl\''), + array(Smarty::PHP_PASSTHRU, 'php_block_comment.tpl', '', 'PHP_PASSTHRU, \'php_block_comment.tpl\''), + array(Smarty::PHP_QUOTE, 'php_block_comment.tpl', '', 'PHP_QUOTE, \'php_block_comment.tpl\''), + array(Smarty::PHP_ALLOW, 'php_block_comment.tpl', '--> hello world <?php ?> <--', 'PHP_ALLOW, \'php_block_comment.tpl\''), + array(Smarty::PHP_REMOVE, 'php2.tpl', '--><--', 'PHP_REMOVE, \'php2.tpl\''), + array(Smarty::PHP_PASSTHRU, 'php2.tpl', '', 'PHP_PASSTHRU, \'php2.tpl\''), + array(Smarty::PHP_QUOTE, 'php2.tpl', '', 'PHP_QUOTE, \'php2.tpl\''), + array(Smarty::PHP_ALLOW, 'php2.tpl', $shortTag || strpos(phpversion(), 'hhvm') !== false ? '--> hello world <? ?> <--' : '--><? echo \' hello world \'; +echo \'<? \'; +echo \'?> \'; +?><--', 'PHP_ALLOW, \'php2.tpl\''), + array(Smarty::PHP_REMOVE, 'asp.tpl', '--><--', 'PHP_REMOVE, \'asp.tpl\''), + array(Smarty::PHP_PASSTHRU, 'asp.tpl', '', 'PHP_PASSTHRU, \'asp.tpl\''), + array(Smarty::PHP_QUOTE, 'asp.tpl', '', 'PHP_QUOTE, \'asp.tpl\''), + array(Smarty::PHP_ALLOW, 'asp.tpl', $aspTag ? '-->hello world <% %> <--' : '--><% echo \'hello world \'; +echo \'<% \'; +echo \'%> \'; +%><--', 'PHP_ALLOW, \'asp.tpl\''), + array(Smarty::PHP_REMOVE, 'script.tpl', '<br><br>', 'PHP_REMOVE, \'script.tpl\''), + array(Smarty::PHP_PASSTHRU, 'script.tpl', '', 'PHP_PASSTHRU, \'script.tpl\''), + array(Smarty::PHP_QUOTE, 'script.tpl', '', 'PHP_QUOTE, \'script.tpl\''), + array(Smarty::PHP_ALLOW, 'phptag.tpl', '--> hello world {php} {/php} <--', 'PHP_ALLOW, \'phptag.tpl\''), + array(Smarty::PHP_ALLOW, 'phptag_line_comment.tpl', '--> hello world {php} {/php} <--', 'PHP_ALLOW, \'phptag_line_comment.tpl\''), + array(Smarty::PHP_ALLOW, 'phptag_block_comment.tpl', '--> hello world {php} {/php} <--', 'PHP_ALLOW, \'phptag_block_comment.tpl\''), + array(Smarty::PHP_ALLOW, 'phptag_literal.tpl', '-->{ php} echo \' hello world \'; +echo \'foo \'; +echo \'bar \'; +$foo = 3; +{ /php}<--', 'PHP_ALLOW, \'phptag_literal.tpl\''), + ); + if (version_compare(phpversion(), '5.7.0', '<')) { + $data[] = array(Smarty::PHP_ALLOW, 'script.tpl', '<br> This is a script <br> 5<br>', 'PHP_ALLOW, \'script.tpl\''); + } + return $data; + } + /* + * Call back function for $php_handling = PHP_QUOTE + * + */ + private function quote($match) + { + return htmlspecialchars($match[0], ENT_QUOTES); + } + +} diff --git a/tests/UnitTests/TemplateSource/TagTests/Php/PHPunitplugins/function.phptest.php b/tests/UnitTests/TemplateSource/TagTests/Php/PHPunitplugins/function.phptest.php new file mode 100644 index 00000000..922609e4 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Php/PHPunitplugins/function.phptest.php @@ -0,0 +1,5 @@ +<?php +function smarty_function_phptest($params,$smarty) +{ + return 'phptest okay'; +} diff --git a/tests/UnitTests/TemplateSource/TagTests/Php/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Php/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Php/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Php/templates/asp.tpl b/tests/UnitTests/TemplateSource/TagTests/Php/templates/asp.tpl new file mode 100644 index 00000000..c3a2433e --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Php/templates/asp.tpl @@ -0,0 +1,4 @@ +--><% echo 'hello world '; +echo '<% '; +echo '%> '; +%><--
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Php/templates/php.tpl b/tests/UnitTests/TemplateSource/TagTests/Php/templates/php.tpl new file mode 100644 index 00000000..8a9acec6 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Php/templates/php.tpl @@ -0,0 +1,5 @@ +--><?php echo ' hello world '; +echo '<?php '; +echo '?> '; +$foo = 3; +?><--
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Php/templates/php2.tpl b/tests/UnitTests/TemplateSource/TagTests/Php/templates/php2.tpl new file mode 100644 index 00000000..44beed4a --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Php/templates/php2.tpl @@ -0,0 +1,4 @@ +--><? echo ' hello world '; +echo '<? '; +echo '?> '; +?><--
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Php/templates/php_block_comment.tpl b/tests/UnitTests/TemplateSource/TagTests/Php/templates/php_block_comment.tpl new file mode 100644 index 00000000..4524e45e --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Php/templates/php_block_comment.tpl @@ -0,0 +1,16 @@ +--><?php echo ' hello world '; +/* +* comment <?php is okay +* +* comment <?php once again +*/ + +echo '<?php '; + +/* +* other comment <% foo +*/ + +echo '?> '; +$foo = 3; +?><--
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Php/templates/php_line_comment.tpl b/tests/UnitTests/TemplateSource/TagTests/Php/templates/php_line_comment.tpl new file mode 100644 index 00000000..176d3580 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Php/templates/php_line_comment.tpl @@ -0,0 +1,12 @@ +--><?php echo ' hello world '; +// comment <?php is okay +// +// comment <?php once again + +echo '<?php '; + +// other comment <% foo + +echo '?> '; +$foo = 3; +?><--
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Php/templates/phptag.tpl b/tests/UnitTests/TemplateSource/TagTests/Php/templates/phptag.tpl new file mode 100644 index 00000000..f7b92e9f --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Php/templates/phptag.tpl @@ -0,0 +1,5 @@ +-->{php} echo ' hello world '; +echo '{php} '; +echo '{/php} '; +$foo = 3; +{/php}<--
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Php/templates/phptag_block_comment.tpl b/tests/UnitTests/TemplateSource/TagTests/Php/templates/phptag_block_comment.tpl new file mode 100644 index 00000000..af837c78 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Php/templates/phptag_block_comment.tpl @@ -0,0 +1,16 @@ +-->{php} echo ' hello world '; +/* +* comment {/php} is okay +* +* comment {/php} once again {/php} foo +*/ + +echo '{php} '; + +/* +* other comment <% foo +*/ + +echo '{/php} '; +$foo = 3; +{/php}<--
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Php/templates/phptag_line_comment.tpl b/tests/UnitTests/TemplateSource/TagTests/Php/templates/phptag_line_comment.tpl new file mode 100644 index 00000000..16907ce2 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Php/templates/phptag_line_comment.tpl @@ -0,0 +1,12 @@ +-->{php} echo ' hello world '; +// comment {/php} is okay +// +// comment {/php} once again {/php} foo + +echo '{php} '; + +// other comment <% foo + +echo '{/php} '; +$foo = 3; +{/php}<--
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Php/templates/phptag_literal.tpl b/tests/UnitTests/TemplateSource/TagTests/Php/templates/phptag_literal.tpl new file mode 100644 index 00000000..24420541 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Php/templates/phptag_literal.tpl @@ -0,0 +1,5 @@ +-->{ php} echo ' hello world '; +echo 'foo '; +echo 'bar '; +$foo = 3; +{ /php}<--
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Php/templates/phptag_nocache.tpl b/tests/UnitTests/TemplateSource/TagTests/Php/templates/phptag_nocache.tpl new file mode 100644 index 00000000..086a25f0 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Php/templates/phptag_nocache.tpl @@ -0,0 +1,2 @@ +-->{php nocache} echo $_smarty_tpl->getTemplateVars('foo'); +{/php}<--
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Php/templates/script.tpl b/tests/UnitTests/TemplateSource/TagTests/Php/templates/script.tpl new file mode 100644 index 00000000..076e32dd --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Php/templates/script.tpl @@ -0,0 +1 @@ +<br><script language='php'>echo ' This is a script <br> ';echo 2+3;</script><br>
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Php/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Php/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Php/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginBlock/PluginBlockTextformatTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginBlock/PluginBlockTextformatTest.php new file mode 100644 index 00000000..382c73ce --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginBlock/PluginBlockTextformatTest.php @@ -0,0 +1,136 @@ +<?php +/** + * Smarty PHPunit tests of modifier + * + * @package PHPunit + * @author Rodney Rehm + */ + +/** + * class for modifier tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class PluginBlockTextformatTest extends PHPUnit_Smarty +{ + protected $string = "\n\nThis is foo.\nThis is foo.\nThis is foo.\nThis is foo.\nThis is foo.\nThis is foo.\n\nThis is bar.\n\nbar foo bar foo foo.\nbar foo bar foo foo.\nbar foo bar foo foo.\nbar foo bar foo foo.\nbar foo bar foo foo.\nbar foo bar foo foo.\nbar foo bar foo foo.\n\n"; + + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + public function testDefault() + { + $result = "This is foo. This is foo. This is foo.\nThis is foo. This is foo. This is foo.\n\nThis is bar.\n\nbar foo bar foo foo. bar foo bar foo\nfoo. bar foo bar foo foo. bar foo bar\nfoo foo. bar foo bar foo foo. bar foo\nbar foo foo. bar foo bar foo foo.\n\n"; + $tpl = $this->smarty->createTemplate('string:{textformat wrap=40}' . $this->string . '{/textformat}'); + $this->assertEquals($result, $this->smarty->fetch($tpl)); + } + + public function testDefaultWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $result = "This is foo. This is foo. This is foo.\nThis is foo. This is foo. This is foo.\n\nThis is bar.\n\nbar foo bar foo foo. bar foo bar foo\nfoo. bar foo bar foo foo. bar foo bar\nfoo foo. bar foo bar foo foo. bar foo\nbar foo foo. bar foo bar foo foo.\n\n"; + $tpl = $this->smarty->createTemplate('string:{textformat wrap=40}' . $this->string . '{/textformat}'); + $this->assertEquals($result, $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testIndent() + { + $result = " This is foo. This is foo. This is\n foo. This is foo. This is foo. This\n is foo.\n\n This is bar.\n\n bar foo bar foo foo. bar foo bar foo\n foo. bar foo bar foo foo. bar foo\n bar foo foo. bar foo bar foo foo.\n bar foo bar foo foo. bar foo bar foo\n foo.\n\n"; + $tpl = $this->smarty->createTemplate('string:{textformat wrap=40 indent=4}' . $this->string . '{/textformat}'); + $this->assertEquals($result, $this->smarty->fetch($tpl)); + } + + public function testIndentWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $result = " This is foo. This is foo. This is\n foo. This is foo. This is foo. This\n is foo.\n\n This is bar.\n\n bar foo bar foo foo. bar foo bar foo\n foo. bar foo bar foo foo. bar foo\n bar foo foo. bar foo bar foo foo.\n bar foo bar foo foo. bar foo bar foo\n foo.\n\n"; + $tpl = $this->smarty->createTemplate('string:{textformat wrap=40 indent=4}' . $this->string . '{/textformat}'); + $this->assertEquals($result, $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testIndentFirst() + { + $result = " This is foo. This is foo. This\n is foo. This is foo. This is foo.\n This is foo.\n\n This is bar.\n\n bar foo bar foo foo. bar foo bar\n foo foo. bar foo bar foo foo. bar\n foo bar foo foo. bar foo bar foo\n foo. bar foo bar foo foo. bar foo\n bar foo foo.\n\n"; + $tpl = $this->smarty->createTemplate('string:{textformat wrap=40 indent=4 indent_first=4}' . $this->string . '{/textformat}'); + $this->assertEquals($result, $this->smarty->fetch($tpl)); + } + + public function testIndentFirstWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $result = " This is foo. This is foo. This\n is foo. This is foo. This is foo.\n This is foo.\n\n This is bar.\n\n bar foo bar foo foo. bar foo bar\n foo foo. bar foo bar foo foo. bar\n foo bar foo foo. bar foo bar foo\n foo. bar foo bar foo foo. bar foo\n bar foo foo.\n\n"; + $tpl = $this->smarty->createTemplate('string:{textformat wrap=40 indent=4 indent_first=4}' . $this->string . '{/textformat}'); + $this->assertEquals($result, $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testIndentchar() + { + $result = "####This is foo. This is foo. This is\n####foo. This is foo. This is foo. This\n####is foo.\n\n####This is bar.\n\n####bar foo bar foo foo. bar foo bar foo\n####foo. bar foo bar foo foo. bar foo\n####bar foo foo. bar foo bar foo foo.\n####bar foo bar foo foo. bar foo bar foo\n####foo.\n\n"; + $tpl = $this->smarty->createTemplate('string:{textformat wrap=40 indent=4 indent_char="#"}' . $this->string . '{/textformat}'); + $this->assertEquals($result, $this->smarty->fetch($tpl)); + } + + public function testIndentcharWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $result = "####This is foo. This is foo. This is\n####foo. This is foo. This is foo. This\n####is foo.\n\n####This is bar.\n\n####bar foo bar foo foo. bar foo bar foo\n####foo. bar foo bar foo foo. bar foo\n####bar foo foo. bar foo bar foo foo.\n####bar foo bar foo foo. bar foo bar foo\n####foo.\n\n"; + $tpl = $this->smarty->createTemplate('string:{textformat wrap=40 indent=4 indent_char="#"}' . $this->string . '{/textformat}'); + $this->assertEquals($result, $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testIndentcharFirst() + { + $result = "########This is foo. This is foo. This\n####is foo. This is foo. This is foo.\n####This is foo.\n\n########This is bar.\n\n########bar foo bar foo foo. bar foo bar\n####foo foo. bar foo bar foo foo. bar\n####foo bar foo foo. bar foo bar foo\n####foo. bar foo bar foo foo. bar foo\n####bar foo foo.\n\n"; + $tpl = $this->smarty->createTemplate('string:{textformat wrap=40 indent=4 indent_first=4 indent_char="#"}' . $this->string . '{/textformat}'); + $this->assertEquals($result, $this->smarty->fetch($tpl)); + } + + public function testIndentcharFirstWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $result = "########This is foo. This is foo. This\n####is foo. This is foo. This is foo.\n####This is foo.\n\n########This is bar.\n\n########bar foo bar foo foo. bar foo bar\n####foo foo. bar foo bar foo foo. bar\n####foo bar foo foo. bar foo bar foo\n####foo. bar foo bar foo foo. bar foo\n####bar foo foo.\n\n"; + $tpl = $this->smarty->createTemplate('string:{textformat wrap=40 indent=4 indent_first=4 indent_char="#"}' . $this->string . '{/textformat}'); + $this->assertEquals($result, $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testWrapchar() + { + $result = " This is foo. This is foo. This is#foo. This is foo. This is foo. This#is foo.## This is bar.## bar foo bar foo foo. bar foo bar foo#foo. bar foo bar foo foo. bar foo#bar foo foo. bar foo bar foo foo.#bar foo bar foo foo. bar foo bar foo#foo.##"; + $tpl = $this->smarty->createTemplate('string:{textformat wrap=40 indent=4 wrap_char="#"}' . $this->string . '{/textformat}'); + $this->assertEquals($result, $this->smarty->fetch($tpl)); + } + + public function testWrapcharWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $result = " This is foo. This is foo. This is#foo. This is foo. This is foo. This#is foo.## This is bar.## bar foo bar foo foo. bar foo bar foo#foo. bar foo bar foo foo. bar foo#bar foo foo. bar foo bar foo foo.#bar foo bar foo foo. bar foo bar foo#foo.##"; + $tpl = $this->smarty->createTemplate('string:{textformat wrap=40 indent=4 wrap_char="#"}' . $this->string . '{/textformat}'); + $this->assertEquals($result, $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testStyleEmail() + { + $result = "This is foo. This is foo. This is foo. This is foo. This is foo. This is\nfoo.\n\nThis is bar.\n\nbar foo bar foo foo. bar foo bar foo foo. bar foo bar foo foo. bar foo\nbar foo foo. bar foo bar foo foo. bar foo bar foo foo. bar foo bar foo\nfoo.\n\n"; + $tpl = $this->smarty->createTemplate('string:{textformat style="email"}' . $this->string . '{/textformat}'); + $this->assertEquals($result, $this->smarty->fetch($tpl)); + } + + public function testStyleEmailWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $result = "This is foo. This is foo. This is foo. This is foo. This is foo. This is\nfoo.\n\nThis is bar.\n\nbar foo bar foo foo. bar foo bar foo foo. bar foo bar foo foo. bar foo\nbar foo foo. bar foo bar foo foo. bar foo bar foo foo. bar foo bar foo\nfoo.\n\n"; + $tpl = $this->smarty->createTemplate('string:{textformat style="email"}' . $this->string . '{/textformat}'); + $this->assertEquals($result, $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginBlock/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/PluginBlock/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginBlock/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginBlock/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/PluginBlock/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginBlock/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionFetchTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionFetchTest.php new file mode 100644 index 00000000..acea7def --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionFetchTest.php @@ -0,0 +1,85 @@ +<?php +/** + * Smarty PHPunit tests of modifier + * + * @package PHPunit + * @author Rodney Rehm + */ + +/** + * class for modifier tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class PluginFunctionFetchTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + + +/** +* test {fetch} from UIR +* +* @runInSeparateProcess +* @preserveGlobalState disabled +*/ + public function testFetchUri() + { + $this->assertContains('<title>Preface | Smarty</title>', $this->smarty->fetch('string:{fetch file="https://www.smarty.net/docs/en/preface.tpl"}')); + } + +/** +* test {fetch} invalid uri +* +* @expectedException SmartyException +* @expectedExceptionMessage {fetch} cannot read resource 'https://foo.smarty.net/foo.dat' +* @runInSeparateProcess +* @preserveGlobalState disabled +*/ + public function testFetchInvalidUri() + { + $result = $this->smarty->fetch('string:{fetch file="https://foo.smarty.net/foo.dat"}'); + } + + /** + * test {fetch file=...} access to file from path not aloo/wed by security settings + * + * @expectedException SmartyException + * @expectedExceptionMessage not trusted file path + * @run InSeparateProcess + * @preserveGlobalState disabled + */ + public function testFetchSecurity() + { + $this->cleanDirs(); + $dir=$this->smarty->getTemplateDir(); + $this->smarty->enableSecurity(); + $result = $this->smarty->fetch('string:{fetch file=\''. $dir[0]. '../../../../../etc/passwd\'}'); + } + /** + * test {fetch file=...} access to file from path not aloo/wed by security settings + * + * @expectedException SmartyException + * @expectedExceptionMessage not trusted file path + * @run InSeparateProcess + * @preserveGlobalState disabled + */ + public function testFetchSecurity2() + { + $this->cleanDirs(); + $dir=$this->smarty->getTemplateDir(); + $this->smarty->enableSecurity(); + $this->smarty->setTemplateDir('/templates'); + $result = $this->smarty->fetch('string:{fetch file="/templates/../etc/passwd"}'); + } + +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlCheckboxesTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlCheckboxesTest.php new file mode 100644 index 00000000..3d28dc67 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlCheckboxesTest.php @@ -0,0 +1,415 @@ +<?php +/** + * Smarty PHPunit tests of modifier + * + * @package PHPunit + * @author Rodney Rehm + */ + +require_once(dirname(__FILE__) . '/helpers/_object_tostring.php'); + +/** + * class for modifier tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class PluginFunctionHtmlCheckboxesTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + public function testAssociativeArray() + { + $n = "\n"; + $expected = '<label><input type="checkbox" name="id[]" value="1000" />Joe Schmoe</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="1001" checked="checked" />Jack Smith</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="1002" />Jane Johnson</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="1003" />Charlie Brown</label><br />'; + + $tpl = $this->smarty->createTemplate('eval:{html_checkboxes name="id" options=$cust_radios selected=$customer_id separator="<br />"}'); + $tpl->assign('customer_id', 1001); + $tpl->assign('cust_radios', array( + 1000 => 'Joe Schmoe', + 1001 => 'Jack Smith', + 1002 => 'Jane Johnson', + 1003 => 'Charlie Brown', + )); + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testSeparateArrays() + { + $n = "\n"; + $expected = '<label><input type="checkbox" name="id[]" value="1000" />Joe Schmoe</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="1001" checked="checked" />Jack Smith</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="1002" />Jane Johnson</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="1003" />Charlie Brown</label><br />'; + + $tpl = $this->smarty->createTemplate('eval:{html_checkboxes name="id" values=$cust_ids output=$cust_names selected=$customer_id separator="<br />"}'); + $tpl->assign('customer_id', 1001); + $tpl->assign('cust_ids', array(1000, 1001, 1002, 1003)); + $tpl->assign('cust_names', array( + 'Joe Schmoe', + 'Jack Smith', + 'Jane Johnson', + 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testIterator() + { + $n = "\n"; + $expected = '<label><input type="checkbox" name="id[]" value="1000" />Joe Schmoe</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="1001" checked="checked" />Jack Smith</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="1002" />Jane Johnson</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="1003" />Charlie Brown</label><br />'; + + $tpl = $this->smarty->createTemplate('eval:{html_checkboxes name="id" values=$cust_ids output=$cust_names selected=$customer_id separator="<br />"}'); + $tpl->assign('customer_id', 1001); + $tpl->assign('cust_ids', array(1000, 1001, 1002, 1003)); + $tpl->assign('cust_names', new ArrayIterator(array( + 'Joe Schmoe', + 'Jack Smith', + 'Jane Johnson', + 'Charlie Brown', + ))); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testNoLabels() + { + $n = "\n"; + $expected = '<input type="checkbox" name="id[]" value="1000" />Joe Schmoe<br />' + . $n . '<input type="checkbox" name="id[]" value="1001" checked="checked" />Jack Smith<br />' + . $n . '<input type="checkbox" name="id[]" value="1002" />Jane Johnson<br />' + . $n . '<input type="checkbox" name="id[]" value="1003" />Charlie Brown<br />'; + + $tpl = $this->smarty->createTemplate('eval:{html_checkboxes name="id" options=$cust_radios labels=false selected=$customer_id separator="<br />"}'); + $tpl->assign('customer_id', 1001); + $tpl->assign('cust_radios', array( + 1000 => 'Joe Schmoe', + 1001 => 'Jack Smith', + 1002 => 'Jane Johnson', + 1003 => 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testWithId() + { + $n = "\n"; + $expected = '<label for="id_1000"><input type="checkbox" name="id[]" value="1000" id="id_1000" />Joe Schmoe</label><br />' + . $n . '<label for="id_1001"><input type="checkbox" name="id[]" value="1001" id="id_1001" checked="checked" />Jack Smith</label><br />' + . $n . '<label for="id_1002"><input type="checkbox" name="id[]" value="1002" id="id_1002" />Jane Johnson</label><br />' + . $n . '<label for="id_work_s_ä"><input type="checkbox" name="id[]" value="work s ä" id="id_work_s_ä" />Charlie Brown</label><br />'; + + $tpl = $this->smarty->createTemplate('eval:{html_checkboxes name="id" options=$cust_radios selected=$customer_id label_ids=true separator="<br />"}'); + $tpl->assign('customer_id', 1001); + $tpl->assign('cust_radios', array( + 1000 => 'Joe Schmoe', + 1001 => 'Jack Smith', + 1002 => 'Jane Johnson', + 'work s ä' => 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testNullString() + { + $n = "\n"; + $expected = '<label><input type="checkbox" name="id[]" value="null" checked="checked" />null</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="" />empty string</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="0" />zero</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="1" />one</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="2" />two</label><br />'; + + $tpl = $this->smarty->createTemplate('eval:{html_checkboxes name="id" options=$options selected=$selected separator="<br />"}'); + $tpl->assign('selected', "null"); + $tpl->assign('options', array( + "null" => 'null', + '' => 'empty string', + 0 => 'zero', + 1 => 'one', + 2 => 'two', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testNullValue() + { + $n = "\n"; + $expected = '<label><input type="checkbox" name="id[]" value="null" />null</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="" checked="checked" />empty string</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="0" />zero</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="1" />one</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="2" />two</label><br />'; + + $tpl = $this->smarty->createTemplate('eval:{html_checkboxes name="id" options=$options selected=$selected separator="<br />"}'); + $tpl->assign('selected', null); + $tpl->assign('options', array( + "null" => 'null', + '' => 'empty string', + 0 => 'zero', + 1 => 'one', + 2 => 'two', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testZeroValue() + { + $n = "\n"; + $expected = '<label><input type="checkbox" name="id[]" value="null" />null</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="" />empty string</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="0" checked="checked" />zero</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="1" />one</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="2" />two</label><br />'; + + $tpl = $this->smarty->createTemplate('eval:{html_checkboxes name="id" options=$options selected=$selected separator="<br />"}'); + $tpl->assign('selected', 0); + $tpl->assign('options', array( + "null" => 'null', + '' => 'empty string', + 0 => 'zero', + 1 => 'one', + 2 => 'two', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testZeroStringValue() + { + $n = "\n"; + $expected = '<label><input type="checkbox" name="id[]" value="null" />null</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="" />empty string</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="0" checked="checked" />zero</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="1" />one</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="2" />two</label><br />'; + + $tpl = $this->smarty->createTemplate('eval:{html_checkboxes name="id" options=$options selected=$selected separator="<br />"}'); + $tpl->assign('selected', "0"); + $tpl->assign('options', array( + "null" => 'null', + '' => 'empty string', + 0 => 'zero', + 1 => 'one', + 2 => 'two', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testEmptyStringValue() + { + $n = "\n"; + $expected = '<label><input type="checkbox" name="id[]" value="null" />null</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="" checked="checked" />empty string</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="0" />zero</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="1" />one</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="2" />two</label><br />'; + + $tpl = $this->smarty->createTemplate('eval:{html_checkboxes name="id" options=$options selected=$selected separator="<br />"}'); + $tpl->assign('selected', ""); + $tpl->assign('options', array( + "null" => 'null', + '' => 'empty string', + 0 => 'zero', + 1 => 'one', + 2 => 'two', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testObject() + { + $n = "\n"; + $expected = '<label><input type="checkbox" name="id[]" value="1000" />Joe Schmoe</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="1001" checked="checked" />Jack Smith</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="1002" />Jane Johnson</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="1003" />Charlie Brown</label><br />'; + + $tpl = $this->smarty->createTemplate('eval:{html_checkboxes name="id" options=$cust_radios selected=$customer_id separator="<br />"}'); + $tpl->assign('customer_id', new _object_toString(1001)); + $tpl->assign('cust_radios', array( + 1000 => 'Joe Schmoe', + 1001 => 'Jack Smith', + 1002 => 'Jane Johnson', + 1003 => 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testObjectList() + { + $n = "\n"; + $expected = '<label><input type="checkbox" name="id[]" value="1000" />Joe Schmoe</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="1001" checked="checked" />Jack Smith</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="1002" />Jane Johnson</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="1003" />Charlie Brown</label><br />'; + + $tpl = $this->smarty->createTemplate('eval:{html_checkboxes name="id" options=$cust_radios selected=$customer_id separator="<br />"}'); + $tpl->assign('customer_id', 1001); + $tpl->assign('cust_radios', array( + 1000 => new _object_toString('Joe Schmoe'), + 1001 => new _object_toString('Jack Smith'), + 1002 => new _object_toString('Jane Johnson'), + 1003 => new _object_toString('Charlie Brown'), + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + protected $_errors = array(); + + public function error_handler($errno, $errstr, $errfile, $errline, $errcontext) + { + $this->_errors[] = $errstr; + } + + public function testObjectNoString() + { + $this->_errors = array(); + set_error_handler(array($this, 'error_handler')); + + $n = "\n"; + $expected = '<label><input type="checkbox" name="id[]" value="1000" />Joe Schmoe</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="1001" checked="checked" />Jack Smith</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="1002" />Jane Johnson</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="1003" />Charlie Brown</label><br />'; + + $tpl = $this->smarty->createTemplate('eval:{html_checkboxes name="id" options=$cust_radios selected=$customer_id separator="<br />"}'); + $tpl->assign('customer_id', new _object_noString(1001)); + $tpl->assign('cust_radios', array( + 1000 => 'Joe Schmoe', + 1001 => 'Jack Smith', + 1002 => 'Jane Johnson', + 1003 => 'Charlie Brown', + )); + + $tpl->fetch(); + $this->assertEquals(1, count($this->_errors)); + $this->assertStringEndsWith("without __toString() method", $this->_errors[0]); + + restore_error_handler(); + } + + public function testObjectListNoString() + { + $this->_errors = array(); + set_error_handler(array($this, 'error_handler')); + + $n = "\n"; + $expected = '<label><input type="checkbox" name="id[]" value="1000" />Joe Schmoe</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="1001" checked="checked" />Jack Smith</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="1002" />Jane Johnson</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="1003" />Charlie Brown</label><br />'; + + $tpl = $this->smarty->createTemplate('eval:{html_checkboxes name="id" options=$cust_radios selected=$customer_id separator="<br />"}'); + $tpl->assign('customer_id', 1001); + $tpl->assign('cust_radios', array( + 1000 => new _object_toString('Joe Schmoe'), + 1001 => new _object_noString('Jack Smith'), + 1002 => new _object_toString('Jane Johnson'), + 1003 => new _object_toString('Charlie Brown'), + )); + + $tpl->fetch(); + $this->assertEquals(1, count($this->_errors)); + $this->assertStringEndsWith("without __toString() method", $this->_errors[0]); + + restore_error_handler(); + } + + public function testDisabled() + { + $n = "\n"; + $expected = '<label><input type="checkbox" name="id[]" value="1000" disabled="1" />Joe Schmoe</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="1001" checked="checked" disabled="1" />Jack Smith</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="1002" disabled="1" />Jane Johnson</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="1003" disabled="1" />Charlie Brown</label><br />'; + + $tpl = $this->smarty->createTemplate('eval:{html_checkboxes name="id" options=$cust_radios selected=$customer_id separator="<br />" disabled="1"}'); + $tpl->assign('customer_id', new _object_toString(1001)); + $tpl->assign('cust_radios', array( + 1000 => 'Joe Schmoe', + 1001 => 'Jack Smith', + 1002 => 'Jane Johnson', + 1003 => 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testDisabledStrict1() + { + $n = "\n"; + $expected = '<label><input type="checkbox" name="id[]" value="1000" disabled="disabled" />Joe Schmoe</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="1001" checked="checked" disabled="disabled" />Jack Smith</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="1002" disabled="disabled" />Jane Johnson</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="1003" disabled="disabled" />Charlie Brown</label><br />'; + + $tpl = $this->smarty->createTemplate('eval:{html_checkboxes name="id" options=$cust_radios selected=$customer_id separator="<br />" disabled=true strict=true}'); + $tpl->assign('customer_id', new _object_toString(1001)); + $tpl->assign('cust_radios', array( + 1000 => 'Joe Schmoe', + 1001 => 'Jack Smith', + 1002 => 'Jane Johnson', + 1003 => 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + public function testDisabledStrict2() + { + $n = "\n"; + $expected = '<label><input type="checkbox" name="id[]" value="1000" />Joe Schmoe</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="1001" checked="checked" />Jack Smith</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="1002" />Jane Johnson</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="1003" />Charlie Brown</label><br />'; + + $tpl = $this->smarty->createTemplate('eval:{html_checkboxes name="id" options=$cust_radios selected=$customer_id separator="<br />" disabled=1 strict=true}'); + $tpl->assign('customer_id', new _object_toString(1001)); + $tpl->assign('cust_radios', array( + 1000 => 'Joe Schmoe', + 1001 => 'Jack Smith', + 1002 => 'Jane Johnson', + 1003 => 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + + } + public function testDisabledStrict3() + { + $n = "\n"; + $expected = '<label><input type="checkbox" name="id[]" value="1000" disabled="disabled" />Joe Schmoe</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="1001" checked="checked" disabled="disabled" />Jack Smith</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="1002" disabled="disabled" />Jane Johnson</label><br />' + . $n . '<label><input type="checkbox" name="id[]" value="1003" disabled="disabled" />Charlie Brown</label><br />'; + + $tpl = $this->smarty->createTemplate('eval:{html_checkboxes name="id" options=$cust_radios selected=$customer_id separator="<br />" disabled="disabled" strict=true}'); + $tpl->assign('customer_id', new _object_toString(1001)); + $tpl->assign('cust_radios', array( + 1000 => 'Joe Schmoe', + 1001 => 'Jack Smith', + 1002 => 'Jane Johnson', + 1003 => 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlImageTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlImageTest.php new file mode 100644 index 00000000..4293450f --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlImageTest.php @@ -0,0 +1,27 @@ +<?php +/** + * Smarty PHPunit tests of modifier + * + * @package PHPunit + * @author Rodney Rehm + */ + +/** + * class for modifier tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class PluginFunctionHtmlImageTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + public function testFoo() + { + // TODO: UnitTests for {html_image} + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlOptionsTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlOptionsTest.php new file mode 100644 index 00000000..c5f7e6c9 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlOptionsTest.php @@ -0,0 +1,502 @@ +<?php +/** + * Smarty PHPunit tests of modifier + * + * @package PHPunit + * @author Rodney Rehm + */ + +require_once(dirname(__FILE__) . '/helpers/_object_tostring.php'); + +/** + * class for modifier tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class PluginFunctionHtmlOptionsTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + public function testAssociativeArray() + { + $n = "\n"; + $expected = '<select name="foo">' + . $n . '<option value="1800">Joe Schmoe</option>' + . $n . '<option value="9904" selected="selected">Jack Smith</option>' + . $n . '<option value="2003">Charlie Brown</option>' + . $n . '</select>' . $n; + + $tpl = $this->smarty->createTemplate('eval:{html_options name="foo" options=$myOptions selected=$mySelect}'); + $tpl->assign('mySelect', 9904); + $tpl->assign('myOptions', array( + 1800 => 'Joe Schmoe', + 9904 => 'Jack Smith', + 2003 => 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testSeparateArrays() + { + $n = "\n"; + $expected = '<select name="foo">' + . $n . '<option value="56">Joe Schmoe</option>' + . $n . '<option value="92" selected="selected">Jane Johnson</option>' + . $n . '<option value="13">Charlie Brown</option>' + . $n . '</select>' . $n; + + $tpl = $this->smarty->createTemplate('eval:{html_options name="foo" values=$cust_ids output=$cust_names selected=$customer_id}'); + $tpl->assign('customer_id', 92); + $tpl->assign('cust_ids', array(56, 92, 13)); + $tpl->assign('cust_names', array( + 'Joe Schmoe', + 'Jane Johnson', + 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testIterator() + { + $n = "\n"; + $expected = '<select name="foo">' + . $n . '<option value="1800">Joe Schmoe</option>' + . $n . '<option value="9904" selected="selected">Jack Smith</option>' + . $n . '<option value="2003">Charlie Brown</option>' + . $n . '</select>' . $n; + + $tpl = $this->smarty->createTemplate('eval:{html_options name="foo" options=$myOptions selected=$mySelect}'); + $tpl->assign('mySelect', 9904); + $tpl->assign('myOptions', new ArrayIterator(array( + 1800 => 'Joe Schmoe', + 9904 => 'Jack Smith', + 2003 => 'Charlie Brown', + ))); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testOptgroup() + { + $n = "\n"; + $expected = '<select name="foo">' + . $n . '<optgroup label="Sport">' + . $n . '<option value="6">Golf</option>' + . $n . '<option value="9">Cricket</option>' + . $n . '<option value="7" selected="selected">Swim</option>' + . $n . '</optgroup>' + . $n . '<optgroup label="Rest">' + . $n . '<option value="3">Sauna</option>' + . $n . '<option value="1">Massage</option>' + . $n . '</optgroup>' + . $n . '</select>' . $n; + + $tpl = $this->smarty->createTemplate('eval:{html_options name=foo options=$lookups selected=$fav}'); + $tpl->assign('fav', 7); + $tpl->assign('lookups', array( + 'Sport' => array( + 6 => 'Golf', + 9 => 'Cricket', + 7 => 'Swim' + ), + 'Rest' => array( + 3 => 'Sauna', + 1 => 'Massage' + ), + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testNullString() + { + $n = "\n"; + $expected = '<select name="foo">' + . $n . '<option value="null" selected="selected">null</option>' + . $n . '<option value="0">zero</option>' + . $n . '<option value="1">one</option>' + . $n . '<option value="2">two</option>' + . $n . '<optgroup label="optgroup">' + . $n . '<option value="null" selected="selected">null</option>' + . $n . '<option value="0">zero</option>' + . $n . '<option value="1">one</option>' + . $n . '<option value="2">two</option>' + . $n . '</optgroup>' + . $n . '</select>' . $n; + + $tpl = $this->smarty->createTemplate('eval:{html_options name=foo options=$array selected=$selected}'); + $tpl->assign('selected', "null"); + $tpl->assign('array', array( + 'null' => 'null', + 0 => 'zero', + 1 => 'one', + 2 => 'two', + 'optgroup' => array( + 'null' => 'null', + 0 => 'zero', + 1 => 'one', + 2 => 'two', + ), + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testNullValue() + { + $n = "\n"; + $expected = '<select name="foo">' + . $n . '<option value="" selected="selected">empty string</option>' + . $n . '<option value="null">null</option>' + . $n . '<option value="0">zero</option>' + . $n . '<option value="1">one</option>' + . $n . '<option value="2">two</option>' + . $n . '<optgroup label="optgroup">' + . $n . '<option value="" selected="selected">empty string</option>' + . $n . '<option value="null">null</option>' + . $n . '<option value="0">zero</option>' + . $n . '<option value="1">one</option>' + . $n . '<option value="2">two</option>' + . $n . '</optgroup>' + . $n . '</select>' . $n; + + $tpl = $this->smarty->createTemplate('eval:{html_options name=foo options=$array selected=$selected}'); + $tpl->assign('selected', null); + $tpl->assign('array', array( + '' => 'empty string', + 'null' => 'null', + 0 => 'zero', + 1 => 'one', + 2 => 'two', + 'optgroup' => array( + '' => 'empty string', + 'null' => 'null', + 0 => 'zero', + 1 => 'one', + 2 => 'two', + ), + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testZeroValue() + { + $n = "\n"; + $expected = '<select name="foo">' + . $n . '<option value="null">null</option>' + . $n . '<option value="0" selected="selected">zero</option>' + . $n . '<option value="1">one</option>' + . $n . '<option value="2">two</option>' + . $n . '<optgroup label="optgroup">' + . $n . '<option value="null">null</option>' + . $n . '<option value="0" selected="selected">zero</option>' + . $n . '<option value="1">one</option>' + . $n . '<option value="2">two</option>' + . $n . '</optgroup>' + . $n . '</select>' . $n; + + $tpl = $this->smarty->createTemplate('eval:{html_options name=foo options=$array selected=$selected}'); + $tpl->assign('selected', 0); + $tpl->assign('array', array( + 'null' => 'null', + 0 => 'zero', + 1 => 'one', + 2 => 'two', + 'optgroup' => array( + 'null' => 'null', + 0 => 'zero', + 1 => 'one', + 2 => 'two', + ), + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testZeroStringValue() + { + $n = "\n"; + $expected = '<select name="foo">' + . $n . '<option value="null">null</option>' + . $n . '<option value="0" selected="selected">zero</option>' + . $n . '<option value="1">one</option>' + . $n . '<option value="2">two</option>' + . $n . '<optgroup label="optgroup">' + . $n . '<option value="null">null</option>' + . $n . '<option value="0" selected="selected">zero</option>' + . $n . '<option value="1">one</option>' + . $n . '<option value="2">two</option>' + . $n . '</optgroup>' + . $n . '</select>' . $n; + + $tpl = $this->smarty->createTemplate('eval:{html_options name=foo options=$array selected=$selected}'); + $tpl->assign('selected', "0"); + $tpl->assign('array', array( + 'null' => "null", + 0 => 'zero', + 1 => 'one', + 2 => 'two', + 'optgroup' => array( + 'null' => 'null', + 0 => 'zero', + 1 => 'one', + 2 => 'two', + ), + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testEmptyStringValue() + { + $n = "\n"; + $expected = '<select name="foo">' + . $n . '<option value="null">null</option>' + . $n . '<option value="0">zero</option>' + . $n . '<option value="1">one</option>' + . $n . '<option value="2">two</option>' + . $n . '<optgroup label="optgroup">' + . $n . '<option value="null">null</option>' + . $n . '<option value="0">zero</option>' + . $n . '<option value="1">one</option>' + . $n . '<option value="2">two</option>' + . $n . '</optgroup>' + . $n . '</select>' . $n; + + $tpl = $this->smarty->createTemplate('eval:{html_options name=foo options=$array selected=$selected}'); + $tpl->assign('selected', ""); + $tpl->assign('array', array( + 'null' => 'null', + '0' => 'zero', + '1' => 'one', + '2' => 'two', + 'optgroup' => array( + 'null' => 'null', + 0 => 'zero', + 1 => 'one', + 2 => 'two', + ), + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testEmptyStringValues() + { + $n = "\n"; + $expected = '<select name="foo">' + . $n . '<option value="" selected="selected">empty string</option>' + . $n . '<option value="null">null</option>' + . $n . '<option value="0">zero</option>' + . $n . '<option value="1">one</option>' + . $n . '<option value="2">two</option>' + . $n . '<optgroup label="optgroup">' + . $n . '<option value="" selected="selected">empty string</option>' + . $n . '<option value="null">null</option>' + . $n . '<option value="0">zero</option>' + . $n . '<option value="1">one</option>' + . $n . '<option value="2">two</option>' + . $n . '</optgroup>' + . $n . '</select>' . $n; + + $tpl = $this->smarty->createTemplate('eval:{html_options name=foo options=$array selected=$selected}'); + $tpl->assign('selected', ""); + $tpl->assign('array', array( + '' => 'empty string', + 'null' => 'null', + '0' => 'zero', + '1' => 'one', + '2' => 'two', + 'optgroup' => array( + '' => 'empty string', + 'null' => 'null', + 0 => 'zero', + 1 => 'one', + 2 => 'two', + ), + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testObject() + { + $n = "\n"; + $expected = '<select name="foo">' + . $n . '<option value="1800">Joe Schmoe</option>' + . $n . '<option value="9904" selected="selected">Jack Smith</option>' + . $n . '<option value="2003">Charlie Brown</option>' + . $n . '</select>' . $n; + + $tpl = $this->smarty->createTemplate('eval:{html_options name="foo" options=$myOptions selected=$mySelect}'); + $tpl->assign('mySelect', new _object_toString(9904)); + $tpl->assign('myOptions', array( + 1800 => 'Joe Schmoe', + 9904 => 'Jack Smith', + 2003 => 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testObjectList() + { + $n = "\n"; + $expected = '<select name="foo">' + . $n . '<option value="1800">Joe Schmoe</option>' + . $n . '<option value="9904" selected="selected">Jack Smith</option>' + . $n . '<option value="2003">Charlie Brown</option>' + . $n . '</select>' . $n; + + $tpl = $this->smarty->createTemplate('eval:{html_options name="foo" options=$myOptions selected=$mySelect}'); + $tpl->assign('mySelect', new _object_toString(9904)); + $tpl->assign('myOptions', array( + 1800 => new _object_toString('Joe Schmoe'), + 9904 => new _object_toString('Jack Smith'), + 2003 => new _object_toString('Charlie Brown'), + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + protected $_errors = array(); + + public function error_handler($errno, $errstr, $errfile, $errline, $errcontext) + { + $this->_errors[] = $errstr; + } + + public function testObjectNoString() + { + $this->_errors = array(); + set_error_handler(array($this, 'error_handler')); + $n = "\n"; + $expected = '<select name="foo">' + . $n . '<option value="1800">Joe Schmoe</option>' + . $n . '<option value="9904" selected="selected">Jack Smith</option>' + . $n . '<option value="2003">Charlie Brown</option>' + . $n . '</select>' . $n; + + $tpl = $this->smarty->createTemplate('eval:{html_options name="foo" options=$myOptions selected=$mySelect}'); + $tpl->assign('mySelect', new _object_noString(9904)); + $tpl->assign('myOptions', array( + 1800 => 'Joe Schmoe', + 9904 => 'Jack Smith', + 2003 => 'Charlie Brown', + )); + + $tpl->fetch(); + $this->assertEquals(1, count($this->_errors)); + $this->assertStringEndsWith("without __toString() method", $this->_errors[0]); + + restore_error_handler(); + } + + public function testObjectListNoString() + { + $this->_errors = array(); + set_error_handler(array($this, 'error_handler')); + $n = "\n"; + $expected = '<select name="foo">' + . $n . '<option value="1800">Joe Schmoe</option>' + . $n . '<option value="9904">Jack Smith</option>' + . $n . '<option value="2003">Charlie Brown</option>' + . $n . '</select>' . $n; + + $tpl = $this->smarty->createTemplate('eval:{html_options name="foo" options=$myOptions selected=$mySelect}'); + $tpl->assign('mySelect', new _object_toString(9904)); + $tpl->assign('myOptions', array( + 1800 => new _object_toString('Joe Schmoe'), + 9904 => new _object_noString('Jack Smith'), + 2003 => new _object_toString('Charlie Brown'), + )); + + $tpl->fetch(); + $this->assertEquals(1, count($this->_errors)); + $this->assertStringEndsWith("without __toString() method", $this->_errors[0]); + + restore_error_handler(); + } + + public function testDisabled() + { + $n = "\n"; + $expected = '<select name="foo" disabled="1">' + . $n . '<option value="1800">Joe Schmoe</option>' + . $n . '<option value="9904" selected="selected">Jack Smith</option>' + . $n . '<option value="2003">Charlie Brown</option>' + . $n . '</select>' . $n; + + $tpl = $this->smarty->createTemplate('eval:{html_options name="foo" options=$myOptions selected=$mySelect disabled=1}'); + $tpl->assign('mySelect', new _object_toString(9904)); + $tpl->assign('myOptions', array( + 1800 => 'Joe Schmoe', + 9904 => 'Jack Smith', + 2003 => 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testDisabledStrict() + { + $n = "\n"; + $expected = '<select name="foo">' + . $n . '<option value="1800">Joe Schmoe</option>' + . $n . '<option value="9904" selected="selected">Jack Smith</option>' + . $n . '<option value="2003">Charlie Brown</option>' + . $n . '</select>' . $n; + + $tpl = $this->smarty->createTemplate('eval:{html_options name="foo" options=$myOptions selected=$mySelect disabled=1 strict=true}'); + $tpl->assign('mySelect', new _object_toString(9904)); + $tpl->assign('myOptions', array( + 1800 => 'Joe Schmoe', + 9904 => 'Jack Smith', + 2003 => 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + + $n = "\n"; + $expected = '<select name="foo" disabled="disabled">' + . $n . '<option value="1800">Joe Schmoe</option>' + . $n . '<option value="9904" selected="selected">Jack Smith</option>' + . $n . '<option value="2003">Charlie Brown</option>' + . $n . '</select>' . $n; + + $tpl = $this->smarty->createTemplate('eval:{html_options name="foo" options=$myOptions selected=$mySelect disabled=true strict=true}'); + $tpl->assign('mySelect', new _object_toString(9904)); + $tpl->assign('myOptions', array( + 1800 => 'Joe Schmoe', + 9904 => 'Jack Smith', + 2003 => 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + + $n = "\n"; + $expected = '<select name="foo" disabled="disabled">' + . $n . '<option value="1800">Joe Schmoe</option>' + . $n . '<option value="9904" selected="selected">Jack Smith</option>' + . $n . '<option value="2003">Charlie Brown</option>' + . $n . '</select>' . $n; + + $tpl = $this->smarty->createTemplate('eval:{html_options name="foo" options=$myOptions selected=$mySelect disabled="disabled" strict=true}'); + $tpl->assign('mySelect', new _object_toString(9904)); + $tpl->assign('myOptions', array( + 1800 => 'Joe Schmoe', + 9904 => 'Jack Smith', + 2003 => 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlRadiosTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlRadiosTest.php new file mode 100644 index 00000000..0f5789b2 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlRadiosTest.php @@ -0,0 +1,410 @@ +<?php +/** + * Smarty PHPunit tests of modifier + * + * @package PHPunit + * @author Rodney Rehm + */ + +require_once(dirname(__FILE__) . '/helpers/_object_tostring.php'); + +/** + * class for modifier tests + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class PluginFunctionHtmlRadiosTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + public function testAssociativeArray() + { + $n = "\n"; + $expected = '<label><input type="radio" name="id" value="1000" />Joe Schmoe</label><br />' + . $n . '<label><input type="radio" name="id" value="1001" checked="checked" />Jack Smith</label><br />' + . $n . '<label><input type="radio" name="id" value="1002" />Jane Johnson</label><br />' + . $n . '<label><input type="radio" name="id" value="1003" />Charlie Brown</label><br />'; + + $tpl = $this->smarty->createTemplate('eval:{html_radios name="id" options=$cust_radios selected=$customer_id separator="<br />"}'); + $tpl->assign('customer_id', 1001); + $tpl->assign('cust_radios', array( + 1000 => 'Joe Schmoe', + 1001 => 'Jack Smith', + 1002 => 'Jane Johnson', + 1003 => 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testSeparateArrays() + { + $n = "\n"; + $expected = '<label><input type="radio" name="id" value="1000" />Joe Schmoe</label><br />' + . $n . '<label><input type="radio" name="id" value="1001" checked="checked" />Jack Smith</label><br />' + . $n . '<label><input type="radio" name="id" value="1002" />Jane Johnson</label><br />' + . $n . '<label><input type="radio" name="id" value="1003" />Charlie Brown</label><br />'; + + $tpl = $this->smarty->createTemplate('eval:{html_radios name="id" values=$cust_ids output=$cust_names selected=$customer_id separator="<br />"}'); + $tpl->assign('customer_id', 1001); + $tpl->assign('cust_ids', array(1000, 1001, 1002, 1003)); + $tpl->assign('cust_names', array( + 'Joe Schmoe', + 'Jack Smith', + 'Jane Johnson', + 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testIterator() + { + $n = "\n"; + $expected = '<label><input type="radio" name="id" value="1000" />Joe Schmoe</label><br />' + . $n . '<label><input type="radio" name="id" value="1001" checked="checked" />Jack Smith</label><br />' + . $n . '<label><input type="radio" name="id" value="1002" />Jane Johnson</label><br />' + . $n . '<label><input type="radio" name="id" value="1003" />Charlie Brown</label><br />'; + + $tpl = $this->smarty->createTemplate('eval:{html_radios name="id" values=$cust_ids output=$cust_names selected=$customer_id separator="<br />"}'); + $tpl->assign('customer_id', 1001); + $tpl->assign('cust_ids', array(1000, 1001, 1002, 1003)); + $tpl->assign('cust_names', new ArrayIterator(array( + 'Joe Schmoe', + 'Jack Smith', + 'Jane Johnson', + 'Charlie Brown', + ))); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testNoLabels() + { + $n = "\n"; + $expected = '<input type="radio" name="id" value="1000" />Joe Schmoe<br />' + . $n . '<input type="radio" name="id" value="1001" checked="checked" />Jack Smith<br />' + . $n . '<input type="radio" name="id" value="1002" />Jane Johnson<br />' + . $n . '<input type="radio" name="id" value="1003" />Charlie Brown<br />'; + + $tpl = $this->smarty->createTemplate('eval:{html_radios name="id" options=$cust_radios labels=false selected=$customer_id separator="<br />"}'); + $tpl->assign('customer_id', 1001); + $tpl->assign('cust_radios', array( + 1000 => 'Joe Schmoe', + 1001 => 'Jack Smith', + 1002 => 'Jane Johnson', + 1003 => 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testWithId() + { + $n = "\n"; + $expected = '<label for="id_1000"><input type="radio" name="id" value="1000" id="id_1000" />Joe Schmoe</label><br />' + . $n . '<label for="id_1001"><input type="radio" name="id" value="1001" id="id_1001" checked="checked" />Jack Smith</label><br />' + . $n . '<label for="id_1002"><input type="radio" name="id" value="1002" id="id_1002" />Jane Johnson</label><br />' + . $n . '<label for="id_work_s_ä"><input type="radio" name="id" value="work s ä" id="id_work_s_ä" />Charlie Brown</label><br />'; + + $tpl = $this->smarty->createTemplate('eval:{html_radios name="id" options=$cust_radios selected=$customer_id label_ids=true separator="<br />"}'); + $tpl->assign('customer_id', 1001); + $tpl->assign('cust_radios', array( + 1000 => 'Joe Schmoe', + 1001 => 'Jack Smith', + 1002 => 'Jane Johnson', + 'work s ä' => 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testNullString() + { + $n = "\n"; + $expected = '<label><input type="radio" name="id" value="null" checked="checked" />null</label><br />' + . $n . '<label><input type="radio" name="id" value="" />empty string</label><br />' + . $n . '<label><input type="radio" name="id" value="0" />zero</label><br />' + . $n . '<label><input type="radio" name="id" value="1" />one</label><br />' + . $n . '<label><input type="radio" name="id" value="2" />two</label><br />'; + + $tpl = $this->smarty->createTemplate('eval:{html_radios name="id" options=$options selected=$selected separator="<br />"}'); + $tpl->assign('selected', "null"); + $tpl->assign('options', array( + "null" => 'null', + '' => 'empty string', + 0 => 'zero', + 1 => 'one', + 2 => 'two', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testNullValue() + { + $n = "\n"; + $expected = '<label><input type="radio" name="id" value="null" />null</label><br />' + . $n . '<label><input type="radio" name="id" value="" checked="checked" />empty string</label><br />' + . $n . '<label><input type="radio" name="id" value="0" />zero</label><br />' + . $n . '<label><input type="radio" name="id" value="1" />one</label><br />' + . $n . '<label><input type="radio" name="id" value="2" />two</label><br />'; + + $tpl = $this->smarty->createTemplate('eval:{html_radios name="id" options=$options selected=$selected separator="<br />"}'); + $tpl->assign('selected', null); + $tpl->assign('options', array( + "null" => 'null', + '' => 'empty string', + 0 => 'zero', + 1 => 'one', + 2 => 'two', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testZeroValue() + { + $n = "\n"; + $expected = '<label><input type="radio" name="id" value="null" />null</label><br />' + . $n . '<label><input type="radio" name="id" value="" />empty string</label><br />' + . $n . '<label><input type="radio" name="id" value="0" checked="checked" />zero</label><br />' + . $n . '<label><input type="radio" name="id" value="1" />one</label><br />' + . $n . '<label><input type="radio" name="id" value="2" />two</label><br />'; + + $tpl = $this->smarty->createTemplate('eval:{html_radios name="id" options=$options selected=$selected separator="<br />"}'); + $tpl->assign('selected', 0); + $tpl->assign('options', array( + "null" => 'null', + '' => 'empty string', + 0 => 'zero', + 1 => 'one', + 2 => 'two', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testZeroStringValue() + { + $n = "\n"; + $expected = '<label><input type="radio" name="id" value="null" />null</label><br />' + . $n . '<label><input type="radio" name="id" value="" />empty string</label><br />' + . $n . '<label><input type="radio" name="id" value="0" checked="checked" />zero</label><br />' + . $n . '<label><input type="radio" name="id" value="1" />one</label><br />' + . $n . '<label><input type="radio" name="id" value="2" />two</label><br />'; + + $tpl = $this->smarty->createTemplate('eval:{html_radios name="id" options=$options selected=$selected separator="<br />"}'); + $tpl->assign('selected', "0"); + $tpl->assign('options', array( + "null" => 'null', + '' => 'empty string', + 0 => 'zero', + 1 => 'one', + 2 => 'two', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testEmptyStringValue() + { + $n = "\n"; + $expected = '<label><input type="radio" name="id" value="null" />null</label><br />' + . $n . '<label><input type="radio" name="id" value="" checked="checked" />empty string</label><br />' + . $n . '<label><input type="radio" name="id" value="0" />zero</label><br />' + . $n . '<label><input type="radio" name="id" value="1" />one</label><br />' + . $n . '<label><input type="radio" name="id" value="2" />two</label><br />'; + + $tpl = $this->smarty->createTemplate('eval:{html_radios name="id" options=$options selected=$selected separator="<br />"}'); + $tpl->assign('selected', ""); + $tpl->assign('options', array( + "null" => 'null', + '' => 'empty string', + 0 => 'zero', + 1 => 'one', + 2 => 'two', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testObject() + { + $n = "\n"; + $expected = '<label><input type="radio" name="id" value="1000" />Joe Schmoe</label><br />' + . $n . '<label><input type="radio" name="id" value="1001" checked="checked" />Jack Smith</label><br />' + . $n . '<label><input type="radio" name="id" value="1002" />Jane Johnson</label><br />' + . $n . '<label><input type="radio" name="id" value="1003" />Charlie Brown</label><br />'; + + $tpl = $this->smarty->createTemplate('eval:{html_radios name="id" options=$cust_radios selected=$customer_id separator="<br />"}'); + $tpl->assign('customer_id', new _object_toString(1001)); + $tpl->assign('cust_radios', array( + 1000 => 'Joe Schmoe', + 1001 => 'Jack Smith', + 1002 => 'Jane Johnson', + 1003 => 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testObjectList() + { + $n = "\n"; + $expected = '<label><input type="radio" name="id" value="1000" />Joe Schmoe</label><br />' + . $n . '<label><input type="radio" name="id" value="1001" checked="checked" />Jack Smith</label><br />' + . $n . '<label><input type="radio" name="id" value="1002" />Jane Johnson</label><br />' + . $n . '<label><input type="radio" name="id" value="1003" />Charlie Brown</label><br />'; + + $tpl = $this->smarty->createTemplate('eval:{html_radios name="id" options=$cust_radios selected=$customer_id separator="<br />"}'); + $tpl->assign('customer_id', 1001); + $tpl->assign('cust_radios', array( + 1000 => new _object_toString('Joe Schmoe'), + 1001 => new _object_toString('Jack Smith'), + 1002 => new _object_toString('Jane Johnson'), + 1003 => new _object_toString('Charlie Brown'), + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + protected $_errors = array(); + + public function error_handler($errno, $errstr, $errfile, $errline, $errcontext) + { + $this->_errors[] = $errstr; + } + + public function testObjectNoString() + { + $this->_errors = array(); + set_error_handler(array($this, 'error_handler')); + + $n = "\n"; + $expected = '<label><input type="radio" name="id" value="1000" />Joe Schmoe</label><br />' + . $n . '<label><input type="radio" name="id" value="1001" checked="checked" />Jack Smith</label><br />' + . $n . '<label><input type="radio" name="id" value="1002" />Jane Johnson</label><br />' + . $n . '<label><input type="radio" name="id" value="1003" />Charlie Brown</label><br />'; + + $tpl = $this->smarty->createTemplate('eval:{html_radios name="id" options=$cust_radios selected=$customer_id separator="<br />"}'); + $tpl->assign('customer_id', new _object_noString(1001)); + $tpl->assign('cust_radios', array( + 1000 => 'Joe Schmoe', + 1001 => 'Jack Smith', + 1002 => 'Jane Johnson', + 1003 => 'Charlie Brown', + )); + + $tpl->fetch(); + $this->assertEquals(1, count($this->_errors)); + $this->assertStringEndsWith("without __toString() method", $this->_errors[0]); + + restore_error_handler(); + } + + public function testObjectListNoString() + { + $this->_errors = array(); + set_error_handler(array($this, 'error_handler')); + + $n = "\n"; + $expected = '<label><input type="radio" name="id" value="1000" />Joe Schmoe</label><br />' + . $n . '<label><input type="radio" name="id" value="1001" checked="checked" />Jack Smith</label><br />' + . $n . '<label><input type="radio" name="id" value="1002" />Jane Johnson</label><br />' + . $n . '<label><input type="radio" name="id" value="1003" />Charlie Brown</label><br />'; + + $tpl = $this->smarty->createTemplate('eval:{html_radios name="id" options=$cust_radios selected=$customer_id separator="<br />"}'); + $tpl->assign('customer_id', 1001); + $tpl->assign('cust_radios', array( + 1000 => new _object_toString('Joe Schmoe'), + 1001 => new _object_noString('Jack Smith'), + 1002 => new _object_toString('Jane Johnson'), + 1003 => new _object_toString('Charlie Brown'), + )); + + $tpl->fetch(); + $this->assertEquals(1, count($this->_errors)); + $this->assertStringEndsWith("without __toString() method", $this->_errors[0]); + + restore_error_handler(); + } + + public function testDisabled() + { + $n = "\n"; + $expected = '<label><input type="radio" name="id" value="1000" disabled="1" />Joe Schmoe</label><br />' + . $n . '<label><input type="radio" name="id" value="1001" checked="checked" disabled="1" />Jack Smith</label><br />' + . $n . '<label><input type="radio" name="id" value="1002" disabled="1" />Jane Johnson</label><br />' + . $n . '<label><input type="radio" name="id" value="1003" disabled="1" />Charlie Brown</label><br />'; + + $tpl = $this->smarty->createTemplate('eval:{html_radios name="id" options=$cust_radios selected=$customer_id separator="<br />" disabled=1}'); + $tpl->assign('customer_id', new _object_toString(1001)); + $tpl->assign('cust_radios', array( + 1000 => 'Joe Schmoe', + 1001 => 'Jack Smith', + 1002 => 'Jane Johnson', + 1003 => 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } + + public function testDisabledStrict() + { + $n = "\n"; + $expected = '<label><input type="radio" name="id" value="1000" disabled="disabled" />Joe Schmoe</label><br />' + . $n . '<label><input type="radio" name="id" value="1001" checked="checked" disabled="disabled" />Jack Smith</label><br />' + . $n . '<label><input type="radio" name="id" value="1002" disabled="disabled" />Jane Johnson</label><br />' + . $n . '<label><input type="radio" name="id" value="1003" disabled="disabled" />Charlie Brown</label><br />'; + + $tpl = $this->smarty->createTemplate('eval:{html_radios name="id" options=$cust_radios selected=$customer_id separator="<br />" disabled=true strict=true}'); + $tpl->assign('customer_id', new _object_toString(1001)); + $tpl->assign('cust_radios', array( + 1000 => 'Joe Schmoe', + 1001 => 'Jack Smith', + 1002 => 'Jane Johnson', + 1003 => 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + + $n = "\n"; + $expected = '<label><input type="radio" name="id" value="1000" />Joe Schmoe</label><br />' + . $n . '<label><input type="radio" name="id" value="1001" checked="checked" />Jack Smith</label><br />' + . $n . '<label><input type="radio" name="id" value="1002" />Jane Johnson</label><br />' + . $n . '<label><input type="radio" name="id" value="1003" />Charlie Brown</label><br />'; + + $tpl = $this->smarty->createTemplate('eval:{html_radios name="id" options=$cust_radios selected=$customer_id separator="<br />" disabled=1 strict=true}'); + $tpl->assign('customer_id', new _object_toString(1001)); + $tpl->assign('cust_radios', array( + 1000 => 'Joe Schmoe', + 1001 => 'Jack Smith', + 1002 => 'Jane Johnson', + 1003 => 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + + $n = "\n"; + $expected = '<label><input type="radio" name="id" value="1000" disabled="disabled" />Joe Schmoe</label><br />' + . $n . '<label><input type="radio" name="id" value="1001" checked="checked" disabled="disabled" />Jack Smith</label><br />' + . $n . '<label><input type="radio" name="id" value="1002" disabled="disabled" />Jane Johnson</label><br />' + . $n . '<label><input type="radio" name="id" value="1003" disabled="disabled" />Charlie Brown</label><br />'; + + $tpl = $this->smarty->createTemplate('eval:{html_radios name="id" options=$cust_radios selected=$customer_id separator="<br />" disabled="disabled" strict=true}'); + $tpl->assign('customer_id', new _object_toString(1001)); + $tpl->assign('cust_radios', array( + 1000 => 'Joe Schmoe', + 1001 => 'Jack Smith', + 1002 => 'Jane Johnson', + 1003 => 'Charlie Brown', + )); + + $this->assertEquals($expected, $tpl->fetch()); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlSelectDateTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlSelectDateTest.php new file mode 100644 index 00000000..8f4f79de --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlSelectDateTest.php @@ -0,0 +1,604 @@ +<?php +/** + * Smarty PHPunit tests of modifier + * + * @package PHPunit + * @author Rodney Rehm + */ + +/** + * class for modifier tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class PluginFunctionHtmlSelectDateTest extends PHPUnit_Smarty +{ + public $now = null; + protected $years = array(); + protected $months = array( + 'none' => '<option value="01">January</option> +<option value="02">February</option> +<option value="03">March</option> +<option value="04">April</option> +<option value="05">May</option> +<option value="06">June</option> +<option value="07">July</option> +<option value="08">August</option> +<option value="09">September</option> +<option value="10">October</option> +<option value="11">November</option> +<option value="12">December</option>', + 'default' => '<option value="01">January</option> +<option value="02" selected="selected">February</option> +<option value="03">March</option> +<option value="04">April</option> +<option value="05">May</option> +<option value="06">June</option> +<option value="07">July</option> +<option value="08">August</option> +<option value="09">September</option> +<option value="10">October</option> +<option value="11">November</option> +<option value="12">December</option>', + 'format_%b' => '<option value="01">Jan</option> +<option value="02" selected="selected">Feb</option> +<option value="03">Mar</option> +<option value="04">Apr</option> +<option value="05">May</option> +<option value="06">Jun</option> +<option value="07">Jul</option> +<option value="08">Aug</option> +<option value="09">Sep</option> +<option value="10">Oct</option> +<option value="11">Nov</option> +<option value="12">Dec</option>', + 'format_value_%b' => '<option value="Jan">January</option> +<option value="Feb" selected="selected">February</option> +<option value="Mar">March</option> +<option value="Apr">April</option> +<option value="May">May</option> +<option value="Jun">June</option> +<option value="Jul">July</option> +<option value="Aug">August</option> +<option value="Sep">September</option> +<option value="Oct">October</option> +<option value="Nov">November</option> +<option value="Dec">December</option>', + 'names' => '<option value="01">alpha</option> +<option value="02" selected="selected">bravo</option> +<option value="03">charlie</option> +<option value="04">delta</option> +<option value="05">echo</option> +<option value="06">foxtrot</option> +<option value="07">golf</option> +<option value="08">hotel</option> +<option value="09">india</option> +<option value="10">juliet</option> +<option value="11">kilo</option> +<option value="12">lima</option>', + ); + + protected $days = array( + 'none' => '<option value="1">01</option> +<option value="2">02</option> +<option value="3">03</option> +<option value="4">04</option> +<option value="5">05</option> +<option value="6">06</option> +<option value="7">07</option> +<option value="8">08</option> +<option value="9">09</option> +<option value="10">10</option> +<option value="11">11</option> +<option value="12">12</option> +<option value="13">13</option> +<option value="14">14</option> +<option value="15">15</option> +<option value="16">16</option> +<option value="17">17</option> +<option value="18">18</option> +<option value="19">19</option> +<option value="20">20</option> +<option value="21">21</option> +<option value="22">22</option> +<option value="23">23</option> +<option value="24">24</option> +<option value="25">25</option> +<option value="26">26</option> +<option value="27">27</option> +<option value="28">28</option> +<option value="29">29</option> +<option value="30">30</option> +<option value="31">31</option>', + 'default' => '<option value="1">01</option> +<option value="2">02</option> +<option value="3">03</option> +<option value="4">04</option> +<option value="5">05</option> +<option value="6">06</option> +<option value="7">07</option> +<option value="8">08</option> +<option value="9">09</option> +<option value="10">10</option> +<option value="11">11</option> +<option value="12">12</option> +<option value="13">13</option> +<option value="14">14</option> +<option value="15">15</option> +<option value="16">16</option> +<option value="17">17</option> +<option value="18">18</option> +<option value="19">19</option> +<option value="20" selected="selected">20</option> +<option value="21">21</option> +<option value="22">22</option> +<option value="23">23</option> +<option value="24">24</option> +<option value="25">25</option> +<option value="26">26</option> +<option value="27">27</option> +<option value="28">28</option> +<option value="29">29</option> +<option value="30">30</option> +<option value="31">31</option>', + 'format_%03d' => '<option value="1">001</option> +<option value="2">002</option> +<option value="3">003</option> +<option value="4">004</option> +<option value="5">005</option> +<option value="6">006</option> +<option value="7">007</option> +<option value="8">008</option> +<option value="9">009</option> +<option value="10">010</option> +<option value="11">011</option> +<option value="12">012</option> +<option value="13">013</option> +<option value="14">014</option> +<option value="15">015</option> +<option value="16">016</option> +<option value="17">017</option> +<option value="18">018</option> +<option value="19">019</option> +<option value="20" selected="selected">020</option> +<option value="21">021</option> +<option value="22">022</option> +<option value="23">023</option> +<option value="24">024</option> +<option value="25">025</option> +<option value="26">026</option> +<option value="27">027</option> +<option value="28">028</option> +<option value="29">029</option> +<option value="30">030</option> +<option value="31">031</option>', + 'format_value_%03d' => '<option value="001">01</option> +<option value="002">02</option> +<option value="003">03</option> +<option value="004">04</option> +<option value="005">05</option> +<option value="006">06</option> +<option value="007">07</option> +<option value="008">08</option> +<option value="009">09</option> +<option value="010">10</option> +<option value="011">11</option> +<option value="012">12</option> +<option value="013">13</option> +<option value="014">14</option> +<option value="015">15</option> +<option value="016">16</option> +<option value="017">17</option> +<option value="018">18</option> +<option value="019">19</option> +<option value="020" selected="selected">20</option> +<option value="021">21</option> +<option value="022">22</option> +<option value="023">23</option> +<option value="024">24</option> +<option value="025">25</option> +<option value="026">26</option> +<option value="027">27</option> +<option value="028">28</option> +<option value="029">29</option> +<option value="030">30</option> +<option value="031">31</option>', + ); + + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + + $year = date('Y'); + $this->now = mktime(15, 0, 0, 2, 20, $year); + $o = ''; + for ($i = 2005; $i < $year; $i ++) { + $o .= "<option value=\"{$i}\">{$i}</option>\n"; + } + $o .= "<option value=\"{$year}\" selected=\"selected\">{$year}</option>"; + $this->years['start_2005'] = $o; + $this->years['end_2005'] = $o; + + $o = "<option value=\"{$year}\" selected=\"selected\">{$year}</option>"; + for ($i = $year + 1; $i < $year + 6; $i ++) { + $o .= "\n<option value=\"{$i}\">{$i}</option>"; + } + $this->years['start_+5'] = $o; + $this->years['end_+5'] = $o; + + $o = ''; + for ($i = $year - 5; $i < $year; $i ++) { + $o .= "<option value=\"{$i}\">{$i}</option>\n"; + } + $o .= "<option value=\"{$year}\" selected=\"selected\">{$year}</option>"; + $this->years['start_-5'] = $o; + $this->years['end_-5'] = $o; + + $this->years['default'] = "<option value=\"{$year}\" selected=\"selected\">{$year}</option>"; + $this->years['none'] = "<option value=\"{$year}\">{$year}</option>"; + } + + protected function reverse($string) + { + $t = explode("\n", $string); + $t = array_reverse($t); + + return join("\n", $t); + } + + public function testDefault() + { + $n = "\n"; + $result = '<select name="Date_Month">' . $n . $this->months['default'] . $n . '</select>' + . $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>' + . $n . '<select name="Date_Year">' . $n . $this->years['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . '}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testPrefix() + { + $n = "\n"; + $result = '<select name="foobar_Month">' . $n . $this->months['default'] . $n . '</select>' + . $n . '<select name="foobar_Day">' . $n . $this->days['default'] . $n . '</select>' + . $n . '<select name="foobar_Year">' . $n . $this->years['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' prefix="foobar_"}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testFieldArray() + { + $n = "\n"; + $result = '<select name="namorized[Date_Month]">' . $n . $this->months['default'] . $n . '</select>' + . $n . '<select name="namorized[Date_Day]">' . $n . $this->days['default'] . $n . '</select>' + . $n . '<select name="namorized[Date_Year]">' . $n . $this->years['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' field_array="namorized"}'); + $this->assertEquals($result, $tpl->fetch()); + + $result = '<select name="namorized[foobar_Month]">' . $n . $this->months['default'] . $n . '</select>' + . $n . '<select name="namorized[foobar_Day]">' . $n . $this->days['default'] . $n . '</select>' + . $n . '<select name="namorized[foobar_Year]">' . $n . $this->years['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' field_array="namorized" prefix="foobar_"}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testExtra() + { + $n = "\n"; + $result = '<select name="Date_Month" data-foo="xy">' . $n . $this->months['default'] . $n . '</select>' + . $n . '<select name="Date_Day" data-foo="xy">' . $n . $this->days['default'] . $n . '</select>' + . $n . '<select name="Date_Year" data-foo="xy">' . $n . $this->years['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' all_extra="data-foo=\"xy\""}'); + $this->assertEquals($result, $tpl->fetch()); + + $result = '<select name="Date_Month" data-foo="month">' . $n . $this->months['default'] . $n . '</select>' + . $n . '<select name="Date_Day" data-foo="day">' . $n . $this->days['default'] . $n . '</select>' + . $n . '<select name="Date_Year" data-foo="year">' . $n . $this->years['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' day_extra="data-foo=\"day\"" month_extra="data-foo=\"month\"" year_extra="data-foo=\"year\""}'); + $this->assertEquals($result, $tpl->fetch()); + + $result = '<select name="Date_Month" data_foo="foo">' . $n . $this->months['default'] . $n . '</select>' + . $n . '<select name="Date_Day" data_foo="foo">' . $n . $this->days['default'] . $n . '</select>' + . $n . '<select name="Date_Year" data_foo="foo">' . $n . $this->years['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' data_foo="foo"}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testFieldOrder() + { + $n = "\n"; + $result = '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>' + . $n . '<select name="Date_Month">' . $n . $this->months['default'] . $n . '</select>' + . $n . '<select name="Date_Year">' . $n . $this->years['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' field_order="DMY"}'); + $this->assertEquals($result, $tpl->fetch()); + + $result = '<select name="Date_Year">' . $n . $this->years['default'] . $n . '</select>' + . $n . '<select name="Date_Month">' . $n . $this->months['default'] . $n . '</select>' + . $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' field_order="YMD"}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testFieldSeparator() + { + $n = "\n"; + $result = '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>' + . ' - <select name="Date_Month">' . $n . $this->months['default'] . $n . '</select>' + . ' - <select name="Date_Year">' . $n . $this->years['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' field_order="DMY" field_separator=" - "}'); + $this->assertEquals($result, $tpl->fetch()); + + $result = '<select name="Date_Year">' . $n . $this->years['default'] . $n . '</select>' + . ' / <select name="Date_Month">' . $n . $this->months['default'] . $n . '</select>' + . ' / <select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' field_order="YMD" field_separator=" / "}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testEmpty() + { + $n = "\n"; + $result = '<select name="Date_Month">' . $n . '<option value=""></option>' . $n . $this->months['default'] . $n . '</select>' + . $n . '<select name="Date_Day">' . $n . '<option value=""></option>' . $n . $this->days['default'] . $n . '</select>' + . $n . '<select name="Date_Year">' . $n . '<option value=""></option>' . $n . $this->years['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' all_empty=""}'); + $this->assertEquals($result, $tpl->fetch()); + + $result = '<select name="Date_Month">' . $n . '<option value="">all</option>' . $n . $this->months['default'] . $n . '</select>' + . $n . '<select name="Date_Day">' . $n . '<option value="">all</option>' . $n . $this->days['default'] . $n . '</select>' + . $n . '<select name="Date_Year">' . $n . '<option value="">all</option>' . $n . $this->years['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' all_empty="all"}'); + $this->assertEquals($result, $tpl->fetch()); + + $result = '<select name="Date_Month">' . $n . $this->months['default'] . $n . '</select>' + . $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>' + . $n . '<select name="Date_Year">' . $n . '<option value=""></option>' . $n . $this->years['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' year_empty=""}'); + $this->assertEquals($result, $tpl->fetch()); + + $result = '<select name="Date_Month">' . $n . '<option value="">month</option>' . $n . $this->months['default'] . $n . '</select>' + . $n . '<select name="Date_Day">' . $n . '<option value="">day</option>' . $n . $this->days['default'] . $n . '</select>' + . $n . '<select name="Date_Year">' . $n . '<option value="">year</option>' . $n . $this->years['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' year_empty="year" month_empty="month" day_empty="day"}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testEmptyUnset() + { + $n = "\n"; + $result = '<select name="Date_Month">' . $n . '<option value=""></option>' . $n . $this->months['none'] . $n . '</select>' + . $n . '<select name="Date_Day">' . $n . '<option value=""></option>' . $n . $this->days['none'] . $n . '</select>' + . $n . '<select name="Date_Year">' . $n . '<option value=""></option>' . $n . $this->years['none'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=null all_empty=""}'); + $this->assertEquals($result, $tpl->fetch()); + + $result = '<select name="Date_Month">' . $n . '<option value="">all</option>' . $n . $this->months['none'] . $n . '</select>' + . $n . '<select name="Date_Day">' . $n . '<option value="">all</option>' . $n . $this->days['none'] . $n . '</select>' + . $n . '<select name="Date_Year">' . $n . '<option value="">all</option>' . $n . $this->years['none'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=null all_empty="all"}'); + $this->assertEquals($result, $tpl->fetch()); + + $result = '<select name="Date_Month">' . $n . $this->months['none'] . $n . '</select>' + . $n . '<select name="Date_Day">' . $n . $this->days['none'] . $n . '</select>' + . $n . '<select name="Date_Year">' . $n . '<option value=""></option>' . $n . $this->years['none'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=null year_empty=""}'); + $this->assertEquals($result, $tpl->fetch()); + + $result = '<select name="Date_Month">' . $n . '<option value="">month</option>' . $n . $this->months['none'] . $n . '</select>' + . $n . '<select name="Date_Day">' . $n . '<option value="">day</option>' . $n . $this->days['none'] . $n . '</select>' + . $n . '<select name="Date_Year">' . $n . '<option value="">year</option>' . $n . $this->years['none'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=null year_empty="year" month_empty="month" day_empty="day"}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testId() + { + $n = "\n"; + $result = '<select name="Date_Month" id="Date_Month">' . $n . $this->months['default'] . $n . '</select>' + . $n . '<select name="Date_Day" id="Date_Day">' . $n . $this->days['default'] . $n . '</select>' + . $n . '<select name="Date_Year" id="Date_Year">' . $n . $this->years['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' all_id=""}'); + $this->assertEquals($result, $tpl->fetch()); + + $result = '<select name="Date_Month" id="all-Date_Month">' . $n . $this->months['default'] . $n . '</select>' + . $n . '<select name="Date_Day" id="all-Date_Day">' . $n . $this->days['default'] . $n . '</select>' + . $n . '<select name="Date_Year" id="all-Date_Year">' . $n . $this->years['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' all_id="all-"}'); + $this->assertEquals($result, $tpl->fetch()); + + $result = '<select name="Date_Month" id="month">' . $n . $this->months['default'] . $n . '</select>' + . $n . '<select name="Date_Day" id="day">' . $n . $this->days['default'] . $n . '</select>' + . $n . '<select name="Date_Year" id="year">' . $n . $this->years['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' year_id="year" month_id="month" day_id="day"}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testStartYearAbsolute() + { + $n = "\n"; + $result = '<select name="Date_Month">' . $n . $this->months['default'] . $n . '</select>' + . $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>' + . $n . '<select name="Date_Year">' . $n . $this->years['start_2005'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' start_year=2005}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testStartYearRelative() + { + $n = "\n"; + $result = '<select name="Date_Month">' . $n . $this->months['default'] . $n . '</select>' + . $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>' + . $n . '<select name="Date_Year">' . $n . $this->years['start_+5'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' start_year="+5"}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testStartYearRelativeNegative() + { + $n = "\n"; + $result = '<select name="Date_Month">' . $n . $this->months['default'] . $n . '</select>' + . $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>' + . $n . '<select name="Date_Year">' . $n . $this->years['start_-5'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' start_year="-5"}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testEndYearAbsolute() + { + $n = "\n"; + $result = '<select name="Date_Month">' . $n . $this->months['default'] . $n . '</select>' + . $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>' + . $n . '<select name="Date_Year">' . $n . $this->years['end_2005'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' end_year=2005}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testEndYearRelative() + { + $n = "\n"; + $result = '<select name="Date_Month">' . $n . $this->months['default'] . $n . '</select>' + . $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>' + . $n . '<select name="Date_Year">' . $n . $this->years['end_+5'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' end_year="+5"}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testEndYearRelativeNegative() + { + $n = "\n"; + $result = '<select name="Date_Month">' . $n . $this->months['default'] . $n . '</select>' + . $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>' + . $n . '<select name="Date_Year">' . $n . $this->years['end_-5'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' end_year="-5"}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testDisplayDaysMonthYear() + { + $n = "\n"; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' display_days=false}'); + $result = '<select name="Date_Month">' . $n . $this->months['default'] . $n . '</select>' + . $n . '<select name="Date_Year">' . $n . $this->years['default'] . $n . '</select>'; + $this->assertEquals($result, $tpl->fetch()); + + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' display_months=false}'); + $result = '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>' + . $n . '<select name="Date_Year">' . $n . $this->years['default'] . $n . '</select>'; + $this->assertEquals($result, $tpl->fetch()); + + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' display_years=false}'); + $result = '<select name="Date_Month">' . $n . $this->months['default'] . $n . '</select>' + . $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>'; + $this->assertEquals($result, $tpl->fetch()); + } + + public function testYearsReversed() + { + $n = "\n"; + $result = '<select name="Date_Month">' . $n . $this->months['default'] . $n . '</select>' + . $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>' + . $n . '<select name="Date_Year">' . $n . $this->reverse($this->years['start_2005']) . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' start_year=2005 reverse_years=true}'); + $this->assertEquals($result, $tpl->fetch()); + + $result = '<select name="Date_Month">' . $n . $this->months['default'] . $n . '</select>' + . $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>' + . $n . '<select name="Date_Year">' . $n . $this->reverse($this->years['start_+5']) . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' start_year="+5" reverse_years=true}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testYearText() + { + $year = date('Y'); + $n = "\n"; + $result = '<select name="Date_Month">' . $n . $this->months['default'] . $n . '</select>' + . $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>' + . $n . "<input type=\"text\" name=\"Date_Year\" value=\"{$year}\" size=\"4\" maxlength=\"4\" />"; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' year_as_text=true}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + + $result = '<select name="foo_Month">' . $n . $this->months['default'] . $n . '</select>' + . $n . '<select name="foo_Day">' . $n . $this->days['default'] . $n . '</select>' + . $n . "<input type=\"text\" name=\"foo_Year\" value=\"{$year}\" size=\"4\" maxlength=\"4\" />"; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' year_as_text=true prefix="foo_"}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testMonthFormat() + { + $n = "\n"; + $result = '<select name="Date_Month">' . $n . $this->months['format_%b'] . $n . '</select>' + . $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>' + . $n . '<select name="Date_Year">' . $n . $this->years['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' month_format="%b"}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testMonthFormatValue() + { + $n = "\n"; + $result = '<select name="Date_Month">' . $n . $this->months['format_value_%b'] . $n . '</select>' + . $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>' + . $n . '<select name="Date_Year">' . $n . $this->years['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' month_value_format="%b"}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testMonthNames() + { + $n = "\n"; + $result = '<select name="Date_Month">' . $n . $this->months['names'] . $n . '</select>' + . $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>' + . $n . '<select name="Date_Year">' . $n . $this->years['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{$names = [1 => "alpha","bravo","charlie","delta","echo","foxtrot","golf","hotel","india","juliet","kilo","lima"]}{html_select_date time=' . $this->now . ' month_names=$names}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testDayFormat() + { + $n = "\n"; + $result = '<select name="Date_Month">' . $n . $this->months['default'] . $n . '</select>' + . $n . '<select name="Date_Day">' . $n . $this->days['format_%03d'] . $n . '</select>' + . $n . '<select name="Date_Year">' . $n . $this->years['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' day_format="%03d"}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testDayFormatValue() + { + $n = "\n"; + $result = '<select name="Date_Month">' . $n . $this->months['default'] . $n . '</select>' + . $n . '<select name="Date_Day">' . $n . $this->days['format_value_%03d'] . $n . '</select>' + . $n . '<select name="Date_Year">' . $n . $this->years['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' day_value_format="%03d"}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testTimeArray() + { + $n = "\n"; + $result = '<select name="namorized[foobar_Month]">' . $n . $this->months['default'] . $n . '</select>' + . $n . '<select name="namorized[foobar_Day]">' . $n . $this->days['default'] . $n . '</select>' + . $n . '<select name="namorized[foobar_Year]">' . $n . $this->years['default'] . $n . '</select>'; + + $date_array = array( + 'namorized' => array( + 'foobar_Month' => '02', + 'foobar_Day' => '20', + 'foobar_Year' => date('Y'), + ), + ); + + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=$date_array.namorized field_array="namorized" prefix="foobar_"}'); + $tpl->assign('date_array', $date_array); + $this->assertEquals($result, $tpl->fetch()); + + $tpl = $this->smarty->createTemplate('eval:{html_select_date time=$date_array field_array="namorized" prefix="foobar_"}'); + $tpl->assign('date_array', $date_array); + $this->assertEquals($result, $tpl->fetch()); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlSelectTimeTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlSelectTimeTest.php new file mode 100644 index 00000000..f152a8e8 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlSelectTimeTest.php @@ -0,0 +1,1151 @@ +<?php +/** + * Smarty PHPunit tests of modifier + * + * @package PHPunit + * @author Rodney Rehm + */ + +/** + * class for modifier tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class PluginFunctionHtmlSelectTimeTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + $this->now = mktime(16, 15, 11, 2, 20, 2011); + } + + protected $now = null; + protected $hours = array( + 'none' => '<option value="00">00</option> +<option value="01">01</option> +<option value="02">02</option> +<option value="03">03</option> +<option value="04">04</option> +<option value="05">05</option> +<option value="06">06</option> +<option value="07">07</option> +<option value="08">08</option> +<option value="09">09</option> +<option value="10">10</option> +<option value="11">11</option> +<option value="12">12</option> +<option value="13">13</option> +<option value="14">14</option> +<option value="15">15</option> +<option value="16">16</option> +<option value="17">17</option> +<option value="18">18</option> +<option value="19">19</option> +<option value="20">20</option> +<option value="21">21</option> +<option value="22">22</option> +<option value="23">23</option>', + 'default' => '<option value="00">00</option> +<option value="01">01</option> +<option value="02">02</option> +<option value="03">03</option> +<option value="04">04</option> +<option value="05">05</option> +<option value="06">06</option> +<option value="07">07</option> +<option value="08">08</option> +<option value="09">09</option> +<option value="10">10</option> +<option value="11">11</option> +<option value="12">12</option> +<option value="13">13</option> +<option value="14">14</option> +<option value="15">15</option> +<option value="16" selected="selected">16</option> +<option value="17">17</option> +<option value="18">18</option> +<option value="19">19</option> +<option value="20">20</option> +<option value="21">21</option> +<option value="22">22</option> +<option value="23">23</option>', + '12h' => '<option value="01">01</option> +<option value="02">02</option> +<option value="03">03</option> +<option value="04" selected="selected">04</option> +<option value="05">05</option> +<option value="06">06</option> +<option value="07">07</option> +<option value="08">08</option> +<option value="09">09</option> +<option value="10">10</option> +<option value="11">11</option> +<option value="12">12</option>', + 'format_%03d' => '<option value="00">000</option> +<option value="01">001</option> +<option value="02">002</option> +<option value="03">003</option> +<option value="04">004</option> +<option value="05">005</option> +<option value="06">006</option> +<option value="07">007</option> +<option value="08">008</option> +<option value="09">009</option> +<option value="10">010</option> +<option value="11">011</option> +<option value="12">012</option> +<option value="13">013</option> +<option value="14">014</option> +<option value="15">015</option> +<option value="16" selected="selected">016</option> +<option value="17">017</option> +<option value="18">018</option> +<option value="19">019</option> +<option value="20">020</option> +<option value="21">021</option> +<option value="22">022</option> +<option value="23">023</option>', + 'format_value_%03d' => '<option value="000">00</option> +<option value="001">01</option> +<option value="002">02</option> +<option value="003">03</option> +<option value="004">04</option> +<option value="005">05</option> +<option value="006">06</option> +<option value="007">07</option> +<option value="008">08</option> +<option value="009">09</option> +<option value="010">10</option> +<option value="011">11</option> +<option value="012">12</option> +<option value="013">13</option> +<option value="014">14</option> +<option value="015">15</option> +<option value="016" selected="selected">16</option> +<option value="017">17</option> +<option value="018">18</option> +<option value="019">19</option> +<option value="020">20</option> +<option value="021">21</option> +<option value="022">22</option> +<option value="023">23</option>', + ); + protected $minutes = array( + 'none' => '<option value="00">00</option> +<option value="01">01</option> +<option value="02">02</option> +<option value="03">03</option> +<option value="04">04</option> +<option value="05">05</option> +<option value="06">06</option> +<option value="07">07</option> +<option value="08">08</option> +<option value="09">09</option> +<option value="10">10</option> +<option value="11">11</option> +<option value="12">12</option> +<option value="13">13</option> +<option value="14">14</option> +<option value="15">15</option> +<option value="16">16</option> +<option value="17">17</option> +<option value="18">18</option> +<option value="19">19</option> +<option value="20">20</option> +<option value="21">21</option> +<option value="22">22</option> +<option value="23">23</option> +<option value="24">24</option> +<option value="25">25</option> +<option value="26">26</option> +<option value="27">27</option> +<option value="28">28</option> +<option value="29">29</option> +<option value="30">30</option> +<option value="31">31</option> +<option value="32">32</option> +<option value="33">33</option> +<option value="34">34</option> +<option value="35">35</option> +<option value="36">36</option> +<option value="37">37</option> +<option value="38">38</option> +<option value="39">39</option> +<option value="40">40</option> +<option value="41">41</option> +<option value="42">42</option> +<option value="43">43</option> +<option value="44">44</option> +<option value="45">45</option> +<option value="46">46</option> +<option value="47">47</option> +<option value="48">48</option> +<option value="49">49</option> +<option value="50">50</option> +<option value="51">51</option> +<option value="52">52</option> +<option value="53">53</option> +<option value="54">54</option> +<option value="55">55</option> +<option value="56">56</option> +<option value="57">57</option> +<option value="58">58</option> +<option value="59">59</option>', + 'default' => '<option value="00">00</option> +<option value="01">01</option> +<option value="02">02</option> +<option value="03">03</option> +<option value="04">04</option> +<option value="05">05</option> +<option value="06">06</option> +<option value="07">07</option> +<option value="08">08</option> +<option value="09">09</option> +<option value="10">10</option> +<option value="11">11</option> +<option value="12">12</option> +<option value="13">13</option> +<option value="14">14</option> +<option value="15" selected="selected">15</option> +<option value="16">16</option> +<option value="17">17</option> +<option value="18">18</option> +<option value="19">19</option> +<option value="20">20</option> +<option value="21">21</option> +<option value="22">22</option> +<option value="23">23</option> +<option value="24">24</option> +<option value="25">25</option> +<option value="26">26</option> +<option value="27">27</option> +<option value="28">28</option> +<option value="29">29</option> +<option value="30">30</option> +<option value="31">31</option> +<option value="32">32</option> +<option value="33">33</option> +<option value="34">34</option> +<option value="35">35</option> +<option value="36">36</option> +<option value="37">37</option> +<option value="38">38</option> +<option value="39">39</option> +<option value="40">40</option> +<option value="41">41</option> +<option value="42">42</option> +<option value="43">43</option> +<option value="44">44</option> +<option value="45">45</option> +<option value="46">46</option> +<option value="47">47</option> +<option value="48">48</option> +<option value="49">49</option> +<option value="50">50</option> +<option value="51">51</option> +<option value="52">52</option> +<option value="53">53</option> +<option value="54">54</option> +<option value="55">55</option> +<option value="56">56</option> +<option value="57">57</option> +<option value="58">58</option> +<option value="59">59</option>', + '30' => '<option value="00" selected="selected">00</option> +<option value="30">30</option>', + '15' => '<option value="00">00</option> +<option value="15" selected="selected">15</option> +<option value="30">30</option> +<option value="45">45</option>', + '10' => '<option value="00">00</option> +<option value="10" selected="selected">10</option> +<option value="20">20</option> +<option value="30">30</option> +<option value="40">40</option> +<option value="50">50</option>', + '5' => '<option value="00">00</option> +<option value="05">05</option> +<option value="10">10</option> +<option value="15" selected="selected">15</option> +<option value="20">20</option> +<option value="25">25</option> +<option value="30">30</option> +<option value="35">35</option> +<option value="40">40</option> +<option value="45">45</option> +<option value="50">50</option> +<option value="55">55</option>', + 'format_%03d' => '<option value="00">000</option> +<option value="01">001</option> +<option value="02">002</option> +<option value="03">003</option> +<option value="04">004</option> +<option value="05">005</option> +<option value="06">006</option> +<option value="07">007</option> +<option value="08">008</option> +<option value="09">009</option> +<option value="10">010</option> +<option value="11">011</option> +<option value="12">012</option> +<option value="13">013</option> +<option value="14">014</option> +<option value="15" selected="selected">015</option> +<option value="16">016</option> +<option value="17">017</option> +<option value="18">018</option> +<option value="19">019</option> +<option value="20">020</option> +<option value="21">021</option> +<option value="22">022</option> +<option value="23">023</option> +<option value="24">024</option> +<option value="25">025</option> +<option value="26">026</option> +<option value="27">027</option> +<option value="28">028</option> +<option value="29">029</option> +<option value="30">030</option> +<option value="31">031</option> +<option value="32">032</option> +<option value="33">033</option> +<option value="34">034</option> +<option value="35">035</option> +<option value="36">036</option> +<option value="37">037</option> +<option value="38">038</option> +<option value="39">039</option> +<option value="40">040</option> +<option value="41">041</option> +<option value="42">042</option> +<option value="43">043</option> +<option value="44">044</option> +<option value="45">045</option> +<option value="46">046</option> +<option value="47">047</option> +<option value="48">048</option> +<option value="49">049</option> +<option value="50">050</option> +<option value="51">051</option> +<option value="52">052</option> +<option value="53">053</option> +<option value="54">054</option> +<option value="55">055</option> +<option value="56">056</option> +<option value="57">057</option> +<option value="58">058</option> +<option value="59">059</option>', + 'format_value_%03d' => '<option value="000">00</option> +<option value="001">01</option> +<option value="002">02</option> +<option value="003">03</option> +<option value="004">04</option> +<option value="005">05</option> +<option value="006">06</option> +<option value="007">07</option> +<option value="008">08</option> +<option value="009">09</option> +<option value="010">10</option> +<option value="011">11</option> +<option value="012">12</option> +<option value="013">13</option> +<option value="014">14</option> +<option value="015" selected="selected">15</option> +<option value="016">16</option> +<option value="017">17</option> +<option value="018">18</option> +<option value="019">19</option> +<option value="020">20</option> +<option value="021">21</option> +<option value="022">22</option> +<option value="023">23</option> +<option value="024">24</option> +<option value="025">25</option> +<option value="026">26</option> +<option value="027">27</option> +<option value="028">28</option> +<option value="029">29</option> +<option value="030">30</option> +<option value="031">31</option> +<option value="032">32</option> +<option value="033">33</option> +<option value="034">34</option> +<option value="035">35</option> +<option value="036">36</option> +<option value="037">37</option> +<option value="038">38</option> +<option value="039">39</option> +<option value="040">40</option> +<option value="041">41</option> +<option value="042">42</option> +<option value="043">43</option> +<option value="044">44</option> +<option value="045">45</option> +<option value="046">46</option> +<option value="047">47</option> +<option value="048">48</option> +<option value="049">49</option> +<option value="050">50</option> +<option value="051">51</option> +<option value="052">52</option> +<option value="053">53</option> +<option value="054">54</option> +<option value="055">55</option> +<option value="056">56</option> +<option value="057">57</option> +<option value="058">58</option> +<option value="059">59</option>', + ); + protected $seconds = array( + 'none' => '<option value="00">00</option> +<option value="01">01</option> +<option value="02">02</option> +<option value="03">03</option> +<option value="04">04</option> +<option value="05">05</option> +<option value="06">06</option> +<option value="07">07</option> +<option value="08">08</option> +<option value="09">09</option> +<option value="10">10</option> +<option value="11">11</option> +<option value="12">12</option> +<option value="13">13</option> +<option value="14">14</option> +<option value="15">15</option> +<option value="16">16</option> +<option value="17">17</option> +<option value="18">18</option> +<option value="19">19</option> +<option value="20">20</option> +<option value="21">21</option> +<option value="22">22</option> +<option value="23">23</option> +<option value="24">24</option> +<option value="25">25</option> +<option value="26">26</option> +<option value="27">27</option> +<option value="28">28</option> +<option value="29">29</option> +<option value="30">30</option> +<option value="31">31</option> +<option value="32">32</option> +<option value="33">33</option> +<option value="34">34</option> +<option value="35">35</option> +<option value="36">36</option> +<option value="37">37</option> +<option value="38">38</option> +<option value="39">39</option> +<option value="40">40</option> +<option value="41">41</option> +<option value="42">42</option> +<option value="43">43</option> +<option value="44">44</option> +<option value="45">45</option> +<option value="46">46</option> +<option value="47">47</option> +<option value="48">48</option> +<option value="49">49</option> +<option value="50">50</option> +<option value="51">51</option> +<option value="52">52</option> +<option value="53">53</option> +<option value="54">54</option> +<option value="55">55</option> +<option value="56">56</option> +<option value="57">57</option> +<option value="58">58</option> +<option value="59">59</option>', + 'default' => '<option value="00">00</option> +<option value="01">01</option> +<option value="02">02</option> +<option value="03">03</option> +<option value="04">04</option> +<option value="05">05</option> +<option value="06">06</option> +<option value="07">07</option> +<option value="08">08</option> +<option value="09">09</option> +<option value="10">10</option> +<option value="11" selected="selected">11</option> +<option value="12">12</option> +<option value="13">13</option> +<option value="14">14</option> +<option value="15">15</option> +<option value="16">16</option> +<option value="17">17</option> +<option value="18">18</option> +<option value="19">19</option> +<option value="20">20</option> +<option value="21">21</option> +<option value="22">22</option> +<option value="23">23</option> +<option value="24">24</option> +<option value="25">25</option> +<option value="26">26</option> +<option value="27">27</option> +<option value="28">28</option> +<option value="29">29</option> +<option value="30">30</option> +<option value="31">31</option> +<option value="32">32</option> +<option value="33">33</option> +<option value="34">34</option> +<option value="35">35</option> +<option value="36">36</option> +<option value="37">37</option> +<option value="38">38</option> +<option value="39">39</option> +<option value="40">40</option> +<option value="41">41</option> +<option value="42">42</option> +<option value="43">43</option> +<option value="44">44</option> +<option value="45">45</option> +<option value="46">46</option> +<option value="47">47</option> +<option value="48">48</option> +<option value="49">49</option> +<option value="50">50</option> +<option value="51">51</option> +<option value="52">52</option> +<option value="53">53</option> +<option value="54">54</option> +<option value="55">55</option> +<option value="56">56</option> +<option value="57">57</option> +<option value="58">58</option> +<option value="59">59</option>', + '30' => '<option value="00" selected="selected">00</option> +<option value="30">30</option>', + '15' => '<option value="00" selected="selected">00</option> +<option value="15">15</option> +<option value="30">30</option> +<option value="45">45</option>', + '10' => '<option value="00">00</option> +<option value="10" selected="selected">10</option> +<option value="20">20</option> +<option value="30">30</option> +<option value="40">40</option> +<option value="50">50</option>', + '5' => '<option value="00">00</option> +<option value="05">05</option> +<option value="10" selected="selected">10</option> +<option value="15">15</option> +<option value="20">20</option> +<option value="25">25</option> +<option value="30">30</option> +<option value="35">35</option> +<option value="40">40</option> +<option value="45">45</option> +<option value="50">50</option> +<option value="55">55</option>', + 'format_%03d' => '<option value="00">000</option> +<option value="01">001</option> +<option value="02">002</option> +<option value="03">003</option> +<option value="04">004</option> +<option value="05">005</option> +<option value="06">006</option> +<option value="07">007</option> +<option value="08">008</option> +<option value="09">009</option> +<option value="10">010</option> +<option value="11" selected="selected">011</option> +<option value="12">012</option> +<option value="13">013</option> +<option value="14">014</option> +<option value="15">015</option> +<option value="16">016</option> +<option value="17">017</option> +<option value="18">018</option> +<option value="19">019</option> +<option value="20">020</option> +<option value="21">021</option> +<option value="22">022</option> +<option value="23">023</option> +<option value="24">024</option> +<option value="25">025</option> +<option value="26">026</option> +<option value="27">027</option> +<option value="28">028</option> +<option value="29">029</option> +<option value="30">030</option> +<option value="31">031</option> +<option value="32">032</option> +<option value="33">033</option> +<option value="34">034</option> +<option value="35">035</option> +<option value="36">036</option> +<option value="37">037</option> +<option value="38">038</option> +<option value="39">039</option> +<option value="40">040</option> +<option value="41">041</option> +<option value="42">042</option> +<option value="43">043</option> +<option value="44">044</option> +<option value="45">045</option> +<option value="46">046</option> +<option value="47">047</option> +<option value="48">048</option> +<option value="49">049</option> +<option value="50">050</option> +<option value="51">051</option> +<option value="52">052</option> +<option value="53">053</option> +<option value="54">054</option> +<option value="55">055</option> +<option value="56">056</option> +<option value="57">057</option> +<option value="58">058</option> +<option value="59">059</option>', + 'format_value_%03d' => '<option value="000">00</option> +<option value="001">01</option> +<option value="002">02</option> +<option value="003">03</option> +<option value="004">04</option> +<option value="005">05</option> +<option value="006">06</option> +<option value="007">07</option> +<option value="008">08</option> +<option value="009">09</option> +<option value="010">10</option> +<option value="011" selected="selected">11</option> +<option value="012">12</option> +<option value="013">13</option> +<option value="014">14</option> +<option value="015">15</option> +<option value="016">16</option> +<option value="017">17</option> +<option value="018">18</option> +<option value="019">19</option> +<option value="020">20</option> +<option value="021">21</option> +<option value="022">22</option> +<option value="023">23</option> +<option value="024">24</option> +<option value="025">25</option> +<option value="026">26</option> +<option value="027">27</option> +<option value="028">28</option> +<option value="029">29</option> +<option value="030">30</option> +<option value="031">31</option> +<option value="032">32</option> +<option value="033">33</option> +<option value="034">34</option> +<option value="035">35</option> +<option value="036">36</option> +<option value="037">37</option> +<option value="038">38</option> +<option value="039">39</option> +<option value="040">40</option> +<option value="041">41</option> +<option value="042">42</option> +<option value="043">43</option> +<option value="044">44</option> +<option value="045">45</option> +<option value="046">46</option> +<option value="047">47</option> +<option value="048">48</option> +<option value="049">49</option> +<option value="050">50</option> +<option value="051">51</option> +<option value="052">52</option> +<option value="053">53</option> +<option value="054">54</option> +<option value="055">55</option> +<option value="056">56</option> +<option value="057">57</option> +<option value="058">58</option> +<option value="059">59</option>', + ); + protected $meridians = array( + 'default' => '<option value="am">AM</option> +<option value="pm" selected="selected">PM</option>', + ); + + public function testDefault() + { + $n = "\n"; + $result = '<select name="Time_Hour">' . $n . $this->hours['default'] . $n . '</select>' + . $n . '<select name="Time_Minute">' . $n . $this->minutes['default'] . $n . '</select>' + . $n . '<select name="Time_Second">' . $n . $this->seconds['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . '}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testPrefix() + { + $n = "\n"; + $result = '<select name="foobar_Hour">' . $n . $this->hours['default'] . $n . '</select>' + . $n . '<select name="foobar_Minute">' . $n . $this->minutes['default'] . $n . '</select>' + . $n . '<select name="foobar_Second">' . $n . $this->seconds['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' prefix="foobar_"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testFieldArray() + { + $n = "\n"; + $result = '<select name="namorized[Time_Hour]">' . $n . $this->hours['default'] . $n . '</select>' + . $n . '<select name="namorized[Time_Minute]">' . $n . $this->minutes['default'] . $n . '</select>' + . $n . '<select name="namorized[Time_Second]">' . $n . $this->seconds['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' field_array="namorized"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + + $result = '<select name="namorized[foobar_Hour]">' . $n . $this->hours['default'] . $n . '</select>' + . $n . '<select name="namorized[foobar_Minute]">' . $n . $this->minutes['default'] . $n . '</select>' + . $n . '<select name="namorized[foobar_Second]">' . $n . $this->seconds['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' field_array="namorized" prefix="foobar_"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testExtra() + { + $n = "\n"; + $result = '<select name="Time_Hour" data-foo="xy">' . $n . $this->hours['default'] . $n . '</select>' + . $n . '<select name="Time_Minute" data-foo="xy">' . $n . $this->minutes['default'] . $n . '</select>' + . $n . '<select name="Time_Second" data-foo="xy">' . $n . $this->seconds['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' all_extra="data-foo=\"xy\""}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + + $result = '<select name="Time_Hour" data-foo="hour">' . $n . $this->hours['default'] . $n . '</select>' + . $n . '<select name="Time_Minute" data-foo="minute">' . $n . $this->minutes['default'] . $n . '</select>' + . $n . '<select name="Time_Second" data-foo="second">' . $n . $this->seconds['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' hour_extra="data-foo=\"hour\"" minute_extra="data-foo=\"minute\"" second_extra="data-foo=\"second\""}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + + $result = '<select name="Time_Hour" data_foo="foo">' . $n . $this->hours['default'] . $n . '</select>' + . $n . '<select name="Time_Minute" data_foo="foo">' . $n . $this->minutes['default'] . $n . '</select>' + . $n . '<select name="Time_Second" data_foo="foo">' . $n . $this->seconds['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' data_foo="foo"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testFieldSeparator() + { + $n = "\n"; + $result = '<select name="Time_Hour">' . $n . $this->hours['default'] . $n . '</select>' + . ' - <select name="Time_Minute">' . $n . $this->minutes['default'] . $n . '</select>' + . ' - <select name="Time_Second">' . $n . $this->seconds['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' field_separator=" - "}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testEmpty() + { + $n = "\n"; + $result = '<select name="Time_Hour">' . $n . '<option value=""></option>' . $n . $this->hours['default'] . $n . '</select>' + . $n . '<select name="Time_Minute">' . $n . '<option value=""></option>' . $n . $this->minutes['default'] . $n . '</select>' + . $n . '<select name="Time_Second">' . $n . '<option value=""></option>' . $n . $this->seconds['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' all_empty=""}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + + $result = '<select name="Time_Hour">' . $n . '<option value="">all</option>' . $n . $this->hours['default'] . $n . '</select>' + . $n . '<select name="Time_Minute">' . $n . '<option value="">all</option>' . $n . $this->minutes['default'] . $n . '</select>' + . $n . '<select name="Time_Second">' . $n . '<option value="">all</option>' . $n . $this->seconds['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' all_empty="all"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + + $result = '<select name="Time_Hour">' . $n . $this->hours['default'] . $n . '</select>' + . $n . '<select name="Time_Minute">' . $n . $this->minutes['default'] . $n . '</select>' + . $n . '<select name="Time_Second">' . $n . '<option value=""></option>' . $n . $this->seconds['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' second_empty=""}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + + $result = '<select name="Time_Hour">' . $n . '<option value="">hour</option>' . $n . $this->hours['default'] . $n . '</select>' + . $n . '<select name="Time_Minute">' . $n . '<option value="">minute</option>' . $n . $this->minutes['default'] . $n . '</select>' + . $n . '<select name="Time_Second">' . $n . '<option value="">second</option>' . $n . $this->seconds['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' hour_empty="hour" minute_empty="minute" second_empty="second"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testEmptyUnset() + { + $n = "\n"; + $result = '<select name="Time_Hour">' . $n . '<option value=""></option>' . $n . $this->hours['none'] . $n . '</select>' + . $n . '<select name="Time_Minute">' . $n . '<option value=""></option>' . $n . $this->minutes['none'] . $n . '</select>' + . $n . '<select name="Time_Second">' . $n . '<option value=""></option>' . $n . $this->seconds['none'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=null all_empty=""}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + + $result = '<select name="Time_Hour">' . $n . '<option value="">all</option>' . $n . $this->hours['none'] . $n . '</select>' + . $n . '<select name="Time_Minute">' . $n . '<option value="">all</option>' . $n . $this->minutes['none'] . $n . '</select>' + . $n . '<select name="Time_Second">' . $n . '<option value="">all</option>' . $n . $this->seconds['none'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=null all_empty="all"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + + $result = '<select name="Time_Hour">' . $n . $this->hours['none'] . $n . '</select>' + . $n . '<select name="Time_Minute">' . $n . $this->minutes['none'] . $n . '</select>' + . $n . '<select name="Time_Second">' . $n . '<option value=""></option>' . $n . $this->seconds['none'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=null second_empty=""}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + + $result = '<select name="Time_Hour">' . $n . '<option value="">hour</option>' . $n . $this->hours['none'] . $n . '</select>' + . $n . '<select name="Time_Minute">' . $n . '<option value="">minute</option>' . $n . $this->minutes['none'] . $n . '</select>' + . $n . '<select name="Time_Second">' . $n . '<option value="">second</option>' . $n . $this->seconds['none'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=null hour_empty="hour" minute_empty="minute" second_empty="second"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testId() + { + $n = "\n"; + $result = '<select name="Time_Hour" id="Time_Hour">' . $n . $this->hours['default'] . $n . '</select>' + . $n . '<select name="Time_Minute" id="Time_Minute">' . $n . $this->minutes['default'] . $n . '</select>' + . $n . '<select name="Time_Second" id="Time_Second">' . $n . $this->seconds['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' all_id=""}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + + $result = '<select name="Time_Hour" id="all-Time_Hour">' . $n . $this->hours['default'] . $n . '</select>' + . $n . '<select name="Time_Minute" id="all-Time_Minute">' . $n . $this->minutes['default'] . $n . '</select>' + . $n . '<select name="Time_Second" id="all-Time_Second">' . $n . $this->seconds['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' all_id="all-"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + + $result = '<select name="Time_Hour" id="hour">' . $n . $this->hours['default'] . $n . '</select>' + . $n . '<select name="Time_Minute" id="minute">' . $n . $this->minutes['default'] . $n . '</select>' + . $n . '<select name="Time_Second" id="second">' . $n . $this->seconds['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' hour_id="hour" minute_id="minute" second_id="second"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testDisplay() + { + $n = "\n"; + $result = '<select name="Time_Hour">' . $n . $this->hours['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' display_minutes=false display_seconds=false}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + + $result = '<select name="Time_Minute">' . $n . $this->minutes['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' display_hours=false display_seconds=false}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + + $result = '<select name="Time_Second">' . $n . $this->seconds['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' display_hours=false display_minutes=false}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testMeridian1() + { + $n = "\n"; + $result = '<select name="Time_Hour">' . $n . $this->hours['12h'] . $n . '</select>' + . $n . '<select name="Time_Minute">' . $n . $this->minutes['default'] . $n . '</select>' + . $n . '<select name="Time_Second">' . $n . $this->seconds['default'] . $n . '</select>' + . $n . '<select name="Time_Meridian">' . $n . $this->meridians['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' use_24_hours=false}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + public function testMeridian2() + { + $n = "\n"; + $result = '<select name="Time_Hour">' . $n . $this->hours['12h'] . $n . '</select>' + . $n . '<select name="Time_Minute">' . $n . $this->minutes['default'] . $n . '</select>' + . $n . '<select name="Time_Second">' . $n . $this->seconds['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' use_24_hours=false display_meridian=false}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + public function testMeridian3() + { + $n = "\n"; + $time = mktime(0, 15, 11, 2, 20, 2011); + $result = '<select name="Time_Hour">' . $n . '<option value="01">01</option> +<option value="02">02</option> +<option value="03">03</option> +<option value="04">04</option> +<option value="05">05</option> +<option value="06">06</option> +<option value="07">07</option> +<option value="08">08</option> +<option value="09">09</option> +<option value="10">10</option> +<option value="11">11</option> +<option value="12" selected="selected">12</option> +</select> +<select name="Time_Meridian"> +<option value="am">AM</option> +<option value="pm">PM</option> +</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $time . ' use_24_hours=false display_minutes=false display_seconds=false}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + public function testMeridian4() + { + $n = "\n"; + + $time = mktime(4, 15, 11, 2, 20, 2011); + $result = '<select name="Time_Hour">' . $n . '<option value="01">01</option> +<option value="02">02</option> +<option value="03">03</option> +<option value="04" selected="selected">04</option> +<option value="05">05</option> +<option value="06">06</option> +<option value="07">07</option> +<option value="08">08</option> +<option value="09">09</option> +<option value="10">10</option> +<option value="11">11</option> +<option value="12">12</option> +</select> +<select name="Time_Meridian"> +<option value="am" selected="selected">AM</option> +<option value="pm">PM</option> +</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $time . ' use_24_hours=false display_minutes=false display_seconds=false}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + public function testMeridian5() + { + $n = "\n"; + + $time = mktime(12, 15, 11, 2, 20, 2011); + $result = '<select name="Time_Hour">' . $n . '<option value="01">01</option> +<option value="02">02</option> +<option value="03">03</option> +<option value="04">04</option> +<option value="05">05</option> +<option value="06">06</option> +<option value="07">07</option> +<option value="08">08</option> +<option value="09">09</option> +<option value="10">10</option> +<option value="11">11</option> +<option value="12" selected="selected">12</option> +</select> +<select name="Time_Meridian"> +<option value="am">AM</option> +<option value="pm" selected="selected">PM</option> +</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $time . ' use_24_hours=false display_minutes=false display_seconds=false}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + public function testMeridian6() + { + $n = "\n"; + + $time = mktime(16, 15, 11, 2, 20, 2011); + $result = '<select name="Time_Hour">' . $n . '<option value="01">01</option> +<option value="02">02</option> +<option value="03">03</option> +<option value="04" selected="selected">04</option> +<option value="05">05</option> +<option value="06">06</option> +<option value="07">07</option> +<option value="08">08</option> +<option value="09">09</option> +<option value="10">10</option> +<option value="11">11</option> +<option value="12">12</option> +</select> +<select name="Time_Meridian"> +<option value="am">AM</option> +<option value="pm" selected="selected">PM</option> +</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $time . ' use_24_hours=false display_minutes=false display_seconds=false}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testMinuteInterval1() + { + $n = "\n"; + $result = '<select name="Time_Hour">' . $n . $this->hours['default'] . $n . '</select>' + . $n . '<select name="Time_Minute">' . $n . $this->minutes['30'] . $n . '</select>' + . $n . '<select name="Time_Second">' . $n . $this->seconds['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' minute_interval=30}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + public function testMinuteInterval2() + { + $n = "\n"; + + $result = '<select name="Time_Hour">' . $n . $this->hours['default'] . $n . '</select>' + . $n . '<select name="Time_Minute">' . $n . $this->minutes['15'] . $n . '</select>' + . $n . '<select name="Time_Second">' . $n . $this->seconds['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' minute_interval=15}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + public function testMinuteInterval3() + { + $n = "\n"; + + $result = '<select name="Time_Hour">' . $n . $this->hours['default'] . $n . '</select>' + . $n . '<select name="Time_Minute">' . $n . $this->minutes['10'] . $n . '</select>' + . $n . '<select name="Time_Second">' . $n . $this->seconds['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' minute_interval=10}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + public function testMinuteInterval4() + { + $n = "\n"; + + $result = '<select name="Time_Hour">' . $n . $this->hours['default'] . $n . '</select>' + . $n . '<select name="Time_Minute">' . $n . $this->minutes['5'] . $n . '</select>' + . $n . '<select name="Time_Second">' . $n . $this->seconds['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' minute_interval=5}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testSecondInterval1() + { + $n = "\n"; + $result = '<select name="Time_Hour">' . $n . $this->hours['default'] . $n . '</select>' + . $n . '<select name="Time_Minute">' . $n . $this->minutes['default'] . $n . '</select>' + . $n . '<select name="Time_Second">' . $n . $this->seconds['30'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' second_interval=30}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + public function testSecondInterval2() + { + $n = "\n"; + + $result = '<select name="Time_Hour">' . $n . $this->hours['default'] . $n . '</select>' + . $n . '<select name="Time_Minute">' . $n . $this->minutes['default'] . $n . '</select>' + . $n . '<select name="Time_Second">' . $n . $this->seconds['15'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' second_interval=15}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + public function testSecondInterval3() + { + $n = "\n"; + + $result = '<select name="Time_Hour">' . $n . $this->hours['default'] . $n . '</select>' + . $n . '<select name="Time_Minute">' . $n . $this->minutes['default'] . $n . '</select>' + . $n . '<select name="Time_Second">' . $n . $this->seconds['10'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' second_interval=10}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + public function testSecondInterval4() + { + $n = "\n"; + + $result = '<select name="Time_Hour">' . $n . $this->hours['default'] . $n . '</select>' + . $n . '<select name="Time_Minute">' . $n . $this->minutes['default'] . $n . '</select>' + . $n . '<select name="Time_Second">' . $n . $this->seconds['5'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' second_interval=5}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testFormat1() + { + $n = "\n"; + $result = '<select name="Time_Hour">' . $n . $this->hours['format_%03d'] . $n . '</select>' + . $n . '<select name="Time_Minute">' . $n . $this->minutes['default'] . $n . '</select>' + . $n . '<select name="Time_Second">' . $n . $this->seconds['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' hour_format="%03d"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + public function testFormat2() + { + $n = "\n"; + + $result = '<select name="Time_Hour">' . $n . $this->hours['default'] . $n . '</select>' + . $n . '<select name="Time_Minute">' . $n . $this->minutes['format_%03d'] . $n . '</select>' + . $n . '<select name="Time_Second">' . $n . $this->seconds['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' minute_format="%03d"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + public function testFormat3() + { + $n = "\n"; + + $result = '<select name="Time_Hour">' . $n . $this->hours['default'] . $n . '</select>' + . $n . '<select name="Time_Minute">' . $n . $this->minutes['default'] . $n . '</select>' + . $n . '<select name="Time_Second">' . $n . $this->seconds['format_%03d'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' second_format="%03d"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testValueFormat1() + { + $n = "\n"; + $result = '<select name="Time_Hour">' . $n . $this->hours['format_value_%03d'] . $n . '</select>' + . $n . '<select name="Time_Minute">' . $n . $this->minutes['default'] . $n . '</select>' + . $n . '<select name="Time_Second">' . $n . $this->seconds['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' hour_value_format="%03d"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + public function testValueFormat2() + { + $n = "\n"; + + $result = '<select name="Time_Hour">' . $n . $this->hours['default'] . $n . '</select>' + . $n . '<select name="Time_Minute">' . $n . $this->minutes['format_value_%03d'] . $n . '</select>' + . $n . '<select name="Time_Second">' . $n . $this->seconds['default'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' minute_value_format="%03d"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + public function testValueFormat3() + { + $n = "\n"; + + $result = '<select name="Time_Hour">' . $n . $this->hours['default'] . $n . '</select>' + . $n . '<select name="Time_Minute">' . $n . $this->minutes['default'] . $n . '</select>' + . $n . '<select name="Time_Second">' . $n . $this->seconds['format_value_%03d'] . $n . '</select>'; + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=' . $this->now . ' second_value_format="%03d"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testTimeArray1() + { + $n = "\n"; + $time_array = array( + 'namorized' => array( + 'foobar_Hour' => '16', + 'foobar_Minute' => '15', + 'foobar_Second' => '11', + ), + ); + $result = '<select name="namorized[foobar_Hour]">' . $n . $this->hours['default'] . $n . '</select>' + . $n . '<select name="namorized[foobar_Minute]">' . $n . $this->minutes['default'] . $n . '</select>' + . $n . '<select name="namorized[foobar_Second]">' . $n . $this->seconds['default'] . $n . '</select>'; + + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=$time_array.namorized field_array="namorized" prefix="foobar_"}'); + $tpl->assign('time_array', $time_array); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + public function testTimeArray2() + { + $n = "\n"; + $time_array = array( + 'namorized' => array( + 'foobar_Hour' => '16', + 'foobar_Minute' => '15', + 'foobar_Second' => '11', + ), + ); + $result = '<select name="namorized[foobar_Hour]">' . $n . $this->hours['default'] . $n . '</select>' + . $n . '<select name="namorized[foobar_Minute]">' . $n . $this->minutes['default'] . $n . '</select>' + . $n . '<select name="namorized[foobar_Second]">' . $n . $this->seconds['default'] . $n . '</select>'; + + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=$time_array field_array="namorized" prefix="foobar_"}'); + $tpl->assign('time_array', $time_array); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testTimeArrayMerdidian() + { + $n = "\n"; + $result = '<select name="namorized[foobar_Hour]">' . $n . $this->hours['12h'] . $n . '</select>' + . $n . '<select name="namorized[foobar_Minute]">' . $n . $this->minutes['default'] . $n . '</select>' + . $n . '<select name="namorized[foobar_Second]">' . $n . $this->seconds['default'] . $n . '</select>' + . $n . '<select name="namorized[foobar_Meridian]">' . $n . $this->meridians['default'] . $n . '</select>'; + + $time_array = array( + 'namorized' => array( + 'foobar_Hour' => '04', + 'foobar_Minute' => '15', + 'foobar_Second' => '11', + 'foobar_Meridian' => 'pm', + ), + ); + + $tpl = $this->smarty->createTemplate('eval:{html_select_time time=$time_array use_24_hours=false field_array="namorized" prefix="foobar_"}'); + $tpl->assign('time_array', $time_array); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionMailtoTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionMailtoTest.php new file mode 100644 index 00000000..2ea16ce5 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionMailtoTest.php @@ -0,0 +1,166 @@ +<?php +/** + * Smarty PHPunit tests of modifier + * + * @package PHPunit + * @author Rodney Rehm + */ + +/** + * class for modifier tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class PluginFunctionMailtoTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + public function testDefault() + { + $result = '<a href="mailto:me@example.com" >me@example.com</a>'; + $tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testDefaultWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $result = '<a href="mailto:me@example.com" >me@example.com</a>'; + $tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testText() + { + $result = '<a href="mailto:me@example.com" >send me some mail</a>'; + $tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" text="send me some mail"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testTextWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $result = '<a href="mailto:me@example.com" >send me some mail</a>'; + $tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" text="send me some mail"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testEncodeJavascript() + { + $result = '<script type="text/javascript">eval(unescape(\'%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%27%3c%61%20%68%72%65%66%3d%22%6d%61%69%6c%74%6f%3a%6d%65%40%65%78%61%6d%70%6c%65%2e%63%6f%6d%22%20%3e%6d%65%40%65%78%61%6d%70%6c%65%2e%63%6f%6d%3c%2f%61%3e%27%29%3b\'))</script>'; + $tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" encode="javascript"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testEncodeJavascriptWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $result = '<script type="text/javascript">eval(unescape(\'%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%27%3c%61%20%68%72%65%66%3d%22%6d%61%69%6c%74%6f%3a%6d%65%40%65%78%61%6d%70%6c%65%2e%63%6f%6d%22%20%3e%6d%65%40%65%78%61%6d%70%6c%65%2e%63%6f%6d%3c%2f%61%3e%27%29%3b\'))</script>'; + $tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" encode="javascript"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testEncodeJavascriptCharcode() + { + $result = "<script type=\"text/javascript\" language=\"javascript\">\n{document.write(String.fromCharCode(60,97,32,104,114,101,102,61,34,109,97,105,108,116,111,58,109,101,64,101,120,97,109,112,108,101,46,99,111,109,34,32,62,109,101,64,101,120,97,109,112,108,101,46,99,111,109,60,47,97,62))}\n</script>\n"; + $tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" encode="javascript_charcode"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testEncodeJavascriptCharcodeWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $result = "<script type=\"text/javascript\" language=\"javascript\">\n{document.write(String.fromCharCode(60,97,32,104,114,101,102,61,34,109,97,105,108,116,111,58,109,101,64,101,120,97,109,112,108,101,46,99,111,109,34,32,62,109,101,64,101,120,97,109,112,108,101,46,99,111,109,60,47,97,62))}\n</script>\n"; + $tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" encode="javascript_charcode"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testEncodeHex() + { + $result = '<a href="mailto:%6d%65@%65%78%61%6d%70%6c%65.%63%6f%6d" >me@example.com</a>'; + $tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" encode="hex"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testEncodeHexWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $result = '<a href="mailto:%6d%65@%65%78%61%6d%70%6c%65.%63%6f%6d" >me@example.com</a>'; + $tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" encode="hex"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testSubject() + { + $result = '<a href="mailto:me@example.com?subject=Hello%20to%20you%21" >me@example.com</a>'; + $tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" subject="Hello to you!"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testSubjectWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $result = '<a href="mailto:me@example.com?subject=Hello%20to%20you%21" >me@example.com</a>'; + $tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" subject="Hello to you!"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testCc() + { + $result = '<a href="mailto:me@example.com?cc=you@example.com,they@example.com" >me@example.com</a>'; + $tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" cc="you@example.com,they@example.com"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testCcWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $result = '<a href="mailto:me@example.com?cc=you@example.com,they@example.com" >me@example.com</a>'; + $tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" cc="you@example.com,they@example.com"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testExtra() + { + $result = '<a href="mailto:me@example.com" class="email">me@example.com</a>'; + $tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" extra=\'class="email"\'}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testExtraWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $result = '<a href="mailto:me@example.com" class="email">me@example.com</a>'; + $tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" extra=\'class="email"\'}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testUmlauts() + { + $result = '<a href="mailto:me+smtpext@example.com?cc=you@example.com,they@example.com&subject=h%C3%A4llo%20w%C3%B6rld" >me+smtpext@example.com</a>'; + $tpl = $this->smarty->createTemplate('eval:{mailto address="me+smtpext@example.com" cc="you@example.com,they@example.com" subject="hällo wörld"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testUmlautsWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $result = '<a href="mailto:me+smtpext@example.com?cc=you@example.com,they@example.com&subject=h%C3%A4llo%20w%C3%B6rld" >me+smtpext@example.com</a>'; + $tpl = $this->smarty->createTemplate('eval:{mailto address="me+smtpext@example.com" cc="you@example.com,they@example.com" subject="hällo wörld"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/helpers/_object_tostring.php b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/helpers/_object_tostring.php new file mode 100644 index 00000000..4cb55e7f --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/helpers/_object_tostring.php @@ -0,0 +1,26 @@ +<?php + +class _object_toString +{ + protected $string = null; + + public function __construct($string) + { + $this->string = (string) $string; + } + + public function __toString() + { + return $this->string; + } +} + +class _object_noString +{ + protected $string = null; + + public function __construct($string) + { + $this->string = (string) $string; + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCapitalizeTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCapitalizeTest.php new file mode 100644 index 00000000..a78dce31 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCapitalizeTest.php @@ -0,0 +1,153 @@ +<?php +/** + * Smarty PHPunit tests of modifier + * + * @package PHPunit + * @author Rodney Rehm + */ + +/** + * class for modifier tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class PluginModifierCapitalizeTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + public function testDefault() + { + $tpl = $this->smarty->createTemplate('string:{"next x-men fiLm, x3, delayed. ümlauts äre cööl."|capitalize}'); + $this->assertEquals("Next X-Men FiLm, x3, Delayed. Ümlauts Äre Cööl.", $this->smarty->fetch($tpl)); + } + + public function testDigits() + { + $tpl = + $this->smarty->createTemplate('string:{"next x-men fiLm, x3, delayed. ümlauts äre cööl."|capitalize:true}'); + $this->assertEquals("Next X-Men FiLm, X3, Delayed. Ümlauts Äre Cööl.", $this->smarty->fetch($tpl)); + } + + public function testTrueCaptials() + { + $tpl = + $this->smarty->createTemplate('string:{"next x-men fiLm, x3, delayed. ümlauts äre cööl."|capitalize:true:true}'); + $this->assertEquals("Next X-Men Film, X3, Delayed. Ümlauts Äre Cööl.", $this->smarty->fetch($tpl)); + } + + public function testDefaultWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"next x-men fiLm, x3, delayed."|capitalize}'); + $this->assertEquals("Next X-Men FiLm, x3, Delayed.", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testDigitsWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"next x-men fiLm, x3, delayed."|capitalize:true}'); + $this->assertEquals("Next X-Men FiLm, X3, Delayed.", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testTrueCaptialsWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"next x-men fiLm, x3, delayed."|capitalize:true:true}'); + $this->assertEquals("Next X-Men Film, X3, Delayed.", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testQuotes() + { + $tpl = $this->smarty->createTemplate('string:{"next x-men fiLm, x3, \"delayed. umlauts\" foo."|capitalize}'); + $this->assertEquals("Next X-Men FiLm, x3, \"Delayed. Umlauts\" Foo.", $this->smarty->fetch($tpl)); + $tpl = $this->smarty->createTemplate('string:{"next x-men fiLm, x3, \'delayed. umlauts\' foo."|capitalize}'); + $this->assertEquals("Next X-Men FiLm, x3, 'Delayed. Umlauts' Foo.", $this->smarty->fetch($tpl)); + } + + public function testQuotesWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"next x-men fiLm, x3, \"delayed. umlauts\" foo."|capitalize}'); + $this->assertEquals("Next X-Men FiLm, x3, \"Delayed. Umlauts\" Foo.", $this->smarty->fetch($tpl)); + $tpl = $this->smarty->createTemplate('string:{"next x-men fiLm, x3, \'delayed. umlauts\' foo."|capitalize}'); + $this->assertEquals("Next X-Men FiLm, x3, 'Delayed. Umlauts' Foo.", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testQuotesDigits() + { + $tpl = + $this->smarty->createTemplate('string:{"next x-men fiLm, x3, \"delayed. umlauts\" foo."|capitalize:true}'); + $this->assertEquals("Next X-Men FiLm, X3, \"Delayed. Umlauts\" Foo.", $this->smarty->fetch($tpl)); + $tpl = + $this->smarty->createTemplate('string:{"next x-men fiLm, x3, \'delayed. umlauts\' foo."|capitalize:true}'); + $this->assertEquals("Next X-Men FiLm, X3, 'Delayed. Umlauts' Foo.", $this->smarty->fetch($tpl)); + } + + public function testQuotesDigitsWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $this->smarty->setCompileId('mb'); + $tpl = + $this->smarty->createTemplate('string:{"next x-men fiLm, x3, \"delayed. umlauts\" foo."|capitalize:true}'); + $this->assertEquals("Next X-Men FiLm, X3, \"Delayed. Umlauts\" Foo.", $this->smarty->fetch($tpl)); + $tpl = + $this->smarty->createTemplate('string:{"next x-men fiLm, x3, \'delayed. umlauts\' foo."|capitalize:true}'); + $this->assertEquals("Next X-Men FiLm, X3, 'Delayed. Umlauts' Foo.", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testQuotesTrueCapitals() + { + $tpl = + $this->smarty->createTemplate('string:{"next x-men fiLm, x3, \"delayed. umlauts\" foo."|capitalize:true:true}'); + $this->assertEquals("Next X-Men Film, X3, \"Delayed. Umlauts\" Foo.", $this->smarty->fetch($tpl)); + $tpl = + $this->smarty->createTemplate('string:{"next x-men fiLm, x3, \'delayed. umlauts\' foo."|capitalize:true:true}'); + $this->assertEquals("Next X-Men Film, X3, 'Delayed. Umlauts' Foo.", $this->smarty->fetch($tpl)); + } + + public function testQuotesTrueCapitalsWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $this->smarty->setCompileId('mb'); + $tpl = + $this->smarty->createTemplate('string:{"next x-men fiLm, x3, \"delayed. umlauts\" foo."|capitalize:true:true}'); + $this->assertEquals("Next X-Men Film, X3, \"Delayed. Umlauts\" Foo.", $this->smarty->fetch($tpl)); + $tpl = + $this->smarty->createTemplate('string:{"next x-men fiLm, x3, \'delayed. umlauts\' foo."|capitalize:true:true}'); + $this->assertEquals("Next X-Men Film, X3, 'Delayed. Umlauts' Foo.", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testQuotesBeginning() + { + $tpl = $this->smarty->createTemplate('string:{"\"delayed. umlauts\" foo."|capitalize}'); + $this->assertEquals("\"Delayed. Umlauts\" Foo.", $this->smarty->fetch($tpl)); + $tpl = $this->smarty->createTemplate('string:{"\'delayed. umlauts\' foo."|capitalize}'); + $this->assertEquals("'Delayed. Umlauts' Foo.", $this->smarty->fetch($tpl)); + } + + public function testQuotesBeginningWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"\"delayed. umlauts\" foo."|capitalize}'); + $this->assertEquals("\"Delayed. Umlauts\" Foo.", $this->smarty->fetch($tpl)); + $tpl = $this->smarty->createTemplate('string:{"\'delayed. umlauts\' foo."|capitalize}'); + $this->assertEquals("'Delayed. Umlauts' Foo.", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCharsetTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCharsetTest.php new file mode 100644 index 00000000..87fd673f --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCharsetTest.php @@ -0,0 +1,98 @@ +<?php +/** + * Smarty PHPunit tests of modifier + * + * @package PHPunit + * @author Rodney Rehm + */ + +/** + * class for modifier tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class PluginModifierCharsetTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + public function testToLatin1() + { + $encoded = "hällö wörld 1"; + $result = utf8_decode($encoded); + $tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|to_charset}'); + $this->assertEquals(str_replace("\r", '', $result), $tpl->fetch()); + } + + public function testToLatin1WithoutMbstring() + { + Smarty::$_MBSTRING = false; + $this->smarty->setCompileId('mb'); + $encoded = "hällö wörld 2"; + $result = utf8_decode($encoded); + $tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|to_charset}'); + $this->assertEquals($encoded, $tpl->fetch()); + Smarty::$_MBSTRING = true; + } + + public function testFromLatin1() + { + $result = "hällö wörld 3"; + $encoded = utf8_decode($result); + $tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|from_charset}'); + $this->assertEquals(str_replace("\r", '', $result), $tpl->fetch()); + } + + public function testFromLatin1WithoutMbstring() + { + Smarty::$_MBSTRING = false; + $this->smarty->setCompileId('mb'); + $result = "hällö wörld 4"; + $encoded = utf8_decode($result); + $tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|from_charset}'); + $this->assertEquals($encoded, $tpl->fetch()); + Smarty::$_MBSTRING = true; + } + + public function testFromUtf32le() + { + $result = "hällö wörld 5"; + $encoded = mb_convert_encoding($result, "UTF-32LE", "UTF-8"); + $tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|from_charset:"UTF-32LE"}'); + $this->assertEquals(str_replace("\r", '', $result), $tpl->fetch()); + } + + public function testFromUtf32leWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $this->smarty->setCompileId('mb'); + $result = "hällö wörld 6"; + $encoded = mb_convert_encoding($result, "UTF-32LE", "UTF-8"); + $tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|from_charset:"UTF-32LE"}'); + $this->assertEquals($encoded, $tpl->fetch()); + Smarty::$_MBSTRING = true; + } + + public function testToUtf32le() + { + $encoded = "hällö wörld 7"; + $result = mb_convert_encoding($encoded, "UTF-32LE", "UTF-8"); + $tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|to_charset:"UTF-32LE"}'); + $this->assertEquals(str_replace("\r", '', $result), $tpl->fetch()); + } + + public function testToUtf32leWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $this->smarty->setCompileId('mb'); + $encoded = "hällö wörld 8"; + $result = mb_convert_encoding($encoded, "UTF-32LE", "UTF-8"); + $tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|to_charset:"UTF-32LE"}'); + $this->assertEquals($encoded, $tpl->fetch()); + Smarty::$_MBSTRING = true; + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountCharactersTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountCharactersTest.php new file mode 100644 index 00000000..b2026cc8 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountCharactersTest.php @@ -0,0 +1,90 @@ +<?php +/** + * Smarty PHPunit tests of modifier + * + * @package PHPunit + * @author Rodney Rehm + */ + +/** + * class for modifier tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class PluginModifierCountCharactersTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + public function testDefault() + { + $result = "29"; + $tpl = $this->smarty->createTemplate('string:{"Cold Wave Linked to Temperatures."|count_characters}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testDefaultWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $this->smarty->setCompileId ('mb'); + $result = "29"; + $tpl = $this->smarty->createTemplate('string:{"Cold Wave Linked to Temperatures."|count_characters}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testSpaces() + { + $result = "33"; + $tpl = $this->smarty->createTemplate('string:{"Cold Wave Linked to Temperatures."|count_characters:true}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testSpacesWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $this->smarty->setCompileId ('mb'); + $result = "33"; + $tpl = $this->smarty->createTemplate('string:{"Cold Wave Linked to Temperatures."|count_characters:true}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testUmlauts() + { + $result = "29"; + $tpl = $this->smarty->createTemplate('string:{"Cold Wäve Linked tö Temperatures."|count_characters}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testUmlautsWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $this->smarty->setCompileId ('mb'); + $result = "29"; + $tpl = $this->smarty->createTemplate('string:{"Cold Wäve Linked tö Temperatures."|count_characters}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testUmlautsSpaces() + { + $result = "33"; + $tpl = $this->smarty->createTemplate('string:{"Cold Wäve Linked tö Temperatures."|count_characters:true}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testUmlautsSpacesWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $this->smarty->setCompileId ('mb'); + $result = "33"; + $tpl = $this->smarty->createTemplate('string:{"Cold Wäve Linked tö Temperatures."|count_characters:true}'); + $this->assertNotEquals($result, $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountSentencesTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountSentencesTest.php new file mode 100644 index 00000000..acca87cb --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountSentencesTest.php @@ -0,0 +1,63 @@ +<?php +/** + * Smarty PHPunit tests of modifier + * + * @package PHPunit + * @author Rodney Rehm + */ + +/** + * class for modifier tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class PluginModifierCountSentencesTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + + public function testDefault() + { + $tpl = $this->smarty->createTemplate('string:{"hello world."|count_sentences}'); + $this->assertEquals("1", $this->smarty->fetch($tpl)); + $tpl = $this->smarty->createTemplate('string:{"hello world. I\'m another? Sentence!"|count_sentences}'); + $this->assertEquals("3", $this->smarty->fetch($tpl)); + $tpl = $this->smarty->createTemplate('string:{"hello world.wrong"|count_sentences}'); + $this->assertEquals("0", $this->smarty->fetch($tpl)); + } + + public function testDefaultWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"hello world."|count_sentences}'); + $this->assertEquals("1", $this->smarty->fetch($tpl)); + $tpl = $this->smarty->createTemplate('string:{"hello world. I\'m another? Sentence!"|count_sentences}'); + $this->assertEquals("3", $this->smarty->fetch($tpl)); + $tpl = $this->smarty->createTemplate('string:{"hello world.wrong"|count_sentences}'); + $this->assertEquals("0", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testUmlauts() + { + $tpl = $this->smarty->createTemplate('string:{"hello worldä."|count_sentences}'); + $this->assertEquals("1", $this->smarty->fetch($tpl)); + $tpl = $this->smarty->createTemplate('string:{"hello worldü. ä\'m another? Sentence!"|count_sentences}'); + $this->assertEquals("3", $this->smarty->fetch($tpl)); + $tpl = $this->smarty->createTemplate('string:{"hello worlä.ärong"|count_sentences}'); + $this->assertEquals("0", $this->smarty->fetch($tpl)); + $tpl = $this->smarty->createTemplate('string:{"hello worlä.wrong"|count_sentences}'); + $this->assertEquals("0", $this->smarty->fetch($tpl)); + $tpl = $this->smarty->createTemplate('string:{"hello world.ärong"|count_sentences}'); + $this->assertEquals("0", $this->smarty->fetch($tpl)); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountWordsTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountWordsTest.php new file mode 100644 index 00000000..2da98e1b --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountWordsTest.php @@ -0,0 +1,70 @@ +<?php +/** + * Smarty PHPunit tests of modifier + * + * @package PHPunit + * @author Rodney Rehm + */ + +/** + * class for modifier tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class PluginModifierCountWordsTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + public function testDefault() + { + $result = "7"; + $tpl = $this->smarty->createTemplate('string:{"Dealers Will Hear Car Talk at Noon."|count_words}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testDefaultWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $result = "7"; + $tpl = $this->smarty->createTemplate('string:{"Dealers Will Hear Car Talk at Noon."|count_words}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testDashes() + { + $result = "7"; + $tpl = $this->smarty->createTemplate('string:{"Smalltime-Dealers Will Hear Car Talk at Noon."|count_words}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testDashesWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $result = "7"; + $tpl = $this->smarty->createTemplate('string:{"Smalltime-Dealers Will Hear Car Talk at Noon."|count_words}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testUmlauts() + { + $result = "7"; + $tpl = $this->smarty->createTemplate('string:{"Dealers Will Hear Cär Talk at Nöön."|count_words}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testUmlautsWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $result = "7"; + $tpl = $this->smarty->createTemplate('string:{"Dealers Will Hear Cär Talk at Nöön."|count_words}'); + $this->assertNotEquals($result, $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierEscapeTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierEscapeTest.php new file mode 100644 index 00000000..afabe71a --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierEscapeTest.php @@ -0,0 +1,210 @@ +<?php +/** + * Smarty PHPunit tests of modifier + * + * @package PHPunit + * @author Rodney Rehm + */ + +/** + * class for modifier tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class PluginModifierEscapeTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + public function testHtml() + { + $tpl = $this->smarty->createTemplate('string:{"I\'m some <html> to ä be \"escaped\" or ©"|escape:"html"}'); + $this->assertEquals("I'm some <html> to ä be "escaped" or &copy;", $this->smarty->fetch($tpl)); + } + + public function testHtmlWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"I\'m some <html> to ä be \"escaped\" or ©"|escape:"html"}'); + $this->assertEquals("I'm some <html> to ä be "escaped" or &copy;", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testHtmlDouble() + { + $tpl = $this->smarty->createTemplate('string:{"I\'m some <html> to ä be \"escaped\" or ©"|escape:"html":null:false}'); + $this->assertEquals("I'm some <html> to ä be "escaped" or ©", $this->smarty->fetch($tpl)); + } + + public function testHtmlDoubleWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"I\'m some <html> to ä be \"escaped\" or ©"|escape:"html":null:false}'); + $this->assertEquals("I'm some <html> to ä be "escaped" or ©", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testHtmlall() + { + $tpl = $this->smarty->createTemplate('string:{"I\'m some <html> to ä be \"escaped\" or ©"|escape:"htmlall"}'); + $this->assertEquals("I'm some <html> to ä be "escaped" or &copy;", $this->smarty->fetch($tpl)); + } + + public function testHtmlallWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"I\'m some <html> to ä be \"escaped\" or ©"|escape:"htmlall"}'); + $this->assertEquals("I'm some <html> to ä be "escaped" or &copy;", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testHtmlallDouble() + { + $tpl = $this->smarty->createTemplate('string:{"I\'m some <html> to ä be \"escaped\" or ©"|escape:"htmlall":null:false}'); + $this->assertEquals("I'm some <html> to ä be "escaped" or ©", $this->smarty->fetch($tpl)); + } + + public function testHtmlallDoubleWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"I\'m some <html> to ä be \"escaped\" or ©"|escape:"htmlall":null:false}'); + $this->assertEquals("I'm some <html> to ä be "escaped" or ©", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testUrl() + { + $tpl = $this->smarty->createTemplate('string:{"http://some.encoded.com/url?parts#foo"|escape:"url"}'); + $this->assertEquals("http%3A%2F%2Fsome.encoded.com%2Furl%3Fparts%23foo", $this->smarty->fetch($tpl)); + } + + public function testUrlWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"http://some.encoded.com/url?parts#foo"|escape:"url"}'); + $this->assertEquals("http%3A%2F%2Fsome.encoded.com%2Furl%3Fparts%23foo", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testUrlpathinfo() + { + $tpl = $this->smarty->createTemplate('string:{"http://some.encoded.com/url?parts#foo"|escape:"urlpathinfo"}'); + $this->assertEquals("http%3A//some.encoded.com/url%3Fparts%23foo", $this->smarty->fetch($tpl)); + } + + public function testUrlpathinfoWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"http://some.encoded.com/url?parts#foo"|escape:"urlpathinfo"}'); + $this->assertEquals("http%3A//some.encoded.com/url%3Fparts%23foo", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testHex() + { + $tpl = $this->smarty->createTemplate('string:{"a/cäa"|escape:"hex"}'); + $this->assertEquals("%61%2f%63%c3%a4%61", $this->smarty->fetch($tpl)); + } + + public function testHexWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"a/cäa"|escape:"hex"}'); + $this->assertEquals("%61%2f%63%c3%a4%61", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testHexentity() + { + $q = "aäЗдравсствуйте"; + $r = html_entity_decode($q, ENT_NOQUOTES, 'UTF-8'); + $tpl = $this->smarty->createTemplate('string:{"' . $r . '"|escape:"hexentity"}'); + $this->assertEquals("aäЗдравсствуйте", $this->smarty->fetch($tpl)); + + $tpl = $this->smarty->createTemplate('string:{"abc"|escape:"hexentity"}'); + $this->assertEquals("abc", $this->smarty->fetch($tpl)); + } + + public function testHexentityWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $q = "aäЗдравсствуйте"; + $r = html_entity_decode($q, ENT_NOQUOTES, 'UTF-8'); + $tpl = $this->smarty->createTemplate('string:{"' . $r . '"|escape:"hexentity"}'); + $this->assertNotEquals("aäЗдравсствуйте", $this->smarty->fetch($tpl)); + + $tpl = $this->smarty->createTemplate('string:{"abc"|escape:"hexentity"}'); + $this->assertEquals("abc", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testDecentity() + { + $q = "aäЗдравсствуйте"; + $r = html_entity_decode($q, ENT_NOQUOTES, 'UTF-8'); + $tpl = $this->smarty->createTemplate('string:{"' . $r . '"|escape:"decentity"}'); + $this->assertEquals("aäЗдравсствуйте", $this->smarty->fetch($tpl)); + + $tpl = $this->smarty->createTemplate('string:{"abc"|escape:"decentity"}'); + $this->assertEquals("abc", $this->smarty->fetch($tpl)); + } + + public function testDecentityWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $q = "aäЗдравсствуйте"; + $r = html_entity_decode($q, ENT_NOQUOTES, 'UTF-8'); + $tpl = $this->smarty->createTemplate('string:{"' . $r . '"|escape:"decentity"}'); + $this->assertNotEquals("aäЗдравсствуйте", $this->smarty->fetch($tpl)); + + $tpl = $this->smarty->createTemplate('string:{"abc"|escape:"decentity"}'); + $this->assertEquals("abc", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testJavascript() + { + $tpl = $this->smarty->createTemplate('string:{"var x = { foo : \"bar\n\" };"|escape:"javascript"}'); + $this->assertEquals("var x = { foo : \\\"bar\\n\\\" };", $this->smarty->fetch($tpl)); + } + + public function testJavascriptWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"var x = { foo : \"bar\n\" };"|escape:"javascript"}'); + $this->assertEquals("var x = { foo : \\\"bar\\n\\\" };", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testMail() + { + $tpl = $this->smarty->createTemplate('string:{"smarty@example.com"|escape:"mail"}'); + $this->assertEquals("smarty [AT] example [DOT] com", $this->smarty->fetch($tpl)); + } + + public function testMailWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"smarty@example.com"|escape:"mail"}'); + $this->assertEquals("smarty [AT] example [DOT] com", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testNonstd() + { + $tpl = $this->smarty->createTemplate('string:{"sma\'rty|»example«.com"|escape:"nonstd"}'); + $this->assertEquals("sma'rty|»example«.com", $this->smarty->fetch($tpl)); + } + + public function testNonstdWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"' . utf8_decode('sma\'rty@»example«.com') . '"|escape:"nonstd"}'); + $this->assertEquals("sma'rty@»example«.com", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierLowerTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierLowerTest.php new file mode 100644 index 00000000..e465c7b9 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierLowerTest.php @@ -0,0 +1,53 @@ +<?php +/** + * Smarty PHPunit tests of modifier + * + * @package PHPunit + * @author Rodney Rehm + */ + +/** + * class for modifier tests + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class PluginModifierLowerTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + public function testDefault() + { + $result = "two convicts evade noose, jury hung."; + $tpl = $this->smarty->createTemplate('string:{"Two Convicts Evade Noose, Jury Hung."|lower}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testDefaultWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $result = "two convicts evade noose, jury hung."; + $tpl = $this->smarty->createTemplate('string:{"Two Convicts Evade Noose, Jury Hung."|lower}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testUmlauts() + { + $result = "two convicts eväde nööse, jury hung."; + $tpl = $this->smarty->createTemplate('string:{"Two Convicts Eväde NöÖse, Jury Hung."|lower}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testUmlautsWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $result = "two convicts eväde nööse, jury hung."; + $tpl = $this->smarty->createTemplate('string:{"Two Convicts Eväde NöÖse, Jury Hung."|lower}'); + $this->assertNotEquals($result, $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierRegexReplaceTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierRegexReplaceTest.php new file mode 100644 index 00000000..88ce0982 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierRegexReplaceTest.php @@ -0,0 +1,45 @@ +<?php +/** + * Smarty PHPunit tests of modifier + * + * @package PHPunit + * @author Rodney Rehm + */ + +/** + * class for modifier tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled +*/ +class PluginModifierRegexReplaceTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + public function testDefault() + { + $tpl = $this->smarty->createTemplate('string:{"Infertility unlikely to\nbe passed on, experts say."|regex_replace:"/[\r\t\n]/":" "}'); + $this->assertEquals("Infertility unlikely to be passed on, experts say.", $this->smarty->fetch($tpl)); + } + + public function testDefaultWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"Infertility unlikely to\nbe passed on, experts say."|regex_replace:"/[\r\t\n]/":" "}'); + $this->assertEquals("Infertility unlikely to be passed on, experts say.", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testUmlauts() + { + $tpl = $this->smarty->createTemplate('string:{"Infertility unlikely tö\näe passed on, experts say."|regex_replace:"/[\r\t\n]/u":" "}'); + $this->assertEquals("Infertility unlikely tö äe passed on, experts say.", $this->smarty->fetch($tpl)); + + $tpl = $this->smarty->createTemplate('string:{"Infertility unlikely tä be passed on, experts say."|regex_replace:"/[ä]/ue":"ae"}'); + $this->assertEquals("Infertility unlikely tae be passed on, experts say.", $this->smarty->fetch($tpl)); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierSpacifyTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierSpacifyTest.php new file mode 100644 index 00000000..2ccd6cdb --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierSpacifyTest.php @@ -0,0 +1,36 @@ +<?php +/** + * Smarty PHPunit tests of modifier + * + * @package PHPunit + * @author Rodney Rehm + */ + +/** + * class for modifier tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class PluginModifierSpacifyTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + public function testDefault() + { + $result = 'h e l l o w ö r l d'; + $tpl = $this->smarty->createTemplate('string:{"hello wörld"|spacify}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testCharacter() + { + $result = 'h##e##l##l##o## ##w##ö##r##l##d'; + $tpl = $this->smarty->createTemplate('string:{"hello wörld"|spacify:"##"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierStripTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierStripTest.php new file mode 100644 index 00000000..9dc7bdf3 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierStripTest.php @@ -0,0 +1,44 @@ +<?php +/** + * Smarty PHPunit tests of modifier + * + * @package PHPunit + * @author Rodney Rehm + */ + +/** + * class for modifier tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class PluginModifierStripTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + public function testDefault() + { + $tpl = $this->smarty->createTemplate('string:{" hello spaced words "|strip}'); + $this->assertEquals(" hello spaced words ", $this->smarty->fetch($tpl)); + } + + public function testUnicodeSpaces() + { + // Some Unicode Spaces + $string = " hello spaced       words "; + $string = mb_convert_encoding($string, 'UTF-8', "HTML-ENTITIES"); + $tpl = $this->smarty->createTemplate('string:{"' . $string . '"|strip}'); + $this->assertEquals(" hello spaced words ", $this->smarty->fetch($tpl)); + } + + public function testLinebreak() + { + $tpl = $this->smarty->createTemplate('string:{" hello + spaced words "|strip}'); + $this->assertEquals(" hello spaced words ", $this->smarty->fetch($tpl)); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierTruncateTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierTruncateTest.php new file mode 100644 index 00000000..7af50af6 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierTruncateTest.php @@ -0,0 +1,134 @@ +<?php +/** + * Smarty PHPunit tests of modifier + * + * @package PHPunit + * @author Rodney Rehm + */ + +/** + * class for modifier tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class PluginModifierTruncateTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + public function testDefault() + { + $result = 'Two Sisters Reunite after Eighteen Years at Checkout Counter.'; + $tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testDefaultWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $result = 'Two Sisters Reunite after Eighteen Years at Checkout Counter.'; + $tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testLength() + { + $result = 'Two Sisters Reunite after...'; + $tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testLengthWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $result = 'Two Sisters Reunite after...'; + $tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testEtc() + { + $result = 'Two Sisters Reunite after'; + $tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:""}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testEtcWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $result = 'Two Sisters Reunite after'; + $tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:""}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testEtc2() + { + $result = 'Two Sisters Reunite after---'; + $tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:"---"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testEtc2WithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $result = 'Two Sisters Reunite after---'; + $tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:"---"}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testBreak() + { + $result = 'Two Sisters Reunite after Eigh'; + $tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:"":true}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testBreakWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $result = 'Two Sisters Reunite after Eigh'; + $tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:"":true}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testBreak2() + { + $result = 'Two Sisters Reunite after E...'; + $tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:"...":true}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testBreak2WithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $result = 'Two Sisters Reunite after E...'; + $tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:"...":true}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testMiddle() + { + $result = 'Two Sisters Re..ckout Counter.'; + $tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:"..":true:true}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testMiddleWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $result = 'Two Sisters Re..ckout Counter.'; + $tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:"..":true:true}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierUnescapeTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierUnescapeTest.php new file mode 100644 index 00000000..608eb5c4 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierUnescapeTest.php @@ -0,0 +1,68 @@ +<?php +/** + * Smarty PHPunit tests of modifier + * + * @package PHPunit + * @author Rodney Rehm + */ + +/** + * class for modifier tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class PluginModifierUnescapeTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + public function testHtml() + { + $encoded = "aäЗдра><&amp;ääвсствуйте"; + $result = "aäЗдра><&ääвсствуйте"; + $tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|unescape:"html"}'); + $this->assertEquals($result, $this->smarty->fetch($tpl)); + } + + public function testHtmlWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $encoded = "aäЗдра><&amp;ääвсствуйте"; + $result = "aäЗдра><&ääвсствуйте"; + $tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|unescape:"html"}'); + $this->assertEquals($result, $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testHtmlall() + { + $encoded = "aäЗдра><&amp;ääвсствуйте"; + $result = "aäЗдра><&ääвсствуйте"; + $tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|unescape:"htmlall"}'); + $this->assertEquals($result, $this->smarty->fetch($tpl)); + } + + public function testHtmlallWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $encoded = "aäЗдра><&amp;ääвсствуйте"; + $result = "aäЗдра><&ääвсствуйте"; + $tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|unescape:"htmlall"}'); + $this->assertEquals($result, $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testUrl() + { + $encoded = "a%C3%A4%D0%97%D0%B4%D1%80%D0%B0%3E%3C%26amp%3B%C3%A4%C3%A4%D0%B2%D1%81%D1%81%D1%82%D0%B2%3F%3D%2B%D1%83%D0%B9%D1%82%D0%B5"; + $result = "aäЗдра><&ääвсств?=+уйте"; + $tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|unescape:"url"}'); + $this->assertEquals($result, $this->smarty->fetch($tpl)); + } +} + +?>
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierUpperTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierUpperTest.php new file mode 100644 index 00000000..fb96fa5b --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierUpperTest.php @@ -0,0 +1,54 @@ +<?php +/** + * Smarty PHPunit tests of modifier + * + * @package PHPunit + * @author Rodney Rehm + */ + +/** + * class for modifier tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class PluginModifierUpperTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + public function testDefault() + { + $result = "IF STRIKE ISN'T SETTLED QUICKLY IT MAY LAST A WHILE."; + $tpl = $this->smarty->createTemplate('string:{"If Strike isn\'t Settled Quickly it may Last a While."|upper}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testDefaultWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $result = "IF STRIKE ISN'T SETTLED QUICKLY IT MAY LAST A WHILE."; + $tpl = $this->smarty->createTemplate('string:{"If Strike isn\'t Settled Quickly it may Last a While."|upper}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testUmlauts() + { + $result = "IF STRIKE ISN'T SÄTTLED ÜQUICKLY IT MAY LAST A WHILE."; + $tpl = $this->smarty->createTemplate('string:{"If Strike isn\'t Sättled ÜQuickly it may Last a While."|upper}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testUmlautsWithoutMbstring() + { + Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + $result = "IF STRIKE ISN'T SÄTTLED ÜQUICKLY IT MAY LAST A WHILE."; + $tpl = $this->smarty->createTemplate('string:{"If Strike isn\'t Sättled ÜQuickly it may Last a While."|upper}'); + $this->assertNotEquals($result, $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierWordwrapTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierWordwrapTest.php new file mode 100644 index 00000000..bd94590d --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierWordwrapTest.php @@ -0,0 +1,163 @@ +<?php +/** + * Smarty PHPunit tests of modifier + * + * @package PHPunit + * @author Rodney Rehm + */ + +/** + * class for modifier tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class PluginModifierWordwrapTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + public function testDefault() + { + $tpl = $this->smarty->createTemplate('string:{"Blind woman gets new kidney from dad she hasn\'t seen in years."|wordwrap}'); + $this->assertEquals("Blind woman gets new kidney from dad she hasn't seen in years.", $this->smarty->fetch($tpl)); + } + + public function testDefaultWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"Blind woman gets new kidney from dad she hasn\'t seen in years."|wordwrap}'); + $this->assertEquals("Blind woman gets new kidney from dad she hasn't seen in years.", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testDefaultUmlauts() + { + $tpl = $this->smarty->createTemplate('string:{"äöüßñ woman ñsä new kidney from dad she hasn\'t seen in years."|wordwrap:30}'); + $this->assertEquals("äöüßñ woman ñsä new kidney\nfrom dad she hasn't seen in\nyears.", $this->smarty->fetch($tpl)); + } + + public function testLength() + { + $tpl = $this->smarty->createTemplate('string:{"Blind woman gets new kidney from dad she hasn\'t seen in years."|wordwrap:30}'); + $this->assertEquals("Blind woman gets new kidney\nfrom dad she hasn't seen in\nyears.", $this->smarty->fetch($tpl)); + } + + public function testLengthWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"Blind woman gets new kidney from dad she hasn\'t seen in years."|wordwrap:30}'); + $this->assertEquals("Blind woman gets new kidney\nfrom dad she hasn't seen in\nyears.", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testBreak() + { + $tpl = $this->smarty->createTemplate('string:{"Blind woman gets new kidney from dad she hasn\'t seen in years."|wordwrap:30:"<br />\n"}'); + $this->assertEquals("Blind woman gets new kidney<br />\nfrom dad she hasn't seen in<br />\nyears.", $this->smarty->fetch($tpl)); + } + + public function testBreakWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"Blind woman gets new kidney from dad she hasn\'t seen in years."|wordwrap:30:"<br />\n"}'); + $this->assertEquals("Blind woman gets new kidney<br />\nfrom dad she hasn't seen in<br />\nyears.", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testLong() + { + $tpl = $this->smarty->createTemplate('string:{"Blind woman withaverylongandunpronoucablenameorso gets new kidney from dad she hasn\'t seen in years."|wordwrap:26:"\n"}'); + $this->assertEquals("Blind woman\nwithaverylongandunpronoucablenameorso\ngets new kidney from dad\nshe hasn't seen in years.", $this->smarty->fetch($tpl)); + } + + public function testLongWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"Blind woman withaverylongandunpronoucablenameorso gets new kidney from dad she hasn\'t seen in years."|wordwrap:26:"\n"}'); + $this->assertEquals("Blind woman\nwithaverylongandunpronoucablenameorso\ngets new kidney from dad\nshe hasn't seen in years.", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testLongUmlauts() + { + $tpl = $this->smarty->createTemplate('string:{"äöüßñ woman ñsääöüßñameorsoäöüßñäöüßñäöüßñäöüßñßñ gets new kidney from dad she hasn\'t seen in years."|wordwrap:26}'); + $this->assertEquals("äöüßñ woman\nñsääöüßñameorsoäöüßñäöüßñäöüßñäöüßñßñ\ngets new kidney from dad\nshe hasn't seen in years.", $this->smarty->fetch($tpl)); + } + + public function testLongCut() + { + $tpl = $this->smarty->createTemplate('string:{"Blind woman withaverylongandunpronoucablenameorso gets new kidney from dad she hasn\'t seen in years."|wordwrap:26:"\n":true}'); + $this->assertEquals("Blind woman\nwithaverylongandunpronouca\nblenameorso gets new\nkidney from dad she hasn't\nseen in years.", $this->smarty->fetch($tpl)); + } + + public function testLongCutWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"Blind woman withaverylongandunpronoucablenameorso gets new kidney from dad she hasn\'t seen in years."|wordwrap:26:"\n":true}'); + $this->assertEquals("Blind woman\nwithaverylongandunpronouca\nblenameorso gets new\nkidney from dad she hasn't\nseen in years.", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testLongCutUmlauts() + { + $tpl = $this->smarty->createTemplate('string:{"äöüßñ woman ñsääöüßñameorsoäöüßñäöüßñäöüßñäöüßñßñ gets new kidney from dad she hasn\'t seen in years."|wordwrap:26:"\n":true}'); + $this->assertEquals("äöüßñ woman\nñsääöüßñameorsoäöüßñäöüßñä\nöüßñäöüßñßñ gets new\nkidney from dad she hasn't\nseen in years.", $this->smarty->fetch($tpl)); + } + + public function testLinebreaks() + { + $tpl = $this->smarty->createTemplate('string:{"Blind woman\ngets new kidney from dad she hasn\'t seen in years."|wordwrap:30}'); + $this->assertEquals("Blind woman\ngets new kidney from dad she\nhasn't seen in years.", $this->smarty->fetch($tpl)); + } + + public function testLinebreaksWithoutMbstring() + { + Smarty::$_MBSTRING = false; + $this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"Blind woman\ngets new kidney from dad she hasn\'t seen in years."|wordwrap:30}'); + $this->assertEquals("Blind woman\ngets new kidney from dad she\nhasn't seen in years.", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + + public function testLinebreaks2() + { + $tpl = $this->smarty->createTemplate('string:{"Blind woman + gets + new kidney from dad she hasn\'t seen in years."|wordwrap:30}'); + $this->assertEquals("Blind woman + gets + new kidney from\ndad she hasn't seen in years.", $this->smarty->fetch($tpl)); + } + + public function testLinebreaks2WithoutMbstring() + { + Smarty::$_MBSTRING = false; + $this->smarty->setCompileId('mb'); + $tpl = $this->smarty->createTemplate('string:{"Blind woman + gets + new kidney from dad she hasn\'t seen in years."|wordwrap:30}'); + $this->assertEquals("Blind woman + gets + new kidney from\ndad she hasn't seen in years.", $this->smarty->fetch($tpl)); + Smarty::$_MBSTRING = true; + } + /* + public function testUnicodeSpaces() + { + // Some Unicode Spaces + $string = " hello spaced       words "; + $string = mb_convert_encoding($string, 'UTF-8', "HTML-ENTITIES"); + $tpl = $this->smarty->createTemplate('string:{"' . $string . '"|strip}'); + $this->assertEquals(" hello spaced words ", $this->smarty->fetch($tpl)); + } + */ +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Section/CompileSectionTest.php b/tests/UnitTests/TemplateSource/TagTests/Section/CompileSectionTest.php new file mode 100644 index 00000000..0cedbcfd --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Section/CompileSectionTest.php @@ -0,0 +1,151 @@ +<?php +/** + * Smarty PHPunit tests compilation of {section} tag + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for {section} tag tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class CompileSectionTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test {section} tag + */ + public function testSection_001() + { + $this->smarty->assign('foo', array(0,1,2,3,4,5,6,7,8,9)); + $this->assertEquals("0123456789", $this->smarty->fetch('001_section.tpl')); + } + + public function testSection_002() + { + $this->smarty->assign('foo', array(0,1,2,3,4,5,6,7,8,9)); + $this->assertEquals("0123456789", $this->smarty->fetch('002_section.tpl')); + } + + public function testSection_003() + { + $this->assertEquals("else", $this->smarty->fetch('003_section.tpl')); + } + + public function testSection_004() + { + $this->smarty->assign('foo', array(0,1,2,3,4,5,6,7,8,9)); + $this->assertEquals("0123456789", $this->smarty->fetch('004_section.tpl')); + } + + public function testSection_006() + { + $this->smarty->assign('foo', array(0,1,2,3,4,5,6,7,8,9)); + $this->assertEquals("0123456789total10", $this->smarty->fetch('006_section.tpl')); + } + + public function testSection_007() + { + $this->smarty->assign('foo', array(0,1,2,3,4,5,6,7,8,9)); + $this->assertEquals("011223344556677889910", $this->smarty->fetch('007_section.tpl')); + } + /** + * 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->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', array(1,2)); + $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("A{section name=bar loop=\$foo}{\$foo[bar]}{/section}C", "A12C", 'T1', $i++), + array("A{section name=bar loop=\$foo}\n{\$foo[bar]}{/section}C", "A12C", 'T2', $i++), + array("A{section name=bar loop=\$foo}{\$foo[bar]}\n{/section}C", "A1\n2\nC", 'T3', $i++), + array("A{section name=bar loop=\$foo}\n{\$foo[bar]}\n{/section}C", "A1\n2\nC", 'T4', $i++), + array("A\n{section name=bar loop=\$foo}{\$foo[bar]}{/section}C", "A\n12C", 'T5', $i++), + array("A{section name=bar loop=\$foo}{\$foo[bar]}{/section}\nC", "A12C", 'T6', $i++), + array("A{section name=bar loop=\$foo}{\$foo[bar]}{sectionelse}D{/section}C", "A12C", 'T7', $i++), + array("A{section name=bar loop=\$foo}{\$foo[bar]}\n{sectionelse}D{/section}C", "A1\n2\nC", 'T8', $i++), + array("{section loop=\$foo name='bar'}{\$foo[bar]}{/section}A{\$smarty.section.bar.total}C", "12A2C", 'T9', $i++), + array("{section loop=\$foo name='bar'}{\$foo[bar]}{/section}A\n{\$smarty.section.bar.total}C", "12A\n2C", 'T10', $i++), + array("{section loop=\$foo name='bar'}{\$foo[bar]}{/section}A{\$smarty.section.bar.total}\nC", "12A2\nC", 'T11', $i++), + ); + } + /** + * Test spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestElseSpacing + * @runInSeparateProcess + */ + public function testElseSpacing($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Spacing_Else_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', array()); + $this->smarty->assign('bar', 'bar'); + $this->assertEquals($result, + $this->smarty->fetch($file), + $file); + } + + /* + * Data provider für testSpacing + */ + public function dataTestElseSpacing() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array( + array("{section name=bar loop=\$foo}{\$foo[bar]}{sectionelse}A{\$bar}B{/section}", "AbarB", 'T1', $i++), + array("{section name=bar loop=\$foo}{\$foo[bar]}{sectionelse}\nA{\$bar}B{/section}", "AbarB", 'T2', $i++), + array("{section name=bar loop=\$foo}{\$foo[bar]}{sectionelse}A{\$bar}\nB{/section}", "Abar\nB", 'T3', $i++), + array("{section name=bar loop=\$foo}{\$foo[bar]}{sectionelse}\nA{\$bar}\nB{/section}", "Abar\nB", 'T4', $i++), + array("{section name=bar loop=\$foo}{\$foo[bar]}{sectionelse}{\$bar}\nB{/section}", "bar\nB", 'T5', $i++), + array("{section name=bar loop=\$foo}{\$foo[bar]}{sectionelse}{\$bar}{/section}", "bar", 'T6', $i++), + ); + } + +} diff --git a/tests/UnitTests/TemplateSource/TagTests/Section/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Section/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Section/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Section/templates/001_section.tpl b/tests/UnitTests/TemplateSource/TagTests/Section/templates/001_section.tpl new file mode 100644 index 00000000..50729b42 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Section/templates/001_section.tpl @@ -0,0 +1 @@ +{section name=bar loop=$foo}{$foo[bar]}{/section}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Section/templates/002_section.tpl b/tests/UnitTests/TemplateSource/TagTests/Section/templates/002_section.tpl new file mode 100644 index 00000000..be7d4559 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Section/templates/002_section.tpl @@ -0,0 +1 @@ +{section name=bar loop=$foo start=$i}{$foo[bar]}{sectionelse} else {/section}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Section/templates/003_section.tpl b/tests/UnitTests/TemplateSource/TagTests/Section/templates/003_section.tpl new file mode 100644 index 00000000..3dc172ea --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Section/templates/003_section.tpl @@ -0,0 +1 @@ +{section name=bar loop=$foo}{$foo[bar]}{sectionelse}else{/section}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Section/templates/004_section.tpl b/tests/UnitTests/TemplateSource/TagTests/Section/templates/004_section.tpl new file mode 100644 index 00000000..4a49fc9e --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Section/templates/004_section.tpl @@ -0,0 +1 @@ +{section name=bar loop=$foo}{$foo[bar]}{sectionelse} else {/section}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Section/templates/006_section.tpl b/tests/UnitTests/TemplateSource/TagTests/Section/templates/006_section.tpl new file mode 100644 index 00000000..edcd6c2e --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Section/templates/006_section.tpl @@ -0,0 +1 @@ +{section name=bar loop=$foo}{$foo[bar]}{sectionelse} else {/section}total{$smarty.section.bar.total}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Section/templates/007_section.tpl b/tests/UnitTests/TemplateSource/TagTests/Section/templates/007_section.tpl new file mode 100644 index 00000000..6c5f9a99 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Section/templates/007_section.tpl @@ -0,0 +1 @@ +{section name=bar loop=$foo}{$smarty.section.bar.index}{$smarty.section.bar.iteration}{sectionelse} else {/section}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Section/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Section/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Section/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Section/templates_tmp/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Section/templates_tmp/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Section/templates_tmp/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/SetFilter/CompileSetfilterTest.php b/tests/UnitTests/TemplateSource/TagTests/SetFilter/CompileSetfilterTest.php new file mode 100644 index 00000000..89b187e5 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/SetFilter/CompileSetfilterTest.php @@ -0,0 +1,57 @@ +<?php +/** + * Smarty PHPunit tests compilation of {setfilter} tag + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for {setfilter} tag tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class CompileSetfilterTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * @run + * InSeparateProcess + * @preserveGlobalState disabled + */ + public function testNestedSetfilter() + { + $this->smarty->setCaching(1); + $tpl = $this->smarty->createTemplate('string:{$foo}{setfilter htmlspecialchars} {$foo}{$foo nocache}{setfilter escape:"mail"} {$foo}{$foo nocache}{/setfilter} {$foo}{/setfilter} {$foo}'); + $tpl->assign('foo', '<a@b.c>'); + $this->assertEquals("<a@b.c> <a@b.c><a@b.c> <a [AT] b [DOT] c><a [AT] b [DOT] c> <a@b.c> <a@b.c>", $this->smarty->fetch($tpl)); + } + public function testNestedSetfilter1() + { + $this->smarty->setCaching(1); + $tpl = $this->smarty->createTemplate('string:{$foo}{setfilter htmlspecialchars} {$foo}{$foo nocache}{setfilter escape:"mail"} {$foo}{$foo nocache}{/setfilter} {$foo}{/setfilter} {$foo}'); + $tpl->assign('foo', '<e@f.d>'); + $this->assertEquals("<a@b.c> <a@b.c><e@f.d> <a [AT] b [DOT] c><e [AT] f [DOT] d> <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)); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/SetFilter/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/SetFilter/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/SetFilter/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/SetFilter/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/SetFilter/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/SetFilter/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Strip/CompileStripTest.php b/tests/UnitTests/TemplateSource/TagTests/Strip/CompileStripTest.php new file mode 100644 index 00000000..a8c37794 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Strip/CompileStripTest.php @@ -0,0 +1,83 @@ +<?php +/** + * Smarty PHPunit tests compilation of strip tags + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for strip tags tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class CompileStripTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); + $this->smarty->addTemplateDir("./templates_tmp"); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * Test {strip} tags + * + * @not runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestStrip + */ + public function testStrip($code, $result, $testName, $testNumber) + { + $file = "testStrip_{$testNumber}.tpl"; + $this->makeTemplateFile($file, "{strip}\n" . $code); + $this->smarty->assignGlobal('file', $file); + $this->assertEquals($result, $this->smarty->fetch($file), "testStrip - {$code} - {$testName}"); + } + + /* + * Data provider für testStrip + */ + public function dataTestStrip() + { + $i = 0; + /* + * Code + * result + * test name + */ + return array(array(" foo\n bar buh\n\n", 'foobar buh', '', $i ++), + array("\n <div style=\"float: right; cursor: url;\">[<a\n onmouseover=\"this.style.cursor='pointer'\"\n onmouseup=\"document.getElementById('screenEdit_(\$screen.id)').style.display='none'\">X</a>]</div>\n\n\n foo\n bar\n", + '<div style="float: right; cursor: url;">[<a onmouseover="this.style.cursor=\'pointer\'" onmouseup="document.getElementById(\'screenEdit_($screen.id)\').style.display=\'none\'">X</a>]</div>foobar', + '', $i ++), + array("\n <ul>\n <li>\n <a href=\"#\">BlaBla</a>\n </li>\n <li>\n <a href=\"#\">BlaBla</a>\n </li>\n </ul>\n", + '<ul><li><a href="#">BlaBla</a></li><li><a href="#">BlaBla</a></li></ul>', '', $i ++), + array("\n <textarea>\n\n some text\n\n </textarea> foo\n bar\n", + "<textarea>\n\n some text\n\n </textarea> foobar", '', $i ++), + // variable in html tag + array("\n <b><c>c</c></b>\n", '<b><c>c</c></b>', '', $i ++), + array("\n <b> <c>c</c></b>\n", '<b> <c>c</c></b>', '', $i ++), + array("\n <b>\n<c>c</c></b>\n", '<b><c>c</c></b>', '', $i ++), + array("{\$foo=1}\n <b>{\$foo}<c>c</c></b>\n", '<b>1<c>c</c></b>', '', $i ++), + array("{\$foo=1}\n <b>{\$foo} <c>c</c></b>\n", '<b>1 <c>c</c></b>', '', $i ++), + array("{\$foo=1}\n <b>\n{\$foo} <c>c</c></b>\n", '<b>1 <c>c</c></b>', '', $i ++), + array("\n<span>#</span>{'Text'}<span>#</span>\n", '<span>#</span>Text<span>#</span>', '', $i ++), + array("\n<span>#</span> {'Text'}\n", '<span>#</span> Text', '', $i ++), + array("\n<span>#</span> {'Text'}\n", '<span>#</span> Text', '', $i ++), + array("\n<b></b><c></c>", '<b></b><c></c>', '', $i ++), + array("{'Var'}\n<b></b> <c></c>", 'Var<b></b> <c></c>', '', $i ++), + array("{'Var'}\n <b></b> <c></c>", 'Var<b></b> <c></c>', '', $i ++), + array("\n<b></b> <c></c>", '<b></b> <c></c>', '', $i ++), + array("\n<b></b>\n <c></c>", '<b></b><c></c>', '', $i ++), + + ); + } + +} diff --git a/tests/UnitTests/TemplateSource/TagTests/Strip/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Strip/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Strip/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/Strip/templates_tmp/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Strip/templates_tmp/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Strip/templates_tmp/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/CompileFunctionTest.php b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/CompileFunctionTest.php new file mode 100644 index 00000000..31ea49f2 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/CompileFunctionTest.php @@ -0,0 +1,435 @@ +<?php +/** + * Smarty PHPunit tests compilation of {function} tag + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for {function} tag tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class CompileFunctionTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider functionProvider + * test simple function call tag + * + */ + public function testSimpleFunction_001($text) + { + $this->smarty->assign('param', 1); + $this->smarty->assign('default', 2); + $this->assertEquals("default param default 1 2 1", $this->smarty->fetch('test_template_function_001.tpl'), $text); + } + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider functionProvider + * test simple function call tag + * + */ + public function testSimpleFunctionAssign_001($text) + { + $this->smarty->assign('param', 1); + $this->smarty->assign('default', 2); + $this->assertEquals("default param default 1 2 1", $this->smarty->fetch('test_template_function_assign_001.tpl'), $text); + } + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider functionProvider + * test simple function call tag cached + */ + public function testSimpleFunctionCached_001($text) + { + $this->smarty->setCaching(1); + $this->smarty->assign('param', 1); + $this->smarty->assign('default', 2); + $this->assertEquals("default param default 1 2 1", $this->smarty->fetch('test_template_function_001.tpl'), $text); + } + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider functionProvider + * test simple function call tag cached + */ + public function testSimpleFunctionCached_002($text) + { + $this->smarty->setCaching(1); + $this->smarty->assign('param', 1); + $this->smarty->assign('default', 2); + $this->assertEquals("default param default 1 2 1", $this->smarty->fetch('test_template_function_002.tpl'), $text); + } + + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider functionProvider + * test simple function call tag cached no cache default variable + */ + public function testSimpleFunctionCachedNocacheDefault_002_1($text) + { + $this->smarty->setCaching(1); + $this->smarty->setCompileId(1); + $this->smarty->assign('param', 1); + $this->smarty->assign('default', 2, true); + $this->assertEquals("default param default 1 2 1", $this->smarty->fetch('test_template_function_002.tpl'), $text); + } + + /** + * test simple function call tag cached no cache default variable 2 + * + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testSimpleFunctionCachedNocacheDefault_002_2() + { + $this->smarty->setCaching(1); + $this->smarty->setCompileId(1); + $this->smarty->assign('param', 4); + $this->smarty->assign('default', 8, true); + $this->assertEquals("default param default 1 8 4", $this->smarty->fetch('test_template_function_002.tpl')); + } + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider functionProviderCachingValue + * test simple function call tag plugin + * + */ + public function testSimpleFunctionPlugin_003($caching, $text, $start,$result) + { + $this->smarty->setCaching($caching); + $this->smarty->assign('start', $start, true); + $this->smarty->assign('start1', $start+10); + $this->assertEquals($result, $this->smarty->fetch('test_template_function_003.tpl'), $text); + } + + + + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider functionProvider + * test simple function call tag 2 + * + */ + public function testSimpleFunctionTag2($text) + { + $this->assertEquals("default param default param2 passed param2 default param", $this->smarty->fetch('test_template_function_tag2.tpl'), $text); + } + + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider functionProvider + * test simple function call recursive + */ + public function testRecursiveFunction($text) + { + $this->assertEquals("012345", $this->smarty->fetch('test_template_function_tag4.tpl'), $text); + } + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider functionProviderInline + * test inherited function call tag + * + */ + public function testInheritedFunction($merge, $text) + { + $this->smarty->setMergeCompiledIncludes($merge); + $this->assertEquals("012345", $this->smarty->fetch('test_template_function_tag5.tpl'), $text); + } + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider functionProviderInline + * test function definition in include + * + */ + public function testDefineFunctionInclude($merge, $text) + { + $this->smarty->setMergeCompiledIncludes($merge); + $tpl = $this->smarty->createTemplate('test_template_function_tag6.tpl'); + $this->assertEquals("012345", $this->smarty->fetch('test_template_function_tag6.tpl'), $text); + } + + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider functionProviderInline + * test external function definition cached + * + */ + public function testExternalDefinedFunctionCached1($merge, $text) + { + $this->smarty->setMergeCompiledIncludes($merge); + $cacheId = $merge ? 'merge' : null; + $this->smarty->caching = 1; + $this->smarty->cache_lifetime = 1000; + $tpl = $this->smarty->createTemplate('test_template_function.tpl', $cacheId); + $tpl->assign('foo', 'foo'); + $this->assertContains('foo foo', $this->smarty->fetch($tpl), $text); + } + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * test external function definition and called by fetch + * + */ + public function testExternalDefinedFunctionCalledByFetch() + { + $this->smarty->assign('foo', 'foo'); + $this->assertContains('foo foo', $this->smarty->fetch('test_template_function.tpl')); + $this->smarty->assign('foo', 'bar'); + $this->assertContains('bar bar', $this->smarty->fetch('test_template_function_call.tpl')); + } + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider functionProviderInline + * test external function definition cached 2 + * + */ + public function testExternalDefinedFunctionCached12($merge, $text) + { + $this->smarty->setMergeCompiledIncludes($merge); + $cacheId = $merge ? 'merge' : null; + $this->smarty->caching = 1; + $this->smarty->cache_lifetime = 1000; + $tpl = $this->smarty->createTemplate('test_template_function.tpl', $cacheId); + $this->assertTrue($this->smarty->isCached($tpl), $text); + $tpl->assign('foo', 'bar'); + $this->assertContains('foo bar', $this->smarty->fetch($tpl), $text); + } + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider functionProviderInline + * test external function definition nocache call + * + */ + public function testExternalDefinedFunctionNocachedCall1($merge, $text) + { + $this->smarty->setMergeCompiledIncludes($merge); + $cacheId = $merge ? 'merge' : null; + $this->smarty->caching = 1; + $this->smarty->cache_lifetime = 1000; + $tpl = $this->smarty->createTemplate('test_template_function_nocache_call.tpl', $cacheId); + $tpl->assign('foo', 'foo'); + $this->assertContains('foo foo', $this->smarty->fetch($tpl), $text); + } + + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider functionProviderInline + * test external function definition nocache call 2 + * + */ + public function testExternalDefinedFunctionNocachedCall2($merge, $text) + { + $this->smarty->setMergeCompiledIncludes($merge); + $cacheId = $merge ? 'merge' : null; + $this->smarty->caching = 1; + $this->smarty->cache_lifetime = 1000; + $tpl = $this->smarty->createTemplate('test_template_function_nocache_call.tpl', $cacheId); + $this->assertTrue($this->smarty->isCached($tpl), $text); + $tpl->assign('foo', 'bar'); + $this->assertContains('bar bar', $this->smarty->fetch($tpl), $text); + } + + /** + * test external function definition nocache call 3 + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider functionProviderInline + */ + public function testExternalDefinedFunctionNocachedCall3($merge, $text) + { + $this->smarty->setMergeCompiledIncludes($merge); + $cacheId = $merge ? 'merge' : null; + $this->smarty->caching = 1; + $this->smarty->cache_lifetime = 1000; + $tpl = $this->smarty->createTemplate('test_template_function_nocache_call.tpl', $cacheId); + $this->assertTrue($this->smarty->isCached($tpl), $text); + $tpl->assign('foo', 'bar'); + $this->assertContains('bar bar', $this->smarty->fetch($tpl), $text); + } + + /** + * test external defined recursion + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider functionProvider + */ + public function testExternalDefinedFunctionRecursion($text) + { + $this->assertEquals('12345', $this->smarty->fetch('test_template_function_recursion2.tpl'), $text); + } + + /** + * Function data provider inline + */ + public function functionProviderInline() + { + return array( + array(false, 'normal compile'), + array(false, 'normal call'), + array(true, 'merged compile'), + array(true, 'merged call'), + ); + } + /** + * Function data provider + */ + public function functionProvider() + { + return array( + array('compile'), + array('call'), + ); + } + /** + * Function data provider + */ + public function functionProviderCaching() + { + return array( + array(false, 'normal compile'), + array(false, 'normal call'), + array(true, 'cached compile'), + array(true, 'cached call'), + ); + } + /** + * Function data provider + */ + public function functionProviderCachingValue() + { + return array( + array(false, 'normal compile',5,'15 215 5'), + array(false, 'normal call',3,'13 213 3'), + array(true, 'cached compile',6,'16 216 6'), + array(true, 'cached call',8,'16 218 8'), + ); + } + /** + * 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->addTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'bar'); + $this->assertEquals($result, + $this->smarty->fetch($file), + $file); + } + /** + * Test Output nocache spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestSpacing + * @runInSeparateProcess + */ + public function testSpacingNocache($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Spacing_{$name}.tpl"; + $this->smarty->setCompileId('VarNocache'); + $this->smarty->setCaching(1); + $this->smarty->addTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'bar',true); + $this->assertEquals($result, + $this->smarty->fetch($file), + "testVarNocache - {$file}"); + } + /** + * Test Output nocache spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestSpacing + * @runInSeparateProcess + */ + public function testSpacingNocache2($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Spacing_{$name}.tpl"; + $this->smarty->setCompileId('VarNocache'); + $this->smarty->setCaching(1); + $this->smarty->addTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'foo',true); + $this->assertEquals(str_replace('bar','foo',$result), + $this->smarty->fetch($file), + "testVarNocache1 - {$file}"); + } + + /* + * Data provider für testSpacing + */ + public function dataTestSpacing() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array(array("{include 'simple_function_lib.tpl'}A{call name='simple' bar=\$foo}C", "AbarC", 'T1', $i++), + array("{include 'simple_function_lib.tpl'}A\n{call name='simple' bar=\$foo}C", "A\nbarC", 'T2', $i++), + array("{include 'simple_function_lib.tpl'}A\n{call name='simple' bar=\$foo}\nC", "A\nbar\nC", 'T3', $i++), + array("{include 'simple_function_lib.tpl'}A\n{call name='simple' bar=\$foo}\nC", "A\nbar\nC", 'T4', $i++), + array("{include 'simple_function_lib.tpl'}A\n\n{call name='simple' bar=\$foo}\n\nC", "A\n\nbar\n\nC", 'T5', $i++), + array("{function name=simple}{\$bar}{/function}{call name='simple' bar=\$foo}", "bar", 'T6', $i++), + array("{function name=simple}A{\$bar}C{/function}{call name='simple' bar=\$foo}", "AbarC", 'T7', $i++), + array("{function name=simple}A\n{\$bar}C{/function}{call name='simple' bar=\$foo}", "A\nbarC", 'T8', $i++), + array("{function name=simple}A{\$bar}\nC{/function}{call name='simple' bar=\$foo}", "Abar\nC", 'T9', $i++), + array("{function name=simple}A\n{\$bar}\nC{/function}{call name='simple' bar=\$foo}", "A\nbar\nC", 'T10', $i++), + array("{function name=simple}{\$foo}{/function}{call name='simple'}", "bar", 'T11', $i++), + array("{function name=simple}A{\$foo}C{/function}{call name='simple'}", "AbarC", 'T12', $i++), + array("{function name=simple}A\n{\$foo}C{/function}{call name='simple'}", "A\nbarC", 'T13', $i++), + array("{function name=simple}A{\$foo}\nC{/function}{call name='simple'}", "Abar\nC", 'T14', $i++), + array("{function name=simple}A\n{\$foo}\nC{/function}{call name='simple'}", "A\nbar\nC", 'T15', $i++), + ); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/nocache_lib.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/nocache_lib.tpl new file mode 100644 index 00000000..8602140e --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/nocache_lib.tpl @@ -0,0 +1,6 @@ +{function 'nocache1' default1='d1' default2='d2'} + default1={$default1} + default2={$default1 nocache} + p1={$p1} + p2={$p2 nocache} +{/function}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test0.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test0.tpl new file mode 100644 index 00000000..ae27c661 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test0.tpl @@ -0,0 +1,4 @@ +Test 1 +<br/> +{include 'test7.tpl' compile_id = 4} + diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test1.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test1.tpl new file mode 100644 index 00000000..c8992cca --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test1.tpl @@ -0,0 +1,7 @@ +Test 1 +<br/> +{include 'test7.tpl' compile_id = $id} +{include 'test6.tpl'} +{include file="test2.tpl"} +{include 'test6.tpl'} + diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test2.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test2.tpl new file mode 100644 index 00000000..9b526949 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test2.tpl @@ -0,0 +1,3 @@ +Test 2 +<br/> +{include file="test3.tpl" compile_id=4} diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test3.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test3.tpl new file mode 100644 index 00000000..c4ca3221 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test3.tpl @@ -0,0 +1,4 @@ +Test 3 {call name='f' nocache} +<br/> +{include file="test4.tpl" compile_id=9} +{include file="test5.tpl" cache_id="7"}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test4.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test4.tpl new file mode 100644 index 00000000..13b0cbbb --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test4.tpl @@ -0,0 +1,3 @@ +Test 4 +<br/> +{include file="test5.tpl" cache_id="7"}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test5.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test5.tpl new file mode 100644 index 00000000..0a65c4c8 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test5.tpl @@ -0,0 +1,4 @@ +test 5 +<br> + +{call 'f'} diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test6.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test6.tpl new file mode 100644 index 00000000..d7379f81 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test6.tpl @@ -0,0 +1,8 @@ +test 6 +<br> +{function name='f'} + <br> + function f {$id} {$foo} + <br> +{/function} +<br> Time 6 = {$t6}<br>
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test7.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test7.tpl new file mode 100644 index 00000000..cc378526 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/CachingTests/test7.tpl @@ -0,0 +1,2 @@ +test 7 +<br> extern
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/simple_function_lib.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/simple_function_lib.tpl new file mode 100644 index 00000000..058f1956 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/simple_function_lib.tpl @@ -0,0 +1 @@ +{function name=simple}{$bar}{/function} diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/template_function_lib.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/template_function_lib.tpl new file mode 100644 index 00000000..a9a1c077 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/template_function_lib.tpl @@ -0,0 +1 @@ +{function name=template_func1 default='d1'}{$foo|escape} {nocache}{$foo|escape}{/nocache} {/function} diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_define_function_tag.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_define_function_tag.tpl new file mode 100644 index 00000000..35edac24 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_define_function_tag.tpl @@ -0,0 +1 @@ +{function name=functest6i loop=0}{$loop}{if $loop < 5}{call name=functest6i loop=$loop+1}{/if}{/function}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_inherit_function_tag.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_inherit_function_tag.tpl new file mode 100644 index 00000000..f50d697e --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_inherit_function_tag.tpl @@ -0,0 +1 @@ +{call name=functest4}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_inherit_function_tag6.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_inherit_function_tag6.tpl new file mode 100644 index 00000000..10d6e88b --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_inherit_function_tag6.tpl @@ -0,0 +1 @@ +{call name=functest6i}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function.tpl new file mode 100644 index 00000000..0997bdd3 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function.tpl @@ -0,0 +1 @@ +{include file='template_function_lib.tpl'}{call name=template_func1}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_001.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_001.tpl new file mode 100644 index 00000000..194dde9a --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_001.tpl @@ -0,0 +1 @@ +{function name=functest default='default'}{$default} {$param}{/function}{call name=functest param='param'} {call name=functest param=$param} {call name=functest param=$param default=$default}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_002.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_002.tpl new file mode 100644 index 00000000..7b6dbc77 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_002.tpl @@ -0,0 +1 @@ +{function name=functest default='default'}{$default} {$param nocache}{/function}{call name=functest param='param'} {call name=functest param=$param} {call name=functest param=$param default=$default}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_003.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_003.tpl new file mode 100644 index 00000000..b332e97b --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_003.tpl @@ -0,0 +1 @@ +{function name=functestplugins}{counter start=$start1} {counter start=$start nocache}{/function}{call name=functestplugins start=2}{call name=functestplugins start=$start}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_assign_001.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_assign_001.tpl new file mode 100644 index 00000000..71ad75ca --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_assign_001.tpl @@ -0,0 +1 @@ +{function name=functest default='default'}{$default} {$param}{$foo = $param scope=local}{/function}{call name=functest param='param'} {call name=functest param=$param} {call name=functest param=$param default=$default}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_call.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_call.tpl new file mode 100644 index 00000000..14829d91 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_call.tpl @@ -0,0 +1 @@ +{call name=template_func1}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_nocache_call.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_nocache_call.tpl new file mode 100644 index 00000000..3be68715 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_nocache_call.tpl @@ -0,0 +1 @@ +{include file='template_function_lib.tpl'}{call 'template_func1' nocache}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_recursion1.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_recursion1.tpl new file mode 100644 index 00000000..977b8515 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_recursion1.tpl @@ -0,0 +1,20 @@ +{strip} +{function 'recursion1' level=0} + {$level} + {if $level < 5} + {call name=recursion1 level=$level+1} + {/if} +{/function} + +{call name=recursion1} + + +{function 'recursion2' level=0} + <br>2 level = {$level} + {if $level < 5} + {call name=recursion2 level=$level+1} + {/if} +{/function} + +{recursion2} +{/strip}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_recursion2.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_recursion2.tpl new file mode 100644 index 00000000..cf9431f0 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_recursion2.tpl @@ -0,0 +1,10 @@ +{strip} +{function 'recursion2' level=0} +{$level} + {if $level < 5} + {call name=recursion2 level=$level+1} + {/if} +{/function} + +{recursion2} +{/strip}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_tag2.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_tag2.tpl new file mode 100644 index 00000000..2464e00a --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_tag2.tpl @@ -0,0 +1 @@ +{function name=functest2 default='default'}{$default} {$param}{/function}{call name=functest2 param='param'} {call name=functest2 param='param2'} {call name=functest2 param='param2' default='passed'} {call name=functest2 param='param'}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_tag4.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_tag4.tpl new file mode 100644 index 00000000..80cf6a0f --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_tag4.tpl @@ -0,0 +1 @@ +{function name=functest4 loop=0}{$loop}{if $loop < 5}{call name=functest4 loop=$loop+1}{/if}{/function}{call name=functest4}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_tag5.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_tag5.tpl new file mode 100644 index 00000000..f20a9617 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_tag5.tpl @@ -0,0 +1 @@ +{function name=functest4 loop=0}{$loop}{if $loop < 5}{call name=functest4 loop=$loop+1}{/if}{/function}{include file='test_inherit_function_tag.tpl'}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_tag6.tpl b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_tag6.tpl new file mode 100644 index 00000000..993a4945 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates/test_template_function_tag6.tpl @@ -0,0 +1 @@ +{include file='test_define_function_tag.tpl'}{include file='test_inherit_function_tag6.tpl'}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates_tmp/.gitignore b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates_tmp/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/templates_tmp/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/While/CompileWhileTest.php b/tests/UnitTests/TemplateSource/TagTests/While/CompileWhileTest.php new file mode 100644 index 00000000..78fe828a --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/While/CompileWhileTest.php @@ -0,0 +1,154 @@ +<?php +/** + * Smarty PHPunit tests compilation of {while} tag + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for {while} tag tests + * + * @not runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class CompileWhileTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test {while 'condition'} tag + */ + public function testWhileCondition() + { + $tpl = $this->smarty->createTemplate('string:{$x=0}{while $x<10}{$x}{$x=$x+1}{/while}'); + $this->assertEquals("0123456789", $this->smarty->fetch($tpl)); + } + + /** + * test {while 'statement'} tag + */ + public function testWhileStatement() + { + $tpl = $this->smarty->createTemplate('string:{$x=5}{while $x=$x-1}{$x}{/while}'); + $this->assertEquals("4321", $this->smarty->fetch($tpl)); + } + + /** + * 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->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 3); + $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("A{while \$foo=\$foo-1}{\$foo}{/while}C", "A21C", 'T1', $i++), + array("A{while \$foo=\$foo-1}\n{\$foo}{/while}C", "A21C", 'T2', $i++), + array("A{while \$foo=\$foo-1}{\$foo}\n{/while}C", "A2\n1\nC", 'T3', $i++), + array("A{while \$foo=\$foo-1}\n{\$foo}\n{/while}C", "A2\n1\nC", 'T4', $i++), + array("A\n{while \$foo=\$foo-1}{\$foo}{/while}C", "A\n21C", 'T5', $i++), + array("A{while \$foo=\$foo-1}{\$foo}{/while}\nC", "A21\nC", 'T6', $i++), + array("A{while \$foo=\$foo-1}{\$foo}{break}{/while}C", "A2C", 'T7', $i++), + array("A{while \$foo=\$foo-1}{\$foo}\n{break}{/while}C", "A2\nC", 'T8', $i++), + array("A{while \$foo=\$foo-1}{\$foo}{break}\n{/while}C", "A2C", 'T9', $i++), + array("A{while \$foo=\$foo-1}{if \$foo === 2}{continue}{/if}{\$foo}{/while}C", "A1C", 'T10', $i++), + array("A{while \$foo=\$foo-1}{if \$foo === 2}{continue}\n{/if}{\$foo}{/while}C", "A1C", 'T11', $i++), + array("A{while \$foo=\$foo-1}{if \$foo === 2}\n{continue}\n{/if}{\$foo}{/while}C", "A1C", 'T12', $i++), + array("A{while \$foo=\$foo-1}\n{continue}{\$foo}{/while}C", "AC", 'T13', $i++), + array("A{while \$foo=\$foo-1}{continue}\n{\$foo}{/while}C", "AC", 'T14', $i++), + array("A{while \$foo=\$foo-1}{break}\n{\$foo}{/while}C", "AC", 'T15', $i++), + array("A{while \$foo=\$foo-1}{\$foo}{continue}{/while}C", "A21C", 'T16', $i++), + array("A{while \$foo=\$foo-1}{\$foo}{continue}\n{/while}C", "A21C", 'T17', $i++), + array("A{while \$foo=\$foo-1}{\$foo}\n{continue}\n{/while}C", "A2\n1\nC", 'T18', $i++), + array("A{while \$foo=\$foo-1}{\$foo} {continue} {/while}C", "A2 1 C", 'T19', $i++), + array("A{while \$foo=\$foo-1} {continue}{\$foo}{/while}C", "A C", 'T20', $i++), + array("A{while \$foo=\$foo-1} {/while}C", "A C", 'T21', $i++), + array("A{while !isset(\$x)}{\$foo}{\$x=1}{/while}C", "A3C", 'T22', $i++), + ); + } + /** + * Test nocache + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestNocache + */ + public function testNocache($value, $nocache, $code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Nocache_{$name}.tpl"; + if ($code) { + $this->makeTemplateFile($file, $code); + } + $this->smarty->setCaching(1); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', $value, $nocache); + $this->assertEquals($result, $this->smarty->fetch($file), + "{$file} - {$testNumber}"); + } + + /* + * Data provider für testNocache + */ + public function dataTestNocache() + { + $i = 1; + /* + * var + * value + * Code + * result + * test name + */ + return array(array(3,false, "{while \$foo=\$foo-1}\n{\$foo}{/while}", '21', 'T1', $i ++), + array(0,false, false, '21', 'T1', $i ++), + array(3,false, "{while \$foo=\$foo-1 nocache}\n{\$foo}{/while}", '21', 'T2', $i ++), + array(4,false, false, '321', 'T2', $i ++), + array(4,true, "{while \$foo=\$foo-1}\n{\$foo}{/while}", '321', 'T3', $i ++), + array(5,true, false, '4321', 'T3', $i ++), + array(array(1,2,3),false, "{\$x=1}{while isset(\$foo[\$x])}\n{\$foo[\$x]}{\$x++}{/while}", '2132', 'T4', $i ++), + array(array(3,4,5),false, false, '2132', 'T4', $i ++), + array(array(1,2,3),false, "{\$x=1 nocache}{while isset(\$foo[\$x])}\n{\$foo[\$x]}{\$x++}{/while}", '2132', 'T5', $i ++), + array(array(3,4,5),false, false, '4152', 'T5', $i ++), + array(array(1,2,3),true, "{\$x=1 nocache}{while isset(\$foo[\$x])}\n{\$foo[\$x]}{\$x++}{/while}", '2132', 'T6', $i ++), + array(array(3,4,5),true, false, '4152', 'T6', $i ++), + array(array(1,2,3,4,5),true, "{\$x=0 nocache}{while \$foo[\$x] <= 3}\n{\$foo[\$x]}{\$x++}{/while}", '102132', 'T7', $i ++), + array(array(2,3,4,5),true, false, '2031', 'T7', $i ++), + array(array(1,2,false,4,5),true, "{\$x=0 nocache}{while \$foo[\$x]}\n{\$foo[\$x]}{\$x++}{/while}", '1021', 'T8', $i ++), + array(array(2,false,4,5),true, false, '20', 'T8', $i ++), + ); + } + +} diff --git a/tests/UnitTests/TemplateSource/TagTests/While/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/While/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/While/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/While/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/While/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/While/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/While/templates_tmp/.gitignore b/tests/UnitTests/TemplateSource/TagTests/While/templates_tmp/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/While/templates_tmp/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/_Attributes/AttributeTest.php b/tests/UnitTests/TemplateSource/TagTests/_Attributes/AttributeTest.php new file mode 100644 index 00000000..b3fe851f --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/_Attributes/AttributeTest.php @@ -0,0 +1,79 @@ +<?php +/** + * Smarty PHPunit tests for tag attributes + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for tag attribute tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class AttributeTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); + } + + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * @expectedException SmartyCompilerException + * @expectedExceptionMessage missing 'var' attribute + * test required attribute + */ + public function testRequiredAttributeVar() + { + $this->smarty->fetch('string:{assign value=1}'); + } + + /** + * @expectedException SmartyCompilerException + * @expectedExceptionMessage unexpected 'bar' attribute + * test unexpected attribute + */ + public function testUnexpectedAttribute() + { + $this->smarty->fetch('string:{assign var=foo value=1 bar=2}'); + } + + /** + * @expectedException SmartyCompilerException + * @expectedExceptionMessage for option flag 'nocache' + * @expectedExceptionMessage illegal value + * test illegal option value + */ + public function testIllegalOptionValue() + { + $this->smarty->fetch('string:{assign var=foo value=1 nocache=buh}'); + } + + /** + * @expectedException SmartyCompilerException + * @expectedExceptionMessage too many shorthand attributes + * test too many shorthands + */ + public function testTooManyShorthands() + { + $this->smarty->fetch('string:{assign foo 1 2}'); + } + + /** + */ + public function testNumericParams() + { + $this->assertEquals('array(\'a\'=>\'pa\',0=>\'isnull\',)', $this->strip($this->smarty->fetch('string:{getparams a=\'pa\' 0=isnull}'))); + } + + +} diff --git a/tests/UnitTests/TemplateSource/TagTests/_Attributes/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/_Attributes/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/_Attributes/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/_Attributes/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/_Attributes/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/_Attributes/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/_Error/CompileErrorTest.php b/tests/UnitTests/TemplateSource/TagTests/_Error/CompileErrorTest.php new file mode 100644 index 00000000..b190c5ff --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/_Error/CompileErrorTest.php @@ -0,0 +1,67 @@ +<?php +/** + * Smarty PHPunit tests compiler errors + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for compiler tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class CompileErrorTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * @expectedException SmartyException + * @expectedExceptionMessage no.tpl + * test none existing template file error + */ + public function testNoneExistingTemplateError() + { + $this->smarty->fetch('eval:{include file=\'no.tpl\'}'); + } + + /** + * @expectedException SmartyCompilerException + * @expectedExceptionMessage unknown tag 'unknown' + * test unkown tag error + */ + public function testUnknownTagError() + { + $this->smarty->fetch('eval:{unknown}'); + } + + /** + * @expectedException SmartyCompilerException + * @expectedExceptionMessage unclosed {if} tag + * test unclosed tag error + */ + public function testUnclosedTagError() + { + $this->smarty->fetch('eval:{if true}'); + } + + /** + * @expectedException SmartyCompilerException + * @expectedExceptionMessage Unexpected "}" + * test syntax error + */ + public function testSyntaxError() + { + $this->smarty->fetch('eval:{assign var=}'); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/_Error/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/_Error/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/_Error/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/_Error/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/_Error/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/_Error/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/_Print/PrintTest.php b/tests/UnitTests/TemplateSource/TagTests/_Print/PrintTest.php new file mode 100644 index 00000000..6c5d624a --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/_Print/PrintTest.php @@ -0,0 +1,108 @@ +<?php +/** + * Smarty PHPunit tests variable output with nocache attribute + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for variable output with nocache attribute tag tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class PrintTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * Test Output spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestOutputSpacing + * @runInSeparateProcess + */ + public function testOutputSpacing($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "testSpacing_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'bar'); + $this->assertEquals($result, + $this->smarty->fetch($file), + "testSpacing - {$file}"); + } + /** + * Test Output nocache spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestOutputSpacing + * @runInSeparateProcess + */ + public function testOutputSpacingNocache($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "testSpacing_{$name}.tpl"; + $this->smarty->setCompileId('1'); + $this->smarty->setCaching(1); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'bar',true); + $this->assertEquals($result, + $this->smarty->fetch($file), + "testSpacing - {$file}"); + } + /** + * Test Output nocache spacings + * + * @preserveGlobalState disabled + * @dataProvider dataTestOutputSpacing + * @runInSeparateProcess + */ + public function testOutputSpacingNocache2($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "testSpacing_{$name}.tpl"; + $this->smarty->setCompileId('1'); + $this->smarty->setCaching(1); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 'foo',true); + $this->assertEquals(str_replace('bar','foo',$result), + $this->smarty->fetch($file), + "testSpacing - {$file}"); + } + + /* + * Data provider für testOutputSpacing + */ + public function dataTestOutputSpacing() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array(array('{$foo}', 'bar', 'Variable', $i++), + array('{$foo}{$foo}', 'barbar', 'twoVariables', $i++), + array('A{$foo}{$foo}B', 'AbarbarB', 'twoVariablesInText', $i++), + array('{$foo} {$foo}', 'bar bar', 'twoVariablesWithSpace', $i++), + array('A{$foo}B', 'AbarB', 'VariableInText1', $i++), + array('A {$foo}B', 'A barB', 'VariableInText2', $i++), + array('A{$foo} B', 'Abar B', 'VariableInText3', $i++), + array("A{\$foo}\nB", "Abar\nB", 'VariableInTextNewline1', $i++), + array("A{\$foo}B\nC", "AbarB\nC", 'VariableInTextNewline2', $i++), + ); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/_Print/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/_Print/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/_Print/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/_Print/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/_Print/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/_Print/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/_Print/templates_tmp/.gitignore b/tests/UnitTests/TemplateSource/TagTests/_Print/templates_tmp/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/_Print/templates_tmp/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/break/CompileBreakTest.php b/tests/UnitTests/TemplateSource/TagTests/break/CompileBreakTest.php new file mode 100644 index 00000000..7594678a --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/break/CompileBreakTest.php @@ -0,0 +1,45 @@ +<?php +/** + * Smarty PHPunit tests compilation of {break} tag + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for {break} tag tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class CompileBreakTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test {break} in foreach + */ + public function testBreakForeach() + { + $this->smarty->assign('array', array(1,2,3)); + $this->assertEquals('1', $this->smarty->fetch('break_foreach.tpl')); + } + /** + * test {break} in foreach nocache + */ + public function testBreakForeachNocache() + { + $this->smarty->assign('array', array(1,2,3), true); + $this->smarty->caching = true; + $this->assertEquals('1', $this->smarty->fetch('break_foreach.tpl')); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/break/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/break/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/break/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/TagTests/break/templates/break_foreach.tpl b/tests/UnitTests/TemplateSource/TagTests/break/templates/break_foreach.tpl new file mode 100644 index 00000000..b289e535 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/break/templates/break_foreach.tpl @@ -0,0 +1,7 @@ +{strip} +{foreach $array as $key => $i} + {if $key == 1} + {break} + {/if} + {$i} +{/foreach}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/break/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/break/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/break/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/Array/ArrayTest.php b/tests/UnitTests/TemplateSource/ValueTests/Array/ArrayTest.php new file mode 100644 index 00000000..d8f5cd63 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Array/ArrayTest.php @@ -0,0 +1,75 @@ +<?php +/** + * Smarty PHPunit tests array definitions and access + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for array tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class ArrayTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + /** + * Test array access + * + * @preserveGlobalState disabled + * @dataProvider dataTestArray + * @runInSeparateProcess + */ + public function testArray($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "Array_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->setTemplateDir('./templates_tmp'); + $this->smarty->assign('foo', 3); + $this->assertEquals($result, + $this->smarty->fetch($file), + $file); + } + + /* + * Data provider für testArray + */ + public function dataTestArray() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array(array('{$foo=[1,2,3,4,5]}{foreach $foo as $bar}{$bar}{/foreach}', '12345', 'T1', $i++), + array('{$foo=[1,2,3,4,5]}{$foo.0}{$foo.1}{$foo.2}', '123', 'T2', $i++), + array('{$foo=[1,2,3,4,5]}{$foo[0]}{$foo[1]}{$foo[2]}', '123', 'T3', $i++), + array('{$x=\'d\'}{$foo=[a=>1,\'b\'=>2,"c"=>3,$x=>4]}{$foo[\'a\']}{$foo[\'b\']}{$foo[\'c\']}{$foo[\'d\']}', '1234', 'T4', $i++), + array('{$foo=[1,2,[a,b,c],4,5]}{$foo[2][1]}', 'b', 'T5', $i++), + array('{$foo=[1,2,[7,8,9],4,5]}{$foo[2][1]+1}', '9', 'T6', $i++), + array('{$foo=[1,2,[7,8,9],4,5]}{$foo.2.1+1}', '9', 'T7', $i++), + array('{$foo=[1,2,[7,8,9],4,5]}{2+$foo[2][1]}', '10', 'T8', $i++), + array('{$foo=[1,2,[7,8,9],4,5]}{2+$foo.2.1}', '10', 'T9', $i++), + array('{$foo=[1,2,[7,8,9],4,5]}{$foo[2][0]+$foo[2][1]}', '15', 'T10', $i++), + array('{$foo=[1,2,[7,8,9],4,5]}{$foo.2.0+$foo.2.1}', '15', 'T11', $i++), + array('{$foo=[1,2,[7,8,9],4,5]}{$x=2}{$y=0}{$foo.$x.$y}', '7', 'T12', $i++), + array('{$foo=[1,2,[7,8,9],4,5]}{$x=2}{$foo.$x.0}', '7', 'T13', $i++), + array('{$foo=[1,2,[7,8,9],4,5]}{$x=0}{$foo.2.$x}', '7', 'T14', $i++), + array('{$foo=[1,2,[7,8,9],4,5]}{$x=[1,0]}{$foo.2.{$x.1}}', '7', 'T15', $i++), + ); + } +} diff --git a/tests/UnitTests/TemplateSource/ValueTests/Array/cache/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/Array/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Array/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/Array/templates_c/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/Array/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Array/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/Array/templates_tmp/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/Array/templates_tmp/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Array/templates_tmp/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/BoolenNull/BooleanNullTest.php b/tests/UnitTests/TemplateSource/ValueTests/BoolenNull/BooleanNullTest.php new file mode 100644 index 00000000..9fba0bac --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/BoolenNull/BooleanNullTest.php @@ -0,0 +1,51 @@ +<?php +/** + * Smarty PHPunit tests literals true false null + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for {$smarty.ldelim} {$smarty.rdelim} tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class BooleanNullTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test true + * + */ + public function testTrue() { + $this->smarty->assign('value', true); + $this->assertEquals('true', $this->smarty->fetch('eval:{if $value === true}true{else}false{/if}')); + } + /** + * test false + * + */ + public function testFalse() { + $this->smarty->assign('value', false); + $this->assertEquals('true', $this->smarty->fetch('eval:{if $value === false}true{else}false{/if}')); + } + /** + * test null + * + */ + public function testNull() { + $this->smarty->assign('value', null); + $this->assertEquals('true', $this->smarty->fetch('eval:{if $value === null}true{else}false{/if}')); + } + } diff --git a/tests/UnitTests/TemplateSource/ValueTests/BoolenNull/cache/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/BoolenNull/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/BoolenNull/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/BoolenNull/templates/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/BoolenNull/templates/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/BoolenNull/templates/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/BoolenNull/templates_c/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/BoolenNull/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/BoolenNull/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/ConstantTests/ConstantsTest.php b/tests/UnitTests/TemplateSource/ValueTests/ConstantTests/ConstantsTest.php new file mode 100644 index 00000000..3ab161b9 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/ConstantTests/ConstantsTest.php @@ -0,0 +1,89 @@ +<?php + +/** + * Smarty PHPunit tests of constants + * + * @package PHPunit + * @author Uwe Tews + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +Class TestConst +{ + const CONSTVAL = 'okay'; +} + +/** + * class for constants tests + */ +class ConstantsTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test constants + */ + public function testConstants() + { + define('MYCONSTANTS', 'hello world'); + $tpl = $this->smarty->createTemplate('eval:{$smarty.const.MYCONSTANTS}'); + $this->assertEquals("hello world", $this->smarty->fetch($tpl)); + } + + public function testConstants2() + { + $tpl = $this->smarty->createTemplate('eval:{MYCONSTANTS}'); + $this->assertEquals("hello world", $this->smarty->fetch($tpl)); + } + + public function testConstants3() + { + $tpl = $this->smarty->createTemplate('eval:{$x=MYCONSTANTS}{$x}'); + $this->assertEquals("hello world", $this->smarty->fetch($tpl)); + } + + public function testConstants4() + { + $tpl = $this->smarty->createTemplate('eval:{TestConst::CONSTVAL}'); + $this->assertEquals("okay", $this->smarty->fetch($tpl)); + } + + public function testConstants5() + { + $tpl = $this->smarty->createTemplate('eval:{if TestConst::CONSTVAL == "okay"}yes{/if}'); + $this->assertEquals("yes", $this->smarty->fetch($tpl)); + } + + public function testConstants6() + { + $tpl = $this->smarty->createTemplate('eval:{$obj::CONSTVAL}'); + $tpl->assign('obj', new TestConst()); + $this->assertEquals("okay", $this->smarty->fetch($tpl)); + } + + public function testConstants7() + { + $tpl = $this->smarty->createTemplate('eval:{if $obj::CONSTVAL == "okay"}yes{/if}'); + $tpl->assign('obj', new TestConst()); + $this->assertEquals("yes", $this->smarty->fetch($tpl)); + } + public function testConstantsUndefined() + { + $tpl = $this->smarty->createTemplate('string:{$smarty.const.MYCONSTANT2}'); + $this->assertEquals("", $this->smarty->fetch($tpl)); + } + public function testConstantsUndefined2() + { + $tpl = $this->smarty->createTemplate('eval:{$foo = MYCONSTANT2}{$foo}'); + $this->assertEquals("MYCONSTANT2", $this->smarty->fetch($tpl)); + } +} diff --git a/tests/UnitTests/TemplateSource/ValueTests/ConstantTests/cache/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/ConstantTests/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/ConstantTests/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/ConstantTests/templates_c/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/ConstantTests/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/ConstantTests/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/DoubleQuotedStringTest.php b/tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/DoubleQuotedStringTest.php new file mode 100644 index 00000000..0b647b4c --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/DoubleQuotedStringTest.php @@ -0,0 +1,105 @@ +<?php +/** + * Smarty PHPunit tests double quoted strings + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for double quoted string tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled +*/ +class DoubleQuotedStringTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); + $this->smarty->addTemplateDir("../../../__shared/templates/"); + $this->smarty->addTemplateDir("./templates_tmp"); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * Test double qouted strings + * + * @preserveGlobalState disabled + * @dataProvider dataTestDoubleQuoted + */ + public function testDoubleQuoted($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "testDoubleQuotes_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->assignGlobal('file', $file); + $this->smarty->assign('bar', 'buh'); + $this->assertEquals($result, $this->smarty->fetch($file), + "testDoubleQuoted - {$code} - {$name}"); + } + + /* + * Data provider für testDoubleQuoted + */ + public function dataTestDoubleQuoted() + { + $i = 1; + /* + * Code + * result + * test name + * test number + */ + return array(array('{$foo="Hello World"}{$foo}', 'Hello World', 'simple', $i ++), + array('{$bar=1}{$foo="Hello {$bar+2} World"}{$foo}', 'Hello 3 World', 'withExpression', $i ++), + array('{$bar=\'blah\'}{$foo="Hello $bar World"}{$foo}', 'Hello blah World', 'withVariable', $i ++), + array('{$bar=\'blah\'}{$buh=\'wow\'}{$foo="Hello $bar$buh World"}{$foo}', 'Hello blahwow World', 'with2Variables', $i ++), + array('{$bar=\'blah\'}{$foo="Hello `$bar`.test World"}{$foo}', 'Hello blah.test World', 'withVarBacktick', $i ++), + array('{$bar=\'blah\'}{$buh=\'buh\'}{$foo="Hello `$bar``$buh`.test World"}{$foo}', 'Hello blahbuh.test World', 'with2VarBacktick', $i ++), + array('{$barbuh=\'blah\'}{$buh=\'buh\'}{$foo="Hello `$bar{$buh}`.test World"}{$foo}', 'Hello blah.test World', 'withVariableVarBacktick', $i ++), + array('{$bar[1][2]=\'blah\'}{$foo="Hello `$bar.1.2`.test World"}{$foo}', 'Hello blah.test World', 'withVarIndexSmartyBacktick', $i ++), + array('{$bar[1][2]=\'blah\'}{$foo="Hello `$bar[1][2]`.test World"}{$foo}', 'Hello blah.test World', 'withVarIndexPhPBacktick', $i ++), + array('{$a=1}{"`$a+1`"}', '2', 'withExpressionBacktick', $i ++), + array('{$foo="Hello {counter start=3} World"}{$foo}', 'Hello 3 World', 'withCounterTag', $i ++), + array('{$foo="Hello {counter start=2}{counter} World"}{$foo}', 'Hello 23 World', 'with2CounterTag', $i ++), + array('{$x=1}{$y=2}{$z=true}{"Hello{if $z} {$x} {else}{$y}{/if}World"}', 'Hello 1 World', 'withIfTag', $i ++), + array('{$bar=\'blah\'}{$foo="Hello {$bar}.test World"}{$foo}', 'Hello blah.test World', 'withDelimiter', $i ++), + array('{$foo="Hello \" World"}{$foo}', 'Hello " World', 'escaped', $i ++), + array('{$foo="Hello \'World\'"}{$foo}', 'Hello \'World\'', 'withSingleQuotes', $i ++), + array('{$foo="Hello {\'World\'} Test"}{$foo}', 'Hello World Test', 'withSingleQuoteTag', $i ++), + array('{$foo=""}{$foo}', '', 'empty', $i ++), + ); + } + + + /** + * + * test unclosed block tag + * + * @expectedException SmartyCompilerException + * @expectedExceptionMessage unclosed '{if}' in doubled quoted string + */ + public function testDoubleQuotedUnclosedBlock_001() + { + $this->smarty->fetch('001_unclosedBlock.tpl'); + } + + /** + * + * test closed block tag + * {"{if true}hello world{/if}"} + * + */ + public function testDoubleQuotedClosedBlock_001() + { + $this->assertEquals('hello world', $this->smarty->fetch('001_closedBlock.tpl')); + } + +} diff --git a/tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/cache/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/templates/001_closedBlock.tpl b/tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/templates/001_closedBlock.tpl new file mode 100644 index 00000000..1ae63043 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/templates/001_closedBlock.tpl @@ -0,0 +1 @@ +{"{if true}hello world{/if}"}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/templates/001_unclosedBlock.tpl b/tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/templates/001_unclosedBlock.tpl new file mode 100644 index 00000000..f30d396c --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/templates/001_unclosedBlock.tpl @@ -0,0 +1 @@ +{"{if true} world"}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/templates_c/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/templates_tmp/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/templates_tmp/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/templates_tmp/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/Math/MathTest.php b/tests/UnitTests/TemplateSource/ValueTests/Math/MathTest.php new file mode 100644 index 00000000..ff0b3a1c --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Math/MathTest.php @@ -0,0 +1,110 @@ +<?php +/** + * Smarty PHPunit tests of modifier + * + * @package PHPunit + * @author Rodney Rehm + */ + +/** + * class for modifier tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class MathTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * test PHP function as modifier + */ + public function testSyntax() + { + $this->smarty->disableSecurity(); + $expected = "20 -- 4"; + $tpl = $this->smarty->createTemplate('eval:{$x = 4}{$y = 5}{$x * $y} -- {20 / 5}'); + $this->assertEquals($expected, $this->smarty->fetch($tpl)); + } + + public function testFunction() + { + $this->smarty->disableSecurity(); + $expected = "20 -- 4"; + $tpl = $this->smarty->createTemplate('eval:{$x = 4}{$y = 5}{math equation="x * y" x=$x y=$y} -- {math equation="20 / 5"}'); + $this->assertEquals($expected, $this->smarty->fetch($tpl)); + } + + public function testSyntaxSin() + { + $this->smarty->disableSecurity(); + $expected = sin(4) . ' -- ' . sin(4); + $tpl = $this->smarty->createTemplate('eval:{$x = 4}{$x|sin} -- {$y = sin($x)}{$y}'); + $this->assertEquals($expected, $this->smarty->fetch($tpl)); + } + + public function testFunctionSin() + { + $this->smarty->disableSecurity(); + $expected = sin(4) . ' -- ' . sin(4); + $tpl = $this->smarty->createTemplate('eval:{$x = 4}{math equation="sin(x)" x=$x} -- {math equation="sin(x)" x=$x assign="y"}{$y}'); + $this->assertEquals($expected, $this->smarty->fetch($tpl)); + } + + public function testSyntaxFloat() + { + $this->smarty->disableSecurity(); + $expected = "22 -- 4.1"; + $tpl = $this->smarty->createTemplate('eval:{$x = 4}{$y = 5.5}{$x * $y} -- {20.5 / 5}'); + $this->assertEquals($expected, $this->smarty->fetch($tpl)); + } + + public function testFunctionFloat() + { + $this->smarty->disableSecurity(); + $expected = "22 -- 4.1"; + $tpl = $this->smarty->createTemplate('eval:{$x = 4}{$y = 5.5}{math equation="x * y" x=$x y=$y} -- {math equation="20.5 / 5"}'); + $this->assertEquals($expected, $this->smarty->fetch($tpl)); + } + + public function testSyntaxFormat() + { + $this->smarty->disableSecurity(); + $expected = "22.00 -- 4.10"; + $tpl = $this->smarty->createTemplate('eval:{$x = 4}{$y = 5.5}{$z = $x * $y}{"%0.2f"|sprintf:$z} -- {$x = 20.5}{$y = 5}{$z = $x / $y}{"%0.2f"|sprintf:$z}'); + $this->assertEquals($expected, $this->smarty->fetch($tpl)); + } + + public function testFunctionFormat() + { + $this->smarty->disableSecurity(); + $expected = "22.00 -- 4.10"; + $tpl = $this->smarty->createTemplate('eval:{$x = 4}{$y = 5.5}{math equation="x * y" x=$x y=$y format="%0.2f"} -- {math equation="20.5 / 5" format="%0.2f"}'); + $this->assertEquals($expected, $this->smarty->fetch($tpl)); + } + + public function testSyntaxString() + { + $this->smarty->disableSecurity(); + $expected = "22.00 -- 4.10"; + $tpl = $this->smarty->createTemplate('eval:{$x = "4"}{$y = "5.5"}{$z = $x * $y}{"%0.2f"|sprintf:$z} -- {$x = "20.5"}{$y = "5"}{$z = $x / $y}{"%0.2f"|sprintf:$z}'); + $this->assertEquals($expected, $this->smarty->fetch($tpl)); + } + + public function testFunctionString() + { + $this->smarty->disableSecurity(); + $expected = "22.00 -- 4.10"; + $tpl = $this->smarty->createTemplate('eval:{$x = "4"}{$y = "5.5"}{math equation="x * y" x=$x y=$y format="%0.2f"} -- {math equation="20.5 / 5" format="%0.2f"}'); + $this->assertEquals($expected, $this->smarty->fetch($tpl)); + } +} diff --git a/tests/UnitTests/TemplateSource/ValueTests/Math/cache/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/Math/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Math/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/Math/templates_c/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/Math/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Math/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/Modifier/ModifierTest.php b/tests/UnitTests/TemplateSource/ValueTests/Modifier/ModifierTest.php new file mode 100644 index 00000000..2dc1751b --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Modifier/ModifierTest.php @@ -0,0 +1,135 @@ +<?php +/** + * Smarty PHPunit tests of modifier + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for modifier tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class ModifierTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + $this->smarty->addTemplateDir("./templates_tmp"); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * Test modifier + * + * @not runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestModifier + */ + public function testModifier($code, $result, $testName, $testNumber) + { + $name = empty($testName) ? $testNumber : $testName; + $file = "testModifier_{$name}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->assignGlobal('file', $file); + $this->smarty->assign('bar', 'buh'); + $this->assertEquals($result, $this->smarty->fetch($file), + "testModifier - {$code} - {$name}"); + } + + /* + * Data provider für testModifier + */ + public function dataTestModifier() + { + $i = 1; + /* + * Code + * result + * test name + */ + return array(array('{"hello world"|strlen}', '11', 'OnString', $i ++), + array('{$foo ="hello world"}{$foo|strlen}', '11', 'OnVar', $i ++), + array('{"hello world"|truncate:6}', 'hel...', 'TruncatePlugin', $i ++), + array('{$foo=7}{"hello world"|truncate:$foo}', 'hell...', 'TruncatePluginLengthVar', $i ++), + array('{$foo=10}{$bar=\'<>\'}{"hello world"|truncate:$foo:$bar}', 'hello<>', 'TruncatePluginAllVar', $i ++), + array('{"hello world"|truncate:6|strlen}', '6', 'Chain', $i ++), + array('{"hello world"|truncate:6:"xx"|cat:"Smarty"}', 'hellxxSmarty', 'ChainVar', $i ++), + array('{"hello world"|truncate:6|strlen}', '6', 'Chain', $i ++), + array('{if "hello world"|truncate:6|strlen == 6}okay{/if}', 'okay', 'InIF', $i ++), + array('{"hello world"|truncate:6|strlen + ("hello world"|truncate:8|strlen)}', '14', 'Expression', $i ++), + array('{1.1*7.1|round}', '7.7', 'InExpression', $i ++), + array('{counter|truncate:5 start=100000}', '10...', 'PluginOutput', $i ++), + array('{1 + [1,2,3]|count}', '4', 'SumExpression', $i ++), + ); + } + + + + + /** + * test registered modifier static class + */ + public function testModifierRegisteredStaticClass() + { + $this->smarty->registerPlugin(Smarty::PLUGIN_MODIFIER, 'testmodifier', array('testmodifierclass', 'staticcall')); + $this->smarty->assign('foo', 1); + $this->assertEquals("mymodifier static 1", $this->smarty->fetch('testModifier_RegisteredStatic.tpl')); + } + + /** + * test registered modifier method call + */ + public function testModifierRegisteredMethodCall() + { + $obj = new testmodifierclass(); + $this->smarty->registerPlugin(Smarty::PLUGIN_MODIFIER, 'testmodifier', array($obj, 'method')); + $this->smarty->assign('foo', 3); + $this->assertEquals("mymodifier method 3", $this->smarty->fetch('testModifier_RegisteredMethod.tpl')); + } + + /** + * @expectedException SmartyCompilerException + * @expectedExceptionMessage unknown modifier 'unknown' + * test unknown modifier error + */ + public function testUnknownModifier() + { + $this->smarty->fetch('eval:{"hello world"|unknown}'); + } + + /** + * test default modifier + */ + public function testDefaultModifier() + { + $this->smarty->default_modifiers = array('escape'); + $this->smarty->assign('foo', '<bar>'); + $this->assertEquals('<bar><bar>', $this->smarty->fetch('testModifier_Default.tpl')); + } +} + +function testmodifier($value) +{ + return "mymodifier function $value"; +} + +class testmodifierclass +{ + static function staticcall($value) + { + return "mymodifier static $value"; + } + + public function method($value) + { + return "mymodifier method $value"; + } +} diff --git a/tests/UnitTests/TemplateSource/ValueTests/Modifier/cache/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/Modifier/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Modifier/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/Modifier/templates/testModifier_Default.tpl b/tests/UnitTests/TemplateSource/ValueTests/Modifier/templates/testModifier_Default.tpl new file mode 100644 index 00000000..e5c4736d --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Modifier/templates/testModifier_Default.tpl @@ -0,0 +1 @@ +{$foo}{$foo nofilter}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/ValueTests/Modifier/templates/testModifier_RegisteredMethod.tpl b/tests/UnitTests/TemplateSource/ValueTests/Modifier/templates/testModifier_RegisteredMethod.tpl new file mode 100644 index 00000000..60ea1847 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Modifier/templates/testModifier_RegisteredMethod.tpl @@ -0,0 +1 @@ +{$foo|testmodifier}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/ValueTests/Modifier/templates/testModifier_RegisteredStatic.tpl b/tests/UnitTests/TemplateSource/ValueTests/Modifier/templates/testModifier_RegisteredStatic.tpl new file mode 100644 index 00000000..60ea1847 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Modifier/templates/testModifier_RegisteredStatic.tpl @@ -0,0 +1 @@ +{$foo|testmodifier}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/ValueTests/Modifier/templates_c/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/Modifier/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Modifier/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/Modifier/templates_tmp/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/Modifier/templates_tmp/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Modifier/templates_tmp/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/Objects/ObjectVariableTest.php b/tests/UnitTests/TemplateSource/ValueTests/Objects/ObjectVariableTest.php new file mode 100644 index 00000000..717b94e8 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Objects/ObjectVariableTest.php @@ -0,0 +1,106 @@ +<?php +/** + * Smarty PHPunit tests object variables + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for object variable tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class ObjectVariableTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + $this->smarty->setForceCompile(true); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test simple object variable + */ + public function testObjectVariableOutput() + { + $object = new VariableObject; + $tpl = $this->smarty->createTemplate('string:{$object->hello}'); + $tpl->assign('object', $object); + $this->assertEquals('hello_world', $this->smarty->fetch($tpl)); + } + + /** + * test simple object variable with variable property + */ + public function testObjectVariableOutputVariableProperty() + { + $object = new VariableObject; + $this->smarty->disableSecurity(); + $tpl = $this->smarty->createTemplate('string:{$p=\'hello\'}{$object->$p}'); + $tpl->assign('object', $object); + $this->assertEquals('hello_world', $this->smarty->fetch($tpl)); + } + + /** + * test simple object variable with method + */ + public function testObjectVariableOutputMethod() + { + $object = new VariableObject; + $tpl = $this->smarty->createTemplate('string:{$object->myhello()}'); + $tpl->assign('object', $object); + $this->assertEquals('hello world', $this->smarty->fetch($tpl)); + } + + /** + * test simple object variable with method + */ + public function testObjectVariableOutputVariableMethod() + { + $object = new VariableObject; + $this->smarty->disableSecurity(); + $tpl = $this->smarty->createTemplate('string:{$p=\'myhello\'}{$object->$p()}'); + $tpl->assign('object', $object); + $this->assertEquals('hello world', $this->smarty->fetch($tpl)); + } + + /** + * test object variable in double quoted string + */ + public function testObjectVariableOutputDoubleQuotes() + { + $object = new VariableObject; + $tpl = $this->smarty->createTemplate('string:{"double quoted `$object->hello` okay"}'); + $tpl->assign('object', $object); + $this->assertEquals('double quoted hello_world okay', $this->smarty->fetch($tpl)); + } + + /** + * test object variable in double quoted string as include name + */ + public function testObjectVariableOutputDoubleQuotesInclude() + { + $object = new VariableObject; + $tpl = $this->smarty->createTemplate('string:{include file="`$object->hello`_test.tpl"}'); + $tpl->assign('object', $object); + $this->assertEquals('hello world', $this->smarty->fetch($tpl)); + } +} + +Class VariableObject +{ + public $hello = 'hello_world'; + + public function myhello() + { + return 'hello world'; + } +} diff --git a/tests/UnitTests/TemplateSource/ValueTests/Objects/cache/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/Objects/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Objects/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/Objects/templates/hello_world_test.tpl b/tests/UnitTests/TemplateSource/ValueTests/Objects/templates/hello_world_test.tpl new file mode 100644 index 00000000..95d09f2b --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Objects/templates/hello_world_test.tpl @@ -0,0 +1 @@ +hello world
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/ValueTests/Objects/templates_c/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/Objects/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Objects/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/PHPfunctions/PhpFunctionTest.php b/tests/UnitTests/TemplateSource/ValueTests/PHPfunctions/PhpFunctionTest.php new file mode 100644 index 00000000..8892a542 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/PHPfunctions/PhpFunctionTest.php @@ -0,0 +1,186 @@ +<?php +/** + * Smarty PHPunit tests of modifier + * + * @package PHPunit + * @author Rodney Rehm + */ + +/** + * class for modifier tests + * + * + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class PhpFunctionTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * test PHP empty() on variables true + */ + public function testEmpty1() + { + $this->smarty->disableSecurity(); + $this->smarty->assign('var', array(null, + false, + (int) 0, + (float) 0.0, + '', + array())); + $expected = ' true , true , true , true , true , true , true , true '; + $this->assertEquals($expected, $this->smarty->fetch('string:{strip}{if empty($var[0])} true {else} false {/IF} + ,{if empty($var[1])} true {else} false {/IF} + ,{if empty($var[2])} true {else} false {/IF} + ,{if empty($var[3])} true {else} false {/IF} + ,{if empty($var[4])} true {else} false {/IF} + ,{if empty($var[5])} true {else} false {/IF} + ,{if empty($var[6])} true {else} false {/IF} + ,{if empty($varr)} true {else} false {/IF} + ')); + } + + /** + * test PHP empty() on function result true + */ + public function testEmpty2() + { + if (version_compare(phpversion(), '5.5', '<')) { + $this->markTestSkipped('runs only on PHP > 5.5'); + } + + $this->smarty->disableSecurity(); + $this->smarty->assign('var', array(null, + false, + (int) 0, + (float) 0.0, + '', + array())); + $expected = ' true , true , true , true , true , true '; + $this->assertEquals($expected, $this->smarty->fetch('string:{strip}{if empty(pass($var[0]))} true {else} false {/IF} + ,{if empty(pass($var[1]))} true {else} false {/IF} + ,{if empty(pass($var[2]))} true {else} false {/IF} + ,{if empty(pass($var[3]))} true {else} false {/IF} + ,{if empty(pass($var[4]))} true {else} false {/IF} + ,{if empty(pass($var[5]))} true {else} false {/IF} + ')); + } + /** + * test PHP empty() on function result false + */ + public function testEmpty3() + { + if (version_compare(phpversion(), '5.5', '<')) { + $this->markTestSkipped('runs only on PHP > 5.5'); + } + $this->smarty->disableSecurity(); + $this->smarty->assign('var', array(true, + (int) 1, + (float) 0.1, + ' ', + array(1))); + $expected = ' false , false , false , false , false '; + $this->assertEquals($expected, $this->smarty->fetch('string:{strip}{if empty(pass($var[0]))} true {else} false {/IF} + ,{if empty(pass($var[1]))} true {else} false {/IF} + ,{if empty(pass($var[2]))} true {else} false {/IF} + ,{if empty(pass($var[3]))} true {else} false {/IF} + ,{if empty(pass($var[4]))} true {else} false {/IF} + ')); + } + /** + * test PHP empty() on object + */ + public function testEmpty4() + { + if (version_compare(phpversion(), '5.5', '<')) { + $this->markTestSkipped('runs only on PHP > 5.5'); + } + + $this->smarty->disableSecurity(); + $this->smarty->assign('var', new TestIsset()); + $expected = ' true , false , false , true , true , true , false '; + $this->assertEquals($expected, $this->smarty->fetch('string:{strip}{if empty($var->isNull)} true {else} false {/IF} + ,{if empty($var->isSet)} true {else} false {/IF} + ,{if empty($var->arr[\'isSet\'])} true {else} false {/IF} + ,{if empty($var->arr[\'isNull\'])} true {else} false {/IF} + ,{if empty($var->arr[\'foo\'])} true {else} false {/IF} + ,{if empty($var->pass(null))} true {else} false {/IF} + ,{if empty($var->pass(1))} true {else} false {/IF} + ')); + } + /** + * test PHP isset() on variables and functions + */ + public function testIsset1() + { + $this->smarty->disableSecurity(); + $this->smarty->assign('isNull', null); + $this->smarty->assign('isSet', 1); + $this->smarty->assign('arr', array('isNull' => null, 'isSet' => 1)); + $expected = ' false , true , false , true , false , false , false , true '; + $this->assertEquals($expected, $this->smarty->fetch('string:{strip}{if isset($isNull)} true {else} false {/IF} + ,{if isset($isSet)} true {else} false {/IF} + ,{if isset($foo)} true {else} false {/IF} + ,{if isset($arr[\'isSet\'])} true {else} false {/IF} + ,{if isset($arr[\'isNull\'])} true {else} false {/IF} + ,{if isset($arr[\'foo\'])} true {else} false {/IF} + ,{if isset(pass(null))} true {else} false {/IF} + ,{if isset(pass(1))} true {else} false {/IF} + ')); + } + /** + * test PHP isset() on object + */ + public function testIsset2() + { + $this->smarty->disableSecurity(); + $this->smarty->assign('var', new TestIsset()); + $expected = ' false , true , true , false , false , false , true '; + $this->assertEquals($expected, $this->smarty->fetch('string:{strip}{if isset($var->isNull)} true {else} false {/IF} + ,{if isset($var->isSet)} true {else} false {/IF} + ,{if isset($var->arr[\'isSet\'])} true {else} false {/IF} + ,{if isset($var->arr[\'isNull\'])} true {else} false {/IF} + ,{if isset($var->arr[\'foo\'])} true {else} false {/IF} + ,{if isset($var->pass(null))} true {else} false {/IF} + ,{if isset($var->pass(1))} true {else} false {/IF} + ')); + } +} + +/** + * @param mixed $v + * + * @return mixed + */ +function pass($v) { + return $v; +} + +/** + * Class TestIsset + */ +class TestIsset { + public $isNull = null; + public $isSet = 1; + public $arr = array('isNull' => null, 'isSet' => 1); + + /** + * @param mixed $v + * + * @return mixed + */ + public function pass($v) { + return $v; + } +}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/ValueTests/PHPfunctions/cache/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/PHPfunctions/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/PHPfunctions/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/PHPfunctions/templates_c/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/PHPfunctions/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/PHPfunctions/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/SingleQouted/SingleQuotedStringTest.php b/tests/UnitTests/TemplateSource/ValueTests/SingleQouted/SingleQuotedStringTest.php new file mode 100644 index 00000000..41378e1b --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SingleQouted/SingleQuotedStringTest.php @@ -0,0 +1,81 @@ +<?php +/** + * Smarty PHPunit tests single quoted strings + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for single quoted string tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class SingleQuotedStringTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * test simple single quoted string + */ + public function testSimpleSingleQuotedString() + { + $tpl = $this->smarty->createTemplate('eval:{$foo=\'Hello World\'}{$foo}'); + $this->assertEquals('Hello World', $this->smarty->fetch($tpl)); + } + + /** + * test that tags not interpreted in single quoted strings + */ + public function testTagsInSingleQuotedString() + { + $tpl = $this->smarty->createTemplate('eval:{$foo=\'Hello {1+2} World\'}{$foo}'); + $this->assertEquals('Hello {1+2} World', $this->smarty->fetch($tpl)); + } + + /** + * test that vars not interpreted in single quoted strings + */ + public function testVarsInSingleQuotedString() + { + $tpl = $this->smarty->createTemplate('eval:{$foo=\'Hello $bar World\'}{$foo}'); + $this->assertEquals('Hello $bar World', $this->smarty->fetch($tpl)); + } + + /** + * test double quotes in single quoted strings + */ + public function testDoubleQuotesInSingleQuotedString() + { + $tpl = $this->smarty->createTemplate('eval:{$foo=\'Hello "World"\'}{$foo}'); + $this->assertEquals('Hello "World"', $this->smarty->fetch($tpl)); + } + + /** + * test escaped single quotes in single quoted strings + */ + public function testEscapedSingleQuotesInSingleQuotedString() + { + $tpl = $this->smarty->createTemplate('eval:{$foo=\'Hello \\\'World\'}{$foo}'); + $this->assertEquals("Hello 'World", $this->smarty->fetch($tpl)); + } + + /** + * test empty single quoted strings + */ + public function testEmptySingleQuotedString() + { + $tpl = $this->smarty->createTemplate('eval:{$foo=\'\'}{$foo}'); + $this->assertEquals("", $this->smarty->fetch($tpl)); + } +} diff --git a/tests/UnitTests/TemplateSource/ValueTests/SingleQouted/cache/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/SingleQouted/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SingleQouted/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/SingleQouted/templates_c/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/SingleQouted/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SingleQouted/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Constant/SmartyConstantTest.php b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Constant/SmartyConstantTest.php new file mode 100644 index 00000000..179f7123 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Constant/SmartyConstantTest.php @@ -0,0 +1,45 @@ +<?php +/** + * Smarty PHPunit tests {$smarty.constant.foo} + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for {$smarty.constant.foo} tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class SmartyConstantTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test {$smarty.constant.foo} + * + */ + public function testSmartyConstant() { + define('MY_CONST_VAL','MyConstant'); + + $this->assertEquals('MyConstant', $this->smarty->fetch('constant.tpl')); + } + /** + * test {$smarty.constant.foo} + * + */ + public function testSmartyConstantVariable() { + define('MY_CONST_VAL2','MyConstantVar'); + $this->smarty->assign('foo', 'MY_CONST_VAL2'); + $this->assertEquals('MyConstantVar', $this->smarty->fetch('constant_variable.tpl')); + } + } diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Constant/cache/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Constant/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Constant/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Constant/templates/constant.tpl b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Constant/templates/constant.tpl new file mode 100644 index 00000000..4349b8c1 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Constant/templates/constant.tpl @@ -0,0 +1 @@ +{$smarty.const.MY_CONST_VAL}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Constant/templates/constant_variable.tpl b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Constant/templates/constant_variable.tpl new file mode 100644 index 00000000..4166c879 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Constant/templates/constant_variable.tpl @@ -0,0 +1 @@ +{$smarty.const.$foo}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Constant/templates_c/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Constant/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Constant/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/CookieTest.php b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/CookieTest.php new file mode 100644 index 00000000..cb92b776 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/CookieTest.php @@ -0,0 +1,84 @@ +<?php +/** + * Smarty PHPunit tests {$smarty.cookies.foo} + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for $smarty.cookies.foo} tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class CookieTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test cookies + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataProvider + */ + public function testCookie($caching, $value) { + $_COOKIE['fooBar'] = $value; + $this->smarty->caching = $caching; + $this->assertEquals($value, $this->smarty->fetch('cookie.tpl')); + } + /** + * test variable cookies + * + */ + public function testCookieVariable() { + $_COOKIE['fooBarVar'] = 'fooBarVarValue'; + $this->smarty->assign('foo', 'fooBarVar'); + $this->assertEquals('fooBarVarValue', $this->smarty->fetch('cookie_variable.tpl')); + } + + /** + * test cookies with modifier + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataProviderModifier + */ + public function testCookieModifier($caching, $value, $result) { + $_COOKIE['fooBar'] = $value; + $this->smarty->caching = $caching; + $this->assertEquals($result, $this->smarty->fetch('cookie_modifier.tpl')); + } + + /** + * data provider + */ + public function dataProvider() + { + return array( + 'compile' => array(false, 'buh'), + 'compiled' => array(false, 'bar'), + 'create cache' => array(true, 'cached buh'), + 'cacheded' => array(true, 'cached bar'), + ); + } + public function dataProviderModifier() + { + return array( + 'compile' => array(false, 'buh', 3), + 'compiled' => array(false, 'bar1', 4), + 'create cache' => array(true, 'cached buh', 10), + 'cacheded' => array(true, 'cached bar1', 11), + ); + } + +} diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/cache/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/templates/cookie.tpl b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/templates/cookie.tpl new file mode 100644 index 00000000..9f206d7b --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/templates/cookie.tpl @@ -0,0 +1 @@ +{$smarty.cookies.fooBar nocache}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/templates/cookie_modifier.tpl b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/templates/cookie_modifier.tpl new file mode 100644 index 00000000..7ed949ef --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/templates/cookie_modifier.tpl @@ -0,0 +1 @@ +{$smarty.cookies.fooBar|strlen nocache}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/templates/cookie_variable.tpl b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/templates/cookie_variable.tpl new file mode 100644 index 00000000..6a135606 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/templates/cookie_variable.tpl @@ -0,0 +1 @@ +{$smarty.cookies.$foo}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/templates_c/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Delimiter/SmartyDelimiterTest.php b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Delimiter/SmartyDelimiterTest.php new file mode 100644 index 00000000..3a298362 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Delimiter/SmartyDelimiterTest.php @@ -0,0 +1,34 @@ +<?php +/** + * Smarty PHPunit tests {$smarty.ldelim} {$smarty.rdelim} + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for {$smarty.ldelim} {$smarty.rdelim} tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class SmartyDelimiterTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test {$smarty.ldelim} {$smarty.rdelim} + * + */ + public function testSmartyDelimiter() { + $this->assertEquals('left = { right = }', $this->smarty->fetch('delimiter.tpl')); + } + } diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Delimiter/cache/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Delimiter/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Delimiter/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Delimiter/templates/delimiter.tpl b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Delimiter/templates/delimiter.tpl new file mode 100644 index 00000000..937b53fc --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Delimiter/templates/delimiter.tpl @@ -0,0 +1 @@ +left = {$smarty.ldelim} right = {$smarty.rdelim}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Delimiter/templates_c/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Delimiter/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Delimiter/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Error/SmartyErrorTest.php b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Error/SmartyErrorTest.php new file mode 100644 index 00000000..b14c271c --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Error/SmartyErrorTest.php @@ -0,0 +1,36 @@ +<?php +/** + * Smarty PHPunit tests undefined Smarty special variable + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for undefined Smarty special variable tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class SmartyErrorTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + /** + * @expectedException SmartyException + * @expectedExceptionMessage $smarty.foo is not defined + * test undefined Smarty special variable + * + */ + public function testSmartyError() { + $this->assertEquals(Smarty::SMARTY_VERSION, $this->smarty->fetch('error.tpl')); + } + } diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Error/cache/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Error/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Error/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Error/templates/error.tpl b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Error/templates/error.tpl new file mode 100644 index 00000000..7c541f67 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Error/templates/error.tpl @@ -0,0 +1 @@ +{$smarty.foo}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Error/templates_c/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Error/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Error/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Now/SmartyNowTest.php b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Now/SmartyNowTest.php new file mode 100644 index 00000000..724f2bf5 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Now/SmartyNowTest.php @@ -0,0 +1,50 @@ +<?php +/** + * Smarty PHPunit tests {$smarty.now} + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for {$smarty.now} tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class SmartyNowTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test {$smarty.now} + * + */ + public function testSmartyNow() { + $result = $this->smarty->fetch('now.tpl'); + $this->assertTrue(is_numeric($result)); + $this->assertTrue((time() - $result) <= 1); + } + /** + * test {$smarty.now nocache} + * + */ + public function testSmartyNowNocache() { + $this->smarty->setCaching(true); + $result = $this->smarty->fetch('now_nocache.tpl'); + $this->assertTrue(is_numeric($result)); + $this->assertTrue((time() - $result) <= 1); + sleep(2); + $result2 = $this->smarty->fetch('now_nocache.tpl'); + $this->assertTrue(is_numeric($result2)); + $this->assertTrue((time() - $result2) <= 1); + } +} diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Now/cache/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Now/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Now/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Now/templates/now.tpl b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Now/templates/now.tpl new file mode 100644 index 00000000..057fabdf --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Now/templates/now.tpl @@ -0,0 +1 @@ +{$smarty.now}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Now/templates/now_nocache.tpl b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Now/templates/now_nocache.tpl new file mode 100644 index 00000000..3d450d50 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Now/templates/now_nocache.tpl @@ -0,0 +1 @@ +{$smarty.now nocache}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Now/templates_c/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Now/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Now/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/PostTest.php b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/PostTest.php new file mode 100644 index 00000000..a49e44d8 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/PostTest.php @@ -0,0 +1,84 @@ +<?php +/** + * Smarty PHPunit tests {$smarty.post.foo} + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for {$smarty.post.foo} tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class PostTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test $_POST + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataProvider + */ + public function testPost($caching, $value) { + $_POST['fooBar'] = $value; + $this->smarty->caching = $caching; + $this->assertEquals($value, $this->smarty->fetch('post.tpl')); + } + + /** + * test $_POST with modifier + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataProviderModifier + */ + public function testPostModifier($caching, $value, $result) { + $_POST['fooBar'] = $value; + $this->smarty->caching = $caching; + $this->assertEquals($result, $this->smarty->fetch('post_modifier.tpl')); + } + + /** + * test variable post + * + */ + public function testPostVariable() { + $_POST['fooBarVar'] = 'fooBarVarValue'; + $this->smarty->assign('foo', 'fooBarVar'); + $this->assertEquals('fooBarVarValue', $this->smarty->fetch('post_variable.tpl')); + } + /** + * data provider + */ + public function dataProvider() + { + return array( + 'compile' => array(false, 'buh'), + 'compiled' => array(false, 'bar'), + 'create cache' => array(true, 'cached buh'), + 'cacheded' => array(true, 'cached bar'), + ); + } + public function dataProviderModifier() + { + return array( + 'compile' => array(false, 'buh', 3), + 'compiled' => array(false, 'bar1', 4), + 'create cache' => array(true, 'cached buh', 10), + 'cacheded' => array(true, 'cached bar1', 11), + ); + } + +} diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/cache/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/templates/post.tpl b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/templates/post.tpl new file mode 100644 index 00000000..fa50e50a --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/templates/post.tpl @@ -0,0 +1 @@ +{$smarty.post.fooBar nocache}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/templates/post_modifier.tpl b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/templates/post_modifier.tpl new file mode 100644 index 00000000..8078b898 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/templates/post_modifier.tpl @@ -0,0 +1 @@ +{$smarty.post.fooBar|strlen nocache}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/templates/post_variable.tpl b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/templates/post_variable.tpl new file mode 100644 index 00000000..98388615 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/templates/post_variable.tpl @@ -0,0 +1 @@ +{$smarty.post.$foo}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/templates_c/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/TemplateObject/SmartyTemplateObjectTest.php b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/TemplateObject/SmartyTemplateObjectTest.php new file mode 100644 index 00000000..6f661b4d --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/TemplateObject/SmartyTemplateObjectTest.php @@ -0,0 +1,34 @@ +<?php +/** + * Smarty PHPunit tests {$smarty.template_objects} + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for {$smarty.template_objects} tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class SmartyTemplateObjectTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test {$smarty.template_objects} + * + */ + public function testSmartyTempalteObject() { + $this->assertEquals('okay', $this->smarty->fetch('template_object.tpl')); + } + } diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/TemplateObject/cache/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/TemplateObject/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/TemplateObject/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/TemplateObject/templates/template_object.tpl b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/TemplateObject/templates/template_object.tpl new file mode 100644 index 00000000..08babe7e --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/TemplateObject/templates/template_object.tpl @@ -0,0 +1 @@ +{if $smarty.template_object instanceof Smarty_Internal_Template}okay{/if}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/TemplateObject/templates_c/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/TemplateObject/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/TemplateObject/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Version/SmartyVersionTest.php b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Version/SmartyVersionTest.php new file mode 100644 index 00000000..733609a3 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Version/SmartyVersionTest.php @@ -0,0 +1,34 @@ +<?php +/** + * Smarty PHPunit tests {$smarty.version} + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for {$smarty.version} tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class SmartyVersionTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test {$smarty.version} + * + */ + public function testSmartyVersion() { + $this->assertEquals(Smarty::SMARTY_VERSION, $this->smarty->fetch('version.tpl')); + } + } diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Version/cache/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Version/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Version/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Version/templates/version.tpl b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Version/templates/version.tpl new file mode 100644 index 00000000..b78488a3 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Version/templates/version.tpl @@ -0,0 +1 @@ +{$smarty.version}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Version/templates_c/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Version/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Version/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/Variables/Stream/StreamVariableTest.php b/tests/UnitTests/TemplateSource/ValueTests/Variables/Stream/StreamVariableTest.php new file mode 100644 index 00000000..670324f1 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Variables/Stream/StreamVariableTest.php @@ -0,0 +1,137 @@ +<?php +/** + * Smarty PHPunit tests stream variables + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for stream variables tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class StreamVariableTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + + stream_wrapper_register("var", "VariableStream") + or die("Failed to register protocol"); + $fp = fopen("var://foo", "r+"); + fwrite($fp, 'hello world'); + fclose($fp); + } + + public function testInit() + { + $this->cleanDirs(); + } + + public function tearDown() + { + parent::tearDown(); + stream_wrapper_unregister("var"); + } + + /** + * test stream variable + */ + public function testStreamVariable1() + { + $tpl = $this->smarty->createTemplate('eval:{$var:foo}', null, null, $this->smarty); + $this->assertEquals('hello world', $this->smarty->fetch($tpl)); + } + /* + public function testStreamVariable2() + { + $tpl = $this->smarty->createTemplate('eval:{var:\'foo\'}', null, null, $this->smarty); + $this->assertEquals('hello world', $this->smarty->fetch($tpl)); + } + + public function testStreamVariable3() + { + $tpl = $this->smarty->createTemplate('eval:{var:"foo"}', null, null, $this->smarty); + $this->assertEquals('hello world', $this->smarty->fetch($tpl)); + } + */ + /** + * test no existant stream variable + */ + // public function testStreamVariable2() + // { + // $tpl = $this->smarty->createTemplate('eval:{$var:bar}', null, null, $this->smarty); + // $this->assertEquals('', $this->smarty->fetch($tpl)); + // } +} + +class VariableStream +{ + private $position; + private $varname; + + public function stream_open($path, $mode, $options, &$opened_path) + { + $url = parse_url($path); + $this->varname = $url["host"]; + $this->position = 0; + + return true; + } + + public function stream_read($count) + { + $p = &$this->position; + $ret = substr($GLOBALS[$this->varname], $p, $count); + $p += strlen($ret); + + return $ret; + } + + public function stream_write($data) + { + $v = &$GLOBALS[$this->varname]; + $l = strlen($data); + $p = &$this->position; + $v = substr($v, 0, $p) . $data . substr($v, $p += $l); + + return $l; + } + + public function stream_tell() + { + return $this->position; + } + + public function stream_eof() + { + return $this->position >= strlen($GLOBALS[$this->varname]); + } + + public function stream_seek($offset, $whence) + { + $l = strlen($GLOBALS[$this->varname]); + $p = &$this->position; + switch ($whence) { + case SEEK_SET: + $newPos = $offset; + break; + case SEEK_CUR: + $newPos = $p + $offset; + break; + case SEEK_END: + $newPos = $l + $offset; + break; + default: + return false; + } + $ret = ($newPos >= 0 && $newPos <= $l); + if ($ret) { + $p = $newPos; + } + return $ret; + } +} diff --git a/tests/UnitTests/TemplateSource/ValueTests/Variables/Stream/cache/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/Variables/Stream/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Variables/Stream/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/Variables/Stream/templates_c/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/Variables/Stream/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Variables/Stream/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/Variables/VariableVariable/VariableVariableTest.php b/tests/UnitTests/TemplateSource/ValueTests/Variables/VariableVariable/VariableVariableTest.php new file mode 100644 index 00000000..cbd7c662 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Variables/VariableVariable/VariableVariableTest.php @@ -0,0 +1,63 @@ +<?php +/** + * Smarty PHPunit tests variable variables + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for variable variables tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class VariableVariableTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * test variable name in variable + */ + public function testVariableVariable1() + { + $tpl = $this->smarty->createTemplate('eval:{$foo=\'bar\'}{$bar=123}{${$foo}}'); + $this->assertEquals('123', $this->smarty->fetch($tpl)); + } + + /** + * test part of variable name in variable + */ + public function testVariableVariable2() + { + $tpl = $this->smarty->createTemplate('eval:{$foo=\'a\'}{$bar=123}{$b{$foo}r}'); + $this->assertEquals('123', $this->smarty->fetch($tpl)); + } + + /** + * test several parts of variable name in variable + */ + public function testVariableVariable3() + { + $tpl = $this->smarty->createTemplate('eval:{$foo=\'a\'}{$foo2=\'r\'}{$bar=123}{$b{$foo}{$foo2}}'); + $this->assertEquals('123', $this->smarty->fetch($tpl)); + } + + /** + * test nesed parts of variable name in variable + */ + public function testVariableVariable4() + { + $tpl = $this->smarty->createTemplate('eval:{$foo=\'ar\'}{$foo2=\'oo\'}{$bar=123}{$b{$f{$foo2}}}'); + $this->assertEquals('123', $this->smarty->fetch($tpl)); + } +} diff --git a/tests/UnitTests/TemplateSource/ValueTests/Variables/VariableVariable/cache/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/Variables/VariableVariable/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Variables/VariableVariable/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/ValueTests/Variables/VariableVariable/templates_c/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/Variables/VariableVariable/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Variables/VariableVariable/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/X_Scopes/ScopeTest.php b/tests/UnitTests/TemplateSource/X_Scopes/ScopeTest.php new file mode 100644 index 00000000..e546b670 --- /dev/null +++ b/tests/UnitTests/TemplateSource/X_Scopes/ScopeTest.php @@ -0,0 +1,299 @@ +<?php +/** + * Smarty PHPunit tests for scopes + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class scope tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class ScopeTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + $this->smarty->addPluginsDir("../../__shared/PHPunitplugins/"); + $this->smarty->addTemplateDir("../../__shared/templates/"); + $this->smarty->addTemplateDir("./templates_tmp"); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * Test scope + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestAppendScope + */ + public function testAppendScope($code, $useSmarty, $result, $testName, $testNumber) + { + $file = "testAppendScope_{$testNumber}.tpl"; + $this->makeTemplateFile($file, $code . '{checkvar var=foo}'); + $this->smarty->assignGlobal('file', $file); + $this->smarty->assign('foo', 'smarty'); + $this->smarty->assignGlobal('foo', 'global'); + $data1 = $this->smarty->createData($useSmarty ? $this->smarty : null); + $data = $this->smarty->createData($data1); + $data1->assign('foo', 'data1'); + $data->assign('foo', 'data'); + $this->assertEquals($result, $this->smarty->fetch('scope_tag.tpl', $data), + "test - {$code} - {$testName}"); + } + + /* + * Data provider für testAppendScope + */ + public function dataTestAppendScope() + { + $i = 0; + /* + * Code + * use Smarty object + * result + * test name + */ + return array(array('{$foo[] = \'newvar\' scope=tpl_root}', true, + '#testAppendScope_0.tpl:$foo =array(0=>\'data\',1=>\'newvar\',)#scope_include.tpl:$foo =array(0=>\'data\',1=>\'newvar\',)#scope_tag.tpl:$foo =array(0=>\'data\',1=>\'newvar\',)#data:$foo =\'data\'#data:$foo =\'data1\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'', + '', $i ++,), + array('{append var=foo value=\'newvar\' scope=tpl_root}', true, + '#testAppendScope_1.tpl:$foo =array(0=>\'data\',1=>\'newvar\',)#scope_include.tpl:$foo =array(0=>\'data\',1=>\'newvar\',)#scope_tag.tpl:$foo =array(0=>\'data\',1=>\'newvar\',)#data:$foo =\'data\'#data:$foo =\'data1\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'', + '', $i ++,), + array('{append var=foo value=\'newvar\' scope=global}', true, + '#testAppendScope_2.tpl:$foo =array(0=>\'data\',1=>\'newvar\',)#scope_include.tpl:$foo =array(0=>\'data\',1=>\'newvar\',)#scope_tag.tpl:$foo =array(0=>\'data\',1=>\'newvar\',)#data:$foo =\'data\'#data:$foo =\'data1\'#Smarty:$foo =\'smarty\'#global:$foo =array(0=>\'data\',1=>\'newvar\',)', + '', $i ++,), + array('{append var=foo value=\'newvar\' scope=smarty}', true, + '#testAppendScope_3.tpl:$foo =array(0=>\'data\',1=>\'newvar\',)#scope_include.tpl:$foo =array(0=>\'data\',1=>\'newvar\',)#scope_tag.tpl:$foo =array(0=>\'data\',1=>\'newvar\',)#data:$foo =\'data\'#data:$foo =\'data1\'#Smarty:$foo =array(0=>\'data\',1=>\'newvar\',)#global:$foo =\'global\'', + '', $i ++,),); + } + + /** + * Test scope + * + * @not runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestAssignScope + */ + public function testAssignScope($code, $useSmarty, $result, $testName, $testNumber) + { + $file = "testAssignScope_{$testNumber}.tpl"; + $this->makeTemplateFile($file, $code . '{checkvar var=foo}'); + $this->smarty->assignGlobal('file', $file); + $this->smarty->assign('foo', 'smarty'); + $this->smarty->assignGlobal('foo', 'global'); + $data = $this->smarty->createData($useSmarty ? $this->smarty : null); + $data->assign('foo', 'data'); + $this->assertEquals('#' . $file . $result, + $this->smarty->fetch('scope_tag.tpl', $data), "test - {$code} - {$testName}"); + } + + /* + * Data provider für testAssignScope + */ + public function dataTestAssignScope() + { + $i = 0; + /* + * Code + * use Smarty object + * result + * test name + */ + return array(array('{$foo = \'newvar\'}', true, + ':$foo =\'newvar\'#scope_include.tpl:$foo =\'data\'#scope_tag.tpl:$foo =\'data\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'', + '', $i ++,), array('{assign var=foo value=\'newvar\'}', true, + ':$foo =\'newvar\'#scope_include.tpl:$foo =\'data\'#scope_tag.tpl:$foo =\'data\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'', + '', $i ++,), array('{$foo = \'newvar\' scope=local}', true, + ':$foo =\'newvar\'#scope_include.tpl:$foo =\'data\'#scope_tag.tpl:$foo =\'data\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'', + '', $i ++,), + array('{assign var=foo value=\'newvar\' scope=local}', true, + ':$foo =\'newvar\'#scope_include.tpl:$foo =\'data\'#scope_tag.tpl:$foo =\'data\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'', + '', $i ++,), array('{$foo = \'newvar\' scope=parent}', true, + ':$foo =\'newvar\'#scope_include.tpl:$foo =\'newvar\'#scope_tag.tpl:$foo =\'data\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'', + '', $i ++,), array('{assign var=foo value=\'newvar\' scope=parent}', true, + ':$foo =\'newvar\'#scope_include.tpl:$foo =\'newvar\'#scope_tag.tpl:$foo =\'data\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'', + '', $i ++,), + array('{$foo = \'newvar\' scope=tpl_root}', true, + ':$foo =\'newvar\'#scope_include.tpl:$foo =\'newvar\'#scope_tag.tpl:$foo =\'newvar\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'', + '', $i ++,), array('{$foo = \'newvar\' scope=global}', true, + ':$foo =\'newvar\'#scope_include.tpl:$foo =\'newvar\'#scope_tag.tpl:$foo =\'newvar\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'#global:$foo =\'newvar\'', + '', $i ++,), array('{$foo = \'newvar\' scope=root}', true, + ':$foo =\'newvar\'#scope_include.tpl:$foo =\'newvar\'#scope_tag.tpl:$foo =\'newvar\'#data:$foo =\'newvar\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'', + '', $i ++,), + array('{$foo = \'newvar\' scope=root}', false, + ':$foo =\'newvar\'#scope_include.tpl:$foo =\'newvar\'#scope_tag.tpl:$foo =\'newvar\'#data:$foo =\'newvar\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'', + 'no smarty', $i ++,), array('{$foo = \'newvar\' scope=smarty}', false, + ':$foo =\'newvar\'#scope_include.tpl:$foo =\'newvar\'#scope_tag.tpl:$foo =\'newvar\'#data:$foo =\'data\'#Smarty:$foo =\'newvar\'#global:$foo =\'global\'', + 'no smarty', $i ++,),); + } + + /** + * Test scope nocache + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestScopeNocache + */ + public function testScopeNocache($var, $file, $result) + { + $this->smarty->setCaching(true); + $this->smarty->assign('bar', $var, true); + $this->smarty->assign('buh', $var); + $this->smarty->assign('foo', 'smarty'); + $this->smarty->assignGlobal('foo', 'global'); + $this->assertEquals($result, $this->smarty->fetch($file), "test - {$file} {$var}"); + } + + /* + * Data provider für testscopenocache + */ + public function dataTestScopeNocache() + { + /* + * variable value + * result + */ + return array(array('b1', 'test_scope_assignbar.tpl', + '#test_scope_assignbar.tpl:$foo =\'b1\'#Smarty:$foo =\'smarty\'#global:$foo =\'b1\'',), + array('b2', 'test_scope_assignbar.tpl', + '#test_scope_assignbar.tpl:$foo =\'b2\'#Smarty:$foo =\'smarty\'#global:$foo =\'b2\'',), + array('b1', 'test_scope_assignnocache.tpl', + '#test_scope_assignnocache.tpl:$foo =\'b1\'#Smarty:$foo =\'smarty\'#global:$foo =\'b1\'',), + array('b2', 'test_scope_assignnocache.tpl', + '#test_scope_assignnocache.tpl:$foo =\'b2\'#Smarty:$foo =\'smarty\'#global:$foo =\'b2\'',),); + } + + /** + * Test scope + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestIncludeScope + */ + public function testIncludeScope($code, $useSmarty, $result, $testName, $testNumber = null) + { + $file = "testIncludeScope_{$testNumber}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->assignGlobal('file', $file); + $this->smarty->assign('foo', 'smarty'); + $this->smarty->assignGlobal('foo', 'global'); + $data = $this->smarty->createData($useSmarty ? $this->smarty : null); + $data->assign('foo', 'data'); + if (!$useSmarty) { + $testName .= 'no smarty'; + } + $this->assertEquals($result, $this->smarty->fetch('test_scope.tpl', $data), + "test - {$code} - {$testName}"); + } + + /* + * Data provider for testIncludeScope + */ + public function dataTestIncludeScope() + { + $i = 0; + return array(/* + * Code + * use Smarty object + * result + * test name + */ + array('{include \'test_scope_assign.tpl\'}', true, + '#test_scope_assign.tpl:$foo =\'newvar\'#testIncludeScope_' . $i . + '.tpl:$foo =\'data\'#test_scope.tpl:$foo =\'data\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'', + '', $i ++), array('{include \'test_scope_assign.tpl\' scope=parent}', true, + '#test_scope_assign.tpl:$foo =\'newvar\'#testIncludeScope_' . $i . + '.tpl:$foo =\'newvar\'#test_scope.tpl:$foo =\'data\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'', + '', $i ++), + array('{include \'test_scope_assign.tpl\' scope=tpl_root}', true, + '#test_scope_assign.tpl:$foo =\'newvar\'#testIncludeScope_' . $i . + '.tpl:$foo =\'newvar\'#test_scope.tpl:$foo =\'newvar\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'', + '', $i ++), array('{include \'test_scope_assign.tpl\' scope=root}', true, + '#test_scope_assign.tpl:$foo =\'newvar\'#testIncludeScope_' . $i . + '.tpl:$foo =\'newvar\'#test_scope.tpl:$foo =\'newvar\'#data:$foo =\'newvar\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'', + '', $i ++), array('{include \'test_scope_assign.tpl\' scope=root}', false, + '#test_scope_assign.tpl:$foo =\'newvar\'#testIncludeScope_' . + $i . + '.tpl:$foo =\'newvar\'#test_scope.tpl:$foo =\'newvar\'#data:$foo =\'newvar\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'', + '', $i ++), + array('{include \'test_scope_assign.tpl\' scope=smarty}', true, + '#test_scope_assign.tpl:$foo =\'newvar\'#testIncludeScope_' . $i . + '.tpl:$foo =\'newvar\'#test_scope.tpl:$foo =\'newvar\'#data:$foo =\'data\'#Smarty:$foo =\'newvar\'#global:$foo =\'global\'', + '', $i ++), array('{include \'test_scope_assign.tpl\' scope=global}', true, + '#test_scope_assign.tpl:$foo =\'newvar\'#testIncludeScope_' . $i . + '.tpl:$foo =\'newvar\'#test_scope.tpl:$foo =\'newvar\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'#global:$foo =\'newvar\'', + '', $i ++), + array('{include \'test_scope_pluginassign.tpl\' scope=global}', true, + '#test_scope_pluginassign.tpl:$foo =\'newvar\'#testIncludeScope_' . $i . + '.tpl:$foo =\'newvar\'#test_scope.tpl:$foo =\'newvar\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'#global:$foo =\'newvar\'', + '', $i ++), array('{include \'test_scope_assign_noscope.tpl\' scope=root}', true, + '#test_scope_assign_noscope.tpl:$foo =\'newvar\'#testIncludeScope_' . $i . + '.tpl:$foo =\'data\'#test_scope.tpl:$foo =\'data\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'', + '', $i ++),); + } + + /** + * Test scope + * + * @not runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestConfigScope + */ + public function testConfigScope($code, $useSmarty, $result, $testName, $testNumber) + { + $file = "testConfigScope_{$testNumber}.tpl"; + $this->makeTemplateFile($file, $code . '{checkconfigvar var=foo}'); + $this->smarty->assignGlobal('file', $file); + $this->smarty->configLoad('smarty.conf'); + $data = $this->smarty->createData($useSmarty ? $this->smarty : null); + $data->configLoad('data.conf'); + $this->assertEquals('#' . $file . $result, + $this->smarty->fetch('scope_tag.tpl', $data), "test - {$code} - {$testName}"); + } + + /* + * Data provider für testConfigScope + */ + public function dataTestConfigScope() + { + $i = 0; + /* + * Code + * use Smarty object + * result + * test name + */ + return array(array('{config_load \'template.conf\'}', true, + ':$foo =\'newvar\'#scope_include.tpl:$foo =\'data\'#scope_tag.tpl:$foo =\'data\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'', + '', $i ++,), array('{config_load \'template.conf\' scope=local}', true, + ':$foo =\'newvar\'#scope_include.tpl:$foo =\'data\'#scope_tag.tpl:$foo =\'data\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'', + '', $i ++,), array('{config_load \'template.conf\' scope=parent}', true, + ':$foo =\'newvar\'#scope_include.tpl:$foo =\'newvar\'#scope_tag.tpl:$foo =\'data\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'', + '', $i ++,), + array('{config_load \'template.conf\' scope=tpl_root}', true, + ':$foo =\'newvar\'#scope_include.tpl:$foo =\'newvar\'#scope_tag.tpl:$foo =\'newvar\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'', + '', $i ++,), array('{config_load \'template.conf\' scope=root}', true, + ':$foo =\'newvar\'#scope_include.tpl:$foo =\'newvar\'#scope_tag.tpl:$foo =\'newvar\'#data:$foo =\'newvar\'#Smarty:$foo =\'smarty\'', + '', $i ++,), array('{config_load \'template.conf\' scope=root}', false, + ':$foo =\'newvar\'#scope_include.tpl:$foo =\'newvar\'#scope_tag.tpl:$foo =\'newvar\'#data:$foo =\'newvar\'#Smarty:$foo =\'smarty\'', + 'no smarty', $i ++,), + array('{config_load \'template.conf\' scope=smarty}', false, + ':$foo =\'newvar\'#scope_include.tpl:$foo =\'newvar\'#scope_tag.tpl:$foo =\'newvar\'#data:$foo =\'data\'#Smarty:$foo =\'newvar\'', + 'no smarty', $i ++,),); + } + + public function testFunctionScope() + { + $this->smarty->assign('scope', 'none'); + $r = $this->smarty->fetch('test_function_scope.tpl'); + } +} diff --git a/tests/UnitTests/TemplateSource/X_Scopes/cache/.gitignore b/tests/UnitTests/TemplateSource/X_Scopes/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/X_Scopes/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/X_Scopes/configs/data.conf b/tests/UnitTests/TemplateSource/X_Scopes/configs/data.conf new file mode 100644 index 00000000..c9349c71 --- /dev/null +++ b/tests/UnitTests/TemplateSource/X_Scopes/configs/data.conf @@ -0,0 +1 @@ +foo = data diff --git a/tests/UnitTests/TemplateSource/X_Scopes/configs/smarty.conf b/tests/UnitTests/TemplateSource/X_Scopes/configs/smarty.conf new file mode 100644 index 00000000..d65d1fd0 --- /dev/null +++ b/tests/UnitTests/TemplateSource/X_Scopes/configs/smarty.conf @@ -0,0 +1 @@ +foo = smarty diff --git a/tests/UnitTests/TemplateSource/X_Scopes/configs/template.conf b/tests/UnitTests/TemplateSource/X_Scopes/configs/template.conf new file mode 100644 index 00000000..303000d4 --- /dev/null +++ b/tests/UnitTests/TemplateSource/X_Scopes/configs/template.conf @@ -0,0 +1 @@ +foo = newvar diff --git a/tests/UnitTests/TemplateSource/X_Scopes/templates/test_function_scope.tpl b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_function_scope.tpl new file mode 100644 index 00000000..3aad88bf --- /dev/null +++ b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_function_scope.tpl @@ -0,0 +1,35 @@ +{strip} + {function 'a'} + {call 'b'} + {/function} +{function 'b'} + {include 'test_function_scope_include.tpl'} +{/function} +{function c} + {call $scope} +{/function} +{function 'none'} + {$foo = 'newvar'} + {checkvar var=foo} +{/function} +{function 'local'} + {$foo = 'newvar' scope='local'} + {checkvar var=foo} +{/function} +{function 'parent'} + {$foo = 'newvar' scope='parent'} + {checkvar var=foo} +{/function} +{function 'tpl_root'} + {$foo = 'newvar' scope='tpl_root'} + {checkvar var=foo} +{/function} +{function 'smarty'} + {$foo = 'newvar' scope='smarty'} + {checkvar var=foo} +{/function} +{function 'global'} + {$foo = 'newvar' scope='global'} + {checkvar var=foo} +{/function} +{call 'a'}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/X_Scopes/templates/test_function_scope_include.tpl b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_function_scope_include.tpl new file mode 100644 index 00000000..5428e13d --- /dev/null +++ b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_function_scope_include.tpl @@ -0,0 +1,2 @@ +{strip} + {call 'c'}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope.tpl b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope.tpl new file mode 100644 index 00000000..bfb1e6cb --- /dev/null +++ b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope.tpl @@ -0,0 +1 @@ +{include $file} diff --git a/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_assign.tpl b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_assign.tpl new file mode 100644 index 00000000..ae7268d8 --- /dev/null +++ b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_assign.tpl @@ -0,0 +1 @@ +{$foo = 'newvar'}{checkvar var=foo}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_assign_noscope.tpl b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_assign_noscope.tpl new file mode 100644 index 00000000..d3ff9f6a --- /dev/null +++ b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_assign_noscope.tpl @@ -0,0 +1 @@ +{$foo = 'newvar' noscope}{checkvar var=foo}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_assignbar.tpl b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_assignbar.tpl new file mode 100644 index 00000000..c0be3a40 --- /dev/null +++ b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_assignbar.tpl @@ -0,0 +1 @@ +{$foo = $bar scope=global}{checkvar var=foo nocache}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_assignnocache.tpl b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_assignnocache.tpl new file mode 100644 index 00000000..4bde90af --- /dev/null +++ b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_assignnocache.tpl @@ -0,0 +1 @@ +{$foo = $buh scope=global nocache}{checkvar var=foo nocache}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_pluginassign.tpl b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_pluginassign.tpl new file mode 100644 index 00000000..e19a560a --- /dev/null +++ b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_pluginassign.tpl @@ -0,0 +1 @@ +{pluginassign var=foo value='newvar'}{checkvar var=foo}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/X_Scopes/templates_c/.gitignore b/tests/UnitTests/TemplateSource/X_Scopes/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/X_Scopes/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/X_Scopes/templates_tmp/.gitignore b/tests/UnitTests/TemplateSource/X_Scopes/templates_tmp/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/X_Scopes/templates_tmp/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/Xml/XmlTest.php b/tests/UnitTests/TemplateSource/Xml/XmlTest.php new file mode 100644 index 00000000..9690a35c --- /dev/null +++ b/tests/UnitTests/TemplateSource/Xml/XmlTest.php @@ -0,0 +1,137 @@ +<?php +/** + * Smarty PHPunit tests of the <?xml...> tag handling + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for <?xml...> tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class XmlTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + $this->smarty->enableSecurity(); + $this->smarty->setForceCompile(true); + } + + + public function testInit() + { + $this->cleanDirs(); + } + /** + * test standard xml + */ + public function testXml() + { + $tpl = $this->smarty->createTemplate('xml.tpl'); + $this->assertEquals('<?xml version="1.0" encoding="UTF-8"?>', $this->smarty->fetch($tpl)); + } + + /** + * test standard xml Smarty::PHP_QUOTE + */ + public function testXmlPhpQuote() + { + $this->smarty->compile_id = 'PHP_QUOTE'; + $this->smarty->security_policy->php_handling = Smarty::PHP_QUOTE; + $tpl = $this->smarty->createTemplate('xml.tpl'); + $this->assertEquals('<?xml version="1.0" encoding="UTF-8"?>', $this->smarty->fetch($tpl)); + } + + /** + * test standard xml Smarty::PHP_ALLOW + */ + public function testXmlPhpAllow() + { + $this->smarty->compile_id = 'PHP_ALLOW'; + $this->smarty->security_policy->php_handling = Smarty::PHP_ALLOW; + $tpl = $this->smarty->createTemplate('xml.tpl'); + $this->assertEquals('<?xml version="1.0" encoding="UTF-8"?>', $this->smarty->fetch($tpl)); + } + + /** + * test xml caching + */ + public function testXmlCaching() + { + $this->smarty->security_policy->php_handling = Smarty::PHP_PASSTHRU; + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $content = $this->smarty->fetch('xml.tpl'); + $this->assertEquals('<?xml version="1.0" encoding="UTF-8"?>', $content); + } + /** + * test subtemplate xml caching + */ + public function testXmlCaching2() + { + $this->smarty->security_policy->php_handling = Smarty::PHP_PASSTHRU; + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $content = $this->smarty->fetch('xml_main.tpl'); + $this->assertEquals('<?xml version="1.0" encoding="UTF-8"?>', $content); + } + + /** + * test xml caching PhpQuote + */ + public function testXmlCachingPhpQuote() + { + $this->smarty->compile_id = 'PHP_QUOTE'; + $this->smarty->security_policy->php_handling = Smarty::PHP_QUOTE; + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $content = $this->smarty->fetch('xml.tpl'); + $this->assertEquals('<?xml version="1.0" encoding="UTF-8"?>', $content); + } + + /** + * test xml caching PhpAllow + */ + public function testXmlCachingPhpAllow() + { + $this->smarty->compile_id = 'PHP_ALLOW'; + $this->smarty->security_policy->php_handling = Smarty::PHP_ALLOW; + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $content = $this->smarty->fetch('xml.tpl'); + $this->assertEquals('<?xml version="1.0" encoding="UTF-8"?>', $content); + } + /** + * test xml with variable + */ + public function testXmlVariable() + { + $this->smarty->assign('foo','bar'); + $content = $this->smarty->fetch('xmlvar.tpl'); + $this->assertEquals('<?xml version="1.0" encoding="bar"?>', $content); + } + /** + * test xml with nocache variable + */ + public function testXmlVariableNocache1() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $this->smarty->assign('foo','bar',true); + $content = $this->smarty->fetch('xmlvar.tpl'); + $this->assertEquals('<?xml version="1.0" encoding="bar"?>', $content); + } + public function testXmlVariableNocache2() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $this->smarty->assign('foo','foo',true); + $content = $this->smarty->fetch('xmlvar.tpl'); + $this->assertEquals('<?xml version="1.0" encoding="foo"?>', $content); + } +} diff --git a/tests/UnitTests/TemplateSource/Xml/cache/.gitignore b/tests/UnitTests/TemplateSource/Xml/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/Xml/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/Xml/templates/xml.tpl b/tests/UnitTests/TemplateSource/Xml/templates/xml.tpl new file mode 100644 index 00000000..b994f536 --- /dev/null +++ b/tests/UnitTests/TemplateSource/Xml/templates/xml.tpl @@ -0,0 +1 @@ +<?xml version="1.0" encoding="UTF-8"?>
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/Xml/templates/xml_main.tpl b/tests/UnitTests/TemplateSource/Xml/templates/xml_main.tpl new file mode 100644 index 00000000..578dc4b8 --- /dev/null +++ b/tests/UnitTests/TemplateSource/Xml/templates/xml_main.tpl @@ -0,0 +1 @@ +{include 'xml.tpl'}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/Xml/templates/xmlvar.tpl b/tests/UnitTests/TemplateSource/Xml/templates/xmlvar.tpl new file mode 100644 index 00000000..254635ea --- /dev/null +++ b/tests/UnitTests/TemplateSource/Xml/templates/xmlvar.tpl @@ -0,0 +1 @@ +<?xml version="1.0" encoding="{$foo}"?>
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/Xml/templates_c/.gitignore b/tests/UnitTests/TemplateSource/Xml/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/Xml/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/_Issues/327/ModifierIssue327Test.php b/tests/UnitTests/TemplateSource/_Issues/327/ModifierIssue327Test.php new file mode 100644 index 00000000..ecbf045d --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/327/ModifierIssue327Test.php @@ -0,0 +1,33 @@ +<?php +/** + * Smarty PHPunit tests compiler errors + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for compiler tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class ModifierIssue327Test extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + + public function testModifier327() + { + $this->assertEquals('hello you', $this->smarty->fetch('string:{"hello world"|substr:0:-5|cat:"you"}')); + } + +} diff --git a/tests/UnitTests/TemplateSource/_Issues/327/cache/.gitignore b/tests/UnitTests/TemplateSource/_Issues/327/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/327/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/_Issues/327/templates_c/.gitignore b/tests/UnitTests/TemplateSource/_Issues/327/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/327/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/_Issues/419/ExtendsIssue419Test.php b/tests/UnitTests/TemplateSource/_Issues/419/ExtendsIssue419Test.php new file mode 100644 index 00000000..1f969291 --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/419/ExtendsIssue419Test.php @@ -0,0 +1,35 @@ +<?php +/** + * Smarty PHPunit tests compiler errors + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for compiler tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class ExtendsIssue419Test extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + + public function testextends419() + { + $this->smarty->left_delimiter = '{{'; + $this->smarty->right_delimiter = '}}'; + $this->assertEquals('child', $this->smarty->fetch('extends:001_parent.tpl|001_child.tpl')); + } + +} diff --git a/tests/UnitTests/TemplateSource/_Issues/419/cache/.gitignore b/tests/UnitTests/TemplateSource/_Issues/419/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/419/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/_Issues/419/templates/001_child.tpl b/tests/UnitTests/TemplateSource/_Issues/419/templates/001_child.tpl new file mode 100644 index 00000000..e9d4ff8f --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/419/templates/001_child.tpl @@ -0,0 +1 @@ +{{block name='b'}}child{{/block}}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/_Issues/419/templates/001_parent.tpl b/tests/UnitTests/TemplateSource/_Issues/419/templates/001_parent.tpl new file mode 100644 index 00000000..15ddde25 --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/419/templates/001_parent.tpl @@ -0,0 +1 @@ +{{block name='b'}}parent{{/block}}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/_Issues/419/templates_c/.gitignore b/tests/UnitTests/TemplateSource/_Issues/419/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/419/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/_Issues/422/NestedLoopIssue422Test.php b/tests/UnitTests/TemplateSource/_Issues/422/NestedLoopIssue422Test.php new file mode 100644 index 00000000..c541b3cb --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/422/NestedLoopIssue422Test.php @@ -0,0 +1,35 @@ +<?php +/** + * Smarty PHPunit tests compiler errors + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for compiler tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + * + * Problem with total property of {section} and {foreach} in nested loop + */ +class NestedLoopIssue422Test extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + + public function testnested422() + { + $this->assertEquals('loop: 1inner: 0loop: 2inner: 1', $this->smarty->fetch('422_test.tpl')); + } + +} diff --git a/tests/UnitTests/TemplateSource/_Issues/422/cache/.gitignore b/tests/UnitTests/TemplateSource/_Issues/422/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/422/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/_Issues/422/templates/422_test.tpl b/tests/UnitTests/TemplateSource/_Issues/422/templates/422_test.tpl new file mode 100644 index 00000000..09fb9d41 --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/422/templates/422_test.tpl @@ -0,0 +1,8 @@ +{strip} +{assign var=samplearr value=[["list" => []],["list" => ["item"]]]} +{foreach $samplearr as $v} + {section name=inner loop=$v.list} + {/section} + loop: {$v@iteration} + inner: {$smarty.section.inner.total} +{/foreach}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/_Issues/422/templates_c/.gitignore b/tests/UnitTests/TemplateSource/_Issues/422/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/422/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/_Issues/428/SectionPropertiesShortSyntaxIssue428Test.php b/tests/UnitTests/TemplateSource/_Issues/428/SectionPropertiesShortSyntaxIssue428Test.php new file mode 100644 index 00000000..7c900349 --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/428/SectionPropertiesShortSyntaxIssue428Test.php @@ -0,0 +1,42 @@ +<?php +/** + * Smarty PHPunit tests compiler errors + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for compiler tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + * + * Short syntax of section properties did not work + */ +class SectionPropertiesShortSyntaxIssue428Test extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + } + + public function testInit() + { + $this->cleanDirs(); + } + + public function testSection_001() + { + $this->smarty->assign('foo', array('a', 'b', 'c')); + $this->assertEquals('abc', $this->smarty->fetch('001_section.tpl')); + } + public function testSection_002() + { + $this->smarty->assign('foo', array('a', 'b', 'c')); + $this->assertEquals('abc', $this->smarty->fetch('002_section.tpl')); + } + + +} diff --git a/tests/UnitTests/TemplateSource/_Issues/428/cache/.gitignore b/tests/UnitTests/TemplateSource/_Issues/428/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/428/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/_Issues/428/templates/001_section.tpl b/tests/UnitTests/TemplateSource/_Issues/428/templates/001_section.tpl new file mode 100644 index 00000000..ea6dc9ab --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/428/templates/001_section.tpl @@ -0,0 +1 @@ +{section name=bar loop=$foo}{$foo[bar.index]}{sectionelse} else {/section}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/_Issues/428/templates/002_section.tpl b/tests/UnitTests/TemplateSource/_Issues/428/templates/002_section.tpl new file mode 100644 index 00000000..4a49fc9e --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/428/templates/002_section.tpl @@ -0,0 +1 @@ +{section name=bar loop=$foo}{$foo[bar]}{sectionelse} else {/section}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/_Issues/428/templates_c/.gitignore b/tests/UnitTests/TemplateSource/_Issues/428/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/428/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/_Issues/topic26878/NewlineSpacing.php b/tests/UnitTests/TemplateSource/_Issues/topic26878/NewlineSpacing.php new file mode 100644 index 00000000..6feac558 --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/topic26878/NewlineSpacing.php @@ -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++), + ); + } + +}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/_Issues/topic26878/cache/.gitignore b/tests/UnitTests/TemplateSource/_Issues/topic26878/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/topic26878/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/_Issues/topic26878/templates_c/.gitignore b/tests/UnitTests/TemplateSource/_Issues/topic26878/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/topic26878/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/TemplateSource/_Issues/topic26878/templates_tmp/.gitignore b/tests/UnitTests/TemplateSource/_Issues/topic26878/templates_tmp/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/topic26878/templates_tmp/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* |
