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

FormatterFactoryTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 19
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testThrowsExceptionOnNotAcceptableFormat() 0 5 1
A setUpFormatterFactory() 0 3 1
A testCreatesFormatter() 0 5 1
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