FromYearFilterTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * File:FromYearFilterTest.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\IncorrectFilterValueException;
14
use MSlwk\Otomoto\App\Stats\Filter\FromYearFilter;
15
use MSlwk\Otomoto\App\Stats\Filter\Validator\FilterValidatorInterface;
16
use PHPUnit\Framework\MockObject\MockObject;
17
use PHPUnit\Framework\TestCase;
18
19
/**
20
 * Class FromYearFilterTest
21
 * @package MSlwk\Otomoto\App\Test\Unit\Stats\Filter
22
 */
23
class FromYearFilterTest extends TestCase
24
{
25
    /**
26
     * @var MockObject|FilterValidatorInterface
27
     */
28
    private $validator;
29
30
    /**
31
     * @return void
32
     */
33
    protected function setUp()
34
    {
35
        $this->validator = $this->getMockBuilder(FilterValidatorInterface::class)
36
            ->getMock();
37
    }
38
39
    /**
40
     * @test
41
     * @throws IncorrectFilterValueException
42
     */
43
    public function testSetGetValue()
44
    {
45
        $this->validator->expects($this->exactly(2))
0 ignored issues
show
Bug introduced by
The method expects() does not exist on MSlwk\Otomoto\App\Stats\...ilterValidatorInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

45
        $this->validator->/** @scrutinizer ignore-call */ 
46
                          expects($this->exactly(2))

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
46
            ->method('validate')
47
            ->withConsecutive(['2015'], ['2017']);
48
49
        $filter = new FromYearFilter($this->validator, '2015');
50
51
        $this->assertEquals('2015', $filter->getValue());
52
        $filter->setValue('2017');
53
        $this->assertEquals('2017', $filter->getValue());
54
    }
55
56
    /**
57
     * @test
58
     */
59
    public function testGetName()
60
    {
61
        $filter = new FromYearFilter($this->validator, '2015');
62
        $expected = 'search[filter_float_year:from]';
63
        $this->assertEquals($expected, $filter->getName());
64
    }
65
66
    /**
67
     * @test
68
     */
69
    public function testGetDescription()
70
    {
71
        $filter = new FromYearFilter($this->validator, '2015');
72
        $expected = 'FROM year of production';
73
        $this->assertEquals($expected, $filter->getDescription());
74
    }
75
}
76