-
-
Notifications
You must be signed in to change notification settings - Fork 218
/
Copy pathDebugger.warnings.html.phpt
74 lines (57 loc) · 1.6 KB
/
Debugger.warnings.html.phpt
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
/**
* Test: Tracy\Debugger notices and warnings in HTML.
* @outputMatch OK!
*/
declare(strict_types=1);
use Tester\Assert;
use Tester\DomQuery;
use Tracy\Debugger;
require __DIR__ . '/../bootstrap.php';
if (PHP_SAPI === 'cli') {
Tester\Environment::skip('Debugger Bar is not rendered in CLI mode');
}
Debugger::$productionMode = false;
setHtmlMode();
ob_start();
Debugger::enable();
register_shutdown_function(function () {
$output = ob_get_clean();
preg_match('#Tracy\.Debug\.init\((".*[^\\\]")\)#', $output, $m);
$rawContent = json_decode($m[1]);
$panelContent = (string) DomQuery::fromHtml($rawContent)->find('#tracy-debug-panel-Tracy-errors')[0]['data-tracy-content'];
Assert::match(<<<'XX'
%A%<table class="tracy-sortable">
<tr>
<td class="tracy-right">1%a%</td>
<td><pre>Notice: Only variables should be assigned by reference in %a%:%d%</a></pre></td>
</tr>
<tr>
<td class="tracy-right">1%a%</td>
<td><pre>Warning: hex2bin(): Hexadecimal input string must have an even length in %a%:%d%</a></pre></td>
</tr>
<tr>
<td class="tracy-right">1%a%</td>
<td><pre>Compile Warning: Unsupported declare 'foo' in %a%:%d%</a></pre></td>
</tr>
</table>
</div>%A%
XX, $panelContent);
echo 'OK!'; // prevents PHP bug #62725
});
function first($arg1, $arg2)
{
second(true, false);
}
function second($arg1, $arg2)
{
third([1, 2, 3]);
}
function third($arg1)
{
$x = &pi(); // E_NOTICE
hex2bin('a'); // E_WARNING
require __DIR__ . '/fixtures/E_COMPILE_WARNING.php'; // E_COMPILE_WARNING
// E_COMPILE_WARNING is handled in shutdownHandler()
}
first(10, 'any string');