require_once dirname(__FILE__).'/../include/CWebTest.php';
require_once dirname(__FILE__).'/behaviors/CTableBehavior.php';
require_once dirname(__FILE__).'/behaviors/CTagBehavior.php';
require_once dirname(__FILE__).'/../include/helpers/CDataHelper.php';
class testPageMonitoringHosts extends CWebTest {
public function getBehaviors() {
'class' => CTagBehavior::class,
'tag_selector' => 'id:tags_0'
protected static $hostid;
public function testPageMonitoringHosts_CheckLayout() {
$this->page->login()->open('zabbix.php?action=host.view')->waitUntilReady();
$form = $this->query('name:zbx_filter')->waitUntilPresent()->asForm()->one();
$table = $this->query('class:list-table')->asTable()->one();
$this->page->assertTitle('Hosts');
$this->page->assertHeader('Hosts');
$headers = ['Name', 'Interface', 'Availability', 'Tags', 'Status', 'Latest data', 'Problems','Graphs',
$this->assertSame($headers, ($this->query('class:list-table')->asTable()->one())->getHeadersText());
foreach ([true, false] as $status) {
$this->assertTrue($this->query('xpath://ul[@class="ui-sortable-container ui-sortable"]//li[contains(@class, "selected")]')
->one()->isPresent($status)
$this->query('xpath://a[@aria-label="Home"]')->one()->click();
foreach(['tags[0][tag]', 'tags[0][value]'] as $field) {
$this->assertEquals(255, $form->query('xpath:.//input[@name="'.$field.'"]')
->one()->getAttribute('maxlength'));
foreach(['name', 'ip', 'dns', 'port'] as $field) {
$this->assertEquals(255, $form->query('xpath:.//input[@id="'.$field.'_0"]')
->one()->getAttribute('maxlength'));
foreach (['Graphs', 'Dashboards', 'Web'] as $disabled) {
$row = $table->findRow('Name', 'Available host');
$this->assertTrue($row->query('xpath://following::td/span[@class="disabled" and text()="'.$disabled.'"]')->exists());