refactor(2meet-data-optimizer): stop registering HivePress entity groups in core

- Drop hp_listing_core / hp_request_core / hp_vendor_core from TMDO_Post_Fields and hp_user from TMDO_Member_Fields; the HivePress AddOn registers identical definitions (PR-019/020a/033b)
- Tests: core asserts it registers none of them; HP-specific core tests removed (covered by the AddOn); SyncBridgeEntityGuardTest registers its own hp_price group
- Verify: core unit 633 / integration 449, HP 145/49, WC 10/22 OK
- Deploy: activate the HivePress AddOn on dev20/21/22 first
- PR: PR-020b
This commit is contained in:
2026-09-26 00:07:31 +08:00
parent e0683a19b1
commit 1eedaa9b3c
7 changed files with 22 additions and 274 deletions
@@ -103,10 +103,11 @@ class SyncBridgeEntityGuardTest extends TestCase {
'indexed' => false,
) );
// Register post adapter + post-fields groups (puts hp_price into Entity_Registry).
// Register post adapter + an entity group that owns hp_price (as the
// HivePress AddOn's hp_listing_core does).
WPDO_Entity_Registry::init();
WPDO_Entity_Registry::register_adapter( 'post', new WPDO_Adapter_Post() );
WPDO_Post_Fields::register_entity_fields();
WPDO_Entity_Registry::register_group( 'post', 'hp_listing_core', array( array( 'key' => 'hp_price', 'type' => 'decimal', 'searchable' => true ) ) );
}
public static function tearDownAfterClass(): void {
-22
View File
@@ -77,26 +77,4 @@ class EntityRegistryScopeTest extends TestCase {
$this->assertSame( '1', TMDO_Installer::post_scoped_routing_default( 'aeav_only', false ) );
$this->assertSame( '1', TMDO_Installer::post_scoped_routing_default( 'disabled', true ) );
}
public function test_core_hivepress_groups_are_scoped_without_changing_their_hash(): void {
TMDO_Entity_Registry::init();
TMDO_Entity_Registry::register_adapter( 'post', $this->createMock( TMDO_Entity_Adapter_Interface::class ) );
TMDO_Post_Fields::register_entity_fields();
$persisted = array(
'hp_listing_core' => 'fb5ab760',
'hp_request_core' => '27d6f4f5',
'hp_vendor_core' => '5366e5c8',
);
foreach ( $persisted as $group => $hash ) {
$fields = TMDO_Entity_Registry::get_group_fields( 'post', $group );
$this->assertSame( $hash, substr( TMDO_Schema_Manager::calculate_schema_hash( $fields ), 0, 8 ), $group );
}
$this->assertSame( 'hp_listing_core', TMDO_Entity_Registry::get_field( 'post', 'hp_rating', 'hp_listing' )['group'] );
$this->assertSame( 'hp_listing_core', TMDO_Entity_Registry::get_field( 'post', 'hp_status', 'hp_listing' )['group'] );
$this->assertSame( 'hp_request_core', TMDO_Entity_Registry::get_field( 'post', 'hp_status', 'hp_request' )['group'] );
$this->assertSame( 'hp_vendor_core', TMDO_Entity_Registry::get_field( 'post', 'hp_user', 'hp_vendor' )['group'] );
$this->assertSame( 'hp_request_core', TMDO_Entity_Registry::get_field( 'post', 'hp_user', 'hp_request' )['group'] );
}
}
@@ -45,6 +45,12 @@ class MemberFieldsRegistrationTest extends TestCase {
}
}
public function test_core_registers_no_hp_user_group(): void {
WPDO_Member_Fields::register_entity_fields();
$this->assertSame( array(), WPDO_Entity_Registry::get_group_fields( 'user', 'hp_user' ), 'hp_user is owned by the HivePress AddOn' );
}
// ── membership group ─────────────────────────────────────────────────────
public function test_membership_group_has_six_fields(): void {
@@ -6,7 +6,7 @@ use PHPUnit\Framework\TestCase;
/**
* Unit tests for WPDO_Post_Fields entity group registration (v2.9.1).
*
* Verifies that register_entity_fields() correctly registers all seven
* Verifies that register_entity_fields() correctly registers all four
* post groups with the expected field counts, types, and post_type targets.
*
* Mirrors MemberFieldsRegistrationTest's structure.
@@ -33,16 +33,13 @@ class PostFieldsRegistrationTest extends TestCase {
$this->assertTrue( true );
}
public function test_all_seven_groups_are_registered(): void {
public function test_all_four_groups_are_registered(): void {
WPDO_Post_Fields::register_entity_fields();
$expected = array(
'wp_core',
'attachment',
'wc_product',
'hp_listing_core',
'hp_request_core',
'hp_vendor_core',
'nav_menu_item',
);
@@ -129,24 +126,15 @@ class PostFieldsRegistrationTest extends TestCase {
$this->assertContains( 'outofstock', $field['options'] );
}
// ── hp_listing_core group ────────────────────────────────────────────────
// ── HivePress groups moved to the HivePress AddOn ───────────────────────
public function test_hp_listing_core_critical_keys_present(): void {
public function test_core_registers_no_hivepress_groups(): void {
WPDO_Post_Fields::register_entity_fields();
$keys = $this->get_field_keys( 'hp_listing_core' );
foreach ( array( 'hp_price', 'hp_status', 'hp_featured', 'hp_verified', 'hp_vendor' ) as $key ) {
$this->assertContains( $key, $keys, "hp_listing_core missing critical key: {$key}" );
foreach ( array( 'hp_listing_core', 'hp_request_core', 'hp_vendor_core' ) as $group ) {
$this->assertSame( array(), WPDO_Entity_Registry::get_group_fields( 'post', $group ), "{$group} is owned by the HivePress AddOn" );
}
}
public function test_hp_listing_price_is_searchable_decimal(): void {
WPDO_Post_Fields::register_entity_fields();
$field = $this->find_field( 'hp_listing_core', 'hp_price' );
$this->assertNotNull( $field );
$this->assertSame( 'decimal', $field['type'] );
$this->assertTrue( (bool) ( $field['searchable'] ?? false ) );
}
// ── nav_menu_item group ──────────────────────────────────────────────────
public function test_nav_menu_item_has_8_keys(): void {
@@ -52,28 +52,4 @@ class PostGroupReconcilerPlanTest extends TestCase {
TMDO_Entity_Registry::init();
$this->assertSame( array(), TMDO_Entity_Registry::get_group_post_types( 'post', 'listing' ) );
}
public function test_core_hivepress_groups_plan_the_eight_misrouted_keys(): void {
TMDO_Post_Fields::register_entity_fields();
$moves = array();
foreach ( TMDO_Post_Group_Reconciler::plan() as $m ) {
$moves[] = "{$m['source']}>{$m['target']}:{$m['key']}";
}
sort( $moves );
$this->assertSame(
array(
'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_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',
'hp_vendor_core>hp_listing_core:hp_verified',
'hp_vendor_core>hp_request_core:hp_user',
),
$moves
);
}
}