diff --git a/tests/Latte/BlockMacros.block.vars.phpt b/tests/Latte/BlockMacros.block.vars.phpt new file mode 100644 index 000000000..3b216c0ef --- /dev/null +++ b/tests/Latte/BlockMacros.block.vars.phpt @@ -0,0 +1,60 @@ +setLoader(new Latte\Loaders\StringLoader); + +$template = <<<'XX' +{var $var = a} + +{define a} + {$var} + {var $var = define} +{/define} + +{$var} + + +{block b} + {$var} + {var $var = blocknamed} +{/block} + +{$var} + + +{block|trim} + {$var} + {var $var = blockmod} +{/block} + +{$var} + + +{block} + {$var} + {var $var = block} +{/block} + +{$var} +XX; + +Assert::matchFile( + __DIR__ . '/expected/BlockMacros.vars.phtml', + $latte->compile($template) +); +Assert::matchFile( + __DIR__ . '/expected/BlockMacros.vars.html', + $latte->renderToString($template) +); diff --git a/tests/Latte/Filters.substring().phpt b/tests/Latte/Filters.substring().phpt index 007b24388..b3da16c7b 100644 --- a/tests/Latte/Filters.substring().phpt +++ b/tests/Latte/Filters.substring().phpt @@ -16,11 +16,15 @@ require __DIR__ . '/../bootstrap.php'; $s = "\u{158}ekn\u{11B}te, jak se (dnes) m\u{E1}te?"; // Řekněte, jak se (dnes) máte? +Assert::same('', Filters::substring('', 0)); +Assert::same('', Filters::substring('', -1)); +Assert::same('', Filters::substring('', 1)); Assert::same('?', Filters::substring($s, -1)); Assert::same('Řekněte, jak se (dnes) máte?', Filters::substring($s, 0)); Assert::same('Řekněte, jak se (dnes) máte?', Filters::substring($s, 0, 99)); Assert::same('ekněte, jak se (dnes) máte?', Filters::substring($s, 1)); Assert::same('ě', Filters::substring($s, 4, 1)); +Assert::same('ěte, jak se (d', Filters::substring($s, 4, -10)); class CountableTraversableStringClass implements Countable, IteratorAggregate diff --git a/tests/Latte/expected/BlockMacros.vars.html b/tests/Latte/expected/BlockMacros.vars.html new file mode 100644 index 000000000..89c493497 --- /dev/null +++ b/tests/Latte/expected/BlockMacros.vars.html @@ -0,0 +1,20 @@ + + +a + + + a + + +a + + +a + +blockmod + + + blockmod + + +block diff --git a/tests/Latte/expected/BlockMacros.vars.phtml b/tests/Latte/expected/BlockMacros.vars.phtml new file mode 100644 index 000000000..3b0d761cb --- /dev/null +++ b/tests/Latte/expected/BlockMacros.vars.phtml @@ -0,0 +1,73 @@ +getParentName()) { + return get_defined_vars(); + } + echo "\n"; + echo LR\Filters::escapeHtmlText($var) /* line %d% */; + echo ' + + +'; + $this->renderBlock('b', get_defined_vars()) /* line %d% */; + echo ' + +'; + echo LR\Filters::escapeHtmlText($var) /* line %d% */; + echo ' + + +'; + ob_start(function () {}) /* line %d% */; + echo ' '; + echo LR\Filters::escapeHtmlText($var) /* line %d% */; + echo "\n"; + $var = 'blockmod' /* line %d% */; + $ʟ_fi = new LR\FilterInfo('html'); + echo LR\Filters::convertTo($ʟ_fi, 'html', $this->filters->filterContent('trim', $ʟ_fi, ob_get_clean())); + echo ' + +'; + echo LR\Filters::escapeHtmlText($var) /* line %d% */; + echo ' + + + '; + echo LR\Filters::escapeHtmlText($var) /* line %d% */; + echo "\n"; + $var = 'block' /* line %d% */; + echo ' + +'; + echo LR\Filters::escapeHtmlText($var) /* line %d% */; + return get_defined_vars(); + } + + + /** {define a} on line %d% */ + public function blockA(array $ʟ_args): void + { + extract($this->params); + extract($ʟ_args); + echo ' '; + echo LR\Filters::escapeHtmlText($var) /* line %d% */; + echo "\n"; + $var = 'define' /* line %d% */; + + } + + + /** {block b} on line %d% */ + public function blockB(array $ʟ_args): void + { + extract($this->params); + extract($ʟ_args); + echo ' '; + echo LR\Filters::escapeHtmlText($var) /* line %d% */; + echo "\n"; + $var = 'blocknamed' /* line %d% */; + + } +%A%