5777210184
- Favorites/Messages adapters reduced to detection only; Requests keeps hot_hp_request fields, drops hp_offer mirror - Delete TMDO_HivePress_Comment_Router (read path to wpdo_comment_hp_* tables that no installer creates) - Verify: addon unit 141 OK, integration 52 OK; phpcs 41E/57W → 35E/48W - PR: PR-013
62 lines
2.4 KiB
PHP
62 lines
2.4 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
// Class loading is handled by tests/integration/bootstrap.php, which requires
|
|
// the core plugin's integration bootstrap and then this AddOn's own files.
|
|
|
|
/**
|
|
* Integration tests for the HivePress family integration.
|
|
*
|
|
* Exercises against real MariaDB (via tests/integration/bootstrap.php) the
|
|
* scenarios that unit tests can only stub:
|
|
*
|
|
* - 7-state FSM lifecycle moves WPDO_Feature_Flags correctly
|
|
*
|
|
* @group integration
|
|
*/
|
|
class HivepressIntegrationTest extends TestCase {
|
|
|
|
protected function setUp(): void {
|
|
// Clear FSM module state between tests.
|
|
$GLOBALS['_wp_options']['wpdo_features'] = array();
|
|
}
|
|
|
|
// ── FSM lifecycle ───────────────────────────────────────────────────────
|
|
|
|
public function test_fsm_lifecycle_progression(): void {
|
|
// Replicates a typical migration: idle → dual_write → backfill → ...
|
|
// → cleanup → complete. Each step verified via Feature_Flags state.
|
|
WPDO_Feature_Flags::set( 'comment_hp_favorite', 'idle' );
|
|
$this->assertSame( 'idle', WPDO_Feature_Flags::get( 'comment_hp_favorite' ) );
|
|
$this->assertFalse( WPDO_Feature_Flags::is_query_active( 'comment_hp_favorite' ) );
|
|
|
|
foreach ( array( 'dual_write', 'backfill', 'verify' ) as $state ) {
|
|
WPDO_Feature_Flags::set( 'comment_hp_favorite', $state );
|
|
// Reads still go to legacy until cutover.
|
|
$this->assertFalse(
|
|
WPDO_Feature_Flags::is_query_active( 'comment_hp_favorite' ),
|
|
"State $state should not be query-active yet"
|
|
);
|
|
}
|
|
|
|
WPDO_Feature_Flags::set( 'comment_hp_favorite', 'cutover' );
|
|
$this->assertTrue( WPDO_Feature_Flags::is_query_active( 'comment_hp_favorite' ) );
|
|
|
|
WPDO_Feature_Flags::set( 'comment_hp_favorite', 'cleanup' );
|
|
$this->assertTrue( WPDO_Feature_Flags::is_query_active( 'comment_hp_favorite' ) );
|
|
|
|
WPDO_Feature_Flags::set( 'comment_hp_favorite', 'complete' );
|
|
$this->assertTrue( WPDO_Feature_Flags::is_query_active( 'comment_hp_favorite' ) );
|
|
}
|
|
|
|
public function test_cron_optimizer_respects_module_state(): void {
|
|
WPDO_HivePress_Cron_Optimizer::reset_for_tests();
|
|
// Module idle → optimizer must not query.
|
|
WPDO_Feature_Flags::set( 'hot_hp_listing', 'idle' );
|
|
$count = WPDO_HivePress_Cron_Optimizer::maybe_run();
|
|
$this->assertSame( 0, $count, 'Optimizer must short-circuit when module is idle.' );
|
|
}
|
|
}
|