mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Add more tests for DetailedErrorFormatter
This commit is contained in:
parent
73df3166b7
commit
2694a47c45
@ -6,7 +6,6 @@ use PHPUnit_Framework_MockObject_MockObject;
|
||||
use SilverStripe\Control\Email\Email;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\Dev\DebugView;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\Logging\DebugViewFriendlyErrorFormatter;
|
||||
|
||||
|
@ -8,7 +8,7 @@ use SilverStripe\Logging\Tests\DetailedErrorFormatterTest\ErrorGenerator;
|
||||
|
||||
class DetailedErrorFormatterTest extends SapphireTest
|
||||
{
|
||||
public function testFormat()
|
||||
public function testFormatWithException()
|
||||
{
|
||||
$generator = new ErrorGenerator();
|
||||
$formatter = new DetailedErrorFormatter();
|
||||
@ -27,4 +27,48 @@ class DetailedErrorFormatterTest extends SapphireTest
|
||||
$output
|
||||
);
|
||||
}
|
||||
|
||||
public function testFormatWithoutException()
|
||||
{
|
||||
$record = [
|
||||
'code' => 401,
|
||||
'message' => 'Denied',
|
||||
'file' => 'index.php',
|
||||
'line' => 4,
|
||||
];
|
||||
|
||||
$formatter = new DetailedErrorFormatter();
|
||||
$result = $formatter->format($record);
|
||||
|
||||
$this->assertContains('ERRNO 401', $result, 'Status code was not found in trace');
|
||||
$this->assertContains('Denied', $result, 'Message was not found in trace');
|
||||
$this->assertContains('Line 4 in index.php', $result, 'Line or filename were not found in trace');
|
||||
$this->assertContains(self::class, $result, 'Backtrace doesn\'t show current test class');
|
||||
}
|
||||
|
||||
public function testFormatBatch()
|
||||
{
|
||||
$records = [
|
||||
[
|
||||
'code' => 401,
|
||||
'message' => 'Denied',
|
||||
'file' => 'index.php',
|
||||
'line' => 4,
|
||||
],
|
||||
[
|
||||
'code' => 404,
|
||||
'message' => 'Not found',
|
||||
'file' => 'admin.php',
|
||||
'line' => 7,
|
||||
],
|
||||
];
|
||||
|
||||
$formatter = new DetailedErrorFormatter();
|
||||
$result = $formatter->formatBatch($records);
|
||||
|
||||
$this->assertContains('ERRNO 401', $result, 'First status code was not found in trace');
|
||||
$this->assertContains('ERRNO 404', $result, 'Second status code was not found in trace');
|
||||
$this->assertContains('Denied', $result, 'First message was not found in trace');
|
||||
$this->assertContains('Not found', $result, 'Second message was not found in trace');
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user