$response = $this->callUntilDataIsPresent('host.get', ['filter' => ['host' => self::HOST_NAME]], 10, 1);
require_once dirname(__FILE__).'/../include/CIntegrationTest.php';
require_once dirname(__FILE__).'/../include/helpers/CDataHelper.php';
class testGraphLinking extends CIntegrationTest {
const HOST_NAME = 'test_graph_linking';
const TEMPLATE_NAME_PRE = 'strata_template_name';
const ITEM_NAME_PRE = 'strata_item_name';
const ITEM_KEY_PRE = 'strata_item_key';
const GRAPH_NAME_PRE = 'strata_graph_name';
const GRAPH_PERCENT_LEFT = 1;
const GRAPH_PERCENT_RIGHT = 100;
const GRAPH_SHOW_LEGEND = 1;
const GRAPH_SHOW_WORK_PERIOD = 1;
const GRAPH_SHOW_TRIGGERS = 1;
const GRAPH_YAXISMAX = 417;
const GRAPH_YAXISMIN = 18;
const GRAPH_YMAX_TYPE = 2;
const GRAPH_YMIN_TYPE = 1;
const GRAPH_ITEM_COLOR = '00AA';
const NUMBER_OF_TEMPLATES = 5;
const NUMBER_OF_GRAPHS_PER_TEMPLATE = 5;
private static $templateids = array();
private static $stringids = array();
private static $colors = array();
public function createTemplates() {
for ($i = 0; $i < self::NUMBER_OF_TEMPLATES; $i++) {
$response = $this->call('template.create', [
'host' => self::TEMPLATE_NAME_PRE . "_" . $i,
$this->assertArrayHasKey('templateids', $response['result']);
$this->assertArrayHasKey(0, $response['result']['templateids']);
array_push(self::$templateids, $response['result']['templateids'][0]);
public function setupActions()
$response = $this->call('action.create', [
'eventsource' => EVENT_SOURCE_AUTOREGISTRATION,
'operationtype' => OPERATION_TYPE_HOST_ADD
$ep = json_encode($response, JSON_PRETTY_PRINT);
$this->assertArrayHasKey('actionids', $response['result'], $ep);