require_once __DIR__.'/../../include/CLegacyWebTest.php';
class testFormHostLinkTemplates extends CLegacyWebTest {
const HOST_VISIBLE_NAME = 'Visible host for template linkage';
const TEMPLATE = 'Form test template';
const LINKED_TEMPLATE = 'Linux by Zabbix agent active';
protected static $hostid;
public function getBehaviors() {
return [CMessageBehavior::class];
public static function prepareHostData() {
self::$hostid = CDataHelper::call('host.create', [
'host' => 'Template linkage test host',
'name' => self::HOST_VISIBLE_NAME,
'groups' => ['groupid' => 4]
public function testFormHostLinkTemplates_Layout() {
$this->page->login()->open('zabbix.php?action=host.list')->waitUntilReady();
$this->query('button:Create host')->one()->click();
$form = COverlayDialogElement::find()->asForm()->one()->waitUntilVisible();
$form->selectTab('Inventory');
$inventoryFields = getHostInventories();
$inventoryFields = zbx_toHash($inventoryFields, 'db_field');
foreach ($inventoryFields as $fieldId => $fieldName) {
$this->zbxTestTextPresent($fieldName['title']);
$this->zbxTestAssertElementPresentId('host_inventory_'.$fieldId.'');
COverlayDialogElement::find()->one()->close();
public function testFormHostLinkTemplates_TemplateLink() {
$this->zbxTestLogin(self::HOST_LIST_PAGE);
$this->query('button:Reset')->one()->click();
$this->zbxTestClickLinkTextWait(self::HOST_VISIBLE_NAME);