array( "array( 'product', 'hp_listing', 'hp_request', 'hp_vendor', 'attachment', 'nav_menu_item', 'post' )" ), ); public function test_routing_code_has_no_hivepress_names(): void { $root = dirname( __DIR__, 2 ); $offences = array(); foreach ( self::FILES as $rel ) { $code = ''; foreach ( token_get_all( (string) file_get_contents( $root . '/' . $rel ) ) as $token ) { if ( is_array( $token ) && in_array( $token[0], array( T_COMMENT, T_DOC_COMMENT ), true ) ) { continue; } $code .= is_array( $token ) ? $token[1] : $token; } $code = str_replace( self::ALLOWED[ $rel ] ?? array(), '', $code ); if ( preg_match_all( '/hp_(listing|request|vendor|taxonomy|review|user)\w*/', $code, $m ) ) { $offences[] = $rel . ': ' . implode( ', ', array_unique( $m[0] ) ); } } $this->assertSame( array(), $offences, "Hardcoded HivePress names in core routing:\n" . implode( "\n", $offences ) ); } public function test_term_comment_groups_come_from_the_registry(): void { TMDO_Entity_Registry::init(); TMDO_Entity_Registry::register_adapter( 'term', $this->createMock( TMDO_Entity_Adapter_Interface::class ) ); TMDO_Entity_Registry::register_adapter( 'comment', $this->createMock( TMDO_Entity_Adapter_Interface::class ) ); TMDO_Entity_Registry::register_group( 'term', 'x_tax', array( array( 'key' => 'x_order', 'type' => 'integer' ) ) ); TMDO_Entity_Registry::register_group( 'comment', 'x_review', array( array( 'key' => 'x_rating', 'type' => 'integer' ) ) ); $this->assertSame( array( 'x_tax' => 'term', 'x_review' => 'comment' ), TMDO_Term_Comment_Backfill::registered_groups() ); $result = TMDO_Term_Comment_Backfill::backfill_group( 'term', 'hp_taxonomy', true ); $this->assertSame( 'Unknown group: hp_taxonomy', $result['error'] ?? '', 'unregistered groups are unknown' ); } }