[PECL-CVS] [pecl-file_formats-yaml] fix-unicode-emit: add yaml_emit_file test

[email protected] (Rasmus Lerdorf) Sun, 5 Apr 2026 14:34:11 +0000
Newsgroups php.pecl.cvs
Message-ID <[email protected]>
Author: Rasmus Lerdorf (rlerdorf)
Date: 2026-04-05T10:33:57-04:00

Commit: https://github.com/php/pecl-file_formats-yaml/commit/917397943af160306c92596bb1daf1b1bfd4bc9c
Raw diff: https://github.com/php/pecl-file_formats-yaml/commit/917397943af160306c92596bb1daf1b1bfd4bc9c.diff

add yaml_emit_file test

Changed paths:
  A  tests/yaml_emit_file_unicode.phpt


Diff:

diff --git a/tests/yaml_emit_file_unicode.phpt b/tests/yaml_emit_file_unicode.phpt
new file mode 100644
index 0000000..4a010a6
--- /dev/null
+++ b/tests/yaml_emit_file_unicode.phpt
@@ -0,0 +1,38 @@
+--TEST--
+yaml_emit_file - Unicode output
+--SKIPIF--
+<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
+--FILE--
+<?php
+$data = array(
+    "city" => "香港",
+    "greeting" => "Iñtërnâtiônàlizætiøn",
+    "emoji" => "Hello 🌍",
+);
+
+$temp_filename = dirname(__FILE__) . '/yaml_emit_file_unicode.tmp';
+var_dump(yaml_emit_file($temp_filename, $data));
+$contents = file_get_contents($temp_filename);
+echo $contents;
+
+// verify roundtrip
+$parsed = yaml_parse($contents);
+var_dump($parsed["city"] === "香港");
+var_dump($parsed["greeting"] === "Iñtërnâtiônàlizætiøn");
+var_dump($parsed["emoji"] === "Hello 🌍");
+?>
+--CLEAN--
+<?php
+$temp_filename = dirname(__FILE__) . '/yaml_emit_file_unicode.tmp';
+@unlink($temp_filename);
+?>
+--EXPECT--
+bool(true)
+---
+city: 香港
+greeting: Iñtërnâtiônàlizætiøn
+emoji: "Hello \U0001F30D"
+...
+bool(true)
+bool(true)
+bool(true)