true ); $GLOBALS['_wp_is_multisite'] = false; } private function activate( string ...$slugs ): void { $GLOBALS['_wp_options']['active_plugins'] = array_map( static fn( $s ) => "2meet-data-optimizer-{$s}-addon/2meet-data-optimizer-{$s}-addon.php", $slugs ); } public function test_lists_only_active_deprecated_addons(): void { $this->activate( 'spoke', 'hivepress', 'bookings' ); $this->assertSame( array( 'bookings', 'spoke' ), TMDO_Deprecated_Addons_Notice::active() ); } public function test_notice_names_the_addons_and_points_to_the_guide(): void { $this->activate( 'spoke' ); ob_start(); TMDO_Deprecated_Addons_Notice::render(); $html = (string) ob_get_clean(); $this->assertStringContainsString( '2meet-data-optimizer-spoke-addon', $html ); $this->assertStringContainsString( 'PARTNER-REGISTRATION.md', $html ); } public function test_sso_hub_and_spoke_addons_are_deprecated_without_replacement(): void { $this->activate( 'hub', 'sso' ); $this->assertSame( array( 'hub', 'sso' ), TMDO_Deprecated_Addons_Notice::active() ); ob_start(); TMDO_Deprecated_Addons_Notice::render(); $html = (string) ob_get_clean(); $this->assertStringContainsString( '2meet-data-optimizer-sso-addon', $html ); $this->assertStringContainsString( '不需替代', $html ); $this->assertStringContainsString( 'bridge-restore-native user --group=sso --retire', $html ); } public function test_no_notice_when_none_active_or_user_cannot_manage(): void { ob_start(); TMDO_Deprecated_Addons_Notice::render(); $this->assertSame( '', ob_get_clean() ); $this->activate( 'spoke' ); $GLOBALS['_wp_current_user_can'] = array(); ob_start(); TMDO_Deprecated_Addons_Notice::render(); $this->assertSame( '', ob_get_clean() ); } public function test_trait_passes_post_type_scope_to_the_registry(): void { TMDO_Entity_Registry::init(); TMDO_Entity_Registry::register_adapter( 'post', $this->createMock( TMDO_Entity_Adapter_Interface::class ) ); $partner = new class() { use TMDO_Anti_EAV_Aware; public function run(): bool { return $this->register_entity_fields( 'post', 'x_item', array( array( 'key' => 'x_price', 'type' => 'decimal' ) ), array( 'post_types' => array( 'x_item' ) ) ); } }; $this->assertTrue( $partner->run() ); $this->assertSame( array( 'x_item' ), TMDO_Entity_Registry::get_group_post_types( 'post', 'x_item' ) ); } }