Passed
Push — master ( a65783...53adb5 )
by Povilas
02:44
created

ListerTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 26
dl 0
loc 40
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Povs\ListerBundle\Service;
4
5
use PHPUnit\Framework\TestCase;
6
use Symfony\Component\HttpFoundation\Response;
7
8
/**
9
 * @author Povilas Margaiatis <[email protected]>
10
 */
11
class ListerTest extends TestCase
12
{
13
    public function testBuildList(): void
14
    {
15
        $mock = $this->createMock(ListManager::class);
16
        $mock->expects($this->once())
17
            ->method('buildList')
18
            ->with('listClass', 'listType', ['param1' => 'val1', 'param2' => 'val2'])
19
            ->willReturnSelf();
20
21
        $lister = new Lister($mock);
22
        $lister->buildList('listClass', 'listType', ['param1' => 'val1', 'param2' => 'val2']);
23
    }
24
25
    public function testGenerateResponse(): void
26
    {
27
        $response = new Response();
28
        $mock = $this->createMock(ListManager::class);
29
        $mock->expects($this->once())
30
            ->method('getResponse')
31
            ->with(['param1' => 'val1', 'param2' => 'val2'])
32
            ->willReturn($response);
33
34
        $lister = new Lister($mock);
35
        $res = $lister->generateResponse(['param1' => 'val1', 'param2' => 'val2']);
36
        $this->assertEquals($response, $res);
37
    }
38
39
    public function testGenerateData(): void
40
    {
41
        $data = 'data';
42
        $mock = $this->createMock(ListManager::class);
43
        $mock->expects($this->once())
44
            ->method('getData')
45
            ->with(['param1' => 'val1', 'param2' => 'val2'])
46
            ->willReturn($data);
47
48
        $lister = new Lister($mock);
49
        $res = $lister->generateData(['param1' => 'val1', 'param2' => 'val2']);
50
        $this->assertEquals($data, $res);
51
    }
52
}
53