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 deprecation warnings from route:list when filtering on name or domain #41421

Merged
merged 2 commits into from Mar 10, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Illuminate/Foundation/Console/RouteListCommand.php
Expand Up @@ -240,10 +240,10 @@ protected function isVendorRoute(Route $route)
*/
protected function filterRoute(array $route)
{
if (($this->option('name') && ! Str::contains($route['name'], $this->option('name'))) ||
if (($this->option('name') && ! Str::contains((string) $route['name'], $this->option('name'))) ||
($this->option('path') && ! Str::contains($route['uri'], $this->option('path'))) ||
($this->option('method') && ! Str::contains($route['method'], strtoupper($this->option('method')))) ||
($this->option('domain') && ! Str::contains($route['domain'], $this->option('domain'))) ||
($this->option('domain') && ! Str::contains((string) $route['domain'], $this->option('domain'))) ||
($this->option('except-vendor') && $route['vendor'])) {
return;
}
Expand Down
21 changes: 21 additions & 0 deletions tests/Testing/Console/RouteListCommandTest.php
Expand Up @@ -5,13 +5,16 @@
use Illuminate\Contracts\Routing\Registrar;
use Illuminate\Foundation\Auth\User;
use Illuminate\Foundation\Console\RouteListCommand;
use Illuminate\Foundation\Testing\Concerns\InteractsWithDeprecationHandling;
use Illuminate\Http\RedirectResponse;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Facade;
use Orchestra\Testbench\TestCase;

class RouteListCommandTest extends TestCase
{
use InteractsWithDeprecationHandling;

/**
* @var \Illuminate\Contracts\Routing\Registrar
*/
Expand Down Expand Up @@ -92,6 +95,24 @@ public function testDisplayRoutesForCliInVerboseMode()
->expectsOutput('');
}

public function testRouteCanBeFilteredByName()
{
$this->withoutDeprecationHandling();

$this->router->get('/', function () {
//
});
$this->router->get('/foo', function () {
//
})->name('foo.show');

$this->artisan(RouteListCommand::class, ['--name' => 'foo'])
->assertSuccessful()
->expectsOutput('')
->expectsOutput(' GET|HEAD foo ...................................... foo.show')
->expectsOutput('');
}

protected function tearDown(): void
{
parent::tearDown();
Expand Down