refactor(2meet-data-optimizer-hivepress-addon): stop registering Hot zone fields
- ADR-003 step 4 (AddOn side): core, requests, bookings, memberships and marketplace adapters no longer register zone=hot fields or contribute hot_* FSM modules; their keys live in TMDO_HivePress_Entity_Groups. Cold/warm registrations are unchanged. - Hot-table doctor probes go with them (trait defaults apply). The hot-clause query rewrite and cron optimizer are now inert and are left for the ADR step-5 removal together with core's hot path. - New NoHotZoneRegistrationTest pins the invariant across all 13 adapters; per-adapter hot assertions removed. - Verify: HP unit 142 / integration 49 green, phpcs clean (WordPress) - PR: PR-037
This commit is contained in:
@@ -33,31 +33,6 @@ class HivePressBookingsAdapterTest extends TestCase {
|
||||
$this->assertSame( 'HivePress\\Bookings\\Plugin', $this->adapter->detection_class() );
|
||||
}
|
||||
|
||||
public function test_on_register_fields_reserves_booking_hot_columns(): void {
|
||||
$registry = WPDO_Schema_Registry::instance();
|
||||
$this->adapter->on_register_fields( $registry );
|
||||
|
||||
$start = $registry->get_field( 'hp_booking', 'hp_start_time' );
|
||||
$this->assertSame( 'hot', $start['zone'] );
|
||||
$this->assertTrue( (bool) $start['indexed'] );
|
||||
|
||||
$end = $registry->get_field( 'hp_booking', 'hp_end_time' );
|
||||
$this->assertSame( 'hot', $end['zone'] );
|
||||
$this->assertTrue( (bool) $end['indexed'] );
|
||||
}
|
||||
|
||||
public function test_on_register_fields_uses_real_booking_meta_keys(): void {
|
||||
$registry = WPDO_Schema_Registry::instance();
|
||||
$this->adapter->on_register_fields( $registry );
|
||||
|
||||
// hivepress-bookings has no guests field; places are stored as hp_quantity.
|
||||
$this->assertNull( $registry->get_field( 'hp_booking', 'hp_guests' ) );
|
||||
|
||||
$quantity = $registry->get_field( 'hp_booking', 'hp_quantity' );
|
||||
$this->assertNotNull( $quantity );
|
||||
$this->assertSame( 'hot', $quantity['zone'] );
|
||||
}
|
||||
|
||||
public function test_score_reflects_unverified_perf_dimension(): void {
|
||||
$score = $this->adapter->suitability_score();
|
||||
// D8 reduced to 0.9 because schema is best-effort until addon installs.
|
||||
@@ -65,8 +40,4 @@ class HivePressBookingsAdapterTest extends TestCase {
|
||||
// Aggregate = (7 × 1.0 + 0.9) / 8 × 10 = 9.875 → 9.88.
|
||||
$this->assertSame( 9.88, $score['aggregate'] );
|
||||
}
|
||||
|
||||
public function test_migrations_lists_booking_module(): void {
|
||||
$this->assertSame( array( 'hot_hp_booking' ), $this->adapter->migrations() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,29 +46,10 @@ class HivePressCoreAdapterTest extends TestCase {
|
||||
$this->assertSame( '1.7.0', $this->adapter->minimum_addon_version() );
|
||||
}
|
||||
|
||||
public function test_migrations_returns_listing_and_vendor_modules(): void {
|
||||
$mods = $this->adapter->migrations();
|
||||
$this->assertContains( 'hot_hp_listing', $mods );
|
||||
$this->assertContains( 'hot_hp_vendor', $mods );
|
||||
}
|
||||
|
||||
public function test_on_register_fields_populates_schema_registry(): void {
|
||||
$registry = WPDO_Schema_Registry::instance();
|
||||
$this->adapter->on_register_fields( $registry );
|
||||
|
||||
// Listing hot fields.
|
||||
$drafted = $registry->get_field( 'hp_listing', 'hp_drafted' );
|
||||
$this->assertIsArray( $drafted );
|
||||
$this->assertSame( 'hot', $drafted['zone'] );
|
||||
$this->assertTrue( (bool) $drafted['indexed'] );
|
||||
|
||||
$expired = $registry->get_field( 'hp_listing', 'hp_expired_time' );
|
||||
$this->assertSame( 'hot', $expired['zone'] );
|
||||
$this->assertStringContainsString( 'bigint', $expired['data_type'] );
|
||||
|
||||
$featured_time = $registry->get_field( 'hp_listing', 'hp_featured_time' );
|
||||
$this->assertSame( 'hot', $featured_time['zone'] );
|
||||
|
||||
// Vendor cold blob.
|
||||
$vendor_image = $registry->get_field( 'hp_vendor', 'hp_image' );
|
||||
$this->assertIsArray( $vendor_image );
|
||||
@@ -87,16 +68,6 @@ class HivePressCoreAdapterTest extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public function test_doctor_check_reports_table_status(): void {
|
||||
$result = $this->adapter->doctor_check();
|
||||
$this->assertIsArray( $result );
|
||||
$this->assertArrayHasKey( 'ok', $result );
|
||||
$this->assertArrayHasKey( 'message', $result );
|
||||
$this->assertArrayHasKey( 'details', $result );
|
||||
// The stub $wpdb returns null for SHOW TABLES, so tables appear missing → ok=false.
|
||||
$this->assertFalse( $result['ok'] );
|
||||
}
|
||||
|
||||
public function test_optimize_query_extracts_hot_clauses(): void {
|
||||
$registry = WPDO_Schema_Registry::instance();
|
||||
$this->adapter->on_register_fields( $registry );
|
||||
|
||||
@@ -33,21 +33,6 @@ class HivePressMarketplaceAdapterTest extends TestCase {
|
||||
$this->assertSame( 'HivePress\\Marketplace\\Plugin', $this->adapter->detection_class() );
|
||||
}
|
||||
|
||||
public function test_on_register_fields_registers_hot_hp_price(): void {
|
||||
$registry = WPDO_Schema_Registry::instance();
|
||||
$this->adapter->on_register_fields( $registry );
|
||||
|
||||
// Marketplace's filterable, sortable listing "price" attribute is stored as hp_price.
|
||||
$price = $registry->get_field( 'hp_listing', 'hp_price' );
|
||||
$this->assertSame( 'hot', $price['zone'] );
|
||||
$this->assertTrue( (bool) $price['indexed'] );
|
||||
$this->assertStringContainsString( 'decimal', $price['data_type'] );
|
||||
|
||||
// Neither key exists in hivepress-marketplace.
|
||||
$this->assertNull( $registry->get_field( 'hp_listing', 'hp_purchase_price' ) );
|
||||
$this->assertNull( $registry->get_field( 'hp_listing', 'hp_purchase_count' ) );
|
||||
}
|
||||
|
||||
public function test_score_aggregates_to_nine_eight_eight(): void {
|
||||
// D8 = 0.9 → aggregate = (7×1.0 + 0.9)/8 × 10 = 9.875 → 9.88.
|
||||
$this->assertSame( 9.88, $this->adapter->suitability_score()['aggregate'] );
|
||||
|
||||
@@ -33,41 +33,8 @@ class HivePressMembershipsAdapterTest extends TestCase {
|
||||
$this->assertSame( '2.0.0', $this->adapter->minimum_addon_version() );
|
||||
}
|
||||
|
||||
public function test_on_register_fields_registers_three_hot_fields(): void {
|
||||
$registry = WPDO_Schema_Registry::instance();
|
||||
$this->adapter->on_register_fields( $registry );
|
||||
|
||||
// Plan fields.
|
||||
$expire_period = $registry->get_field( 'hp_membership_plan', 'hp_expire_period' );
|
||||
$this->assertSame( 'hot', $expire_period['zone'] );
|
||||
$this->assertStringContainsString( 'int', $expire_period['data_type'] );
|
||||
|
||||
$primary = $registry->get_field( 'hp_membership_plan', 'hp_primary' );
|
||||
$this->assertSame( 'hot', $primary['zone'] );
|
||||
$this->assertTrue( (bool) $primary['indexed'] );
|
||||
|
||||
// Membership field — the hottest path.
|
||||
$expired = $registry->get_field( 'hp_membership', 'hp_expired_time' );
|
||||
$this->assertSame( 'hot', $expired['zone'] );
|
||||
$this->assertTrue( (bool) $expired['indexed'] );
|
||||
$this->assertStringContainsString( 'bigint', $expired['data_type'] );
|
||||
}
|
||||
|
||||
public function test_doctor_check_reports_missing_tables_in_stub_env(): void {
|
||||
$result = $this->adapter->doctor_check();
|
||||
$this->assertFalse( $result['ok'] );
|
||||
$this->assertArrayHasKey( 'hp_membership_plan', $result['details'] );
|
||||
$this->assertArrayHasKey( 'hp_membership', $result['details'] );
|
||||
}
|
||||
|
||||
public function test_score_aggregates_to_perfect_ten(): void {
|
||||
$score = $this->adapter->suitability_score();
|
||||
$this->assertSame( 10.0, $score['aggregate'] );
|
||||
}
|
||||
|
||||
public function test_migrations_lists_both_hot_modules(): void {
|
||||
$mods = $this->adapter->migrations();
|
||||
$this->assertContains( 'hot_hp_membership_plan', $mods );
|
||||
$this->assertContains( 'hot_hp_membership', $mods );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* ADR-003: post fields converge on entity groups; the Hot zone is frozen.
|
||||
*
|
||||
* No HivePress adapter registers zone=hot fields or contributes hot_* FSM
|
||||
* modules. The fields they used to cover live in TMDO_HivePress_Entity_Groups.
|
||||
*/
|
||||
class NoHotZoneRegistrationTest extends TestCase {
|
||||
|
||||
private const ADAPTERS = array(
|
||||
'TMDO_HivePress_Core_Adapter',
|
||||
'TMDO_HivePress_Requests_Adapter',
|
||||
'TMDO_HivePress_Bookings_Adapter',
|
||||
'TMDO_HivePress_Memberships_Adapter',
|
||||
'TMDO_HivePress_Marketplace_Adapter',
|
||||
'TMDO_HivePress_Favorites_Adapter',
|
||||
'TMDO_HivePress_Reviews_Adapter',
|
||||
'TMDO_HivePress_Social_Links_Adapter',
|
||||
'TMDO_HivePress_Blocks_Adapter',
|
||||
'TMDO_HivePress_Seo_Adapter',
|
||||
'TMDO_HivePress_Messages_Adapter',
|
||||
'TMDO_HivePress_Statistics_Adapter',
|
||||
'TMDO_HivePress_Tags_Adapter',
|
||||
);
|
||||
|
||||
protected function setUp(): void {
|
||||
$prop = ( new ReflectionClass( TMDO_Schema_Registry::class ) )->getProperty( 'instance' );
|
||||
$prop->setAccessible( true );
|
||||
$prop->setValue( null, null );
|
||||
}
|
||||
|
||||
public function test_no_adapter_registers_hot_fields(): void {
|
||||
$registry = TMDO_Schema_Registry::instance();
|
||||
foreach ( self::ADAPTERS as $class ) {
|
||||
( new $class() )->on_register_fields( $registry );
|
||||
}
|
||||
|
||||
$this->assertSame( array(), $registry->get_zone_fields( 'hot' ) );
|
||||
$this->assertSame( 'cold', $registry->get_field_zone( 'hp_listing', 'hp_images' ), 'cold fields stay' );
|
||||
}
|
||||
|
||||
public function test_no_adapter_contributes_hot_modules(): void {
|
||||
foreach ( self::ADAPTERS as $class ) {
|
||||
$this->assertSame( array(), ( new $class() )->migrations(), $class );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,19 +35,6 @@ class HivePressRequestsAdapterTest extends TestCase {
|
||||
$this->assertSame( 'hp_offer', WPDO_HivePress_Requests_Adapter::OFFER_COMMENT_TYPE );
|
||||
}
|
||||
|
||||
public function test_on_register_fields_registers_request_hot_columns(): void {
|
||||
$registry = WPDO_Schema_Registry::instance();
|
||||
$this->adapter->on_register_fields( $registry );
|
||||
|
||||
$drafted = $registry->get_field( 'hp_request', 'hp_drafted' );
|
||||
$this->assertSame( 'hot', $drafted['zone'] );
|
||||
$this->assertTrue( (bool) $drafted['indexed'] );
|
||||
|
||||
$expired = $registry->get_field( 'hp_request', 'hp_expired_time' );
|
||||
$this->assertSame( 'hot', $expired['zone'] );
|
||||
$this->assertTrue( (bool) $expired['indexed'] );
|
||||
}
|
||||
|
||||
public function test_registers_no_offer_shadow_table(): void {
|
||||
// The offer shadow table was never created, so every mirror write failed.
|
||||
$registry = WPDO_Custom_Table_Registry::instance();
|
||||
@@ -69,8 +56,4 @@ class HivePressRequestsAdapterTest extends TestCase {
|
||||
public function test_score_aggregates_to_perfect_ten(): void {
|
||||
$this->assertSame( 10.0, $this->adapter->suitability_score()['aggregate'] );
|
||||
}
|
||||
|
||||
public function test_migrations_lists_only_request_hot_module(): void {
|
||||
$this->assertSame( array( 'hot_hp_request' ), $this->adapter->migrations() );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user