[8.x] Stop test suite making a live HTTP request to example.com #38410
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#37596 introduced a test that's sending an actual HTTP request to https://example.com/ on every test run. Mock that request to remove this external dependency that can intermittently fail. Running Laravel's test suite locally today I had
testClonedClientsWorkSuccessfullyWithTheRequestObject()
fail because a connection to example.com failed.Also move Mockery
m::close()
into PHPUnit'stearDown()
lifecycle since failed test cases were causing registered mocks to leak into subsequent test cases.Fun with test suites: try disconnecting your WiFi and running the whole lot locally. A couple Laravel tests that rely on external services:
ValidationValidatorTest@testValidateActiveUrl()
The
active_url
validation rule calls PHP global functiondns_get_record()
. It could be wrapped in a new container-bound class.ValidationPasswordRuleTest@testUncompromised()
&testMessagesOrder()
The new
Password@uncompromised()
rule option does bindIlluminate\Contracts\Validation\UncompromisedVerifier
to the container so this is mock-ready. A test fake could be added here to stop calling api.pwnedpasswords.com although for a full-coverage integration test we may want to actually call the API as long as requests don't get rate limited.