This repository was archived by the owner on Sep 16, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -190,8 +190,11 @@ public function getReferringAutoRoutes($contentDocument)
190
190
public function findRouteForUri ($ uri , UriContext $ uriContext )
191
191
{
192
192
$ path = $ this ->getPathFromUri ($ uri );
193
-
194
- return $ this ->dm ->find (null , $ path );
193
+ $ node = $ this ->dm ->find (null , $ path );
194
+ if ($ node instanceof AutoRouteInterface) {
195
+ return $ node ;
196
+ }
197
+ return false ;
195
198
}
196
199
197
200
private function getPathFromUri ($ uri )
Original file line number Diff line number Diff line change @@ -174,11 +174,19 @@ public function testGetReferringRoutes()
174
174
public function testFindRouteForUri ()
175
175
{
176
176
$ uri = '/this/is/uri ' ;
177
- $ expectedRoutes = array ( $ this ->route ->reveal () );
177
+ $ expectedRoute = $ this ->route ->reveal ();
178
178
179
- $ this ->dm ->find (null , $ this ->baseRoutePath . $ uri )->willReturn ($ expectedRoutes );
179
+ $ this ->dm ->find (null , $ this ->baseRoutePath . $ uri )->willReturn ($ expectedRoute );
180
180
181
181
$ res = $ this ->adapter ->findRouteForUri ($ uri , $ this ->uriContext ->reveal ());
182
- $ this ->assertSame ($ expectedRoutes , $ res );
182
+ $ this ->assertSame ($ expectedRoute , $ res );
183
+ }
184
+
185
+ public function testFindRouteForUriShouldReturnFalseWhenNodeAtGivenPathIsNotAnAutoRoute ()
186
+ {
187
+ $ uri = '/this/is/uri ' ;
188
+ $ genericNode = $ this ->prophesize ('Doctrine\ODM\PHPCR\Document\Generic ' );
189
+ $ this ->dm ->find (null , $ this ->baseRoutePath . $ uri )->willReturn ($ genericNode );
190
+ $ this ->assertFalse ($ this ->adapter ->findRouteForUri ($ uri , $ this ->uriContext ->reveal ()));
183
191
}
184
192
}
You can’t perform that action at this time.
0 commit comments