feat(2meet-data-optimizer-hivepress-addon): register Hot-only HivePress fields as entity groups
- New scoped post groups for fields only the Hot zone covered (ADR-003): hp_draft_flags (hp_listing, hp_request: hp_drafted), hp_booking_core, hp_membership_plan_core, hp_membership_core. hp_drafted lives in one group spanning both post types, so it adds no shared key. - New groups register before the existing ones: the legacy (unscoped) owner of hp_expired_time stays hp_request_core; existing hashes unchanged. - Reconciler now also plans hp_membership rows of hp_expired_time out of hp_request_core. dev20-22 hold 0 native rows for these keys. - Verify: HP unit 151 / integration 49 green, phpcs clean - PR: PR-036
This commit is contained in:
@@ -75,7 +75,41 @@ class HivePressEntityGroupsTest extends TestCase {
|
||||
$this->assertNull( TMDO_Entity_Registry::get_field( 'post', 'hp_rating', 'post' ), 'HivePress keys stay native on other post types' );
|
||||
}
|
||||
|
||||
public function test_reconciler_plans_the_eight_misrouted_hivepress_keys(): void {
|
||||
/**
|
||||
* Fields only the Hot zone used to cover (ADR-003), as their own groups.
|
||||
*/
|
||||
private const HOT_ONLY_GROUPS = array(
|
||||
'hp_draft_flags' => array( array( 'hp_listing', 'hp_request' ), array( 'hp_drafted' ) ),
|
||||
'hp_booking_core' => array( array( 'hp_booking' ), array( 'hp_start_time', 'hp_end_time', 'hp_quantity' ) ),
|
||||
'hp_membership_plan_core' => array( array( 'hp_membership_plan' ), array( 'hp_expire_period', 'hp_primary' ) ),
|
||||
'hp_membership_core' => array( array( 'hp_membership' ), array( 'hp_expired_time' ) ),
|
||||
);
|
||||
|
||||
public function test_hot_only_fields_have_entity_groups_scoped_to_their_post_types(): void {
|
||||
foreach ( self::HOT_ONLY_GROUPS as $group => list( $post_types, $keys ) ) {
|
||||
$this->assertSame( $post_types, TMDO_Entity_Registry::get_group_post_types( 'post', $group ), $group );
|
||||
$this->assertSame( $keys, TMDO_Entity_Registry::get_group_keys( 'post', $group ), $group );
|
||||
}
|
||||
}
|
||||
|
||||
public function test_hot_only_fields_route_to_their_group_when_scoped_routing_is_on(): void {
|
||||
$GLOBALS['_wp_options'][ TMDO_Entity_Registry::SCOPED_ROUTING_OPTION ] = '1';
|
||||
|
||||
foreach ( self::HOT_ONLY_GROUPS as $group => list( $post_types, $keys ) ) {
|
||||
foreach ( $post_types as $post_type ) {
|
||||
foreach ( $keys as $key ) {
|
||||
$this->assertSame( $group, TMDO_Entity_Registry::get_field( 'post', $key, $post_type )['group'], "{$post_type}:{$key}" );
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->assertSame( 'hp_listing_core', TMDO_Entity_Registry::get_field( 'post', 'hp_expired_time', 'hp_listing' )['group'] );
|
||||
}
|
||||
|
||||
public function test_hot_only_groups_add_no_collisions(): void {
|
||||
$this->assertSame( array(), TMDO_Entity_Registry::get_collisions() );
|
||||
}
|
||||
|
||||
public function test_reconciler_plans_the_misrouted_hivepress_keys(): void {
|
||||
$moves = array();
|
||||
foreach ( TMDO_Post_Group_Reconciler::plan() as $m ) {
|
||||
$moves[] = "{$m['source']}>{$m['target']}:{$m['key']}";
|
||||
@@ -87,6 +121,7 @@ class HivePressEntityGroupsTest extends TestCase {
|
||||
'hp_request_core>hp_listing_core:hp_expired_time',
|
||||
'hp_request_core>hp_listing_core:hp_status',
|
||||
'hp_request_core>hp_listing_core:hp_view_count',
|
||||
'hp_request_core>hp_membership_core:hp_expired_time',
|
||||
'hp_vendor_core>hp_listing_core:hp_hourly_rate',
|
||||
'hp_vendor_core>hp_listing_core:hp_rating',
|
||||
'hp_vendor_core>hp_listing_core:hp_rating_count',
|
||||
|
||||
Reference in New Issue
Block a user