diff --git a/tests/phpunit/README.md b/tests/phpunit/README.md index 679ed831112d2..6308e75c3d3da 100644 --- a/tests/phpunit/README.md +++ b/tests/phpunit/README.md @@ -6,6 +6,10 @@ For more information, please review the relevant Core Handbook pages: - [PHP: PHPUnit](https://make.wordpress.org/core/handbook/testing/automated-testing/phpunit/) - [Writing PHP Tests](https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/) +## Run on a host that prohibits loopback listening + +Set `WP_TESTS_SKIP_HTTP_LOOPBACK=1` in the PHPUnit process environment if the host prohibits listening on a local TCP port. When PHP cannot reserve a port, PHPUnit skips only the HTTP transport tests that need the local fixture server. If PHP reserves a port, the tests run normally and server startup errors still fail. + ## Run the full matrix on a pull request Add the `Full PHPUnit Matrix` label to a pull request in `WordPress/wordpress-develop` to run the same PHP and database combinations as the weekly scheduled run. The label-triggered workflow uses the same path filters as normal PHPUnit runs. diff --git a/tests/phpunit/tests/http/base.php b/tests/phpunit/tests/http/base.php index a279a8386024a..3b6456b5e9d53 100644 --- a/tests/phpunit/tests/http/base.php +++ b/tests/phpunit/tests/http/base.php @@ -151,6 +151,11 @@ static function () { if ( ! $socket ) { self::remove_file_stream_fixture_dir( $fixture_dir ); + if ( '1' === getenv( 'WP_TESTS_SKIP_HTTP_LOOPBACK' ) ) { + self::$file_stream_fixture_skip_reason = 'Loopback listening is restricted on this test host.'; + return; + } + self::$file_stream_fixture_fail_reason = sprintf( 'Could not reserve a local TCP port for the HTTP stream fixture server (%d: %s).', (int) $errno,