ToYearFilterTest::testSetGetValue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

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

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