File tree Expand file tree Collapse file tree 2 files changed +46
-1
lines changed Expand file tree Collapse file tree 2 files changed +46
-1
lines changed Original file line number Diff line number Diff line change @@ -260,5 +260,6 @@ bind! {
260
260
zend_eval_string,
261
261
zend_file_handle,
262
262
zend_stream_init_filename,
263
- php_execute_script
263
+ php_execute_script,
264
+ zend_register_module_ex
264
265
}
Original file line number Diff line number Diff line change
1
+ #![ cfg_attr( windows, feature( abi_vectorcall) ) ]
2
+ extern crate ext_php_rs;
3
+
4
+ #[ cfg( feature = "embed" ) ]
5
+ use ext_php_rs:: embed:: Embed ;
6
+ #[ cfg( feature = "embed" ) ]
7
+ use ext_php_rs:: ffi:: zend_register_module_ex;
8
+ use ext_php_rs:: prelude:: * ;
9
+
10
+ #[ test]
11
+ #[ cfg( feature = "embed" ) ]
12
+ fn test_module ( ) {
13
+ Embed :: run ( || {
14
+ // Allow to load the module
15
+ unsafe { zend_register_module_ex ( get_module ( ) ) } ;
16
+
17
+ let result = Embed :: eval ( "$foo = hello_world('foo');" ) ;
18
+
19
+ assert ! ( result. is_ok( ) ) ;
20
+
21
+ let zval = result. unwrap ( ) ;
22
+
23
+ assert ! ( zval. is_string( ) ) ;
24
+
25
+ let string = zval. string ( ) . unwrap ( ) ;
26
+
27
+ assert_eq ! ( string. to_string( ) , "Hello, foo!" ) ;
28
+ } ) ;
29
+ }
30
+
31
+ /// Gives you a nice greeting!
32
+ ///
33
+ /// @param string $name Your name.
34
+ ///
35
+ /// @return string Nice greeting!
36
+ #[ php_function]
37
+ pub fn hello_world ( name : String ) -> String {
38
+ format ! ( "Hello, {}!" , name)
39
+ }
40
+
41
+ #[ php_module]
42
+ pub fn module ( module : ModuleBuilder ) -> ModuleBuilder {
43
+ module
44
+ }
You can’t perform that action at this time.
0 commit comments