Hi, I would like to add a few unit tests to our test cases that (contrary to before) also would write some records into the DB. I would like to setup an own test-DB for this purpose to avoid any remnants from failed unit-tests. Is there a way to tell phpunit to use other DB-credentials than the one specified in the config.php?
Thanks. Not exactly what I wanted to do. What could work (it seems to work at least) you override the connection to another system after the ‘default’ environment started via phpunit.
I just would have to make sure that the central DB handle is overwritten globally or that each unittest really sets this up correct. If you do a truncate by accident on a production DB with the intention to clean up your unittest records you dig your own grave :o.
I have ran into some problems when I am trying to unittest a class that uses internally the SuiteCRM Bean API.
I get as error:
Undefined index: rname
which origins in data\SugarBean.php:3998
the bean-call that causes this exception looks like this: $bean->get_list("name", "<module>.name = '$name'");
within the regular interative usage this works without problems. Just calling it in a unittest environment the call fails. Is there more to do to setup this SugarBean API correctly? The code in the reported lines indeed expects a field ‘rname’ to be there. I am not sure when/how to populate it in a unittest setup?
I also faced the same problem.
I configured the following settings to connect to a different database in the test environment.
This is the solution for version 7.14.
copy tests/config.test.dist.php to tests/config.test.php and add the code below.