2017-05-11 07:38:29 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace SilverStripe\Logging\Tests;
|
|
|
|
|
|
|
|
use SilverStripe\Control\Email\Email;
|
|
|
|
use SilverStripe\Dev\SapphireTest;
|
|
|
|
use SilverStripe\Logging\DebugViewFriendlyErrorFormatter;
|
|
|
|
|
|
|
|
class DebugViewFriendlyErrorFormatterTest extends SapphireTest
|
|
|
|
{
|
|
|
|
public function setUp()
|
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
Email::config()->set('admin_email', 'testy@mctest.face');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testOutput()
|
|
|
|
{
|
|
|
|
$formatter = new DebugViewFriendlyErrorFormatter();
|
|
|
|
$formatter->setTitle("There has been an error");
|
|
|
|
$formatter->setBody("The website server has not been able to respond to your request");
|
|
|
|
|
|
|
|
$expected = <<<TEXT
|
|
|
|
WEBSITE ERROR
|
|
|
|
There has been an error
|
|
|
|
-----------------------
|
|
|
|
The website server has not been able to respond to your request
|
|
|
|
|
|
|
|
Contact an administrator: testy [at] mctest [dot] face
|
|
|
|
|
|
|
|
|
2019-10-03 00:31:43 +02:00
|
|
|
TEXT
|
|
|
|
;
|
|
|
|
|
|
|
|
$this->assertEquals($expected, $formatter->output(404));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testAdminEmailWithName()
|
|
|
|
{
|
|
|
|
Email::config()->set('admin_email', ['testy@mctest.face' => 'The ad&min']);
|
|
|
|
|
|
|
|
$formatter = new DebugViewFriendlyErrorFormatter();
|
|
|
|
$formatter->setTitle("There has been an error");
|
|
|
|
$formatter->setBody("The website server has not been able to respond to your request");
|
|
|
|
|
|
|
|
$expected = <<<TEXT
|
|
|
|
WEBSITE ERROR
|
|
|
|
There has been an error
|
|
|
|
-----------------------
|
|
|
|
The website server has not been able to respond to your request
|
|
|
|
|
|
|
|
Contact The ad&min: testy [at] mctest [dot] face
|
|
|
|
|
|
|
|
|
2017-05-11 07:38:29 +02:00
|
|
|
TEXT
|
|
|
|
;
|
|
|
|
|
|
|
|
$this->assertEquals($expected, $formatter->output(404));
|
|
|
|
}
|
|
|
|
}
|