/
githubmirror
/
framework
Обзор
Документация
Войти
/
githubmirror
/
framework
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
13.x
tests/Testing/AssertRedirectToSignedRouteTest.php
104 строки
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 AssertRedirectToSignedRouteTest 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('signed-route') ->name('signed-route'); $this->router ->get('signed-route-with-param/{param}') ->name('signed-route-with-param'); $this->urlGenerator = $this->app->make(UrlGenerator::class); } protected function defineEnvironment($app): void { $app['config']->set(['app.key' => 'AckfSECXIvnK5r28GVIWUAxmbBSjTsmF']); } public function testAssertRedirectToSignedRouteWithoutRouteName(): void { $this->router->get('test-route', function () { return new RedirectResponse($this->urlGenerator->signedRoute('signed-route')); }); $this->get('test-route') ->assertRedirectToSignedRoute(); } public function testAssertRedirectToSignedRouteWithRouteName(): void { $this->router->get('test-route', function () { return new RedirectResponse($this->urlGenerator->signedRoute('signed-route')); }); $this->get('test-route') ->assertRedirectToSignedRoute('signed-route'); } public function testAssertRedirectToSignedRouteWithRouteNameAndParams(): void { $this->router->get('test-route', function () { return new RedirectResponse($this->urlGenerator->signedRoute('signed-route-with-param', 'hello')); }); $this->router->get('test-route-with-extra-param', function () { return new RedirectResponse($this->urlGenerator->signedRoute('signed-route-with-param', [ 'param' => 'foo', 'extra' => 'another', ])); }); $this->get('test-route') ->assertRedirectToSignedRoute('signed-route-with-param', 'hello'); $this->get('test-route-with-extra-param') ->assertRedirectToSignedRoute('signed-route-with-param', [ 'param' => 'foo', 'extra' => 'another', ]); } public function testAssertRedirectToSignedRouteWithRouteNameToTemporarySignedRoute(): void { $this->router->get('test-route', function () { return new RedirectResponse($this->urlGenerator->temporarySignedRoute('signed-route', 60)); }); $this->get('test-route') ->assertRedirectToSignedRoute('signed-route'); } protected function tearDown(): void { Facade::setFacadeApplication(null); parent::tearDown(); } }