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
This commit is contained in:
@@ -65,65 +65,65 @@ class FSMAdvisorTest extends TestCase {
|
||||
}
|
||||
|
||||
public function test_idle_state_returns_HOLD(): void {
|
||||
$this->set_module_state( 'reviews', 'idle' );
|
||||
$advice = WPDO_FSM_Advisor::advise( 'reviews' );
|
||||
$this->set_module_state( 'wc_orders', 'idle' );
|
||||
$advice = WPDO_FSM_Advisor::advise( 'wc_orders' );
|
||||
$this->assertSame( 'HOLD', $advice['action'] );
|
||||
$this->assertSame( 'info', $advice['level'] );
|
||||
}
|
||||
|
||||
public function test_complete_state_returns_HOLD(): void {
|
||||
$this->set_module_state( 'reviews', 'complete' );
|
||||
$advice = WPDO_FSM_Advisor::advise( 'reviews' );
|
||||
$this->set_module_state( 'wc_orders', 'complete' );
|
||||
$advice = WPDO_FSM_Advisor::advise( 'wc_orders' );
|
||||
$this->assertSame( 'HOLD', $advice['action'] );
|
||||
}
|
||||
|
||||
public function test_dual_write_with_short_soak_returns_WAIT(): void {
|
||||
// In dual_write 0 days < 1 day min soak.
|
||||
$this->set_module_state( 'reviews', 'dual_write', 0 );
|
||||
$advice = WPDO_FSM_Advisor::advise( 'reviews' );
|
||||
$this->set_module_state( 'wc_orders', 'dual_write', 0 );
|
||||
$advice = WPDO_FSM_Advisor::advise( 'wc_orders' );
|
||||
$this->assertSame( 'WAIT', $advice['action'] );
|
||||
$this->assertGreaterThanOrEqual( 1, $advice['days_remaining'] );
|
||||
}
|
||||
|
||||
public function test_dual_write_after_min_soak_returns_PROMOTE(): void {
|
||||
$this->set_module_state( 'reviews', 'dual_write', 2 );
|
||||
$advice = WPDO_FSM_Advisor::advise( 'reviews' );
|
||||
$this->set_module_state( 'wc_orders', 'dual_write', 2 );
|
||||
$advice = WPDO_FSM_Advisor::advise( 'wc_orders' );
|
||||
$this->assertSame( 'PROMOTE', $advice['action'] );
|
||||
$this->assertSame( 'backfill', $advice['next_state'] );
|
||||
}
|
||||
|
||||
public function test_verify_with_long_soak_returns_PROMOTE(): void {
|
||||
// verify needs 7 days; 10 days = should promote.
|
||||
$this->set_module_state( 'reviews', 'verify', 10 );
|
||||
$advice = WPDO_FSM_Advisor::advise( 'reviews' );
|
||||
$this->set_module_state( 'wc_orders', 'verify', 10 );
|
||||
$advice = WPDO_FSM_Advisor::advise( 'wc_orders' );
|
||||
$this->assertSame( 'PROMOTE', $advice['action'] );
|
||||
$this->assertSame( 'cutover', $advice['next_state'] );
|
||||
}
|
||||
|
||||
public function test_verify_with_short_soak_returns_WAIT(): void {
|
||||
$this->set_module_state( 'reviews', 'verify', 3 );
|
||||
$advice = WPDO_FSM_Advisor::advise( 'reviews' );
|
||||
$this->set_module_state( 'wc_orders', 'verify', 3 );
|
||||
$advice = WPDO_FSM_Advisor::advise( 'wc_orders' );
|
||||
$this->assertSame( 'WAIT', $advice['action'] );
|
||||
$this->assertSame( 4, $advice['days_remaining'] );
|
||||
}
|
||||
|
||||
public function test_cleanup_with_short_wash_returns_WAIT(): void {
|
||||
$this->set_module_state( 'reviews', 'cleanup', 1 );
|
||||
$advice = WPDO_FSM_Advisor::advise( 'reviews' );
|
||||
$this->set_module_state( 'wc_orders', 'cleanup', 1 );
|
||||
$advice = WPDO_FSM_Advisor::advise( 'wc_orders' );
|
||||
$this->assertSame( 'WAIT', $advice['action'] );
|
||||
$this->assertSame( 2, $advice['days_remaining'] );
|
||||
}
|
||||
|
||||
public function test_cleanup_after_wash_returns_PROMOTE(): void {
|
||||
$this->set_module_state( 'reviews', 'cleanup', 5 );
|
||||
$advice = WPDO_FSM_Advisor::advise( 'reviews' );
|
||||
$this->set_module_state( 'wc_orders', 'cleanup', 5 );
|
||||
$advice = WPDO_FSM_Advisor::advise( 'wc_orders' );
|
||||
$this->assertSame( 'PROMOTE', $advice['action'] );
|
||||
$this->assertSame( 'complete', $advice['next_state'] );
|
||||
}
|
||||
|
||||
public function test_advice_metrics_include_state_and_soak(): void {
|
||||
$this->set_module_state( 'reviews', 'dual_write', 5 );
|
||||
$advice = WPDO_FSM_Advisor::advise( 'reviews' );
|
||||
$this->set_module_state( 'wc_orders', 'dual_write', 5 );
|
||||
$advice = WPDO_FSM_Advisor::advise( 'wc_orders' );
|
||||
$this->assertSame( 'dual_write', $advice['metrics']['state'] );
|
||||
$this->assertSame( 5, $advice['metrics']['days_in_state'] );
|
||||
$this->assertSame( 1, $advice['metrics']['min_soak_days'] );
|
||||
@@ -132,8 +132,8 @@ class FSMAdvisorTest extends TestCase {
|
||||
public function test_advise_all_returns_map_for_all_modules(): void {
|
||||
$advice = WPDO_FSM_Advisor::advise_all();
|
||||
$this->assertNotEmpty( $advice );
|
||||
// All known HPCT + zone modules should be present (default idle).
|
||||
foreach ( WPDO_Feature_Flags::HPCT_MODULES as $m ) {
|
||||
// All known AddOn + zone modules should be present (default idle).
|
||||
foreach ( WPDO_Feature_Flags::ADDON_MODULES as $m ) {
|
||||
$this->assertArrayHasKey( $m, $advice );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,15 +67,15 @@ class ModuleDetectorTest extends TestCase {
|
||||
|
||||
public function test_module_rules_known_modules_count(): void {
|
||||
$modules = WPDO_Module_Rules::known_modules();
|
||||
$this->assertGreaterThanOrEqual( 14, count( $modules ), '預期 ≥ 14 個 module(9 HPCT + 6 zone - 1 dup)' );
|
||||
$this->assertContains( 'reviews', $modules );
|
||||
$this->assertGreaterThanOrEqual( 8, count( $modules ), '預期 ≥ 8 個 module(2 AddOn + 6 zone)' );
|
||||
$this->assertContains( 'wc_orders', $modules );
|
||||
$this->assertContains( 'warm', $modules );
|
||||
$this->assertContains( 'archive', $modules );
|
||||
$this->assertContains( 'hot_hp_listing', $modules );
|
||||
}
|
||||
|
||||
public function test_module_rule_for_module_returns_array(): void {
|
||||
$rule = WPDO_Module_Rules::for_module( 'reviews' );
|
||||
$rule = WPDO_Module_Rules::for_module( 'wc_orders' );
|
||||
$this->assertIsArray( $rule );
|
||||
$this->assertArrayHasKey( 'compat_required', $rule );
|
||||
$this->assertArrayHasKey( 'description', $rule );
|
||||
@@ -86,9 +86,9 @@ class ModuleDetectorTest extends TestCase {
|
||||
}
|
||||
|
||||
public function test_detector_skip_when_module_not_idle(): void {
|
||||
// Set reviews to dual_write.
|
||||
WPDO_Feature_Flags::set( 'reviews', 'dual_write' );
|
||||
$r = WPDO_Module_Detector::detect_one( 'reviews' );
|
||||
// Set wc_orders to dual_write.
|
||||
WPDO_Feature_Flags::set( 'wc_orders', 'dual_write' );
|
||||
$r = WPDO_Module_Detector::detect_one( 'wc_orders' );
|
||||
$this->assertSame( 'skip', $r['recommendation'] );
|
||||
$this->assertFalse( $r['available'] );
|
||||
$this->assertNotEmpty( $r['blockers'] );
|
||||
@@ -123,9 +123,9 @@ class ModuleDetectorTest extends TestCase {
|
||||
}
|
||||
|
||||
public function test_detector_hivepress_required_blocks_when_inactive(): void {
|
||||
// reviews requires hivepress; Compatibility class isn't loaded in this test.
|
||||
// hot_hp_listing requires hivepress; Compatibility class isn't loaded in this test.
|
||||
// Without Compatibility class, the helper returns the full required list as missing.
|
||||
$r = WPDO_Module_Detector::detect_one( 'reviews' );
|
||||
$r = WPDO_Module_Detector::detect_one( 'hot_hp_listing' );
|
||||
$this->assertSame( 'skip', $r['recommendation'] );
|
||||
$this->assertNotEmpty( $r['blockers'] );
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
<?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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user