@@ 72-113 (lines=42) @@ | ||
69 | ); |
|
70 | } |
|
71 | ||
72 | public function testPathFromEntityToDestination() |
|
73 | { |
|
74 | $this->samepleJson = [ |
|
75 | "AppBundle\\Entity\\Root" => [ |
|
76 | "relations" => [ |
|
77 | "foo" => "AppBundle\\Entity\\Foo", |
|
78 | ] |
|
79 | ], |
|
80 | "AppBundle\\Entity\\Foo" => [ |
|
81 | "relations" => [ |
|
82 | "bar" => "AppBundle\\Entity\\Bar", |
|
83 | ] |
|
84 | ], |
|
85 | "AppBundle\\Entity\\Bar" => [ |
|
86 | "relations" => [ |
|
87 | "fizz" => "AppBundle\\Entity\\Fizz", |
|
88 | ] |
|
89 | ], |
|
90 | ]; |
|
91 | ||
92 | $this->mapper = $this |
|
93 | ->getMockBuilder('Mado\QueryBundle\Component\Meta\RelationDatamapper') |
|
94 | ->disableOriginalConstructor() |
|
95 | ->getMock(); |
|
96 | ||
97 | $this->mapper->expects($this->once()) |
|
98 | ->method('getMap') |
|
99 | ->will($this->returnValue( |
|
100 | $this->samepleJson |
|
101 | )); |
|
102 | ||
103 | $this->pathFinder = new JsonPathFinder( |
|
104 | $this->mapper |
|
105 | ); |
|
106 | ||
107 | $this->pathFinder->setEntity("AppBundle\\Entity\\Root"); |
|
108 | ||
109 | $this->assertEquals( |
|
110 | "foo.bar.fizz", |
|
111 | $this->pathFinder->getPathTo("AppBundle\\Entity\\Fizz") |
|
112 | ); |
|
113 | } |
|
114 | ||
115 | public function testBuildPathBetweenTwoEntities() |
|
116 | { |
|
@@ 115-156 (lines=42) @@ | ||
112 | ); |
|
113 | } |
|
114 | ||
115 | public function testBuildPathBetweenTwoEntities() |
|
116 | { |
|
117 | $this->samepleJson = [ |
|
118 | "GammaBundle\\Entity\\Item" => [ |
|
119 | "relations" => [ |
|
120 | "items" => "AppBundle\\Entity\\Foo", |
|
121 | ] |
|
122 | ], |
|
123 | "AppBundle\\Entity\\Foo" => [ |
|
124 | "relations" => [ |
|
125 | "item" => "ZarroBundle\\Entity\\Item", |
|
126 | ] |
|
127 | ], |
|
128 | "ZarroBundle\\Entity\\Item" => [ |
|
129 | "relations" => [ |
|
130 | "family" => "AppBundle\\Entity\\Family", |
|
131 | ] |
|
132 | ], |
|
133 | ]; |
|
134 | ||
135 | $this->mapper = $this |
|
136 | ->getMockBuilder('Mado\QueryBundle\Component\Meta\RelationDatamapper') |
|
137 | ->disableOriginalConstructor() |
|
138 | ->getMock(); |
|
139 | ||
140 | $this->mapper->expects($this->once()) |
|
141 | ->method('getMap') |
|
142 | ->will($this->returnValue( |
|
143 | $this->samepleJson |
|
144 | )); |
|
145 | ||
146 | $this->pathFinder = new JsonPathFinder( |
|
147 | $this->mapper |
|
148 | ); |
|
149 | ||
150 | $this->pathFinder->setQueryStartEntity("GammaBundle\\Entity\\Item"); |
|
151 | ||
152 | $this->assertEquals( |
|
153 | "_embedded.items.item.family", |
|
154 | $this->pathFinder->getPathToEntity("AppBundle\\Entity\\Family") |
|
155 | ); |
|
156 | } |
|
157 | ||
158 | /** |
|
159 | * @expectedException \RuntimeException |