@@ 8-50 (lines=43) @@ | ||
5 | ||
6 | class DijkstraTest extends TestCase |
|
7 | { |
|
8 | public function testFindShortestPath() |
|
9 | { |
|
10 | $this->samepleJson = [ |
|
11 | "AppBundle\\Entity\\a" => [ |
|
12 | "relations" => [ |
|
13 | "item" => "AppBundle\\Entity\\Fizz", |
|
14 | ] |
|
15 | ], |
|
16 | "AppBundle\\Entity\\mood" => [ |
|
17 | "relations" => [ |
|
18 | "item" => "AppBundle\\Entity\\b", |
|
19 | ] |
|
20 | ], |
|
21 | "AppBundle\\Entity\\Fizz" => [ |
|
22 | "relations" => [ |
|
23 | "item" => "AppBundle\\Entity\\mood", |
|
24 | "item" => "AppBundle\\Entity\\b", |
|
25 | ] |
|
26 | ], |
|
27 | "AppBundle\\Entity\\b" => [ |
|
28 | "relations" => [ |
|
29 | "item" => "AppBundle\\Entity\\Fizz", |
|
30 | "icdsatem" => "AppBundle\\Entity\\a", |
|
31 | ] |
|
32 | ], |
|
33 | ]; |
|
34 | ||
35 | $dijkstra = new Dijkstra($this->samepleJson); |
|
36 | ||
37 | $paths = $dijkstra->shortestPaths( |
|
38 | 'AppBundle\\Entity\\a', |
|
39 | 'AppBundle\\Entity\\b' |
|
40 | ); |
|
41 | ||
42 | $this->assertEquals( |
|
43 | [[ |
|
44 | 'AppBundle\\Entity\\a', |
|
45 | 'AppBundle\\Entity\\Fizz', |
|
46 | 'AppBundle\\Entity\\b', |
|
47 | ]], |
|
48 | $paths |
|
49 | ); |
|
50 | } |
|
51 | ||
52 | public function testFindAlternativePaths() |
|
53 | { |
|
@@ 52-97 (lines=46) @@ | ||
49 | ); |
|
50 | } |
|
51 | ||
52 | public function testFindAlternativePaths() |
|
53 | { |
|
54 | $this->samepleJson = [ |
|
55 | "AppBundle\\Entity\\a" => [ |
|
56 | "relations" => [ |
|
57 | "item" => "AppBundle\\Entity\\Fizz", |
|
58 | ] |
|
59 | ], |
|
60 | "AppBundle\\Entity\\mood" => [ |
|
61 | "relations" => [ |
|
62 | "item" => "AppBundle\\Entity\\b", |
|
63 | ] |
|
64 | ], |
|
65 | "AppBundle\\Entity\\Fizz" => [ |
|
66 | "relations" => [ |
|
67 | "item" => "AppBundle\\Entity\\mood", |
|
68 | "item" => "AppBundle\\Entity\\b", |
|
69 | ] |
|
70 | ], |
|
71 | "AppBundle\\Entity\\b" => [ |
|
72 | "relations" => [ |
|
73 | "item" => "AppBundle\\Entity\\Fizz", |
|
74 | "icdsatem" => "AppBundle\\Entity\\a", |
|
75 | ] |
|
76 | ], |
|
77 | ]; |
|
78 | ||
79 | $dijkstra = new Dijkstra($this->samepleJson); |
|
80 | ||
81 | $paths = $dijkstra->shortestPaths( |
|
82 | 'AppBundle\\Entity\\a', |
|
83 | 'AppBundle\\Entity\\b', |
|
84 | $excluded = [ |
|
85 | 'AppBundle\\Entity\\mood', |
|
86 | ] |
|
87 | ); |
|
88 | ||
89 | $this->assertEquals( |
|
90 | [ |
|
91 | 'AppBundle\\Entity\\a', |
|
92 | 'AppBundle\\Entity\\Fizz', |
|
93 | 'AppBundle\\Entity\\b', |
|
94 | ], |
|
95 | $paths[0] |
|
96 | ); |
|
97 | } |
|
98 | } |
|
99 |