FilterFactoryTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 38
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testCreateFromYearFilter() 0 7 1
A testCreateFromToFilter() 0 7 1
A testCreateNotExistingFilterThrowsException() 0 6 1
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * File:FilterFactoryTest.php
6
 *
7
 * @author Maciej Sławik <[email protected]>
8
 * @copyright Copyright (C) 2018 Lizard Media (http://lizardmedia.pl)
9
 */
10
11
namespace MSlwk\Otomoto\App\Test\Unit\Stats\Filter;
12
13
use MSlwk\Otomoto\App\Exception\NoSuchFilterException;
14
use MSlwk\Otomoto\App\Stats\Filter\FilterFactory;
15
use MSlwk\Otomoto\App\Stats\Filter\FromYearFilter;
16
use MSlwk\Otomoto\App\Stats\Filter\ToYearFilter;
17
use PHPUnit\Framework\TestCase;
18
19
/**
20
 * Class FilterFactoryTest
21
 * @package MSlwk\Otomoto\App\Test\Unit\Stats\Filter
22
 */
23
class FilterFactoryTest extends TestCase
24
{
25
    /**
26
     * @test
27
     * @throws NoSuchFilterException
28
     */
29
    public function testCreateFromYearFilter()
30
    {
31
        $filterFactory = new FilterFactory();
32
        $expectedType = FromYearFilter::class;
33
        $result = $filterFactory->create('from', '2016');
34
35
        $this->assertInstanceOf($expectedType, $result);
36
    }
37
38
    /**
39
     * @test
40
     * @throws NoSuchFilterException
41
     */
42
    public function testCreateFromToFilter()
43
    {
44
        $filterFactory = new FilterFactory();
45
        $expectedType = ToYearFilter::class;
46
        $result = $filterFactory->create('to', '2016');
47
48
        $this->assertInstanceOf($expectedType, $result);
49
    }
50
51
    /**
52
     * @test
53
     * @throws NoSuchFilterException
54
     */
55
    public function testCreateNotExistingFilterThrowsException()
56
    {
57
        $filterFactory = new FilterFactory();
58
59
        $this->expectException(NoSuchFilterException::class);
60
        $filterFactory->create('not', 'existing');
61
    }
62
}
63