Completed
Push — fix-2494 ( 3153ee...40d9bb )
by Sam
13:43 queued 06:38
created

DetailedErrorFormatterTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A testFormat() 0 19 1
1
<?php
2
3
namespace SilverStripe\Logging\Tests;
4
5
use SilverStripe\Dev\SapphireTest;
6
use SilverStripe\Logging\DetailedErrorFormatter;
7
use SilverStripe\Logging\Tests\DetailedErrorFormatterTest\ErrorGenerator;
8
9
class DetailedErrorFormatterTest extends SapphireTest
10
{
11
    public function testFormat()
12
    {
13
        $generator = new ErrorGenerator();
14
        $formatter = new DetailedErrorFormatter();
15
        $exception = $generator->mockException();
16
17
        $output = ''.$formatter->format(['context' => [
18
            'exception' => $exception,
19
        ]]);
20
21
        $base = __DIR__;
22
        $this->assertContains('ERROR [Emergency]: Uncaught Exception: Error', $output);
23
        $this->assertContains("Line 32 in $base/DetailedErrorFormatterTest/ErrorGenerator.php", $output);
24
        $this->assertContains('* 32:                  throw new Exception(\'Error\');', $output);
25
        $this->assertContains(
26
            'SilverStripe\\Logging\\Tests\\DetailedErrorFormatterTest\\ErrorGenerator->mockException(4)',
27
            $output
28
        );
29
    }
30
}
31