Permalink
Browse files

task latteSyntaxChecker: warns on unknown macros

  • Loading branch information...
dg committed Mar 26, 2018
1 parent 2509273 commit dc19656fabdc2ea3af79d44ae26446b46a261121
Showing with 9 additions and 1 deletion.
  1. +2 −0 src/Tasks.php
  2. +7 −1 tests/Tasks.latteSyntaxChecker.phpt
@@ -172,6 +172,8 @@ public static function latteSyntaxChecker($contents, Result $result)
} catch (Latte\CompileException $e) {
if (!preg_match('#Unknown (macro|attribute)#A', $e->getMessage())) {
$result->error($e->getMessage(), $e->sourceLine);
} else {
$result->warning($e->getMessage(), $e->sourceLine);
}
}
}
@@ -9,10 +9,16 @@ require __DIR__ . '/bootstrap.php';
test(function () {
$result = new Result;
Tasks::latteSyntaxChecker('{hello}', $result); // ignores unknown macros
Tasks::latteSyntaxChecker('', $result); // no error
Assert::same([], $result->getMessages());
});
test(function () {
$result = new Result;
Tasks::latteSyntaxChecker('{hello}', $result); // ignores unknown macros
Assert::same([[Result::WARNING, 'Unknown macro {hello}', 1]], $result->getMessages());
});
test(function () {
$result = new Result;
Tasks::latteSyntaxChecker('{hello', $result);

0 comments on commit dc19656

Please sign in to comment.