[Vtigercrm-developers] Vtiger and PHPUnit (automated testing)

Alan Lord alanslists at gmail.com
Sat Nov 30 09:21:27 GMT 2019

On 29/11/2019 17:12, Rubén A. Estrada Orozco wrote:
> Hi everyone,
> The other day I was playing around with PHPUnit trying to do some 
> automated tests for a custom module. However, in some cases the tests 
> won't run because the database object or log object are not initialized.
> I included the following at the top of my test script:
> require_once 'vtlib/Vtiger/Module.php';
> require_once 'include/utils/VtlibUtils.php';
> require_once 'config.inc.php';
> require_once 'includes/Loader.php';
> require_once 'modules/Emails/mail.php';
> vimport ('includes.runtime.EntryPoint');
> $current_user = Users::getActiveAdminUser();

I'm not sure you need all of that.

This is what I use generally for command line based scripts:

include_once('vtlib/Vtiger/Menu.php'); // Not sure this one is necessary
global $log, $adb;
$current_user = Users::getActiveAdminUser();

If you need logging for PHPUnit maybe just add:




More information about the vtigercrm-developers mailing list