Passed
Pull Request — master (#168)
by Alexander
11:02
created

HtmlRendererTest::testSimple()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 9
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 11
rs 9.9666
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