RequestFactoryTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 15
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testCreatesRequest() 0 13 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gorynych\Tests\Http;
6
7
use Gorynych\Http\RequestFactory;
8
use PHPUnit\Framework\TestCase;
9
use Symfony\Component\HttpFoundation\Request;
10
11
class RequestFactoryTest extends TestCase
12
{
13
    public function testCreatesRequest(): void
14
    {
15
        $_ENV['BASE_URI'] = 'http://localhost';
16
17
        $request = (new RequestFactory())->create(Request::METHOD_POST, '/resources', [
18
            RequestFactory::REQUEST_JSON => ['foo' => 'bar']
19
        ]);
20
21
        $this->assertSame(json_encode(['foo' => 'bar']), $request->getContent());
22
        $this->assertSame(Request::METHOD_POST, $request->getMethod());
23
        $this->assertSame('http://localhost/resources', $request->getUri());
24
        $this->assertSame('application/json', $request->headers->get('Accept'));
25
        $this->assertSame('application/json', $request->headers->get('Content-Type'));
26
    }
27
}
28