'fb5ab760', 'post/hp_request_core' => '27d6f4f5', 'post/hp_vendor_core' => '5366e5c8', 'user/hp_user' => '61ac526f', ); /** * 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. */ private const SHARED_KEY_OWNERS = array( 'hp_status' => 'hp_request_core', 'hp_expired_time' => 'hp_request_core', 'hp_view_count' => 'hp_request_core', 'hp_verified' => 'hp_vendor_core', 'hp_rating' => 'hp_vendor_core', 'hp_rating_count' => 'hp_vendor_core', 'hp_hourly_rate' => 'hp_vendor_core', 'hp_user' => 'hp_vendor_core', ); protected function setUp(): void { TMDO_Entity_Registry::init(); TMDO_Entity_Registry::register_adapter( 'post', $this->createMock( TMDO_Entity_Adapter_Interface::class ) ); TMDO_Entity_Registry::register_adapter( 'user', $this->createMock( TMDO_Entity_Adapter_Interface::class ) ); TMDO_HivePress_Entity_Groups::register_entity_fields(); } public function test_definitions_match_persisted_schema_hashes(): void { foreach ( self::PERSISTED_HASHES as $id => $hash ) { list( $type, $group ) = explode( '/', $id ); $fields = TMDO_Entity_Registry::get_group_fields( $type, $group ); $this->assertNotEmpty( $fields, "{$id} not registered" ); $this->assertSame( $hash, substr( TMDO_Schema_Manager::calculate_schema_hash( $fields ), 0, 8 ), "{$id} drifted from the persisted definition" ); } } public function test_shared_keys_keep_their_current_owner(): void { foreach ( self::SHARED_KEY_OWNERS as $key => $group ) { $this->assertSame( $group, TMDO_Entity_Registry::get_field( 'post', $key )['group'], $key ); } } public function test_core_adapter_does_not_register_a_conflicting_group(): void { ( new TMDO_HivePress_Core_Adapter() )->on_register_entity_fields(); $this->assertSame( array(), TMDO_Entity_Registry::get_collisions() ); } }