Skip to content

Commit ba805e8

Browse files
authored
[9.x] Add test for assertLocation in response assertions (#41825)
1 parent 756097c commit ba805e8

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/Testing/TestResponseTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
use Illuminate\Encryption\Encrypter;
1111
use Illuminate\Filesystem\Filesystem;
1212
use Illuminate\Http\RedirectResponse;
13+
use Illuminate\Http\Request;
1314
use Illuminate\Http\Response;
15+
use Illuminate\Routing\RouteCollection;
16+
use Illuminate\Routing\UrlGenerator;
1417
use Illuminate\Session\ArraySessionHandler;
1518
use Illuminate\Session\Store;
1619
use Illuminate\Support\MessageBag;
@@ -1626,6 +1629,20 @@ public function testAssertCookieMissing()
16261629
$response->assertCookieMissing('cookie-name');
16271630
}
16281631

1632+
public function testAssertLocation()
1633+
{
1634+
app()->instance('url', $url = new UrlGenerator(new RouteCollection, new Request));
1635+
1636+
$response = TestResponse::fromBaseResponse(
1637+
(new RedirectResponse($url->to('https://foo.com')))
1638+
);
1639+
1640+
$response->assertLocation('https://foo.com');
1641+
1642+
$this->expectException(ExpectationFailedException::class);
1643+
$response->assertLocation('https://foo.net');
1644+
}
1645+
16291646
public function testAssertRedirectContains()
16301647
{
16311648
$response = TestResponse::fromBaseResponse(

0 commit comments

Comments
 (0)