This commit is contained in:
ldestailleur
2025-03-25 22:31:49 +01:00
parent 507262a1a8
commit fd0889cebb
3 changed files with 32 additions and 4 deletions

View File

@@ -46,7 +46,9 @@ class InterfaceWebhookTriggers extends DolibarrTriggers
*/
public function __construct($db)
{
parent::__construct($db);
$this->db = $db;
$this->name = preg_replace('/^Interface/i', '', get_class($this));
$this->family = "demo";
$this->description = "Webhook triggers.";
$this->version = self::VERSIONS['dev'];
@@ -76,7 +78,7 @@ class InterfaceWebhookTriggers extends DolibarrTriggers
$nbPosts = 0;
$errors = 0;
$static_object = new Target($this->db);
$target_url = $static_object->fetchAll();
$target_url = $static_object->fetchAll(); // TODO Replace this with a search with filter on $action trigger to avoid to filter later.
if (is_numeric($target_url) && $target_url < 0) {
dol_syslog("Error Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
@@ -91,7 +93,12 @@ class InterfaceWebhookTriggers extends DolibarrTriggers
$sendmanualtriggers = (!empty($object->context['sendmanualtriggers']) ? $object->context['sendmanualtriggers'] : "");
foreach ($target_url as $key => $tmpobject) {
$actionarray = explode(",", $tmpobject->trigger_codes);
// Set list of all triggers for this targetinto $actionarray
$actionarraytmp = explode(",", $tmpobject->trigger_codes);
$actionarray = array();
foreach ($actionarraytmp as $val) {
$actionarray = trim($val);
}
// Test on Target status
$testontargetstatus = ($tmpobject->status == Target::STATUS_AUTOMATIC_TRIGGER || ($tmpobject->status == Target::STATUS_MANUAL_TRIGGER && !empty($sendmanualtriggers)));

View File

@@ -308,6 +308,7 @@ class AllTests
$suite->addTestSuite('WebsiteTest');
// At end because it's the longer
// Also enabling and disabling modules is changing the context and global variables that changes behaviour of previous tests
require_once dirname(__FILE__).'/ModulesTest.php';
$suite->addTestSuite('ModulesTest');

View File

@@ -51,6 +51,26 @@ use PHPUnit\Framework\TestCase;
*/
class ModulesTest extends CommonClassTest // TestCase //CommonClassTest
{
/**
* setUpBeforeClass
*
* @return void
*/
public static function setUpBeforeClass(): void
{
global $conf,$user,$langs,$db;
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
if ((int) getenv('PHPUNIT_DEBUG') > 0) {
print get_called_class()."::".__FUNCTION__.PHP_EOL;
}
$infotable = $db->DDLListTablesFull($db->database_name);
print "List of existing tables before running test ModulesTest\n";
print var_export($infotable, true)."\n";
}
/**
* Return list of modules for which to test initialisation
*
@@ -90,7 +110,7 @@ class ModulesTest extends CommonClassTest // TestCase //CommonClassTest
$mod = new $class($db);
$result = $mod->remove();
print __METHOD__." test remove for module ".$modlabel.", result=".$result."\n";
print __METHOD__." test remove for module ".$modlabel.", result=".$result."\n";
$result = $mod->init();
print __METHOD__." test init for module ".$modlabel.", result=".$result."\n";