PHPUnit and Mongo with Phactory

360 Views Asked by At

I am new to Unit testing and trying to use Phactory with Mongo, but when I run the test I keep getting the following error.

PHP Fatal error:  Class 'Mongo' not found in /vagrant/Test/user/LoginTest.php on line 19

I know Mongo is installed because when I pull up the site it works, but for some reason PHPUnit isn't recognizing it.

I feel I am missing a step. Do I need to install the Mongo extension locally, or do I need to include the location in a config file somewhere?

1

There are 1 best solutions below

0
Sven On

Are you sure Mongo is installed as a module in the command line version of PHP?

Do a quick run of php -i and have a look at the output (which is phpinfo() without fancy formatting) or php -m for a list of modules. If the Mongo extension does not show up, you have to install it.

Also note that the Mongo class has been deprecated. You'd probably update to using MongoClient.