Running PHP tests – the basics

Before diving into how the parallel code works it is worth just covering how run-tests.php works – at a very simple level.

The easiest way to run a PHP test case is from the command line, like this:

The run-tests.php code parses the file “mytest.phpt”, finds the php code in the FILE section and runs it like this:

The run-tests.php code goes on to compare the output from the above with some expected test output. If they are the same the test passes, if not it fails.

As I said, this is a very simple example. The run-tests.php code can be thought of in three parts:

  1. The code required to set up the test environment and “php_options
  2. Code that handles running tests.
  3. Retrieving, comparing and displaying output.

Over the next few posts I’ll work through each of these stages, explaining how they are handled by the new parallel run-tests code.