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 | |
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')
93 files changed, 445 insertions, 290 deletions
diff --git a/tests/dump_ast.php b/tests/dump_ast.php deleted file mode 100644 index 70a15af..0000000 --- a/tests/dump_ast.php +++ /dev/null @@ -1,6 +0,0 @@ -<?php - -require(dirname(__FILE__) . "/../ste.php"); - -ini_set("xdebug.var_display_max_depth", 1000); -var_dump(\ste\Parser::parse(file_get_contents("php://stdin"), "-")); 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/test_array/test.tpl b/tests/functional/test_array/test.tpl index 050045d..050045d 100644 --- a/tests/test_array/test.tpl +++ b/tests/functional/test_array/test.tpl diff --git a/tests/test_array/want b/tests/functional/test_array/want index d86bac9..d86bac9 100644 --- a/tests/test_array/want +++ b/tests/functional/test_array/want 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/test_blocks/master.tpl b/tests/functional/test_blocks/main.tpl index a9608bd..a9608bd 100644 --- a/tests/test_blocks/master.tpl +++ b/tests/functional/test_blocks/main.tpl diff --git a/tests/test_blocks/test.tpl b/tests/functional/test_blocks/test.tpl index 44c6891..3d14e46 100644 --- a/tests/test_blocks/test.tpl +++ b/tests/functional/test_blocks/test.tpl @@ -1,2 +1,2 @@ -<ste:load name="master.tpl" /> +<ste:load name="main.tpl" /> <ste:block name="blk1">Replaced</ste:block>
\ No newline at end of file diff --git a/tests/test_blocks/want b/tests/functional/test_blocks/want index 640cfef..640cfef 100644 --- a/tests/test_blocks/want +++ b/tests/functional/test_blocks/want 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/test_closure/test.tpl b/tests/functional/test_closure/test.tpl index c84ed0a..c84ed0a 100644 --- a/tests/test_closure/test.tpl +++ b/tests/functional/test_closure/test.tpl diff --git a/tests/test_closure/want b/tests/functional/test_closure/want index 98d2f20..98d2f20 100644 --- a/tests/test_closure/want +++ b/tests/functional/test_closure/want 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/test_escapes/test.tpl b/tests/functional/test_escapes/test.tpl index 5458fde..5458fde 100644 --- a/tests/test_escapes/test.tpl +++ b/tests/functional/test_escapes/test.tpl diff --git a/tests/test_escapes/want b/tests/functional/test_escapes/want index 3278c4d..3278c4d 100644 --- a/tests/test_escapes/want +++ b/tests/functional/test_escapes/want 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/test_foreach/test.tpl b/tests/functional/test_foreach/test.tpl index 1aec8b4..1aec8b4 100644 --- a/tests/test_foreach/test.tpl +++ b/tests/functional/test_foreach/test.tpl diff --git a/tests/test_foreach/want b/tests/functional/test_foreach/want index 5710bf7..5710bf7 100644 --- a/tests/test_foreach/want +++ b/tests/functional/test_foreach/want 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/test_getset/test.tpl b/tests/functional/test_getset/test.tpl index 06f865a..06f865a 100644 --- a/tests/test_getset/test.tpl +++ b/tests/functional/test_getset/test.tpl diff --git a/tests/test_getset/want b/tests/functional/test_getset/want index 567c753..567c753 100644 --- a/tests/test_getset/want +++ b/tests/functional/test_getset/want 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/test_loop/test.tpl b/tests/functional/test_loop/test.tpl index 399f05a..399f05a 100644 --- a/tests/test_loop/test.tpl +++ b/tests/functional/test_loop/test.tpl diff --git a/tests/test_loop/want b/tests/functional/test_loop/want index 30b148d..30b148d 100644 --- a/tests/test_loop/want +++ b/tests/functional/test_loop/want 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/test_mktag/test.tpl b/tests/functional/test_mktag/test.tpl index c446206..c446206 100644 --- a/tests/test_mktag/test.tpl +++ b/tests/functional/test_mktag/test.tpl diff --git a/tests/test_mktag/want b/tests/functional/test_mktag/want index 3e2351c..3e2351c 100644 --- a/tests/test_mktag/want +++ b/tests/functional/test_mktag/want 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/test_pseudotags/test.tpl b/tests/functional/test_pseudotags/test.tpl index 756be8a..756be8a 100644 --- a/tests/test_pseudotags/test.tpl +++ b/tests/functional/test_pseudotags/test.tpl diff --git a/tests/test_pseudotags/want b/tests/functional/test_pseudotags/want index 3aaffdc..3aaffdc 100644 --- a/tests/test_pseudotags/want +++ b/tests/functional/test_pseudotags/want 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/test_recursive/test.tpl b/tests/functional/test_recursive/test.tpl index bea3934..bea3934 100644 --- a/tests/test_recursive/test.tpl +++ b/tests/functional/test_recursive/test.tpl diff --git a/tests/test_recursive/want b/tests/functional/test_recursive/want index 3fbd4a8..3fbd4a8 100644 --- a/tests/test_recursive/want +++ b/tests/functional/test_recursive/want 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/test_scoping/test.tpl b/tests/functional/test_scoping/test.tpl index e8a5cf2..e8a5cf2 100644 --- a/tests/test_scoping/test.tpl +++ b/tests/functional/test_scoping/test.tpl diff --git a/tests/test_scoping/want b/tests/functional/test_scoping/want index 6e7a154..6e7a154 100644 --- a/tests/test_scoping/want +++ b/tests/functional/test_scoping/want 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/test_short/test.tpl b/tests/functional/test_short/test.tpl index 42d498b..42d498b 100644 --- a/tests/test_short/test.tpl +++ b/tests/functional/test_short/test.tpl diff --git a/tests/test_short/want b/tests/functional/test_short/want index d86bac9..d86bac9 100644 --- a/tests/test_short/want +++ b/tests/functional/test_short/want 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/test_short_for_additional_attribs/test.tpl b/tests/functional/test_short_for_additional_attribs/test.tpl index e6b30e4..e6b30e4 100644 --- a/tests/test_short_for_additional_attribs/test.tpl +++ b/tests/functional/test_short_for_additional_attribs/test.tpl diff --git a/tests/test_short_for_additional_attribs/want b/tests/functional/test_short_for_additional_attribs/want index c46d63f..c46d63f 100644 --- a/tests/test_short_for_additional_attribs/want +++ b/tests/functional/test_short_for_additional_attribs/want 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/test_simple/test.tpl b/tests/functional/test_simple/test.tpl index 30a4f22..30a4f22 100644 --- a/tests/test_simple/test.tpl +++ b/tests/functional/test_simple/test.tpl diff --git a/tests/test_simple/want b/tests/functional/test_simple/want index 980a0d5..980a0d5 100644 --- a/tests/test_simple/want +++ b/tests/functional/test_simple/want 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/test_static_numeric_array_access/test.tpl b/tests/functional/test_static_numeric_array_access/test.tpl index a313c6b..a313c6b 100644 --- a/tests/test_static_numeric_array_access/test.tpl +++ b/tests/functional/test_static_numeric_array_access/test.tpl diff --git a/tests/test_static_numeric_array_access/want b/tests/functional/test_static_numeric_array_access/want index 86e041d..86e041d 100644 --- a/tests/test_static_numeric_array_access/want +++ b/tests/functional/test_static_numeric_array_access/want 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/test_tagname/test.tpl b/tests/functional/test_tagname/test.tpl index 30ca889..30ca889 100644 --- a/tests/test_tagname/test.tpl +++ b/tests/functional/test_tagname/test.tpl diff --git a/tests/test_tagname/want b/tests/functional/test_tagname/want index 3233294..3233294 100644 --- a/tests/test_tagname/want +++ b/tests/functional/test_tagname/want 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/test_trailing_closing_array_bracket/test.tpl b/tests/functional/test_trailing_closing_array_bracket/test.tpl index 68f6caa..68f6caa 100644 --- a/tests/test_trailing_closing_array_bracket/test.tpl +++ b/tests/functional/test_trailing_closing_array_bracket/test.tpl diff --git a/tests/test_trailing_closing_array_bracket/want b/tests/functional/test_trailing_closing_array_bracket/want index 86e041d..86e041d 100644 --- a/tests/test_trailing_closing_array_bracket/want +++ b/tests/functional/test_trailing_closing_array_bracket/want diff --git a/tests/mktest.sh b/tests/mktest.sh deleted file mode 100755 index 126aebc..0000000 --- a/tests/mktest.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -mkdir "$1" -touch "$1/test.tpl" -touch "$1/want" - -echo '<?php - -use kch42\ste\STECore; - -function test_func(STECore $ste) -{ - -}' > "$1/code.php" - -echo 'have -*.ast -*.transc.php' > "$1/.gitignore" diff --git a/tests/run_tests.sh b/tests/run_tests.sh deleted file mode 100755 index 4e46977..0000000 --- a/tests/run_tests.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh - -set -e - -run() { - ( # So we don't have to cd .. - cd "$1" || return 1 - - php ../test.php > have - - printf '\e[1m%s\e[0m: ' "$1" - if sed 's/\s*//' < have | grep -v '^$' | cmp -s want; then - echo "OK" - rm ./*.transc.php - else - echo "FAILED" - for tpl in *.tpl; do - php ../dump_ast.php < "$tpl" > "$tpl.ast" - done - return 1 - fi - ) -} - -run_many() { - retval=0 - while [ $# -gt 0 ]; do - if ! run "$1"; then - retval=1 - fi - - shift - done - - return $retval -} - -if [ $# -eq 0 ]; then - run_many test_* -else - run_many "$@" -fi diff --git a/tests/test.php b/tests/test.php deleted file mode 100644 index 15453b0..0000000 --- a/tests/test.php +++ /dev/null @@ -1,29 +0,0 @@ -<?php - -require(dirname(__FILE__) . "/../steloader.php"); -require("code.php"); - -use \kch42\ste; - -class TestStorage implements ste\StorageAccess -{ - public function load($tpl, &$mode) - { - $mode = ste\StorageAccess::MODE_SOURCE; - return file_get_contents($tpl); - } - - public function save($tpl, $data, $mode) - { - if ($mode != ste\StorageAccess::MODE_TRANSCOMPILED) { - return; - } - - file_put_contents("$tpl.transc.php", $data); - } -} - -$ste = new ste\STECore(new TestStorage()); -$ste->mute_runtime_errors = false; -test_func($ste); -echo $ste->exectemplate("test.tpl"); diff --git a/tests/test_array/.gitignore b/tests/test_array/.gitignore deleted file mode 100644 index de2a41b..0000000 --- a/tests/test_array/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -have -*.ast -*.transc.php diff --git a/tests/test_array/code.php b/tests/test_array/code.php deleted file mode 100644 index b524c15..0000000 --- a/tests/test_array/code.php +++ /dev/null @@ -1,14 +0,0 @@ -<?php - -function test_func($ste) -{ - $ste->vars["foo"] = array( - "a" => array( - "blabla" => "OK" - ), - "b" => "bla" - ); - $ste->vars["bar"] = array( - "baz" => "a" - ); -} diff --git a/tests/test_blocks/.gitignore b/tests/test_blocks/.gitignore deleted file mode 100644 index de2a41b..0000000 --- a/tests/test_blocks/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -have -*.ast -*.transc.php diff --git a/tests/test_blocks/code.php b/tests/test_blocks/code.php deleted file mode 100644 index 25e7f00..0000000 --- a/tests/test_blocks/code.php +++ /dev/null @@ -1,5 +0,0 @@ -<?php - -function test_func($ste) -{ -} diff --git a/tests/test_closure/.gitignore b/tests/test_closure/.gitignore deleted file mode 100644 index de2a41b..0000000 --- a/tests/test_closure/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -have -*.ast -*.transc.php diff --git a/tests/test_closure/code.php b/tests/test_closure/code.php deleted file mode 100644 index 25e7f00..0000000 --- a/tests/test_closure/code.php +++ /dev/null @@ -1,5 +0,0 @@ -<?php - -function test_func($ste) -{ -} diff --git a/tests/test_escapes/.gitignore b/tests/test_escapes/.gitignore deleted file mode 100644 index de2a41b..0000000 --- a/tests/test_escapes/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -have -*.ast -*.transc.php diff --git a/tests/test_escapes/code.php b/tests/test_escapes/code.php deleted file mode 100644 index a1904c8..0000000 --- a/tests/test_escapes/code.php +++ /dev/null @@ -1,8 +0,0 @@ -<?php - -function test_func($ste) -{ - $ste->register_tag("my_echo", function ($ste, $params, $sub) { - return $params["text"]; - }); -} diff --git a/tests/test_foreach/.gitignore b/tests/test_foreach/.gitignore deleted file mode 100644 index de2a41b..0000000 --- a/tests/test_foreach/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -have -*.ast -*.transc.php diff --git a/tests/test_foreach/code.php b/tests/test_foreach/code.php deleted file mode 100644 index 60ad311..0000000 --- a/tests/test_foreach/code.php +++ /dev/null @@ -1,10 +0,0 @@ -<?php - -function test_func($ste) -{ - $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/test_getset/.gitignore b/tests/test_getset/.gitignore deleted file mode 100644 index de2a41b..0000000 --- a/tests/test_getset/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -have -*.ast -*.transc.php diff --git a/tests/test_getset/code.php b/tests/test_getset/code.php deleted file mode 100644 index 722af1e..0000000 --- a/tests/test_getset/code.php +++ /dev/null @@ -1,6 +0,0 @@ -<?php - -function test_func($ste) -{ - $ste->vars["foo"] = "bar"; -} diff --git a/tests/test_loop/.gitignore b/tests/test_loop/.gitignore deleted file mode 100644 index de2a41b..0000000 --- a/tests/test_loop/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -have -*.ast -*.transc.php diff --git a/tests/test_loop/code.php b/tests/test_loop/code.php deleted file mode 100644 index 25e7f00..0000000 --- a/tests/test_loop/code.php +++ /dev/null @@ -1,5 +0,0 @@ -<?php - -function test_func($ste) -{ -} diff --git a/tests/test_mktag/.gitignore b/tests/test_mktag/.gitignore deleted file mode 100644 index de2a41b..0000000 --- a/tests/test_mktag/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -have -*.ast -*.transc.php diff --git a/tests/test_mktag/code.php b/tests/test_mktag/code.php deleted file mode 100644 index 25e7f00..0000000 --- a/tests/test_mktag/code.php +++ /dev/null @@ -1,5 +0,0 @@ -<?php - -function test_func($ste) -{ -} diff --git a/tests/test_pseudotags/.gitignore b/tests/test_pseudotags/.gitignore deleted file mode 100644 index de2a41b..0000000 --- a/tests/test_pseudotags/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -have -*.ast -*.transc.php diff --git a/tests/test_pseudotags/code.php b/tests/test_pseudotags/code.php deleted file mode 100644 index 25e7f00..0000000 --- a/tests/test_pseudotags/code.php +++ /dev/null @@ -1,5 +0,0 @@ -<?php - -function test_func($ste) -{ -} diff --git a/tests/test_recursive/.gitignore b/tests/test_recursive/.gitignore deleted file mode 100644 index de2a41b..0000000 --- a/tests/test_recursive/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -have -*.ast -*.transc.php diff --git a/tests/test_recursive/code.php b/tests/test_recursive/code.php deleted file mode 100644 index 96b967b..0000000 --- a/tests/test_recursive/code.php +++ /dev/null @@ -1,6 +0,0 @@ -<?php - -function test_func($ste) -{ - $ste->mute_runtime_errors = false; -} diff --git a/tests/test_scoping/.gitignore b/tests/test_scoping/.gitignore deleted file mode 100644 index de2a41b..0000000 --- a/tests/test_scoping/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -have -*.ast -*.transc.php diff --git a/tests/test_scoping/code.php b/tests/test_scoping/code.php deleted file mode 100644 index 25e7f00..0000000 --- a/tests/test_scoping/code.php +++ /dev/null @@ -1,5 +0,0 @@ -<?php - -function test_func($ste) -{ -} diff --git a/tests/test_short/.gitignore b/tests/test_short/.gitignore deleted file mode 100644 index de2a41b..0000000 --- a/tests/test_short/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -have -*.ast -*.transc.php diff --git a/tests/test_short/code.php b/tests/test_short/code.php deleted file mode 100644 index 25e7f00..0000000 --- a/tests/test_short/code.php +++ /dev/null @@ -1,5 +0,0 @@ -<?php - -function test_func($ste) -{ -} diff --git a/tests/test_short_for_additional_attribs/.gitignore b/tests/test_short_for_additional_attribs/.gitignore deleted file mode 100644 index de2a41b..0000000 --- a/tests/test_short_for_additional_attribs/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -have -*.ast -*.transc.php diff --git a/tests/test_short_for_additional_attribs/code.php b/tests/test_short_for_additional_attribs/code.php deleted file mode 100644 index 5d75d34..0000000 --- a/tests/test_short_for_additional_attribs/code.php +++ /dev/null @@ -1,12 +0,0 @@ -<?php - -use kch42\ste\STECore; - -function test_func(STECore $ste) -{ - $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/test_simple/.gitignore b/tests/test_simple/.gitignore deleted file mode 100644 index de2a41b..0000000 --- a/tests/test_simple/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -have -*.ast -*.transc.php diff --git a/tests/test_simple/code.php b/tests/test_simple/code.php deleted file mode 100644 index 2712e2b..0000000 --- a/tests/test_simple/code.php +++ /dev/null @@ -1,6 +0,0 @@ -<?php - -function test_func($ste) -{ - $ste->vars["foo"] = "World"; -} diff --git a/tests/test_static_numeric_array_access/.gitignore b/tests/test_static_numeric_array_access/.gitignore deleted file mode 100644 index de2a41b..0000000 --- a/tests/test_static_numeric_array_access/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -have -*.ast -*.transc.php diff --git a/tests/test_static_numeric_array_access/code.php b/tests/test_static_numeric_array_access/code.php deleted file mode 100644 index 77f48be..0000000 --- a/tests/test_static_numeric_array_access/code.php +++ /dev/null @@ -1,12 +0,0 @@ -<?php - -use kch42\ste\STECore; - -function test_func(STECore $ste) -{ - $ste->set_var_by_name("foo", array( - "foo", - "bar", - "baz", - )); -} diff --git a/tests/test_tagname/.gitignore b/tests/test_tagname/.gitignore deleted file mode 100644 index de2a41b..0000000 --- a/tests/test_tagname/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -have -*.ast -*.transc.php diff --git a/tests/test_tagname/code.php b/tests/test_tagname/code.php deleted file mode 100644 index e934989..0000000 --- a/tests/test_tagname/code.php +++ /dev/null @@ -1,22 +0,0 @@ -<?php - -use kch42\ste\STECore; - -function test_func(STECore $ste) -{ - $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/test_trailing_closing_array_bracket/.gitignore b/tests/test_trailing_closing_array_bracket/.gitignore deleted file mode 100644 index de2a41b..0000000 --- a/tests/test_trailing_closing_array_bracket/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -have -*.ast -*.transc.php diff --git a/tests/test_trailing_closing_array_bracket/code.php b/tests/test_trailing_closing_array_bracket/code.php deleted file mode 100644 index 77f48be..0000000 --- a/tests/test_trailing_closing_array_bracket/code.php +++ /dev/null @@ -1,12 +0,0 @@ -<?php - -use kch42\ste\STECore; - -function test_func(STECore $ste) -{ - $ste->set_var_by_name("foo", array( - "foo", - "bar", - "baz", - )); -} |