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

DetailedErrorFormatterTest::testFormat()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 13
nc 1
nop 0
dl 0
loc 19
rs 9.4285
c 0
b 0
f 0
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