-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathExceptionCodeProcessorTest.php
More file actions
59 lines (49 loc) · 1.5 KB
/
ExceptionCodeProcessorTest.php
File metadata and controls
59 lines (49 loc) · 1.5 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php declare(strict_types=1);
namespace KoderHut\OnelogBundle\Tests\Middleware;
use KoderHut\OnelogBundle\Middleware\ExceptionCodeProcessor;
use PHPUnit\Framework\TestCase;
/**
* Class ExceptionCodeProcessorTest
*
* @author Joao Jacome <969041+joaojacome@users.noreply.github.com>
*
* @covers \KoderHut\OnelogBundle\Middleware\ExceptionCodeProcessor
*/
class ExceptionCodeProcessorTest extends TestCase
{
/**
* @test
*/
public function testProcessWithException()
{
$processor = new ExceptionCodeProcessor();
$parentException = new \Exception('parent exception', 204);
$processed = $processor->process('debug', $parentException, []);
$this->assertEquals([
$parentException,
[
'code' => 204
]],
$processed
);
}
/**
* @test
*/
public function testProcessWithNestedExceptions()
{
$processor = new ExceptionCodeProcessor();
$grandChildException = new \Exception('grand child exception', 202);
$childException = new \Exception('child exception', 203, $grandChildException);
$parentException = new \Exception('parent exception', 204, $childException);
$processed = $processor->process('debug', $parentException, []);
$this->assertEquals([
$parentException,
[
'codes' => [204, 203, 202],
'code' => 204
]],
$processed
);
}
}