diff options
author | Laria Carolin Chabowski <laria@laria.me> | 2020-09-13 21:35:16 +0200 |
---|---|---|
committer | Laria Carolin Chabowski <laria@laria.me> | 2020-09-13 21:35:16 +0200 |
commit | 4e2bfed23c17929795f2082d6e77937170caeaa9 (patch) | |
tree | 4d9f66596c80af8081e4279580a3bbb4721ef184 /tests/functional | |
parent | 5ee6bbbf3002daf075fa77007daccf4d2af25241 (diff) | |
download | ste-4e2bfed23c17929795f2082d6e77937170caeaa9.tar.gz ste-4e2bfed23c17929795f2082d6e77937170caeaa9.tar.bz2 ste-4e2bfed23c17929795f2082d6e77937170caeaa9.zip |
Turn our functional tests into PhpUnit tests
Diffstat (limited to 'tests/functional')
55 files changed, 614 insertions, 0 deletions
diff --git a/tests/functional/.gitignore b/tests/functional/.gitignore new file mode 100644 index 0000000..448d02b --- /dev/null +++ b/tests/functional/.gitignore @@ -0,0 +1 @@ +*.transc.php
\ No newline at end of file diff --git a/tests/functional/BaseTest.php b/tests/functional/BaseTest.php new file mode 100644 index 0000000..ce045fb --- /dev/null +++ b/tests/functional/BaseTest.php @@ -0,0 +1,55 @@ +<?php + + +namespace tests\functional; + +use PHPUnit\Framework\TestCase; +use kch42\ste\STECore; + +abstract class BaseTest extends TestCase +{ + /** @var STECore */ + protected $ste; + + private static function normalize(string $string): string + { + $lines = explode("\n", $string); + + $lines = array_map(static function ($line) { + return preg_replace('/\s{2,}/', " ", $line); + }, $lines); + $lines = array_map('trim', $lines); + $lines = array_filter($lines); + + return implode("\n", $lines); + } + + public function setUp(): void + { + $this->ste = new STECore(new TestStorage($this->getDirectory())); + $this->ste->mute_runtime_errors = false; + + $this->setUpSte($this->ste); + } + + protected function setUpSte(STECore $ste): void + { + } + + public function testTemplate(): void + { + $have = $this->ste->exectemplate("test.tpl"); + $want = file_get_contents($this->getDirectory() . DIRECTORY_SEPARATOR . "want"); + + $normalizedHave = self::normalize($have); + $normalizedWant = self::normalize($want); + + self::assertSame($normalizedWant, $normalizedHave); + } + + /** + * Get the directory of the test. + * @return string + */ + abstract protected function getDirectory(): string; +} diff --git a/tests/functional/TestStorage.php b/tests/functional/TestStorage.php new file mode 100644 index 0000000..2403668 --- /dev/null +++ b/tests/functional/TestStorage.php @@ -0,0 +1,32 @@ +<?php + + +namespace tests\functional; + +use kch42\ste\StorageAccess; + +class TestStorage implements StorageAccess +{ + /** @var string */ + private $dir; + + public function __construct(string $dir) + { + $this->dir = $dir; + } + + public function load($tpl, &$mode) + { + $mode = StorageAccess::MODE_SOURCE; + return file_get_contents($this->dir . DIRECTORY_SEPARATOR . $tpl); + } + + public function save($tpl, $data, $mode) + { + if ($mode != StorageAccess::MODE_TRANSCOMPILED) { + return; + } + + file_put_contents($this->dir . DIRECTORY_SEPARATOR . "$tpl.transc.php", $data); + } +} diff --git a/tests/functional/test_array/Test.php b/tests/functional/test_array/Test.php new file mode 100644 index 0000000..58f0cb8 --- /dev/null +++ b/tests/functional/test_array/Test.php @@ -0,0 +1,27 @@ +<?php + +namespace tests\functional\test_array; + +use kch42\ste\STECore; +use tests\functional\BaseTest; + +class Test extends BaseTest +{ + protected function getDirectory(): string + { + return __DIR__; + } + + protected function setUpSte(STECore $ste): void + { + $ste->vars["foo"] = array( + "a" => array( + "blabla" => "OK" + ), + "b" => "bla" + ); + $ste->vars["bar"] = array( + "baz" => "a" + ); + } +} diff --git a/tests/functional/test_array/test.tpl b/tests/functional/test_array/test.tpl new file mode 100644 index 0000000..050045d --- /dev/null +++ b/tests/functional/test_array/test.tpl @@ -0,0 +1 @@ +${foo[$bar[baz]][${foo[b]}bla]}
\ No newline at end of file diff --git a/tests/functional/test_array/want b/tests/functional/test_array/want new file mode 100644 index 0000000..d86bac9 --- /dev/null +++ b/tests/functional/test_array/want @@ -0,0 +1 @@ +OK diff --git a/tests/functional/test_blocks/Test.php b/tests/functional/test_blocks/Test.php new file mode 100644 index 0000000..05e8e09 --- /dev/null +++ b/tests/functional/test_blocks/Test.php @@ -0,0 +1,18 @@ +<?php + +namespace tests\functional\test_blocks; + +use kch42\ste\STECore; +use tests\functional\BaseTest; + +class Test extends BaseTest +{ + protected function getDirectory(): string + { + return __DIR__; + } + + protected function setUpSte(STECore $ste): void + { + } +} diff --git a/tests/functional/test_blocks/main.tpl b/tests/functional/test_blocks/main.tpl new file mode 100644 index 0000000..a9608bd --- /dev/null +++ b/tests/functional/test_blocks/main.tpl @@ -0,0 +1,3 @@ +Foo +<ste:block name="blk1">Bar</ste:block> +<ste:block name="blk2">Baz</ste:block>
\ No newline at end of file diff --git a/tests/functional/test_blocks/test.tpl b/tests/functional/test_blocks/test.tpl new file mode 100644 index 0000000..3d14e46 --- /dev/null +++ b/tests/functional/test_blocks/test.tpl @@ -0,0 +1,2 @@ +<ste:load name="main.tpl" /> +<ste:block name="blk1">Replaced</ste:block>
\ No newline at end of file diff --git a/tests/functional/test_blocks/want b/tests/functional/test_blocks/want new file mode 100644 index 0000000..640cfef --- /dev/null +++ b/tests/functional/test_blocks/want @@ -0,0 +1,3 @@ +Foo +Replaced +Baz diff --git a/tests/functional/test_closure/Test.php b/tests/functional/test_closure/Test.php new file mode 100644 index 0000000..012e4c6 --- /dev/null +++ b/tests/functional/test_closure/Test.php @@ -0,0 +1,18 @@ +<?php + +namespace tests\functional\test_closure; + +use kch42\ste\STECore; +use tests\functional\BaseTest; + +class Test extends BaseTest +{ + protected function getDirectory(): string + { + return __DIR__; + } + + protected function setUpSte(STECore $ste): void + { + } +} diff --git a/tests/functional/test_closure/test.tpl b/tests/functional/test_closure/test.tpl new file mode 100644 index 0000000..c84ed0a --- /dev/null +++ b/tests/functional/test_closure/test.tpl @@ -0,0 +1,10 @@ +<ste:mktag name="inittag" mandatory="innername"> + <ste:set var="x"><ste:tagcontent /></ste:set> + <ste:mktag name="$_tag_parameters[innername]"> + <ste:calc>$x + <ste:tagcontent /></ste:calc> + </ste:mktag> +</ste:mktag> +<ste:inittag innername="foo">10</ste:inittag> +<ste:inittag innername="bar">20</ste:inittag> +<ste:foo>30</ste:foo> +<ste:bar>40</ste:bar>
\ No newline at end of file diff --git a/tests/functional/test_closure/want b/tests/functional/test_closure/want new file mode 100644 index 0000000..98d2f20 --- /dev/null +++ b/tests/functional/test_closure/want @@ -0,0 +1,2 @@ +40 +60 diff --git a/tests/functional/test_escapes/Test.php b/tests/functional/test_escapes/Test.php new file mode 100644 index 0000000..5c2a2ab --- /dev/null +++ b/tests/functional/test_escapes/Test.php @@ -0,0 +1,21 @@ +<?php + +namespace tests\functional\test_escapes; + +use kch42\ste\STECore; +use tests\functional\BaseTest; + +class Test extends BaseTest +{ + protected function getDirectory(): string + { + return __DIR__; + } + + protected function setUpSte(STECore $ste): void + { + $ste->register_tag("my_echo", function ($ste, $params, $sub) { + return $params["text"]; + }); + } +} diff --git a/tests/functional/test_escapes/test.tpl b/tests/functional/test_escapes/test.tpl new file mode 100644 index 0000000..5458fde --- /dev/null +++ b/tests/functional/test_escapes/test.tpl @@ -0,0 +1,7 @@ +\\\\\\\$foo +\${bar} +\?{foo|bar|baz} +?{|Foo|Bar\|Baz} +<ste:my_echo text="foo\\\"bar\$" /> +<ste:my_echo text='\'' /> +\'
\ No newline at end of file diff --git a/tests/functional/test_escapes/want b/tests/functional/test_escapes/want new file mode 100644 index 0000000..3278c4d --- /dev/null +++ b/tests/functional/test_escapes/want @@ -0,0 +1,7 @@ +\\\$foo +${bar} +?{foo|bar|baz} +Bar|Baz +foo\"bar$ +' +\' diff --git a/tests/functional/test_foreach/Test.php b/tests/functional/test_foreach/Test.php new file mode 100644 index 0000000..3f8cc73 --- /dev/null +++ b/tests/functional/test_foreach/Test.php @@ -0,0 +1,23 @@ +<?php + +namespace tests\functional\test_foreach; + +use kch42\ste\STECore; +use tests\functional\BaseTest; + +class Test extends BaseTest +{ + protected function getDirectory(): string + { + return __DIR__; + } + + protected function setUpSte(STECore $ste): void + { + $ste->vars["foo"] = array( + "a" => array("a" => 100, "b" => 200), + "b" => array("a" => 1, "b" => 2), + "c" => array("a" => 42, "b" => 1337) + ); + } +} diff --git a/tests/functional/test_foreach/test.tpl b/tests/functional/test_foreach/test.tpl new file mode 100644 index 0000000..1aec8b4 --- /dev/null +++ b/tests/functional/test_foreach/test.tpl @@ -0,0 +1,8 @@ +<ste:foreach array="foo" key="k" value="v" counter="i"> + $i: $k -> $v[a], $v[b] +</ste:foreach> +--- +<ste:foreach array="bar" value="v"> + $v + <ste:else>--empty--</ste:else> +</ste:foreach> diff --git a/tests/functional/test_foreach/want b/tests/functional/test_foreach/want new file mode 100644 index 0000000..5710bf7 --- /dev/null +++ b/tests/functional/test_foreach/want @@ -0,0 +1,5 @@ +0: a -> 100, 200 +1: b -> 1, 2 +2: c -> 42, 1337 +--- +--empty-- diff --git a/tests/functional/test_getset/Test.php b/tests/functional/test_getset/Test.php new file mode 100644 index 0000000..6f34500 --- /dev/null +++ b/tests/functional/test_getset/Test.php @@ -0,0 +1,19 @@ +<?php + +namespace tests\functional\test_getset; + +use kch42\ste\STECore; +use tests\functional\BaseTest; + +class Test extends BaseTest +{ + protected function getDirectory(): string + { + return __DIR__; + } + + protected function setUpSte(STECore $ste): void + { + $ste->vars["foo"] = "bar"; + } +} diff --git a/tests/functional/test_getset/test.tpl b/tests/functional/test_getset/test.tpl new file mode 100644 index 0000000..06f865a --- /dev/null +++ b/tests/functional/test_getset/test.tpl @@ -0,0 +1,5 @@ +\$foo = $foo +\$foo = <ste:get var="foo" /> +<ste:set var="foo">baz</ste:set> +\$foo = $foo +\$foo = <ste:get var="foo" /> diff --git a/tests/functional/test_getset/want b/tests/functional/test_getset/want new file mode 100644 index 0000000..567c753 --- /dev/null +++ b/tests/functional/test_getset/want @@ -0,0 +1,4 @@ +$foo = bar +$foo = bar +$foo = baz +$foo = baz diff --git a/tests/functional/test_loop/Test.php b/tests/functional/test_loop/Test.php new file mode 100644 index 0000000..05a76d7 --- /dev/null +++ b/tests/functional/test_loop/Test.php @@ -0,0 +1,18 @@ +<?php + +namespace tests\functional\test_loop; + +use kch42\ste\STECore; +use tests\functional\BaseTest; + +class Test extends BaseTest +{ + protected function getDirectory(): string + { + return __DIR__; + } + + protected function setUpSte(STECore $ste): void + { + } +} diff --git a/tests/functional/test_loop/test.tpl b/tests/functional/test_loop/test.tpl new file mode 100644 index 0000000..399f05a --- /dev/null +++ b/tests/functional/test_loop/test.tpl @@ -0,0 +1,3 @@ +<ste:for start="10" stop="0" step="-1" counter="i"> +$i +</ste:for>
\ No newline at end of file diff --git a/tests/functional/test_loop/want b/tests/functional/test_loop/want new file mode 100644 index 0000000..30b148d --- /dev/null +++ b/tests/functional/test_loop/want @@ -0,0 +1,11 @@ +10 +9 +8 +7 +6 +5 +4 +3 +2 +1 +0 diff --git a/tests/functional/test_mktag/Test.php b/tests/functional/test_mktag/Test.php new file mode 100644 index 0000000..c850509 --- /dev/null +++ b/tests/functional/test_mktag/Test.php @@ -0,0 +1,18 @@ +<?php + +namespace tests\functional\test_mktag; + +use kch42\ste\STECore; +use tests\functional\BaseTest; + +class Test extends BaseTest +{ + protected function getDirectory(): string + { + return __DIR__; + } + + protected function setUpSte(STECore $ste): void + { + } +} diff --git a/tests/functional/test_mktag/test.tpl b/tests/functional/test_mktag/test.tpl new file mode 100644 index 0000000..c446206 --- /dev/null +++ b/tests/functional/test_mktag/test.tpl @@ -0,0 +1,11 @@ +<ste:mktag name="double"><ste:calc>2 * <ste:tagcontent /></ste:calc></ste:mktag> +<ste:mktag name="foo" mandatory="a|b"> + <ste:for counter="i" start="0" stop="$_tag_parameters[a]"> + <ste:if> + <ste:even>$i</ste:even> + <ste:then><ste:double>$i</ste:double></ste:then> + <ste:else>$_tag_parameters[b]</ste:else> + </ste:if> + </ste:for> +</ste:mktag> +<ste:foo a="10" b="-" />
\ No newline at end of file diff --git a/tests/functional/test_mktag/want b/tests/functional/test_mktag/want new file mode 100644 index 0000000..3e2351c --- /dev/null +++ b/tests/functional/test_mktag/want @@ -0,0 +1,11 @@ +0 +- +4 +- +8 +- +12 +- +16 +- +20 diff --git a/tests/functional/test_pseudotags/Test.php b/tests/functional/test_pseudotags/Test.php new file mode 100644 index 0000000..f64ff5f --- /dev/null +++ b/tests/functional/test_pseudotags/Test.php @@ -0,0 +1,18 @@ +<?php + +namespace tests\functional\test_pseudotags; + +use kch42\ste\STECore; +use tests\functional\BaseTest; + +class Test extends BaseTest +{ + protected function getDirectory(): string + { + return __DIR__; + } + + protected function setUpSte(STECore $ste): void + { + } +} diff --git a/tests/functional/test_pseudotags/test.tpl b/tests/functional/test_pseudotags/test.tpl new file mode 100644 index 0000000..756be8a --- /dev/null +++ b/tests/functional/test_pseudotags/test.tpl @@ -0,0 +1,2 @@ +<ste:comment><ste:comment><ste:foo>Ignore $me<ste:rawtext>Foo</ste:rawtext></ste:comment> +<ste:rawtext><ste:rawtext>$foo bar <ste:bla a="$b" /></ste:rawtext>
\ No newline at end of file diff --git a/tests/functional/test_pseudotags/want b/tests/functional/test_pseudotags/want new file mode 100644 index 0000000..3aaffdc --- /dev/null +++ b/tests/functional/test_pseudotags/want @@ -0,0 +1 @@ +<ste:rawtext>$foo bar <ste:bla a="$b" /> diff --git a/tests/functional/test_recursive/Test.php b/tests/functional/test_recursive/Test.php new file mode 100644 index 0000000..d393791 --- /dev/null +++ b/tests/functional/test_recursive/Test.php @@ -0,0 +1,19 @@ +<?php + +namespace tests\functional\test_recursive; + +use kch42\ste\STECore; +use tests\functional\BaseTest; + +class Test extends BaseTest +{ + protected function getDirectory(): string + { + return __DIR__; + } + + protected function setUpSte(STECore $ste): void + { + $ste->mute_runtime_errors = false; + } +} diff --git a/tests/functional/test_recursive/test.tpl b/tests/functional/test_recursive/test.tpl new file mode 100644 index 0000000..bea3934 --- /dev/null +++ b/tests/functional/test_recursive/test.tpl @@ -0,0 +1,11 @@ +<ste:mktag name="fac" mandatory="n"> + <ste:if> + ~{$_tag_parameters[n]|eq|0} + <ste:then>1</ste:then> + <ste:else> + <ste:set var="nextn"><ste:calc>$_tag_parameters[n] - 1</ste:calc></ste:set> + <ste:calc><ste:fac n="$nextn" /> * $_tag_parameters[n]</ste:calc> + </ste:else> + </ste:if> +</ste:mktag> +<ste:fac n="10" />
\ No newline at end of file diff --git a/tests/functional/test_recursive/want b/tests/functional/test_recursive/want new file mode 100644 index 0000000..3fbd4a8 --- /dev/null +++ b/tests/functional/test_recursive/want @@ -0,0 +1 @@ +3628800 diff --git a/tests/functional/test_scoping/Test.php b/tests/functional/test_scoping/Test.php new file mode 100644 index 0000000..b15f911 --- /dev/null +++ b/tests/functional/test_scoping/Test.php @@ -0,0 +1,18 @@ +<?php + +namespace tests\functional\test_scoping; + +use kch42\ste\STECore; +use tests\functional\BaseTest; + +class Test extends BaseTest +{ + protected function getDirectory(): string + { + return __DIR__; + } + + protected function setUpSte(STECore $ste): void + { + } +} diff --git a/tests/functional/test_scoping/test.tpl b/tests/functional/test_scoping/test.tpl new file mode 100644 index 0000000..e8a5cf2 --- /dev/null +++ b/tests/functional/test_scoping/test.tpl @@ -0,0 +1,18 @@ +<ste:set var="a">A</ste:set> +<ste:set var="b">B</ste:set> +<ste:mktag name="foo"> + in foo: \$a = $a + in foo: \$b = $b + in foo: \$c = $c + <ste:set var="a">X</ste:set> + <ste:setlocal var="b">Y</ste:setlocal> + <ste:set var="c">Z</ste:set> + in foo (after set): \$a = $a + in foo (after set): \$b = $b + in foo (after set): \$c = $c +</ste:mktag> + +<ste:foo /> +\$a = $a +\$b = $b +\$c = $c
\ No newline at end of file diff --git a/tests/functional/test_scoping/want b/tests/functional/test_scoping/want new file mode 100644 index 0000000..6e7a154 --- /dev/null +++ b/tests/functional/test_scoping/want @@ -0,0 +1,9 @@ +in foo: $a = A +in foo: $b = B +in foo: $c = +in foo (after set): $a = X +in foo (after set): $b = Y +in foo (after set): $c = Z +$a = X +$b = B +$c = diff --git a/tests/functional/test_short/Test.php b/tests/functional/test_short/Test.php new file mode 100644 index 0000000..2b138f5 --- /dev/null +++ b/tests/functional/test_short/Test.php @@ -0,0 +1,18 @@ +<?php + +namespace tests\functional\test_short; + +use kch42\ste\STECore; +use tests\functional\BaseTest; + +class Test extends BaseTest +{ + protected function getDirectory(): string + { + return __DIR__; + } + + protected function setUpSte(STECore $ste): void + { + } +} diff --git a/tests/functional/test_short/test.tpl b/tests/functional/test_short/test.tpl new file mode 100644 index 0000000..42d498b --- /dev/null +++ b/tests/functional/test_short/test.tpl @@ -0,0 +1 @@ +?{~{foo|eq|bar}|FAIL|?{~{~{1|gt|2}|?{y|eq|neq}|~{3|lt|2}}|OK|FAIL}}
\ No newline at end of file diff --git a/tests/functional/test_short/want b/tests/functional/test_short/want new file mode 100644 index 0000000..d86bac9 --- /dev/null +++ b/tests/functional/test_short/want @@ -0,0 +1 @@ +OK diff --git a/tests/functional/test_short_for_additional_attribs/Test.php b/tests/functional/test_short_for_additional_attribs/Test.php new file mode 100644 index 0000000..8099869 --- /dev/null +++ b/tests/functional/test_short_for_additional_attribs/Test.php @@ -0,0 +1,23 @@ +<?php + +namespace tests\functional\test_short_for_additional_attribs; + +use kch42\ste\STECore; +use tests\functional\BaseTest; + +class Test extends BaseTest +{ + protected function getDirectory(): string + { + return __DIR__; + } + + protected function setUpSte(STECore $ste): void + { + $ste->set_var_by_name("data", array( + array('content' => 'foo', 'foo' => true), + array('content' => 'bar', 'foo' => false), + array('content' => 'baz', 'foo' => false), + )); + } +} diff --git a/tests/functional/test_short_for_additional_attribs/test.tpl b/tests/functional/test_short_for_additional_attribs/test.tpl new file mode 100644 index 0000000..e6b30e4 --- /dev/null +++ b/tests/functional/test_short_for_additional_attribs/test.tpl @@ -0,0 +1,5 @@ +<ul> + <ste:foreach array="data" value="x"> + <li?{$x[foo]| class="foo"|}>$x[content]</li> + </ste:foreach> +</ul>
\ No newline at end of file diff --git a/tests/functional/test_short_for_additional_attribs/want b/tests/functional/test_short_for_additional_attribs/want new file mode 100644 index 0000000..c46d63f --- /dev/null +++ b/tests/functional/test_short_for_additional_attribs/want @@ -0,0 +1,5 @@ +<ul> +<li class="foo">foo</li> +<li>bar</li> +<li>baz</li> +</ul> diff --git a/tests/functional/test_simple/Test.php b/tests/functional/test_simple/Test.php new file mode 100644 index 0000000..e2b58d9 --- /dev/null +++ b/tests/functional/test_simple/Test.php @@ -0,0 +1,19 @@ +<?php + +namespace tests\functional\test_simple; + +use kch42\ste\STECore; +use tests\functional\BaseTest; + +class Test extends BaseTest +{ + protected function getDirectory(): string + { + return __DIR__; + } + + protected function setUpSte(STECore $ste): void + { + $ste->vars["foo"] = "World"; + } +} diff --git a/tests/functional/test_simple/test.tpl b/tests/functional/test_simple/test.tpl new file mode 100644 index 0000000..30a4f22 --- /dev/null +++ b/tests/functional/test_simple/test.tpl @@ -0,0 +1 @@ +Hello $foo!
\ No newline at end of file diff --git a/tests/functional/test_simple/want b/tests/functional/test_simple/want new file mode 100644 index 0000000..980a0d5 --- /dev/null +++ b/tests/functional/test_simple/want @@ -0,0 +1 @@ +Hello World! diff --git a/tests/functional/test_static_numeric_array_access/Test.php b/tests/functional/test_static_numeric_array_access/Test.php new file mode 100644 index 0000000..0c6a853 --- /dev/null +++ b/tests/functional/test_static_numeric_array_access/Test.php @@ -0,0 +1,23 @@ +<?php + +namespace tests\functional\test_static_numeric_array_access; + +use kch42\ste\STECore; +use tests\functional\BaseTest; + +class Test extends BaseTest +{ + protected function getDirectory(): string + { + return __DIR__; + } + + protected function setUpSte(STECore $ste): void + { + $ste->set_var_by_name("foo", array( + "foo", + "bar", + "baz", + )); + } +} diff --git a/tests/functional/test_static_numeric_array_access/test.tpl b/tests/functional/test_static_numeric_array_access/test.tpl new file mode 100644 index 0000000..a313c6b --- /dev/null +++ b/tests/functional/test_static_numeric_array_access/test.tpl @@ -0,0 +1,3 @@ +$foo[0] +$foo[1] +$foo[2] diff --git a/tests/functional/test_static_numeric_array_access/want b/tests/functional/test_static_numeric_array_access/want new file mode 100644 index 0000000..86e041d --- /dev/null +++ b/tests/functional/test_static_numeric_array_access/want @@ -0,0 +1,3 @@ +foo +bar +baz diff --git a/tests/functional/test_tagname/Test.php b/tests/functional/test_tagname/Test.php new file mode 100644 index 0000000..8e3d8f6 --- /dev/null +++ b/tests/functional/test_tagname/Test.php @@ -0,0 +1,33 @@ +<?php + +namespace tests\functional\test_tagname; + +use kch42\ste\STECore; +use tests\functional\BaseTest; + +class Test extends BaseTest +{ + protected function getDirectory(): string + { + return __DIR__; + } + + protected function setUpSte(STECore $ste): void + { + $names = array( + "foo", + "ab_cd", + "foo123baz", + "x0123", + ); + + foreach ($names as $name) { + $ste->register_tag( + $name, + function ($ste, $params, $sub) use ($name) { + return $name; + } + ); + } + } +} diff --git a/tests/functional/test_tagname/test.tpl b/tests/functional/test_tagname/test.tpl new file mode 100644 index 0000000..30ca889 --- /dev/null +++ b/tests/functional/test_tagname/test.tpl @@ -0,0 +1,4 @@ +<ste:foo /> +<ste:ab_cd /> +<ste:foo123baz /> +<ste:x0123 />
\ No newline at end of file diff --git a/tests/functional/test_tagname/want b/tests/functional/test_tagname/want new file mode 100644 index 0000000..3233294 --- /dev/null +++ b/tests/functional/test_tagname/want @@ -0,0 +1,4 @@ +foo +ab_cd +foo123baz +x0123 diff --git a/tests/functional/test_trailing_closing_array_bracket/Test.php b/tests/functional/test_trailing_closing_array_bracket/Test.php new file mode 100644 index 0000000..9e6ff2c --- /dev/null +++ b/tests/functional/test_trailing_closing_array_bracket/Test.php @@ -0,0 +1,23 @@ +<?php + +namespace tests\functional\test_trailing_closing_array_bracket; + +use kch42\ste\STECore; +use tests\functional\BaseTest; + +class Test extends BaseTest +{ + protected function getDirectory(): string + { + return __DIR__; + } + + protected function setUpSte(STECore $ste): void + { + $ste->set_var_by_name("foo", array( + "foo", + "bar", + "baz", + )); + } +} diff --git a/tests/functional/test_trailing_closing_array_bracket/test.tpl b/tests/functional/test_trailing_closing_array_bracket/test.tpl new file mode 100644 index 0000000..68f6caa --- /dev/null +++ b/tests/functional/test_trailing_closing_array_bracket/test.tpl @@ -0,0 +1,3 @@ +$foo[0] +$foo[1] +$foo[2]
\ No newline at end of file diff --git a/tests/functional/test_trailing_closing_array_bracket/want b/tests/functional/test_trailing_closing_array_bracket/want new file mode 100644 index 0000000..86e041d --- /dev/null +++ b/tests/functional/test_trailing_closing_array_bracket/want @@ -0,0 +1,3 @@ +foo +bar +baz |