Conditions | 1 |
Paths | 1 |
Total Lines | 34 |
Code Lines | 24 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
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 | } |