|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Yiisoft\Yii\Web\Tests\ErrorHandler; |
|
4
|
|
|
|
|
5
|
|
|
use Nyholm\Psr7\ServerRequest; |
|
6
|
|
|
use PHPUnit\Framework\TestCase; |
|
7
|
|
|
use RuntimeException; |
|
8
|
|
|
use Yiisoft\Yii\Web\ErrorHandler\HtmlRenderer; |
|
9
|
|
|
|
|
10
|
|
|
class HtmlRendererTest extends TestCase |
|
11
|
|
|
{ |
|
12
|
|
|
public function testNonVerboseOutput(): void |
|
13
|
|
|
{ |
|
14
|
|
|
$renderer = new HtmlRenderer(); |
|
15
|
|
|
$request = new ServerRequest('GET', '/', ['Accept' => ['text/html']]); |
|
16
|
|
|
$renderer->setRequest($request); |
|
17
|
|
|
$exceptionMessage = 'exception-test-message'; |
|
18
|
|
|
$exception = new \RuntimeException($exceptionMessage); |
|
19
|
|
|
$renderedOutput = $renderer->render($exception); |
|
20
|
|
|
$this->assertContains('<html', $renderedOutput); |
|
21
|
|
|
$this->assertNotContains(RuntimeException::class, $renderedOutput); |
|
22
|
|
|
$this->assertNotContains($exceptionMessage, $renderedOutput); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
public function testVerboseOutput(): void |
|
26
|
|
|
{ |
|
27
|
|
|
$renderer = new HtmlRenderer(); |
|
28
|
|
|
$request = new ServerRequest('GET', '/', ['Accept' => ['text/html']]); |
|
29
|
|
|
$renderer->setRequest($request); |
|
30
|
|
|
$exceptionMessage = 'exception-test-message'; |
|
31
|
|
|
$exception = new \RuntimeException($exceptionMessage); |
|
32
|
|
|
$renderedOutput = $renderer->renderVerbose($exception); |
|
33
|
|
|
$this->assertContains('<html', $renderedOutput); |
|
34
|
|
|
$this->assertContains(RuntimeException::class, $renderedOutput); |
|
35
|
|
|
$this->assertContains($exceptionMessage, $renderedOutput); |
|
36
|
|
|
} |
|
37
|
|
|
} |
|
38
|
|
|
|