run(); DBconnect($error); } public static function providerTriggers() { return [ [ '13517', 'trigger host.host:Host for trigger description macros | '. 'host.host2:{HOST.HOST2} | host.name:Host for trigger description macros | '. 'item.value:5 | item.value1:5 | item.lastvalue:5 | host.ip:127.0.0.1 | '. 'host.dns: | host.conn:127.0.0.1' ] ]; } public static function providerReferenceMacros() { return [ [ 'expression' => '{123}=1', 'text' => 'd $1' ], [ 'expression' => '{1}=1&{2}>2', 'text' => 'd $1 $2 $3' ], [ 'expression' => '{1}=123&{2}>{$MACRO}', 'text' => 'd $1 $2 $3' ] ]; } /** * @dataProvider providerTriggers */ public function test_expandTrigger($triggerId, $expectedDescription) { $trigger = DBfetch(DBselect( 'SELECT t.triggerid,t.expression,t.description'. ' FROM triggers t'. ' WHERE t.triggerid='.$triggerId )); $description = CMacrosResolverHelper::resolveTriggerName($trigger); $this->assertEquals($expectedDescription, $description); } /** * @dataProvider providerReferenceMacros */ public function test_resolveTriggerReference($expression, $text) { $result = CMacrosResolverHelper::resolveTriggerReference($expression, $text); $this->assertEquals($text, $result); } }