mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-06 01:28:19 +01:00
Test
This commit is contained in:
@@ -46,7 +46,9 @@ class InterfaceWebhookTriggers extends DolibarrTriggers
|
|||||||
*/
|
*/
|
||||||
public function __construct($db)
|
public function __construct($db)
|
||||||
{
|
{
|
||||||
parent::__construct($db);
|
$this->db = $db;
|
||||||
|
|
||||||
|
$this->name = preg_replace('/^Interface/i', '', get_class($this));
|
||||||
$this->family = "demo";
|
$this->family = "demo";
|
||||||
$this->description = "Webhook triggers.";
|
$this->description = "Webhook triggers.";
|
||||||
$this->version = self::VERSIONS['dev'];
|
$this->version = self::VERSIONS['dev'];
|
||||||
@@ -76,7 +78,7 @@ class InterfaceWebhookTriggers extends DolibarrTriggers
|
|||||||
$nbPosts = 0;
|
$nbPosts = 0;
|
||||||
$errors = 0;
|
$errors = 0;
|
||||||
$static_object = new Target($this->db);
|
$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) {
|
if (is_numeric($target_url) && $target_url < 0) {
|
||||||
dol_syslog("Error Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
|
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'] : "");
|
$sendmanualtriggers = (!empty($object->context['sendmanualtriggers']) ? $object->context['sendmanualtriggers'] : "");
|
||||||
foreach ($target_url as $key => $tmpobject) {
|
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
|
// Test on Target status
|
||||||
$testontargetstatus = ($tmpobject->status == Target::STATUS_AUTOMATIC_TRIGGER || ($tmpobject->status == Target::STATUS_MANUAL_TRIGGER && !empty($sendmanualtriggers)));
|
$testontargetstatus = ($tmpobject->status == Target::STATUS_AUTOMATIC_TRIGGER || ($tmpobject->status == Target::STATUS_MANUAL_TRIGGER && !empty($sendmanualtriggers)));
|
||||||
|
|||||||
@@ -308,6 +308,7 @@ class AllTests
|
|||||||
$suite->addTestSuite('WebsiteTest');
|
$suite->addTestSuite('WebsiteTest');
|
||||||
|
|
||||||
// At end because it's the longer
|
// 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';
|
require_once dirname(__FILE__).'/ModulesTest.php';
|
||||||
$suite->addTestSuite('ModulesTest');
|
$suite->addTestSuite('ModulesTest');
|
||||||
|
|
||||||
|
|||||||
@@ -51,6 +51,26 @@ use PHPUnit\Framework\TestCase;
|
|||||||
*/
|
*/
|
||||||
class ModulesTest extends CommonClassTest // TestCase //CommonClassTest
|
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
|
* Return list of modules for which to test initialisation
|
||||||
*
|
*
|
||||||
@@ -90,7 +110,7 @@ class ModulesTest extends CommonClassTest // TestCase //CommonClassTest
|
|||||||
$mod = new $class($db);
|
$mod = new $class($db);
|
||||||
|
|
||||||
$result = $mod->remove();
|
$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();
|
$result = $mod->init();
|
||||||
print __METHOD__." test init for module ".$modlabel.", result=".$result."\n";
|
print __METHOD__." test init for module ".$modlabel.", result=".$result."\n";
|
||||||
|
|||||||
Reference in New Issue
Block a user