Skip to content

Commit 031b7d1

Browse files
authored
[9.x] Improve test for HasNameRoute in RouteCollection Class (#44419)
1 parent 870ebe6 commit 031b7d1

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/Routing/RouteCollectionTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,4 +281,32 @@ public function testRouteCollectionDontMatchNonMatchingDoubleSlashes()
281281
);
282282
$this->routeCollection->match($request);
283283
}
284+
285+
public function testHasNameRouteMehod()
286+
{
287+
$this->routeCollection->add(
288+
new Route('GET', 'users', ['uses' => 'UsersController@index', 'as' => 'users'])
289+
);
290+
$this->routeCollection->add(
291+
new Route('GET', 'posts/{post}', ['uses' => 'PostController@show', 'as' => 'posts'])
292+
);
293+
294+
$this->routeCollection->add(
295+
new Route('GET', 'books/{book}', ['uses' => 'BookController@show'])
296+
);
297+
298+
$this->assertTrue($this->routeCollection->hasNamedRoute('users'));
299+
$this->assertTrue($this->routeCollection->hasNamedRoute('posts'));
300+
$this->assertFalse($this->routeCollection->hasNamedRoute('article'));
301+
$this->assertFalse($this->routeCollection->hasNamedRoute('books'));
302+
}
303+
304+
public function testToSymfonyRouteCollection()
305+
{
306+
$this->routeCollection->add(
307+
new Route('GET', 'users', ['uses' => 'UsersController@index', 'as' => 'users'])
308+
);
309+
310+
$this->assertInstanceOf("\Symfony\Component\Routing\RouteCollection", $this->routeCollection->toSymfonyRouteCollection());
311+
}
284312
}

0 commit comments

Comments
 (0)