Running the Driver's Tests
The PECL package does not come with the tests, but they are available at » Github. There are two types of tests: the PHPUnit tests and the C tests.
To run the tests, you must download the driver from Github (the tests are in the tests/ directory). You'll also need » PHPUnit to run the tests. PHPUnit can be installed via PEAR (although you should look at the installation instructions, it requires a couple of prerequisites).
Some tests expect warnings or errors, so you must set error_reporting in php.ini to E_STRICT | E_ALL for these tests to pass. If you do not, you will get some failures that say the test was expecting a warning or error.
To run the tests, make sure that there is a MongoDB server running locally on port 27017. Before reporting errors, please try running the tests against the latest development version of MongoDB: often there are tests for features that aren't yet in the stable release.
The test suite uses the "phpunit" database. If you are using a database called "phpunit" in your application, make sure point MongoDB at a different data directory before running the tests.
Make sure you're in the main directory of the driver source you downloaded from Github. Run:
$ phpunit tests/MongoSuite.php
The C tests mostly check internal functions that are not exposed through PHP. If you'd like to run these tests, you'll need to compile PHP with the --enable-embed flag. Then switch to the tests directory and run make. This will create a binary called unit. Run unit to execute the tests. These tests do no require a database to be running.
If a test passes, it will print a ".". If a test fails, it will assert and stop the tests. Please report any asserts.
If make cannot find your PHP embedded library (libphp5.so) or header files, you may have to specify the PHP_PATH variable.
Run make clean to remove all testing objects.
If you run these tests with valgrind, you should get no invalid memory access errors and the "no leaks are possible" message at the end.
Please report any failures or errors in the » bugtracker. There may be skipped tests, these are normal and can be ignored.
New tests are always welcome! Please feel free to contribute new tests of any type testing any functionality.