StatsTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 30
dl 0
loc 65
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetStats() 0 22 1
A setUp() 0 13 1
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * File:StatsTest.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\Middleware\Test\Unit\App\Stats;
12
13
use MSlwk\Otomoto\App\Manufacturer\Data\ManufacturerDTOInterface;
14
use MSlwk\Otomoto\App\Model\Data\ModelDTOInterface;
15
use MSlwk\Otomoto\App\Stats\Data\StatsDTOInterface;
16
use MSlwk\Otomoto\App\Stats\Filter\FilterArray;
17
use MSlwk\Otomoto\App\Stats\StatsProvider;
18
use MSlwk\Otomoto\Middleware\App\Stats\Stats;
19
use PHPUnit\Framework\MockObject\MockObject;
20
use PHPUnit\Framework\TestCase;
21
22
/**
23
 * Class StatsTest
24
 * @package MSlwk\Otomoto\Middleware\Test\Unit\App\Stats
25
 */
26
class StatsTest extends TestCase
27
{
28
    /**
29
     * @var MockObject|StatsProvider
30
     */
31
    private $statsProvider;
32
33
    /**
34
     * @var MockObject|ManufacturerDTOInterface
35
     */
36
    private $manufacturer;
37
38
    /**
39
     * @var MockObject|ModelDTOInterface
40
     */
41
    private $model;
42
43
    /**
44
     * @var MockObject|FilterArray
45
     */
46
    private $filters;
47
48
    /**
49
     * @return void
50
     */
51
    protected function setUp()
52
    {
53
        $this->statsProvider = $this->getMockBuilder(StatsProvider::class)
54
            ->disableOriginalConstructor()
55
            ->getMock();
56
57
        $this->manufacturer = $this->getMockBuilder(ManufacturerDTOInterface::class)
58
            ->getMock();
59
        $this->model = $this->getMockBuilder(ModelDTOInterface::class)
60
            ->getMock();
61
        $this->filters = $this->getMockBuilder(FilterArray::class)
62
            ->disableOriginalConstructor()
63
            ->getMock();
64
    }
65
66
    /**
67
     * @test
68
     */
69
    public function testGetStats()
70
    {
71
        $statsMiddleware = new Stats($this->statsProvider);
72
73
        $stats = $this->getMockBuilder(StatsDTOInterface::class)
74
            ->getMock();
75
76
        $this->statsProvider->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not exist on MSlwk\Otomoto\App\Stats\StatsProvider. ( Ignorable by Annotation )

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

76
        $this->statsProvider->/** @scrutinizer ignore-call */ 
77
                              expects($this->once())

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...
77
            ->method('getStats')
78
            ->with(
79
                $this->manufacturer,
80
                $this->model,
81
                $this->filters
82
            )
83
            ->will($this->returnValue($stats));
84
85
        $result = $statsMiddleware->getStats(
86
            $this->manufacturer,
87
            $this->model,
88
            $this->filters
89
        );
90
        $this->assertEquals($stats, $result);
91
    }
92
}
93