Passed
Push — master ( dce891...d0c2d0 )
by Paweł
02:40
created

testThrowsExceptionOnNotAcceptableFormat()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Http\Formatter;
6
7
use Gorynych\Http\Exception\NotAcceptableHttpException;
8
use Gorynych\Http\Formatter\FormatterFactory;
9
use Gorynych\Http\Formatter\JsonFormatter;
10
use PHPUnit\Framework\TestCase;
11
use Symfony\Component\Config\FileLocator;
12
13
class FormatterFactoryTest extends TestCase
14
{
15
    public function testCreatesFormatter(): void
16
    {
17
        $formatter = $this->setUpFormatterFactory()->create('application/json');
18
19
        $this->assertInstanceOf(JsonFormatter::class, $formatter);
20
    }
21
22
    public function testThrowsExceptionOnNotAcceptableFormat(): void
23
    {
24
        $this->expectException(NotAcceptableHttpException::class);
25
26
        $this->setUpFormatterFactory()->create('application/xml');
27
    }
28
29
    private function setUpFormatterFactory(): FormatterFactory
30
    {
31
        return new FormatterFactory(new FileLocator(__DIR__ . '/Resource'));
32
    }
33
}
34