-
Notifications
You must be signed in to change notification settings - Fork 326
Open
Labels
P1Medium priorityMedium priorityType: InfrastructureEngineering infrastructure & toolingEngineering infrastructure & tooling
Description
Feature Description
We have several tests that use runkit7_constant_remove to remove declared variables in tests. We should refactor this approach to use @runInSeparateProcess like we do in several other tests, for example here:
site-kit-wp/tests/phpunit/integration/Core/Authentication/Google_ProxyTest.php
Lines 168 to 179 in 0c1cc33
| /** | |
| * @runInSeparateProcess | |
| */ | |
| public function test_url_handles_staging() { | |
| $url = $this->google_proxy->url(); | |
| $this->assertEquals( $url, Google_Proxy::PRODUCTION_BASE_URL, 'URL should be production base URL by default.' ); | |
| define( 'GOOGLESITEKIT_PROXY_URL', Google_Proxy::STAGING_BASE_URL ); | |
| $url = $this->google_proxy->url(); | |
| $this->assertEquals( $url, Google_Proxy::STAGING_BASE_URL, 'URL should be staging base URL when constant is set.' ); | |
| } |
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- All test usage of
runkit-related functions (e.g.runkit7_constant_remove) is refactored to use@runInSeparateProcessinstead.- Declaring constants in test classes should be done using the standard
@runInSeparateProcessapproach (as seen in tests likeGoogle_ProxyTest).
- Declaring constants in test classes should be done using the standard
- The
runkitandrunkit7extensions are removed from the PHP Test workflow configuration.
Implementation Brief
- Replace every test-time constant reset that currently relies on
runkit:- For each affected test class (
WP_COM_CheckTest, the conversion-event provider tests forWPForms,Ninja Forms,Mailchimp,OptinMonster, Contact Form 7, Popup Maker), remove thetear_down_after_classmethod that callsrunkit*_constant_remove. - Add
@runInSeparateProcessto every test method that defines a plugin/host constant (define( 'WPFORMS_VERSION', … ), etc.) so the definition occurs in its own PHP process and does not leak to other tests. - Remove the existing skip guards (
if ( defined( … ) ) $this->markTestSkipped) inWP_COM_CheckTest.
- For each affected test class (
- In
.github/workflows/php-lint-tests.yml, removerunkit7andrunkitfrom the extensions list for the PHPUnit jobs.
Test Coverage
- No changes, issue about test edits
QA Brief
Changelog entry
Metadata
Metadata
Assignees
Labels
P1Medium priorityMedium priorityType: InfrastructureEngineering infrastructure & toolingEngineering infrastructure & tooling