Skip to content

Commit fba827a

Browse files
authored
[10.x] Fix assertRedirectToRoute when route uri is empty (#48023)
* Fix assertRedirectToRoute with empty url in destination route * Fix typo
1 parent b9cbac1 commit fba827a

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/Illuminate/Testing/TestResponse.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,7 @@ public function assertRedirectToRoute($name, $parameters = [])
193193
$this->statusMessageWithDetails('201, 301, 302, 303, 307, 308', $this->getStatusCode()),
194194
);
195195

196-
$request = Request::create($this->headers->get('Location'));
197-
198-
PHPUnit::assertEquals(
199-
app('url')->to($uri), $request->fullUrl()
200-
);
196+
$this->assertLocation($uri);
201197

202198
return $this;
203199
}

tests/Testing/AssertRedirectToRouteTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ protected function setUp(): void
3434
->get('named-route-with-param/{param}')
3535
->name('named-route-with-param');
3636

37+
$this->router
38+
->get('')
39+
->name('route-with-empty-uri');
40+
3741
$this->urlGenerator = $this->app->make(UrlGenerator::class);
3842
}
3943

@@ -70,6 +74,16 @@ public function testAssertRedirectToRouteWithRouteNameAndParams()
7074
]);
7175
}
7276

77+
public function testAssertRedirectToRouteWithRouteNameAndParamsWhenRouteUriIsEmpty()
78+
{
79+
$this->router->get('test-route', function () {
80+
return new RedirectResponse($this->urlGenerator->route('route-with-empty-uri', ['foo' => 'bar']));
81+
});
82+
83+
$this->get('test-route')
84+
->assertRedirectToRoute('route-with-empty-uri', ['foo' => 'bar']);
85+
}
86+
7387
protected function tearDown(): void
7488
{
7589
parent::tearDown();

0 commit comments

Comments
 (0)