Is it possible to run PHPUnit with a dynamically loaded extension library?

Posted by therefromhere on Stack Overflow See other posts from Stack Overflow or by therefromhere
Published on 2010-04-23T16:45:50Z Indexed on 2010/04/23 17:03 UTC
Read the original article Hit count: 354

Filed under:
|

I have a suite of PHPUnit tests for my extension, and I want to run them as part of the extension's Hudson build process.

So I want to run PHPUnit specifying the extension library to load at runtime, but I can't figure out how to do this.

My directory structure is as follows:

/myextension.c
/otherextensionfiles.*
/modules/myextension.so
/tests/unittests.php

I've tried running PHPUnit with an configuration XML file as follows:

<phpunit>
<php>
<ini name="extension_dir" value="../modules/"/>
<ini name="extension" value="myextension.so"/>
</php>
</phpunit>

And then running it as follows (from the tests directory):

phpunit --configuration config.xml unittests.php

But then I get Fatal error: Call to undefined function myfunction(), so it's not loading the library.

I've also tried:

phpunit -d extension_dir=../modules/ -d extension=myextension.so unittests.php 

And also dl('myextension.so') to the test setup, but no joy.

If it's relevant, this is using PHP 5.2 and PHPUnit 3.4.11.

© Stack Overflow or respective owner

Related posts about phpunit

Related posts about php-extension