[wp-trac] [WordPress Trac] #64963: Unit tests make unconditional HTTP request for GP_Locales class PHP file
WordPress Trac
noreply at wordpress.org
Fri Mar 27 00:07:07 UTC 2026
#64963: Unit tests make unconditional HTTP request for GP_Locales class PHP file
------------------------------+-------------------------
Reporter: westonruter | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 7.1
Component: Build/Test Tools | Version: 4.9
Severity: normal | Keywords: needs-patch
Focuses: |
------------------------------+-------------------------
I noticed that running PHPUnit can be quite slow on a poor connection,
even though I'm not doing any `external-http` tests. I threw in a
`debug_print_backtrace()` to `WP_Http::request()` and I found that after
these lines are printed:
{{{
Installing...
Running as single site... To run multisite, use -c
tests/phpunit/multisite.xml
Not running ajax tests. To execute these, use --group ajax.
Not running ms-files tests. To execute these, use --group ms-files.
Not running external-http tests. To execute these, use --group external-
http.
}}}
An HTTP request is made from the `PluralFormsTest::data_locales()` data
provider:
{{{
#0 /var/www/src/wp-includes/class-wp-http.php(659): WP_Http->request()
#1 /var/www/src/wp-includes/http.php(84): WP_Http->get()
#2 /var/www/src/wp-admin/includes/file.php(1166): wp_safe_remote_get()
#3 /var/www/tests/phpunit/tests/pomo/pluralForms.php(75): download_url()
#4 [internal function]: PluralFormsTest::data_locales()
#5 /var/www/vendor/phpunit/phpunit/src/Util/Annotation/DocBlock.php(421):
ReflectionMethod->invoke()
#6 /var/www/vendor/phpunit/phpunit/src/Util/Annotation/DocBlock.php(278):
PHPUnit\Util\Annotation\DocBlock->getDataFromDataProviderAnnotation()
#7 /var/www/vendor/phpunit/phpunit/src/Util/Test.php(329):
PHPUnit\Util\Annotation\DocBlock->getProvidedData()
#8 /var/www/vendor/phpunit/phpunit/src/Framework/TestBuilder.php(72):
PHPUnit\Util\Test::getProvidedData()
#9 /var/www/vendor/phpunit/phpunit/src/Framework/TestSuite.php(891):
PHPUnit\Framework\TestBuilder->build()
#10 /var/www/vendor/phpunit/phpunit/src/Framework/TestSuite.php(232):
PHPUnit\Framework\TestSuite->addTestMethod()
#11 /var/www/vendor/phpunit/phpunit/src/Framework/TestSuite.php(362):
PHPUnit\Framework\TestSuite->__construct()
#12 /var/www/vendor/phpunit/phpunit/src/Framework/TestSuite.php(512):
PHPUnit\Framework\TestSuite->addTestSuite()
#13 /var/www/vendor/phpunit/phpunit/src/Framework/TestSuite.php(537):
PHPUnit\Framework\TestSuite->addTestFile()
#14 /var/www/vendor/phpunit/phpunit/src/TextUI/TestSuiteMapper.php(67):
PHPUnit\Framework\TestSuite->addTestFiles()
#15 /var/www/vendor/phpunit/phpunit/src/TextUI/Command.php(391):
PHPUnit\TextUI\TestSuiteMapper->map()
#16 /var/www/vendor/phpunit/phpunit/src/TextUI/Command.php(114):
PHPUnit\TextUI\Command->handleArguments()
#17 /var/www/vendor/phpunit/phpunit/src/TextUI/Command.php(99):
PHPUnit\TextUI\Command->run()
#18 /var/www/vendor/phpunit/phpunit/phpunit(107):
PHPUnit\TextUI\Command::main()
#19 /var/www/vendor/bin/phpunit(122): include('/var/www/vendor...')
}}}
This is in spite of me running `npm run test:php -- --group=64890` to
limit execution to a specific group without any `external-http` requests.
It seems the `PluralFormsTest::test_regression()` test needs to be
refactored to not use `PluralFormsTest::data_locales()` as a data
provider, since apparently PHPUnit has a test collector which runs all
data providers unconditionally when initializing.
This issue was introduced in r41722 for #41562.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/64963>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list