N°985 - Add applicable contexts on Trigger

This commit is contained in:
Eric
2020-01-20 15:50:08 +01:00
parent 2fcea4d02e
commit 900e8ac6d7
21 changed files with 366 additions and 93 deletions

32
test/core/TriggerTest.php Normal file
View File

@@ -0,0 +1,32 @@
<?php
namespace Combodo\iTop\Test\UnitTest\Core;
use Combodo\iTop\Test\UnitTest\ItopDataTestCase;
use ContextTag;
use MetaModel;
use TriggerOnObjectCreate;
/**
* Class TriggerTest
*
* @package Combodo\iTop\Test\UnitTest\Core
*
* @runTestsInSeparateProcesses
*/
class TriggerTest extends ItopDataTestCase
{
const USE_TRANSACTION = false;
public function testIsContextValid()
{
/** @var TriggerOnObjectCreate $oTrigger */
$oTrigger = MetaModel::NewObject('TriggerOnObjectCreate');
$oTrigger->Set('context', ContextTag::TAG_PORTAL.', '.ContextTag::TAG_CRON);
$this->assertFalse($oTrigger->IsContextValid());
ContextTag::AddContext(ContextTag::TAG_SETUP);
$this->assertFalse($oTrigger->IsContextValid());
ContextTag::AddContext(ContextTag::TAG_CRON);
$this->assertTrue($oTrigger->IsContextValid());
}
}