|
11 | 11 | use Illuminate\Support\Facades\Request;
|
12 | 12 | use Inertia\Tests\Stubs\ExampleMiddleware;
|
13 | 13 | use Illuminate\Contracts\Support\Arrayable;
|
| 14 | +use Illuminate\Http\Request as HttpRequest; |
14 | 15 | use Illuminate\Session\Middleware\StartSession;
|
| 16 | +use Illuminate\Session\NullSessionHandler; |
| 17 | +use Illuminate\Session\Store; |
15 | 18 |
|
16 | 19 | class ResponseFactoryTest extends TestCase
|
17 | 20 | {
|
@@ -75,6 +78,20 @@ public function test_location_response_for_non_inertia_requests_using_redirect_r
|
75 | 78 | $this->assertEquals('https://inertiajs.com', $response->headers->get('location'));
|
76 | 79 | }
|
77 | 80 |
|
| 81 | + public function test_location_response_for_non_inertia_requests_using_redirect_response_with_existing_session_and_request_properties(): void |
| 82 | + { |
| 83 | + $redirect = new RedirectResponse('https://inertiajs.com'); |
| 84 | + $redirect->setSession($session = new Store('test', new NullSessionHandler)); |
| 85 | + $redirect->setRequest($request = new HttpRequest); |
| 86 | + $response = (new ResponseFactory())->location($redirect); |
| 87 | + |
| 88 | + $this->assertInstanceOf(RedirectResponse::class, $response); |
| 89 | + $this->assertEquals(Response::HTTP_FOUND, $response->getStatusCode()); |
| 90 | + $this->assertEquals('https://inertiajs.com', $response->headers->get('location')); |
| 91 | + $this->assertSame($session, $response->getSession()); |
| 92 | + $this->assertSame($request, $response->getRequest()); |
| 93 | + } |
| 94 | + |
78 | 95 | public function test_the_version_can_be_a_closure(): void
|
79 | 96 | {
|
80 | 97 | Route::middleware([StartSession::class, ExampleMiddleware::class])->get('/', function () {
|
|
0 commit comments