WordPress.org

Make WordPress Core

Opened 8 months ago

Last modified 8 months ago

#42076 new enhancement

Allow the external HTTP tests to run internally

Reported by: johnbillion Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: needs-unit-tests
Focuses: Cc:

Description

The tests in the external-http group are the worst. They not only perform calls out over the internet, but they rely on a combination of wordpress.org, wordpress.com, example.org, example.com, and youtube.com.

The external oEmbed tests that use youtube.com (Tests_External_HTTP_OEmbed) can probably be removed. They're technically fragile (YouTube could change the structure of their embed URLs and cause the tests to fail) and don't actually test anything that core has control over.

It _should_ be possible to run the rest of the external-http tests against a local web server running PHP. As an example, frameworks such as Behat usually run against a server being run by PHP's built in web server.

If the test files from wordpress.com and wordpress.org were downloaded and placed into the test suite data directory, they could be served by a local web server and therefore tested without a remote HTTP request.

Spinning up a local web server in PHP could be made optional via a flag or an environment variable, and could be enabled on Travis by default.

It may even be that the functionality that is being tested by these external HTTP tests can be abstracted and made testable without performing an HTTP request at all, or it could be that the functionality is already covered by unit tests in the Requests framework.

Feedback / ideas welcome.

Change History (1)

#1 @johnbillion
8 months ago

In 41712:

Embeds: Remove the external oEmbed tests for YouTube.

These tests no longer test anything that WordPress core has control over. YouTube now serves everything
over HTTPS by default, so the tests for #23149 will always pass, and the tests for #32714 aren't testing
anything that core has control over.

Tests for the responses from oEmbed providers has been attempted and reverted in #32360.

See #42076, #32714, #23149

Note: See TracTickets for help on using tickets.