From 4c708a7444e5feb4c81b4f5d53e2111e89b3d1e5 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Thu, 26 Sep 2024 09:58:46 +0800 Subject: [PATCH] [11.x] Test Improvements Ensure that it is expected that `Str::isUrl()` and `url` validation accepts URL without a valid TLD such as `localhost` Issue: #52921 Signed-off-by: Mior Muhammad Zaki --- tests/Support/SupportStrTest.php | 1 + tests/Validation/ValidationValidatorTest.php | 3 +++ 2 files changed, 4 insertions(+) diff --git a/tests/Support/SupportStrTest.php b/tests/Support/SupportStrTest.php index a132b32b9500..497bc7b76998 100755 --- a/tests/Support/SupportStrTest.php +++ b/tests/Support/SupportStrTest.php @@ -529,6 +529,7 @@ public function testIs() public function testIsUrl() { $this->assertTrue(Str::isUrl('https://laravel.com')); + $this->assertTrue(Str::isUrl('http://localhost')); $this->assertFalse(Str::isUrl('invalid url')); } diff --git a/tests/Validation/ValidationValidatorTest.php b/tests/Validation/ValidationValidatorTest.php index b557c94ef995..c0b3d37365b2 100755 --- a/tests/Validation/ValidationValidatorTest.php +++ b/tests/Validation/ValidationValidatorTest.php @@ -4503,6 +4503,9 @@ public function testValidateUrlWithProtocols() // Test with a standard protocol $v = new Validator($trans, ['x' => 'http://laravel.com'], ['x' => 'url:https']); $this->assertFalse($v->passes()); + + $v = new Validator($trans, ['x' => 'http://localhost'], ['x' => 'url']); + $this->assertTrue($v->passes()); } #[DataProvider('validUrls')]