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