/** * Test for PMA_getHtmlForServerStatus * * @return void * @group medium */ public function testPMAGetHtmlForServerStatus() { //parameters $upTime = "10h"; $bytes_received = 100; $bytes_sent = 200; $max_used_conn = 500; $aborted_conn = 200; $conn = 1000; $this->ServerStatusData->status['Uptime'] = $upTime; $this->ServerStatusData->status['Bytes_received'] = $bytes_received; $this->ServerStatusData->status['Bytes_sent'] = $bytes_sent; $this->ServerStatusData->status['Max_used_connections'] = $max_used_conn; $this->ServerStatusData->status['Aborted_connects'] = $aborted_conn; $this->ServerStatusData->status['Connections'] = $conn; //Call the test function $html = PMA_getHtmlForServerStatus($this->ServerStatusData); //validate 1: PMA_getHtmlForServerStateGeneralInfo //traffic: $bytes_received + $bytes_sent $traffic = $bytes_received + $bytes_sent; $traffic_html = 'Network traffic since startup: ' . $traffic . ' B'; $this->assertContains($traffic_html, $html); //updatetime $upTime_html = 'This MySQL server has been running for ' . '0 days, 0 hours, 0 minutes and 10h seconds'; $this->assertContains($upTime_html, $html); //master state $master_html = 'This MySQL server works as <b>master</b>'; $this->assertContains($master_html, $html); //validate 2: PMA_getHtmlForServerStateTraffic $traffic_html = '<table id="serverstatustraffic" class="data noclick">'; $this->assertContains($traffic_html, $html); //traffic hint $traffic_html = 'On a busy server, the byte counters may overrun'; $this->assertContains($traffic_html, $html); //$bytes_received $this->assertContains('<td class="value">' . $bytes_received . ' B', $html); //$bytes_sent $this->assertContains('<td class="value">' . $bytes_sent . ' B', $html); //validate 3: PMA_getHtmlForServerStateConnections $this->assertContains('<th>Connections</th>', $html); $this->assertContains('<th>ø per hour</th>', $html); $this->assertContains('<table id="serverstatusconnections" class="data noclick">', $html); $this->assertContains('<th class="name">Max. concurrent connections</th>', $html); //Max_used_connections $this->assertContains('<td class="value">' . $max_used_conn, $html); $this->assertContains('<th class="name">Failed attempts</th>', $html); //Aborted_connects $this->assertContains('<td class="value">' . $aborted_conn, $html); $this->assertContains('<th class="name">Aborted</th>', $html); $GLOBALS['replication_info']['master']['status'] = true; $GLOBALS['replication_info']['slave']['status'] = true; $this->ServerStatusData->status['Connections'] = 0; $html = PMA_getHtmlForServerStatus($this->ServerStatusData); $this->assertContains('This MySQL server works as <b>master</b> and <b>slave</b>', $html); $GLOBALS['replication_info']['master']['status'] = false; $GLOBALS['replication_info']['slave']['status'] = true; $html = PMA_getHtmlForServerStatus($this->ServerStatusData); $this->assertContains('This MySQL server works as <b>slave</b>', $html); }
/* vim: set expandtab sw=4 ts=4 sts=4: */ /** * object the server status page: processes, connections and traffic * * @package PhpMyAdmin */ require_once 'libraries/common.inc.php'; require_once 'libraries/server_common.inc.php'; require_once 'libraries/ServerStatusData.class.php'; require_once 'libraries/server_status.lib.php'; /** * Replication library */ if (PMA_DRIZZLE) { $server_master_status = false; $server_slave_status = false; } else { include_once 'libraries/replication.inc.php'; include_once 'libraries/replication_gui.lib.php'; } $ServerStatusData = new PMA_ServerStatusData(); /** * start output */ $response = PMA_Response::getInstance(); $response->addHTML('<div>'); $response->addHTML($ServerStatusData->getMenuHtml()); $response->addHTML(PMA_getHtmlForServerStatus($ServerStatusData)); $response->addHTML('</div>'); exit;