Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[9.x] Fix route:list command output #41177

Merged
merged 1 commit into from
Feb 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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