Skip to content

[13.x] Allow faking DNS lookups in validation rules#60879

Merged
taylorotwell merged 3 commits into
laravel:13.xfrom
SjorsO:validator-fake-dns-lookups
Jul 24, 2026
Merged

[13.x] Allow faking DNS lookups in validation rules#60879
taylorotwell merged 3 commits into
laravel:13.xfrom
SjorsO:validator-fake-dns-lookups

Conversation

@SjorsO

@SjorsO SjorsO commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Some of our tests are flaky because the active_url validation rule does a real DNS lookup that can randomly fail (even for a reliable domain like google.com). There is currently no straightforward way to fake these DNS lookups.

This PR adds Validator::fakeDnsLookups(), which makes active_url and email:dns skip the DNS lookup and treat it as successful. Everything else about these rules keeps working: malformed URLs and emails still fail.

);
$v = new Validator($trans, $data, ['x' => 'active_url']);
$this->assertEquals($outcome, $v->passes());
}

@SjorsO SjorsO Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This mock was added 4 years ago in #43781 to solve flaky tests in Laravel's own test suite

@taylorotwell
taylorotwell merged commit 1632fe8 into laravel:13.x Jul 24, 2026
52 of 53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants