diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-27 19:44:01 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-27 20:18:56 +0900 |
| commit | e63ccb5cbb479df0f0e5010065ff57bbf4ca238f (patch) | |
| tree | f91c7db9b3475e845b023f51cef2d6379e80ae5e /crates/shirabe/tests/command/repository_command_test.rs | |
| parent | 3cb13f1d7025351615c254b9225a4c5d1bcbd170 (diff) | |
| download | php-shirabe-e63ccb5cbb479df0f0e5010065ff57bbf4ca238f.tar.gz php-shirabe-e63ccb5cbb479df0f0e5010065ff57bbf4ca238f.tar.zst php-shirabe-e63ccb5cbb479df0f0e5010065ff57bbf4ca238f.zip | |
fix(json): encode empty stdClass fields as {} not []
Empty PhpMixed::Array now serializes as [], so the several places that build a
PHP `new \stdClass` via an empty Array were emitting [] where Composer writes
{}. Use PhpMixed::Object for those empty-object cases:
- InitCommand: require / require-dev
- Locker::fixupJsonDataType: stability-flags / platform / platform-dev
- JsonConfigSource fallback: require/config keys that must stay objects
Align the affected test expectations with Composer: JsonFile::read() decodes
with assoc=true, collapsing the on-disk {} back to [], so reads expect [].
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/tests/command/repository_command_test.rs')
| -rw-r--r-- | crates/shirabe/tests/command/repository_command_test.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/crates/shirabe/tests/command/repository_command_test.rs b/crates/shirabe/tests/command/repository_command_test.rs index 1d104e7..901b9f3 100644 --- a/crates/shirabe/tests/command/repository_command_test.rs +++ b/crates/shirabe/tests/command/repository_command_test.rs @@ -34,7 +34,7 @@ fn test_list_with_no_repositories() { app_tester.get_display().trim() ); // composer.json should remain unchanged - assert_eq!(serde_json::json!({}), read_composer_json()); + assert_eq!(serde_json::json!([]), read_composer_json()); drop(tear_down); } @@ -216,7 +216,7 @@ fn test_remove_repository() { if let Some(repositories) = json.get("repositories") { assert_eq!(&serde_json::json!([]), repositories); } else { - assert_eq!(serde_json::json!({}), json); + assert_eq!(serde_json::json!([]), json); } drop(tear_down); @@ -392,7 +392,7 @@ fn test_disable_and_enable_packagist() { ) .unwrap(); assert_eq!(0, status_code); - assert_eq!(serde_json::json!({}), read_composer_json()); + assert_eq!(serde_json::json!([]), read_composer_json()); drop(tear_down); } |
