|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Camspiers\LoggerBridge; |
|
4
|
|
|
|
|
5
|
|
|
use Camspiers\LoggerBridge\BacktraceReporter\BasicBacktraceReporter; |
|
6
|
|
|
|
|
7
|
|
|
class BasicBacktraceReporterTest extends \PHPUnit_Framework_TestCase |
|
8
|
|
|
{ |
|
9
|
|
|
public function testBacktraceLimitGet() |
|
10
|
|
|
{ |
|
11
|
|
|
$reporter = new BasicBacktraceReporter(); |
|
12
|
|
|
|
|
13
|
|
|
$this->assertEquals(0, $reporter->getBacktraceLimit()); |
|
14
|
|
|
} |
|
15
|
|
|
|
|
16
|
|
|
public function testGetExceptionBacktrace() |
|
17
|
|
|
{ |
|
18
|
|
|
$reporter = new BasicBacktraceReporter(); |
|
19
|
|
|
|
|
20
|
|
|
$exception = new \Exception('Test'); |
|
21
|
|
|
|
|
22
|
|
|
$backtrace = $exception->getTrace(); |
|
23
|
|
|
|
|
24
|
|
|
foreach ($backtrace as $index => $backtraceCall) { |
|
25
|
|
|
unset($backtrace[$index]['args']); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
$this->assertEquals($backtrace, $reporter->getBacktrace($exception)); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
public function testGetGlobalBacktrace() |
|
32
|
|
|
{ |
|
33
|
|
|
$reporter = new BasicBacktraceReporter(); |
|
34
|
|
|
|
|
35
|
|
|
$reporterBacktrace = $reporter->getBacktrace(); |
|
36
|
|
|
|
|
37
|
|
|
array_shift($reporterBacktrace); |
|
38
|
|
|
|
|
39
|
|
|
$this->assertEquals(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS), $reporterBacktrace); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public function testGetGlobalExceptionWithLimit() |
|
43
|
|
|
{ |
|
44
|
|
|
$reporter = new BasicBacktraceReporter(); |
|
45
|
|
|
$reporter->setBacktraceLimit(2); |
|
46
|
|
|
|
|
47
|
|
|
$exception = new \Exception('Test'); |
|
48
|
|
|
|
|
49
|
|
|
$this->assertEquals(2, count($reporter->getBacktrace($exception))); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
public function testGetGlobalBacktraceWithLimit() |
|
53
|
|
|
{ |
|
54
|
|
|
$reporter = new BasicBacktraceReporter(); |
|
55
|
|
|
$reporter->setBacktraceLimit(2); |
|
56
|
|
|
|
|
57
|
|
|
$this->assertEquals(2, count($reporter->getBacktrace())); |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|