Skip to content

Commit

Permalink
[9.x] Fix route:list command output (#41177)
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgergo authored Feb 22, 2022
1 parent 81e2441 commit 97d67e1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Illuminate/Foundation/Console/RouteListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ protected function forCli($routes)
fn ($route) => array_merge($route, [
'action' => $this->formatActionForCli($route),
'method' => $route['method'] == 'GET|HEAD|POST|PUT|PATCH|DELETE|OPTIONS' ? 'ANY' : $route['method'],
'uri' => $route['domain'] ? ($route['domain'].'/'.$route['uri']) : $route['uri'],
'uri' => $route['domain'] ? ($route['domain'].'/'.ltrim($route['uri'], '/')) : $route['uri'],
]),
);

Expand Down
10 changes: 10 additions & 0 deletions tests/Testing/Console/RouteListCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,21 @@ protected function setUp(): void

public function testDisplayRoutesForCli()
{
$this->router->get('/', function () {
//
});

$this->router->get('closure', function () {
return new RedirectResponse($this->urlGenerator->signedRoute('signed-route'));
});

$this->router->get('controller-method/{user}', [FooController::class, 'show']);
$this->router->post('controller-invokable', FooController::class);
$this->router->domain('{account}.example.com')->group(function () {
$this->router->get('/', function () {
//
});

$this->router->get('user/{id}', function ($account, $id) {
//
})->name('user.show')->middleware('web');
Expand All @@ -50,6 +58,8 @@ public function testDisplayRoutesForCli()
$this->artisan(RouteListCommand::class)
->assertSuccessful()
->expectsOutput('')
->expectsOutput(' GET|HEAD / ..................................................... ')
->expectsOutput(' GET|HEAD {account}.example.com/ ................................ ')
->expectsOutput(' GET|HEAD closure ............................................... ')
->expectsOutput(' POST controller-invokable Illuminate\Tests\Testing\Console\…')
->expectsOutput(' GET|HEAD controller-method/{user} Illuminate\Tests\Testing\Cons…')
Expand Down

0 comments on commit 97d67e1

Please sign in to comment.