assertContains( 'hp_sort_order', $keys ); $this->assertContains( 'hp_default', $keys ); $this->assertContains( 'hp_icon', $keys ); $this->assertCount( 3, $keys ); } public function test_comment_hp_review_group_registered(): void { $keys = WPDO_Entity_Registry::get_group_keys( 'comment', 'hp_review' ); $this->assertContains( 'hp_rating', $keys ); $this->assertCount( 1, $keys ); } // ── is_managed contract ───────────────────────────────────────────────── public function test_term_hp_keys_are_managed(): void { $this->assertTrue( WPDO_Entity_Registry::is_managed( 'term', 'hp_sort_order' ) ); $this->assertTrue( WPDO_Entity_Registry::is_managed( 'term', 'hp_default' ) ); $this->assertTrue( WPDO_Entity_Registry::is_managed( 'term', 'hp_icon' ) ); } public function test_comment_hp_keys_are_managed(): void { $this->assertTrue( WPDO_Entity_Registry::is_managed( 'comment', 'hp_rating' ) ); } public function test_unregistered_term_keys_pass_through(): void { $this->assertFalse( WPDO_Entity_Registry::is_managed( 'term', 'note_group' ) ); $this->assertFalse( WPDO_Entity_Registry::is_managed( 'term', 'product_count_product_cat' ) ); $this->assertFalse( WPDO_Entity_Registry::is_managed( 'term', '_wxr_import_user' ) ); } public function test_unregistered_comment_keys_pass_through(): void { $this->assertFalse( WPDO_Entity_Registry::is_managed( 'comment', 'note_group' ) ); $this->assertFalse( WPDO_Entity_Registry::is_managed( 'comment', '_wxr_import_user' ) ); } public function test_term_keys_not_treated_as_comment_keys(): void { // hp_sort_order is term-only; comment side should not see it as managed. $this->assertFalse( WPDO_Entity_Registry::is_managed( 'comment', 'hp_sort_order' ) ); } public function test_comment_keys_not_treated_as_term_keys(): void { // hp_rating is comment-only; term side should not see it as managed. $this->assertFalse( WPDO_Entity_Registry::is_managed( 'term', 'hp_rating' ) ); } // ── Field metadata contract ───────────────────────────────────────────── public function test_hp_sort_order_field_metadata(): void { $field = WPDO_Entity_Registry::get_field( 'term', 'hp_sort_order' ); $this->assertNotNull( $field ); $this->assertSame( 'hp_sort_order', $field['key'] ); $this->assertSame( 'integer', $field['type'] ); $this->assertTrue( ! empty( $field['searchable'] ) ); } public function test_hp_rating_field_metadata(): void { $field = WPDO_Entity_Registry::get_field( 'comment', 'hp_rating' ); $this->assertNotNull( $field ); $this->assertSame( 'hp_rating', $field['key'] ); $this->assertSame( 'integer', $field['type'] ); $this->assertTrue( ! empty( $field['searchable'] ) ); } public function test_hp_default_is_enum_with_options(): void { $field = WPDO_Entity_Registry::get_field( 'term', 'hp_default' ); $this->assertSame( 'enum', $field['type'] ); $this->assertSame( array( '0', '1' ), $field['options'] ?? array() ); } // ── get_field returns null for unregistered ───────────────────────────── public function test_get_field_returns_null_for_unregistered(): void { $this->assertNull( WPDO_Entity_Registry::get_field( 'term', 'unregistered_key' ) ); $this->assertNull( WPDO_Entity_Registry::get_field( 'comment', 'unregistered_key' ) ); } // ── Bootstrap idempotency ─────────────────────────────────────────────── public function test_register_entity_fields_is_idempotent(): void { // Re-running registration should not duplicate fields. WPDO_Hivepress_Term_Comment_Fields::register_entity_fields(); WPDO_Hivepress_Term_Comment_Fields::register_entity_fields(); $keys = WPDO_Entity_Registry::get_group_keys( 'term', 'hp_taxonomy' ); $this->assertCount( 3, $keys, 'Re-registration must not duplicate keys' ); } }