` (2.2 PR-069): the CLI way to change an * entity's bridge mode. It must go through TMDO_Mode_Manager::set(), so unsafe * jumps and promotions refused by the Promotion Guard never reach the option. * (The Guard matrix itself is covered by PromotionGuardTest.) */ class CliBridgeModeTest extends TestCase { protected function setUp(): void { ini_set( 'error_log', '/dev/null' ); $GLOBALS['_wp_options'] = array(); $GLOBALS['_wp_filter_callbacks'] = array(); $GLOBALS['_wp_current_user_can'] = array( 'manage_options' => true ); TMDO_Mode_Manager::reset_cache(); } private function modes( array $modes ): void { $GLOBALS['_wp_options']['wpdo_bridge_modes'] = $modes; TMDO_Mode_Manager::reset_cache(); } public function test_sets_the_mode_of_one_entity(): void { $this->modes( array( 'user' => 'disabled', 'post' => 'dual_write' ) ); ( new TMDO_CLI_V2() )->bridge_mode( array( 'user', 'dual_write' ), array() ); $this->assertSame( 'dual_write', TMDO_Mode_Manager::get( 'user' ) ); $this->assertSame( 'dual_write', TMDO_Mode_Manager::get( 'post' ), 'other entities untouched' ); } public function test_an_unsafe_jump_is_refused(): void { $this->modes( array( 'user' => 'disabled' ) ); ( new TMDO_CLI_V2() )->bridge_mode( array( 'user', 'aeav_only' ), array() ); $this->assertSame( 'disabled', TMDO_Mode_Manager::get( 'user' ) ); } /** * @runInSeparateProcess * @preserveGlobalState disabled */ public function test_a_promotion_refused_by_the_guard_leaves_the_mode_unchanged(): void { eval( 'namespace HivePress; class Core {}' ); $this->modes( array( 'user' => 'shadow_read' ) ); ( new TMDO_CLI_V2() )->bridge_mode( array( 'user', 'aeav_only' ), array() ); $this->assertSame( 'shadow_read', TMDO_Mode_Manager::get( 'user' ) ); $this->assertSame( array( 'user' => 'shadow_read' ), $GLOBALS['_wp_options']['wpdo_bridge_modes'] ); } }