How to set a global before PHPUnit's skeleton-test is run

Posted by ministerOfPower on Stack Overflow See other posts from Stack Overflow or by ministerOfPower
Published on 2009-10-01T21:03:12Z Indexed on 2010/05/03 21:58 UTC
Read the original article Hit count: 349

Filed under:
|

We set a global in our prepend file used to form the path for our require_once calls. For example:

require_once($GLOBALS['root'].'/library/particleboard/JsonUtil.php');

Problem is, when I run PHPUnit's skeleton test builder, the prepend file is not run, so the global is never set. When I run

cd /company/trunk/queue/process; phpunit --skeleton-test QueueProcessView

PHPUnit tries to resolve a require_once in QueueProcessView, but since the $GLOBALS['root'] is never set, I get a fatal error when including the required file.

For example, to PHPUnit, what should be

require_once(/code/trunk/library/particleboard/JsonUtil.php)

is resolved as

require_once(/library/particleboard/JsonUtil.php)

Notice the missing root.

Does anyone know if the skeleton-test code has some way to call PHP file before it is run? In this I could set my GLOBAL['root'] in this file.

Any other creative solutions would be appreciated.

© Stack Overflow or respective owner

Related posts about php

Related posts about phpunit