Is there a way to define constants in PHPUnit that can be used in all your test suites? For example, say I want to be able to test on jason.dev.mysite.com sometimes and jim.dev.mysite.com sometimes, and maybe specify when I run the command on which site I want to test. Is anything like this possible?
The closest thing I found was this: http://www.phpunit.de/manual/3.4/en/appendixes.configuration.html
This should be in the bootstrap file.
Check here : http://www.phpunit.de/manual/current/en/textui.html for the bootstrap file option.
You can also check out the setUp()
and setUpBeforeClass()
methods, but they are related to one test class only.
For those who already have a bootstrap and are wanting to define a constant separately checkout the <php>
tag in the XML Configuration file. The link seem to change on a regular basis with version updates so an example is:
<phpunit bootstrap="../libraries/global/bootstrap.lib.php">
<php>
<env name="db_user" value="admin"/>
<env name="db_pass" value="admin"/>
<env name="db_host" value="127.0.0.1"/>
<env name="db_port" value="1433"/>
<const name="DEBUG" value="FALSE"/>
</php>
<testsuites>
<testsuite name="role">
<file>modules/role/role.test.php</file>
</testsuite>
</testsuites>
</phpunit>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With