Skip to content

Commit aabda88

Browse files
committed
fix(embed): change sapi tests to outer macro pattern
Refs: #335
1 parent 11e0d20 commit aabda88

File tree

2 files changed

+23
-27
lines changed

2 files changed

+23
-27
lines changed

tests/module.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use ext_php_rs::prelude::*;
1010
fn test_module() {
1111
Embed::run(|| {
1212
// Allow to load the module
13-
unsafe { zend_register_module_ex(get_module()) };
13+
unsafe { zend_register_module_ex(module::get_module()) };
1414

1515
let result = Embed::eval("$foo = hello_world('foo');");
1616

@@ -26,17 +26,15 @@ fn test_module() {
2626
});
2727
}
2828

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-
3929
#[php_module]
40-
pub fn module(module: ModuleBuilder) -> ModuleBuilder {
41-
module
30+
mod module {
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+
}
4240
}

tests/sapi.rs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ use ext_php_rs::ffi::{
88
php_module_shutdown, php_module_startup, php_request_shutdown, php_request_startup,
99
sapi_shutdown, sapi_startup, ZEND_RESULT_CODE_SUCCESS,
1010
};
11-
use ext_php_rs::prelude::*;
1211
use ext_php_rs::zend::try_catch_first;
12+
use ext_php_rs::{php_module, prelude::*};
1313
use std::ffi::c_char;
1414

1515
static mut LAST_OUTPUT: String = String::new();
@@ -33,7 +33,7 @@ fn test_sapi() {
3333
builder = builder.ub_write_function(output_tester);
3434

3535
let sapi = builder.build().unwrap().into_raw();
36-
let module = get_module();
36+
let module = module::get_module();
3737

3838
unsafe {
3939
ext_php_rs_sapi_startup();
@@ -82,17 +82,15 @@ fn test_sapi() {
8282
}
8383
}
8484

85-
/// Gives you a nice greeting!
86-
///
87-
/// @param string $name Your name.
88-
///
89-
/// @return string Nice greeting!
90-
#[php_function]
91-
pub fn hello_world(name: String) -> String {
92-
format!("Hello, {}!", name)
93-
}
94-
9585
#[php_module]
96-
pub fn module(module: ModuleBuilder) -> ModuleBuilder {
97-
module
86+
mod module {
87+
/// Gives you a nice greeting!
88+
///
89+
/// @param string $name Your name.
90+
///
91+
/// @return string Nice greeting!
92+
#[php_function]
93+
pub fn hello_world(name: String) -> String {
94+
format!("Hello, {}!", name)
95+
}
9896
}

0 commit comments

Comments
 (0)