Skip to content

Replace usage of runkit7_constant_remove in tests #11736

@zutigrm

Description

@zutigrm

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:

/**
* @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 @runInSeparateProcess instead.
    • Declaring constants in test classes should be done using the standard @runInSeparateProcess approach (as seen in tests like Google_ProxyTest).
  • The runkit and runkit7 extensions 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 for WPForms, Ninja Forms, Mailchimp, OptinMonster, Contact Form 7, Popup Maker), remove the tear_down_after_class method that calls runkit*_constant_remove.
    • Add @runInSeparateProcess to 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) in WP_COM_CheckTest.
  • In .github/workflows/php-lint-tests.yml, remove runkit7 and runkit from the extensions list for the PHPUnit jobs.

Test Coverage

  • No changes, issue about test edits

QA Brief

Changelog entry

Metadata

Metadata

Assignees

Labels

P1Medium priorityType: InfrastructureEngineering infrastructure & tooling

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions