The principle and realization of PHP automation test framework
In the running example in Listing 3, the actual execution statement is "$HOME/php-5.2.8/sapi/cli/php run-tests.php $HOME/php-5.2.8/sapi/cli/tests/001.phpt". where "001.PHPT" is the test script, "run-tests.php" is the driver script for the PHP test, the official script, and "$HOME/php-5.2.8/sapi/cli/php" is the PHP executable object that runs the driver script. One point to point out here is that the PHP executable object set in the environment variable test_php_executable and the "$HOME/php-5.2.8/sapi/cli/php" in the Run test script here, although pointing to the same executable object, But its meaning is not the same. The PHP set in the environment variable test_php_executable is the test object, and the "$HOME/php-5.2.8/sapi/cli/php" used in the run test is intended only to drive the test script to run.
In Figure 1, you can see the relationship between two PHP executables and two PHP scripts in the PHP test process. In the process of testing, the first is "$HOME/php-5.2.8/sapi/cli/php" to run the script "run-tests.php" (step 1th). In the "run-tests.php" script, the value "test_php_executable = $HOME/php-5.2.8/sapi/cli/php" of the environment variable is resolved (step 2nd). Here PHP executable object is tested PHP. The "run-tests.php" script also resolves the FILE section in the test script "001.phpt" to the php script "001.php" (step 3rd), the PHP executable with the "test_php_executable" setting object to perform the "001.php" (step 4th) and get the actual output, outputting the test results (step 5th) After the expected results of the actual output and EXPECT segments. The above run process can be derived from the analysis of the "run-tests.php" script.
Figure 1. PHP Test Run diagram