createMock( TMDO_Entity_Adapter_Interface::class ) ); } public function test_plan_lists_shared_keys_whose_legacy_owner_is_another_group(): void { TMDO_Entity_Registry::register_group( 'post', 'listing', array( array( 'key' => 'shared', 'type' => 'text' ), array( 'key' => 'price', 'type' => 'decimal' ) ), array( 'post_types' => array( 'hp_listing' ) ) ); TMDO_Entity_Registry::register_group( 'post', 'vendor', array( array( 'key' => 'shared', 'type' => 'text' ) ), array( 'post_types' => array( 'hp_vendor' ) ) ); $this->assertSame( array( array( 'target' => 'listing', 'source' => 'vendor', 'key' => 'shared', 'post_types' => array( 'hp_listing' ), ), ), TMDO_Post_Group_Reconciler::plan() ); } public function test_unscoped_groups_and_unshared_keys_need_no_move(): void { TMDO_Entity_Registry::register_group( 'post', 'site', array( array( 'key' => '_edit_lock', 'type' => 'text' ) ) ); TMDO_Entity_Registry::register_group( 'post', 'listing', array( array( 'key' => 'price', 'type' => 'decimal' ) ), array( 'post_types' => array( 'hp_listing' ) ) ); $this->assertSame( array(), TMDO_Post_Group_Reconciler::plan() ); } public function test_registry_exposes_group_post_types(): void { TMDO_Entity_Registry::register_group( 'post', 'listing', array( array( 'key' => 'price', 'type' => 'decimal' ) ), array( 'post_types' => array( 'hp_listing' ) ) ); TMDO_Entity_Registry::register_group( 'post', 'site', array( array( 'key' => '_edit_lock', 'type' => 'text' ) ) ); $this->assertSame( array( 'hp_listing' ), TMDO_Entity_Registry::get_group_post_types( 'post', 'listing' ) ); $this->assertSame( array(), TMDO_Entity_Registry::get_group_post_types( 'post', 'site' ) ); 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 ); } }