Files
2meet-data-optimizer/tests/unit/NoHpctLegacyTest.php
T
wpdev 8a1c9c0353 refactor(2meet-data-optimizer): remove HPCT legacy from core
- Feature flags keep only the live AddOn modules (wc_orders, latepoint) as ADDON_MODULES / addon_modules(); drop map_hpct_status() and the 7 HivePress HPCT modules whose interceptors were removed in PR-014
- Remove HPCT detection/notice (Compatibility, core), the admin HPCT import tab and status row, CLI import-hpct, the 7 advisor rules for dead modules, and the removed interceptors from COEXIST_WHITELIST
- Verify: NoHpctLegacyTest guard; core unit 635 / integration 449, HP 145/49, WC 10/22 OK; all sites have every module idle and never imported HPCT
- PR: PR-020c
2026-09-26 00:14:18 +08:00

62 lines
2.3 KiB
PHP

<?php
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
/**
* Core carries no HPCT (HivePress Custom Tables) legacy.
*
* The HPCT interceptors were removed from the HivePress AddOn (PR-014) and no
* site ever ran the HPCT import, so the modules, compatibility probes, admin
* tab and CLI command that fed them are gone too. The only survivor is the
* `wpdo_hpct_imported` option name in the uninstall cleanup list, so old
* installs still get it removed.
*/
class NoHpctLegacyTest extends TestCase {
private const ALLOWED = array(
'includes/class-tmdo-installer.php' => array( 'wpdo_hpct_imported' ),
);
public function test_core_code_does_not_mention_hpct(): void {
$root = dirname( __DIR__, 2 );
$offences = array();
foreach ( array( 'includes', 'cli', 'admin' ) as $dir ) {
$files = new RecursiveIteratorIterator( new RecursiveDirectoryIterator( $root . '/' . $dir, FilesystemIterator::SKIP_DOTS ) );
foreach ( $files as $file ) {
if ( 'php' !== $file->getExtension() ) {
continue;
}
$rel = substr( $file->getPathname(), strlen( $root ) + 1 );
$code = '';
foreach ( token_get_all( (string) file_get_contents( $file->getPathname() ) ) as $token ) {
if ( is_array( $token ) && in_array( $token[0], array( T_COMMENT, T_DOC_COMMENT ), true ) ) {
continue;
}
$code .= is_array( $token ) ? $token[1] : $token;
}
$code = str_replace( self::ALLOWED[ $rel ] ?? array(), '', $code );
if ( preg_match_all( '/\w*hpct\w*/i', $code, $m ) ) {
$offences[] = $rel . ': ' . implode( ', ', array_unique( $m[0] ) );
}
}
}
$this->assertSame( array(), $offences, "HPCT legacy left in core:\n" . implode( "\n", $offences ) );
}
public function test_only_live_addon_modules_remain_besides_zone_modules(): void {
$this->assertSame( array( 'wc_orders', 'latepoint' ), TMDO_Feature_Flags::ADDON_MODULES );
$GLOBALS['_wp_options'] = array();
$ref = new ReflectionProperty( TMDO_Feature_Flags::class, 'cache' );
$ref->setAccessible( true );
$ref->setValue( null, null );
$modules = array_keys( TMDO_Feature_Flags::all() );
foreach ( array( 'reviews', 'messages', 'favorites', 'memberships', 'statistics', 'requests', 'listing_meta' ) as $gone ) {
$this->assertNotContains( $gone, $modules );
}
}
}