'debug', 'conflict_strategy' => 'manual_review', 'sync_pairs' => array( array( 'name' => 'Staging', 'source_url' => 'https://example.test', 'destination_url' => 'https://staging.example.test', ), ), ); ( new SettingsController( new SettingsRepository() ) )->handleSave(); self::assertSame( 'debug', $GLOBALS['wpcs_test_options'][ SettingsRepository::OPTION_NAME ]['logging_level'] ); self::assertSame( 'manual_review', $GLOBALS['wpcs_test_options'][ SettingsRepository::OPTION_NAME ]['conflict_strategy'] ); self::assertStringContainsString( 'wpcs_settings_saved=1', $GLOBALS['wpcs_redirect_location'] ); } public function test_it_rejects_users_without_manage_options(): void { $GLOBALS['wpcs_current_user_can']['manage_options'] = false; $this->expectException( \RuntimeException::class ); $this->expectExceptionMessage( 'You do not have permission to save WP Content Sync settings.' ); ( new SettingsController( new SettingsRepository() ) )->handleSave(); } public function test_it_rejects_invalid_nonces(): void { $GLOBALS['wpcs_nonce_valid']['wpcs_save_settings']['wpcs_settings_nonce'] = false; $this->expectException( \RuntimeException::class ); $this->expectExceptionMessage( 'The settings save request could not be verified.' ); ( new SettingsController( new SettingsRepository() ) )->handleSave(); } }