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)) |
|
|
|
|
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
|
|
|
|
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.