ListControllerTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 4
Bugs 0 Features 3
Metric Value
wmc 1
c 4
b 0
f 3
lcom 0
cbo 4
dl 0
loc 37
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B testOnDispatch() 0 34 1
1
<?php
2
3
namespace Sebaks\CrudTest\Controller\Admin;
4
5
use Sebaks\Crud\Controller\ListController;
6
use Sebaks\Crud\View\Model\ListViewModel;
7
8
class ListControllerTest extends \PHPUnit_Framework_TestCase
9
{
10
    public function testOnDispatch()
11
    {
12
        $query = ['foo' => 'bar'];
13
        $filter = $query;
14
        $collection = new \ArrayObject();
15
16
        $repositoryMock = $this->getMock('T4webDomainInterface\Infrastructure\RepositoryInterface');
17
        $criteriaMock = $this->getMock('T4webDomainInterface\Infrastructure\CriteriaInterface');
18
19
        $repositoryMock->method('createCriteria')
20
            ->with($filter)
21
            ->willReturn($criteriaMock);
22
23
        $repositoryMock->method('findMany')
24
            ->with($criteriaMock)
25
            ->willReturn($collection);
26
27
        $listViewModel = new ListViewModel();
28
29
        $eventMock = $this->getMock('Zend\Mvc\MvcEvent');
30
        $eventMock->method('setResult')
31
            ->with($listViewModel);
32
33
        $controller = new ListController(
34
            $query,
35
            $repositoryMock,
36
            $listViewModel
37
        );
38
        $actualViewModel = $controller->onDispatch($eventMock);
39
40
        $this->assertSame($listViewModel, $actualViewModel);
41
        $this->assertSame($collection, $actualViewModel->getCollection());
42
        $this->assertSame($filter, $actualViewModel->getInputData());
43
    }
44
}