Skip to content

Commit 30fd19f

Browse files
authored
test(integration): reorganise integration tests
Refs: #414
1 parent 232916c commit 30fd19f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+623
-497
lines changed

tests/src/integration/array.rs

Lines changed: 0 additions & 4 deletions
This file was deleted.

tests/src/integration/array.php renamed to tests/src/integration/array/array.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22

3-
require('_utils.php');
4-
53
// Tests sequential arrays
64
$array = test_array(['a', 'b', 'c', 'd']);
75
unset($array[2]);

tests/src/integration/array/mod.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
use std::collections::HashMap;
2+
3+
use ext_php_rs::{php_function, prelude::ModuleBuilder, wrap_function};
4+
5+
#[php_function]
6+
pub fn test_array(a: Vec<String>) -> Vec<String> {
7+
a
8+
}
9+
10+
#[php_function]
11+
pub fn test_array_assoc(a: HashMap<String, String>) -> HashMap<String, String> {
12+
a
13+
}
14+
15+
pub fn build_module(builder: ModuleBuilder) -> ModuleBuilder {
16+
builder
17+
.function(wrap_function!(test_array))
18+
.function(wrap_function!(test_array_assoc))
19+
}
20+
21+
#[cfg(test)]
22+
mod tests {
23+
#[test]
24+
fn array_works() {
25+
assert!(crate::integration::test::run_php("array/array.php"));
26+
}
27+
}

tests/src/integration/binary.rs

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22

3-
require('_utils.php');
4-
53
$bin = test_binary(pack('L*', 1, 2, 3, 4, 5));
64
$result = unpack('L*', $bin);
75

@@ -10,4 +8,4 @@
108
assert(in_array(2, $result));
119
assert(in_array(3, $result));
1210
assert(in_array(4, $result));
13-
assert(in_array(5, $result));
11+
assert(in_array(5, $result));

tests/src/integration/binary/mod.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
use ext_php_rs::{binary::Binary, prelude::*};
2+
3+
#[php_function]
4+
pub fn test_binary(a: Binary<u32>) -> Binary<u32> {
5+
a
6+
}
7+
8+
pub fn build_module(builder: ModuleBuilder) -> ModuleBuilder {
9+
builder.function(wrap_function!(test_binary))
10+
}
11+
12+
#[cfg(test)]
13+
mod tests {
14+
#[test]
15+
fn binary_works() {
16+
assert!(crate::integration::test::run_php("binary/binary.php"));
17+
}
18+
}

tests/src/integration/bool.rs

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
<?php
22

3-
require('_utils.php');
4-
53
assert(test_bool(true) === true);
64
assert(test_bool(false) === false);

tests/src/integration/bool/mod.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
use ext_php_rs::prelude::*;
2+
3+
#[php_function]
4+
pub fn test_bool(a: bool) -> bool {
5+
a
6+
}
7+
8+
pub fn build_module(builder: ModuleBuilder) -> ModuleBuilder {
9+
builder.function(wrap_function!(test_bool))
10+
}
11+
12+
#[cfg(test)]
13+
mod tests {
14+
#[test]
15+
fn bool_works() {
16+
assert!(crate::integration::test::run_php("bool/bool.php"));
17+
}
18+
}

tests/src/integration/callable.rs

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)