Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Unit Test with MongoDB
  • In in the new version 1.4 (thanks a lot for the new version) I tried to write a unit test, which uses a mongo connection. In my application everything runs fine, but my unit test abort with the following message:



    Tests Running...This may take a few moments.
    PHPUnit 3.7.9 by Sebastian Bergmann.

    Configuration read from /var/www/dev/_kai/htdocs/fuel/core/phpunit.xml

    E

    Time: 0 seconds, Memory: 14,25Mb

    There was 1 error:

    1) Test_Product_Courses::test_create_save_get
    Fuel\Core\Mongo_DbException: The MongoDB PECL extension has not been installed or enabled

    /var/www/dev/_kai/htdocs/fuel/core/classes/mongo/db.php:136
    /var/www/dev/_kai/htdocs/fuel/core/classes/mongo/db.php:120
    /var/www/dev/_kai/htdocs/fuel/app/classes/model/products.php:164
    /var/www/dev/_kai/htdocs/fuel/app/classes/model/products.php:104
    /var/www/dev/_kai/htdocs/fuel/app/classes/product/courses.php:91
    /var/www/dev/_kai/htdocs/fuel/app/tests/product/courses.php:29

    FAILURES!
    Tests: 1, Assertions: 2, Errors: 1.



    The MongoDB PECL extension is installed and enabled. This is shown via phpinfo() and otherwise my application wouldn't run. My test-area and my dev-area have the same db-config. Any ideas?



  • Most obvious reason that that your commandline environment uses a different php.ini from the one your webserver is using, causing extensions not to be loaded.

    This is almost always the case in xAMP type installations.

    You can test this by locating the one your webserver is using, and then run your tests like this:


    $ php -c <path-to-your-ini> oil test
  • Your're right: my commandline environment uses a different php.ini from the one my webserver is using. Thanks for the tip!

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion