Analysis of the official Automation test method of PHP (II.)

Source: Internet
Author: User
Tags php script sapi

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.