Function test_php_script_with_condition

Source
pub fn test_php_script_with_condition(
    lib_path: impl AsRef<Path>,
    script: impl AsRef<Path>,
    condition: impl Fn(Output) -> bool,
)
Expand description

Check your extension by executing a single php script with custom condition.

This function allows you to specify a custom condition function to check the execution result of a PHP script, providing more flexibility than the default success-only check.

§Arguments

  • lib_path - The path to the extension library file
  • script - The path to the PHP script to execute
  • condition - A function that takes the command output and returns true if the test passes

§Panics

Panics if the script execution fails or the condition function returns false.

§Examples

use phper_test::cli::test_php_script_with_condition;
use std::process::Output;

// Test that script outputs specific text
let condition =
    |output: Output| String::from_utf8_lossy(&output.stdout).contains("expected output");
test_php_script_with_condition("/path/to/extension.so", "test.php", condition);