Passed
Pull Request — master (#233)
by Dmitriy
01:58
created

HtmlFormatterTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 13
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testFormatter() 0 11 1
1
<?php
2
3
namespace Yiisoft\Yii\Web\Tests;
4
5
use Nyholm\Psr7\Factory\Psr17Factory;
6
use Nyholm\Psr7\Response;
7
use PHPUnit\Framework\TestCase;
8
use Yiisoft\Yii\Web\Formatter\HtmlResponseFormatter;
9
use Yiisoft\Yii\Web\Response as WebResponse;
10
11
class HtmlFormatterTest extends TestCase
12
{
13
    public function testFormatter(): void
14
    {
15
        $streamFactory = new Psr17Factory();
16
        $response = new Response();
17
        $webResponse = new WebResponse('test', $response, $streamFactory);
18
        $formatter = new HtmlResponseFormatter();
19
        $result = $formatter->format($webResponse);
20
        $result->getBody()->rewind();
21
22
        $this->assertSame('test', $response->getBody()->getContents());
23
        $this->assertSame(['text/html; charset=UTF-8'], $result->getHeader('Content-Type'));
24
    }
25
}
26