Running the Driver's Tests

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 .phpt tests and the PHPUnit tests. The PHPUnit tests are being replaced by .phpt tests.

.phpt Tests

.phpt tests are the standard way of testing PHP extensions. After compiling the MongoDB driver with "make" you can then issue "make test" to run the tests. These tests require MongoDB to be working, and hence, you need to configure the test suite itself. You do that by editting the tests/mongo-test-cfg.inc file.

There is more information about this in the contributing guidelines on » GitHub.

PHPUnit 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

Reporting Errors

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.


Customers Area | Contact us | Affiliates