fix(2meet-data-optimizer-hivepress-addon): declare post_type scopes on HivePress post groups
- hp_listing_core / hp_request_core / hp_vendor_core declare hp_listing / hp_request / hp_vendor, matching core (PR-033), so the AddOn keeps scoped routing once core stops registering them (PR-020b) - Test: with tmdo_post_scoped_routing on, every key of each group resolves to its own post type's group; legacy owner and hash pins unchanged - Verify: HP unit 145 / integration 49 OK - PR: PR-033b
This commit is contained in:
@@ -21,14 +21,10 @@ class HivePressEntityGroupsTest extends TestCase {
|
||||
);
|
||||
|
||||
/**
|
||||
* Keys shared by several post groups resolve to the LAST group registered
|
||||
* (the post entity has a single field index, not one per post_type).
|
||||
*
|
||||
* ⚠️ This pins current behaviour, not desired behaviour: a listing's
|
||||
* hp_rating is routed to the hp_vendor_core table, its hp_status to
|
||||
* hp_request_core, etc. It is pinned so that moving the registration
|
||||
* between plugins cannot change routing silently; fixing the routing is
|
||||
* tracked separately in the backlog.
|
||||
* Lookups that do not pass a post type (or run with scoped routing off,
|
||||
* until a site's rows are reconciled) keep the legacy owner of keys shared
|
||||
* by several post groups: the LAST group registered. Pinned so the
|
||||
* registration order cannot change silently.
|
||||
*/
|
||||
private const SHARED_KEY_OWNERS = array(
|
||||
'hp_status' => 'hp_request_core',
|
||||
@@ -48,6 +44,10 @@ class HivePressEntityGroupsTest extends TestCase {
|
||||
TMDO_HivePress_Entity_Groups::register_entity_fields();
|
||||
}
|
||||
|
||||
protected function tearDown(): void {
|
||||
unset( $GLOBALS['_wp_options'][ TMDO_Entity_Registry::SCOPED_ROUTING_OPTION ] );
|
||||
}
|
||||
|
||||
public function test_definitions_match_persisted_schema_hashes(): void {
|
||||
foreach ( self::PERSISTED_HASHES as $id => $hash ) {
|
||||
list( $type, $group ) = explode( '/', $id );
|
||||
@@ -63,6 +63,17 @@ class HivePressEntityGroupsTest extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public function test_shared_keys_follow_the_post_type_when_scoped_routing_is_on(): void {
|
||||
$GLOBALS['_wp_options'][ TMDO_Entity_Registry::SCOPED_ROUTING_OPTION ] = '1';
|
||||
|
||||
foreach ( array( 'hp_listing' => 'hp_listing_core', 'hp_request' => 'hp_request_core', 'hp_vendor' => 'hp_vendor_core' ) as $post_type => $group ) {
|
||||
foreach ( TMDO_Entity_Registry::get_group_keys( 'post', $group ) as $key ) {
|
||||
$this->assertSame( $group, TMDO_Entity_Registry::get_field( 'post', $key, $post_type )['group'], "{$post_type}:{$key}" );
|
||||
}
|
||||
}
|
||||
$this->assertNull( TMDO_Entity_Registry::get_field( 'post', 'hp_rating', 'post' ), 'HivePress keys stay native on other post types' );
|
||||
}
|
||||
|
||||
public function test_core_adapter_does_not_register_a_conflicting_group(): void {
|
||||
( new TMDO_HivePress_Core_Adapter() )->on_register_entity_fields();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user