Skip to content

Commit

Permalink
append output
Browse files Browse the repository at this point in the history
  • Loading branch information
matthes committed Jul 27, 2018
1 parent 0b6d09e commit 821d199
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 22 deletions.
20 changes: 10 additions & 10 deletions test/unit/tpls/15_print/out.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
1:
2:
3:
4:
2:
3:
4:

AAA
5:
AAA
5:

BBB
BBB
6:
BBB
BBB
6:

CCC
7:
CCC
7:
20 changes: 8 additions & 12 deletions test/value-redirection.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,19 @@ $tpl = <<<EOT
EOT;

$compare = <<<EOT
-A-*AAA*
-A-
-B-
-C-
*BBB*
AAA
-D-
BBB
BBB
EOT;


$template = new TextTemplate($tpl);
$sec = [];
$template->addSection("section", function ($content, $params, $command, $context, $cmdParam) use (&$sec) {
$sec[$params["name"]] = $content;
if ($command !== "section")
throw new InvalidArgumentException("Command missing");
return "*" . trim ($content) . "*";
});
$textResult = $template->apply([]);

Assert::equal($compare, $textResult);
Assert::equal("AAA", trim($sec["A"]));
Assert::equal("BBB", trim($sec["B"]));
Assert::equal($compare, $textResult);

0 comments on commit 821d199

Please sign in to comment.