From 69afca5e9406887a21bb25bf6679ea92c4dbbb2c Mon Sep 17 00:00:00 2001 From: jmjoy Date: Thu, 10 Apr 2025 11:51:47 +0800 Subject: [PATCH] feat: Add tests for new_persistent function in ZString integration --- tests/integration/src/strings.rs | 17 +++++++++++++++++ tests/integration/tests/php/strings.php | 1 + 2 files changed, 18 insertions(+) diff --git a/tests/integration/src/strings.rs b/tests/integration/src/strings.rs index c62c9aeb..2e9875e7 100644 --- a/tests/integration/src/strings.rs +++ b/tests/integration/src/strings.rs @@ -25,4 +25,21 @@ pub fn integrate(module: &mut Module) { Ok(()) }, ); + + module.add_function( + "integrate_strings_zend_string_new_persistent", + |_: &mut [ZVal]| -> phper::Result<()> { + let zs = ZString::new_persistent("persistent_hello"); + assert_eq!(zs.to_str()?, "persistent_hello"); + + let zs = ZString::new_persistent([4, 5, 6]); + assert_eq!(zs.as_ref(), &[4, 5, 6]); + + assert!( + ZString::new_persistent("persistent") == ZString::new_persistent(b"persistent") + ); + + Ok(()) + }, + ); } diff --git a/tests/integration/tests/php/strings.php b/tests/integration/tests/php/strings.php index ac6745bd..9eb906a1 100644 --- a/tests/integration/tests/php/strings.php +++ b/tests/integration/tests/php/strings.php @@ -14,3 +14,4 @@ require_once __DIR__ . '/_common.php'; integrate_strings_zend_string_new(); +integrate_strings_zend_string_new_persistent();