-
-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathTasks.latteSyntaxChecker.phpt
More file actions
36 lines (28 loc) · 1.02 KB
/
Tasks.latteSyntaxChecker.phpt
File metadata and controls
36 lines (28 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
declare(strict_types=1);
use Nette\CodeChecker\Result;
use Nette\CodeChecker\Tasks;
use Tester\Assert;
require __DIR__ . '/bootstrap.php';
test(function () {
$result = new Result;
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, 'Unexpected tag {hello} (on line 1 at column 1)', 1]], $result->getMessages());
});
test(function () {
$result = new Result;
Tasks::latteSyntaxChecker('{hello', $result);
Assert::same([[Result::ERROR, 'Unterminated Latte tag (on line 1 at column 2)', 1]], $result->getMessages());
});
test(function () {
$result = new Result;
Tasks::latteSyntaxChecker('{var $x = +}', $result); // invalid PHP code
Assert::count(1, $result->getMessages());
Assert::same(Result::ERROR, $result->getMessages()[0][0]);
Assert::contains('Unexpected end (on line 1 at column 12)', $result->getMessages()[0][1]);
});