Skip to content

Commit 28ff7a4

Browse files
committed
test(array): actually add tests
Github wont let me amend this, so here is a commit that hopefully gets squashed. Refs: #453
1 parent dbadc00 commit 28ff7a4

File tree

1 file changed

+17
-1
lines changed
  • tests/src/integration/array

1 file changed

+17
-1
lines changed

tests/src/integration/array/mod.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
use std::collections::HashMap;
22

3-
use ext_php_rs::{php_function, prelude::ModuleBuilder, wrap_function};
3+
use ext_php_rs::{
4+
convert::IntoZval, ffi::HashTable, php_function, prelude::ModuleBuilder, types::Zval,
5+
wrap_function,
6+
};
47

58
#[php_function]
69
pub fn test_array(a: Vec<String>) -> Vec<String> {
@@ -12,10 +15,23 @@ pub fn test_array_assoc(a: HashMap<String, String>) -> HashMap<String, String> {
1215
a
1316
}
1417

18+
#[php_function]
19+
pub fn test_array_keys() -> Zval {
20+
let mut ht = HashTable::new();
21+
ht.insert(-42, "foo").unwrap();
22+
ht.insert(0, "bar").unwrap();
23+
ht.insert(5, "baz").unwrap();
24+
ht.insert("10", "qux").unwrap();
25+
ht.insert("quux", "quuux").unwrap();
26+
27+
ht.into_zval(false).unwrap()
28+
}
29+
1530
pub fn build_module(builder: ModuleBuilder) -> ModuleBuilder {
1631
builder
1732
.function(wrap_function!(test_array))
1833
.function(wrap_function!(test_array_assoc))
34+
.function(wrap_function!(test_array_keys))
1935
}
2036

2137
#[cfg(test)]

0 commit comments

Comments
 (0)