/
githubmirror
/
framework
Обзор
Документация
Войти
/
githubmirror
/
framework
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
13.x
tests/Testing/AssertRedirectToRouteTest.php
93 строки
3 KB
Lucas Michot
[12.x] Run Mockery cleanup via PHPUnit subscriber instead of explicit `m::close()` calls (#58278)
05 янв 2026, 20:12
Не верифицирован
05 янв 2026, 20:12
7b3351e
Код
Авторство
О чём код?
<?php namespace Illuminate\Tests\Testing; use Illuminate\Contracts\Routing\Registrar; use Illuminate\Http\RedirectResponse; use Illuminate\Routing\UrlGenerator; use Illuminate\Support\Facades\Facade; use Orchestra\Testbench\TestCase; class AssertRedirectToRouteTest extends TestCase { /** * @var \Illuminate\Contracts\Routing\Registrar */ private $router; /** * @var \Illuminate\Routing\UrlGenerator */ private $urlGenerator; protected function setUp(): void { parent::setUp(); $this->router = $this->app->make(Registrar::class); $this->router ->get('named-route') ->name('named-route'); $this->router ->get('named-route-with-param/{param}') ->name('named-route-with-param'); $this->router ->get('') ->name('route-with-empty-uri'); $this->urlGenerator = $this->app->make(UrlGenerator::class); } public function testAssertRedirectToRouteWithRouteName(): void { $this->router->get('test-route', function () { return new RedirectResponse($this->urlGenerator->route('named-route')); }); $this->get('test-route') ->assertRedirectToRoute('named-route'); } public function testAssertRedirectToRouteWithRouteNameAndParams(): void { $this->router->get('test-route', function () { return new RedirectResponse($this->urlGenerator->route('named-route-with-param', 'hello')); }); $this->router->get('test-route-with-extra-param', function () { return new RedirectResponse($this->urlGenerator->route('named-route-with-param', [ 'param' => 'foo', 'extra' => 'another', ])); }); $this->get('test-route') ->assertRedirectToRoute('named-route-with-param', 'hello'); $this->get('test-route-with-extra-param') ->assertRedirectToRoute('named-route-with-param', [ 'param' => 'foo', 'extra' => 'another', ]); } public function testAssertRedirectToRouteWithRouteNameAndParamsWhenRouteUriIsEmpty(): void { $this->router->get('test-route', function () { return new RedirectResponse($this->urlGenerator->route('route-with-empty-uri', ['foo' => 'bar'])); }); $this->get('test-route') ->assertRedirectToRoute('route-with-empty-uri', ['foo' => 'bar']); } protected function tearDown(): void { Facade::setFacadeApplication(null); parent::tearDown(); } }