forked from phpmyadmin/phpmyadmin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServerStatusDataTest.php
More file actions
136 lines (118 loc) · 3.58 KB
/
Copy pathServerStatusDataTest.php
File metadata and controls
136 lines (118 loc) · 3.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Test for ServerStatusData class
*
* @package PhpMyAdmin-test
*/
/*
* Include to test.
*/
use PMA\libraries\Core;
use PMA\libraries\ServerStatusData;
require_once 'libraries/database_interface.inc.php';
require_once 'test/PMATestCase.php';
/**
* Test for ServerStatusData class
*
* @package PhpMyAdmin-test
*/
class ServerStatusDataTest extends PMATestCase
{
/**
* @access protected
*/
protected $object;
/**
* Configures global environment.
*
* @return void
*/
function setup()
{
$GLOBALS['PMA_PHP_SELF'] = Core::getenv('PHP_SELF');
$GLOBALS['cfg']['Server']['host'] = "::1";
$GLOBALS['replication_info']['master']['status'] = true;
$GLOBALS['replication_info']['slave']['status'] = true;
$GLOBALS['replication_types'] = array();
//Mock DBI
$dbi = $this->getMockBuilder('PMA\libraries\DatabaseInterface')
->disableOriginalConstructor()
->getMock();
//this data is needed when ServerStatusData constructs
$server_status = array(
"Aborted_clients" => "0",
"Aborted_connects" => "0",
"Com_delete_multi" => "0",
"Com_create_function" => "0",
"Com_empty_query" => 3,
"Key_blocks_used" => 2,
"Key_writes" => true,
"Key_reads" => true,
"Key_write_requests" => 5,
"Key_read_requests" => 1,
"Threads_created" => true,
"Connections" => 2,
);
$server_variables= array(
"auto_increment_increment" => "1",
"auto_increment_offset" => "1",
"automatic_sp_privileges" => "ON",
"back_log" => "50",
"big_tables" => "OFF",
"key_buffer_size" => 10,
);
$fetchResult = array(
array(
"SHOW GLOBAL STATUS",
0,
1,
null,
0,
$server_status
),
array(
"SHOW GLOBAL VARIABLES",
0,
1,
null,
0,
$server_variables
),
array(
"SELECT concat('Com_', variable_name), variable_value "
. "FROM data_dictionary.GLOBAL_STATEMENTS",
0,
1,
null,
0,
$server_status
),
);
$dbi->expects($this->any())->method('fetchResult')
->will($this->returnValueMap($fetchResult));
$GLOBALS['dbi'] = $dbi;
$this->object = new ServerStatusData();
}
/**
* tests getMenuHtml()
*
* @return void
*/
function testGetMenuHtml()
{
$html = $this->object->getMenuHtml();
$this->assertContains('Server', $html);
$this->assertContains('server_status.php', $html);
$this->assertContains('Processes', $html);
$this->assertContains('server_status_processes.php', $html);
$this->assertContains('Query statistics', $html);
$this->assertContains('server_status_queries.php', $html);
$this->assertContains('All status variables', $html);
$this->assertContains('server_status_variables.php', $html);
$this->assertContains('Monitor', $html);
$this->assertContains('server_status_monitor.php', $html);
$this->assertContains('Advisor', $html);
$this->assertContains('server_status_advisor.php', $html);
}
}