Conditions | 1 |
Paths | 1 |
Total Lines | 47 |
Code Lines | 33 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
31 | public function testBuildPathUsingDijkstra() |
||
32 | { |
||
33 | $this->mapper = $this |
||
34 | ->getMockBuilder('Mado\QueryBundle\Component\Meta\DataMapper') |
||
35 | ->disableOriginalConstructor() |
||
36 | ->getMock(); |
||
37 | $this->mapper->expects($this->once()) |
||
38 | ->method('getMap') |
||
39 | ->will($this->returnValue($laMappa = [ |
||
40 | 'start' => [ |
||
41 | 'relations' => [ |
||
42 | 'fine' => 'end', |
||
43 | ] |
||
44 | ], |
||
45 | 'end' => [ |
||
46 | 'relations' => [ |
||
47 | 'inizio' => 'start', |
||
48 | ] |
||
49 | ] |
||
50 | ])); |
||
51 | |||
52 | $this->dijkstra = $this |
||
53 | ->getMockBuilder('Mado\QueryBundle\Component\Meta\Dijkstra') |
||
54 | ->disableOriginalConstructor() |
||
55 | ->getMock(); |
||
56 | $this->dijkstra->expects($this->once()) |
||
57 | ->method('setMap') |
||
58 | ->with($laMappa); |
||
59 | $this->dijkstra->expects($this->once()) |
||
60 | ->method('shortestPaths') |
||
61 | ->will($this->returnValue([[ |
||
62 | 'start', |
||
63 | 'end' |
||
64 | ]])); |
||
65 | |||
66 | $this->walker = new DijkstraWalker( |
||
67 | $this->mapper, |
||
68 | $this->dijkstra |
||
69 | ); |
||
70 | |||
71 | $this->walker->buildPathBetween('start', 'end'); |
||
72 | |||
73 | $pathFound = $this->walker->getPath(); |
||
74 | |||
75 | $this->assertEquals( |
||
76 | '_embedded.fine', |
||
77 | $pathFound |
||
78 | ); |
||
81 |