aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/tests/command
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-25 03:20:08 +0900
committernsfisis <nsfisis@gmail.com>2026-06-25 03:33:09 +0900
commitc65cab710bb3d79db20862c9361d4dbbac8ac5d7 (patch)
treeb4d192237bbb8dbaa80166f1ffa24703e57243f4 /crates/shirabe/tests/command
parentf73e9ab05f8d94937d2437919199d9d9681c8cde (diff)
downloadphp-shirabe-c65cab710bb3d79db20862c9361d4dbbac8ac5d7.tar.gz
php-shirabe-c65cab710bb3d79db20862c9361d4dbbac8ac5d7.tar.zst
php-shirabe-c65cab710bb3d79db20862c9361d4dbbac8ac5d7.zip
feat(php-shim): model $_ENV/$_SERVER as OsString snapshots
Rework the environment shim around getenv/putenv on the real environment and $_ENV/$_SERVER as startup snapshots, all over OsString. Migrate every caller off the old server()/server_argv() helpers and force the snapshots in main() before any putenv() runs. Document the porting rules in docs/dev/env-vars-porting.md. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/tests/command')
-rw-r--r--crates/shirabe/tests/command/init_command_test.rs14
1 files changed, 9 insertions, 5 deletions
diff --git a/crates/shirabe/tests/command/init_command_test.rs b/crates/shirabe/tests/command/init_command_test.rs
index 1c2fca6..0c38bf4 100644
--- a/crates/shirabe/tests/command/init_command_test.rs
+++ b/crates/shirabe/tests/command/init_command_test.rs
@@ -4,12 +4,13 @@ use crate::test_case::{RunOptions, get_application_tester, init_temp_composer};
use serial_test::serial;
use shirabe::command::init_command::InitCommand;
use shirabe::json::JsonFile;
-use shirabe_php_shim::{PhpMixed, server_set, server_unset};
+use shirabe_php_shim::{PHP_SERVER, PhpMixed};
use tempfile::TempDir;
fn set_up() {
- server_set("COMPOSER_DEFAULT_AUTHOR", "John Smith".to_string());
- server_set("COMPOSER_DEFAULT_EMAIL", "john@example.com".to_string());
+ let mut server = PHP_SERVER.lock().unwrap();
+ server.put("COMPOSER_DEFAULT_AUTHOR".into(), "John Smith".into());
+ server.put("COMPOSER_DEFAULT_EMAIL".into(), "john@example.com".into());
}
/// const DEFAULT_AUTHORS in PHP.
@@ -497,12 +498,15 @@ fn test_run_guess_name_from_dir_sanitizes_dir() {
std::fs::create_dir(dir_name).unwrap();
std::env::set_current_dir(dir_name).unwrap();
- server_set("COMPOSER_DEFAULT_VENDOR", ".vendorName".to_string());
+ PHP_SERVER
+ .lock()
+ .unwrap()
+ .put("COMPOSER_DEFAULT_VENDOR".into(), ".vendorName".into());
let mut app_tester = get_application_tester();
let result = app_tester.run(non_interactive_input(vec![]), RunOptions::default());
- server_unset("COMPOSER_DEFAULT_VENDOR");
+ PHP_SERVER.lock().unwrap().clear("COMPOSER_DEFAULT_VENDOR");
result.unwrap();
assert_eq!(0, app_tester.get_status_code());