/
githubmirror
/
framework
Обзор
Документация
Войти
/
githubmirror
/
framework
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
13.x
tests/Testing/AssertRedirectToActionTest.php
70 строк
2 KB
Lucas Michot
[13.x] testsuite (#59702)
15 апр 2026, 15:58
Не верифицирован
15 апр 2026, 15:58
0c22f7b
Код
Авторство
О чём код?
<?php namespace Illuminate\Tests\Testing; use Illuminate\Contracts\Routing\Registrar; use Illuminate\Http\RedirectResponse; use Illuminate\Routing\Controller; use Illuminate\Routing\UrlGenerator; use Illuminate\Support\Facades\Facade; use Orchestra\Testbench\TestCase; class AssertRedirectToActionTest extends TestCase { /** * @var \Illuminate\Routing\UrlGenerator */ public $urlGenerator; protected function setUp(): void { parent::setUp(); $router = $this->app->make(Registrar::class); $router->get('controller/index', [TestActionController::class, 'index']); $router->get('controller/show/{id}', [TestActionController::class, 'show']); $router->get('redirect-to-index', function () { return new RedirectResponse($this->urlGenerator->action([TestActionController::class, 'index'])); }); $router->get('redirect-to-show', function () { return new RedirectResponse($this->urlGenerator->action([TestActionController::class, 'show'], ['id' => 123])); }); $this->urlGenerator = $this->app->make(UrlGenerator::class); } public function testAssertRedirectToActionWithoutParameters(): void { $this->get('redirect-to-index') ->assertRedirectToAction([TestActionController::class, 'index']); } public function testAssertRedirectToActionWithParameters(): void { $this->get('redirect-to-show') ->assertRedirectToAction([TestActionController::class, 'show'], ['id' => 123]); } protected function tearDown(): void { Facade::setFacadeApplication(null); parent::tearDown(); } } class TestActionController extends Controller { public function index() { return 'ok'; } public function show($id) { return "id: $id"; } }