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

XmlFormatterTest::testFormatter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 10
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 14
rs 9.9332
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\XmlResponseFormatter;
9
use Yiisoft\Yii\Web\Response as WebResponse;
10
11
class XmlFormatterTest 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 XmlResponseFormatter($streamFactory);
19
        $result = $formatter->format($webResponse);
20
        $result->getBody()->rewind();
21
22
        $this->assertSame(
23
            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<response>test</response>\n",
24
            $response->getBody()->getContents()
25
        );
26
        $this->assertSame(['application/xml; UTF-8'], $result->getHeader('Content-Type'));
27
    }
28
}
29
30