$sqlTriggers = "select triggerid,expression,description,url,status,value,priority,comments,error,templateid,type,state,flags from triggers order by triggerid";
require_once dirname(__FILE__).'/../include/CLegacyWebTest.php';
require_once dirname(__FILE__).'/traits/FilterTrait.php';
require_once dirname(__FILE__).'/traits/TableTrait.php';
class testPageTemplates extends CLegacyWebTest {
public $templateName = 'Template OS Linux by Zabbix agent';
public static function allTemplates() {
return CDBHelper::getRandomizedDataProvider('SELECT * FROM hosts WHERE status IN ('.HOST_STATUS_TEMPLATE.')', 25);
public function testPageTemplates_CheckLayout() {
$this->zbxTestLogin('templates.php');
$this->zbxTestCheckTitle('Configuration of templates');
$this->zbxTestCheckHeader('Templates');
$filter = $this->query('name:zbx_filter')->asForm()->one();
$filter->getField('Host groups')->select('Templates/Operating systems');
$this->zbxTestTextPresent($this->templateName);
$table = $this->query('class:list-table')->asTable()->one();
$headers = ['', 'Name', 'Hosts', 'Applications', 'Items', 'Triggers', 'Graphs',
'Screens', 'Discovery', 'Web', 'Linked templates', 'Linked to templates', 'Tags'];
$this->assertSame($headers, $table->getHeadersText());
foreach (['Export', 'Mass update', 'Delete', 'Delete and clear'] as $button) {
$element = $this->query('button', $button)->one();
$this->assertTrue($element->isPresent());
$this->assertFalse($element->isEnabled());
$this->zbxTestAssertElementPresentXpath("//div[@class='table-stats'][contains(text(),'Displaying')]");