Font Library: use resolvable domain in test #54763
Merged
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.
What?
Fix test than can break in different test envs depending the URL of the test env run.
Why?
To validate the URL of a font collection we have a function that calls
wp_http_validate_url()
function.Because wp_http_validate_url() function uses the PHP native function
gethostbyname()
function that is not being mocked. We just mock the URL request to fetch the data. If the domain of the url used can't be resolved or the url of the test env is not localhost, the url likehttps://localhost/example
can be evaluated as invalid.How?
To fix this problem easily we can use a resolvable domain as
wordpress.org
in the test instead oflocalhost.
Testing Instructions
Run PHP unit tests and check if they are running ok.