Remove some useless comments
[phpmyadmin.git] / test / classes / ReplicationGuiTest.php
blobf3f9460d93010069e65ae6d24ad12706134241ea
1 <?php
3 declare(strict_types=1);
5 namespace PhpMyAdmin\Tests;
7 use PhpMyAdmin\Replication;
8 use PhpMyAdmin\ReplicationGui;
9 use PhpMyAdmin\ReplicationInfo;
10 use PhpMyAdmin\Template;
12 /**
13 * PhpMyAdmin\Tests\ReplicationGuiTest class
15 * this class is for testing PhpMyAdmin\ReplicationGui methods
17 class ReplicationGuiTest extends AbstractTestCase
19 /**
20 * ReplicationGui instance
22 * @var ReplicationGui
24 private $replicationGui;
26 /**
27 * Prepares environment for the test.
29 protected function setUp(): void
31 parent::setUp();
32 //$_POST
33 $_POST['mr_adduser'] = 'mr_adduser';
35 //$GLOBALS
36 $GLOBALS['cfg']['MaxRows'] = 10;
37 $GLOBALS['cfg']['ServerDefault'] = 'server';
38 $GLOBALS['cfg']['RememberSorting'] = true;
39 $GLOBALS['cfg']['SQP'] = [];
40 $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'] = 1000;
41 $GLOBALS['cfg']['ShowSQL'] = true;
42 $GLOBALS['cfg']['TableNavigationLinksMode'] = 'icons';
43 $GLOBALS['cfg']['LimitChars'] = 100;
44 $GLOBALS['cfg']['DBG']['sql'] = false;
45 $GLOBALS['cfg']['ShowHint'] = true;
47 $GLOBALS['table'] = 'table';
48 $GLOBALS['server'] = 0;
49 $GLOBALS['url_params'] = [];
51 $this->replicationGui = new ReplicationGui(new Replication(), new Template());
54 /**
55 * Test for getHtmlForMasterReplication
57 * @group medium
59 public function testGetHtmlForMasterReplication(): void
61 $html = $this->replicationGui->getHtmlForMasterReplication();
63 //validate 1: Master replication
64 $this->assertStringContainsString(
65 '<legend>Master replication</legend>',
66 $html
68 $this->assertStringContainsString(
69 'This server is configured as master in a replication process.',
70 $html
73 //validate 2: getHtmlForReplicationStatusTable
74 $this->assertStringContainsString(
75 '<div id="replication_master_section"',
76 $html
79 $this->assertStringContainsString(
80 'Binlog_Do_DB',
81 $html
83 $this->assertStringContainsString(
84 'Binlog_Ignore_DB',
85 $html
88 $this->assertStringContainsString(
89 'master-bin.000030',
90 $html
93 //validate 3: getHtmlForReplicationSlavesTable
94 $this->assertStringContainsString(
95 'replication_slaves_section',
96 $html
98 $this->assertStringContainsString(
99 '<th>Server ID</th>',
100 $html
102 $this->assertStringContainsString(
103 '<th>Host</th>',
104 $html
106 //slave host
107 $this->assertStringContainsString(
108 '<td class="value">Server_id1</td>',
109 $html
111 $this->assertStringContainsString(
112 '<td class="value">Server_id2</td>',
113 $html
115 $this->assertStringContainsString(
116 '<td class="value">Host1</td>',
117 $html
119 $this->assertStringContainsString(
120 '<td class="value">Host2</td>',
121 $html
123 //Notice
124 $this->assertStringContainsString(
125 'Only slaves started with the',
126 $html
129 //validate 4: navigation URL
130 $this->assertStringContainsString(
131 '<a href="index.php?route=/server/replication',
132 $html
134 $this->assertStringContainsString(
135 'Add slave replication user',
136 $html
139 //validate 5: 'Add replication slave user' form
140 $this->assertStringContainsString(
141 '<div id="master_addslaveuser_gui">',
142 $html
147 * Test for getHtmlForSlaveConfiguration
149 public function testGetHtmlForSlaveConfiguration(): void
151 $replicationInfo = new ReplicationInfo($GLOBALS['dbi']);
152 $replicationInfo->load();
154 //Call the test function
155 $html = $this->replicationGui->getHtmlForSlaveConfiguration(
156 true,
157 $replicationInfo->getReplicaStatus()
160 //legend
161 $this->assertStringContainsString(
162 '<legend>Slave replication</legend>',
163 $html
165 $this->assertStringContainsString(
166 '<div id="slave_configuration_gui">',
167 $html
169 //notice
170 $this->assertStringContainsString(
171 'Server is configured as slave in a replication process.',
172 $html
174 //slave session
175 $this->assertStringContainsString(
176 '<div id="replication_slave_section"',
177 $html
179 //variable
180 $this->assertStringContainsString(
181 'Master_SSL_CA_Path',
182 $html
184 $this->assertStringContainsString(
185 'Master_SSL_Cert',
186 $html
188 $this->assertStringContainsString(
189 'Master_SSL_Cipher',
190 $html
192 $this->assertStringContainsString(
193 'Seconds_Behind_Master',
194 $html
199 * Test for getHtmlForReplicationChangeMaster
201 public function testGetHtmlForReplicationChangeMaster(): void
203 //Call the test function
204 $html = $this->replicationGui->getHtmlForReplicationChangeMaster(
205 'slave_changemaster'
208 $this->assertStringContainsString(
209 '<form method="post" action="index.php?route=/server/replication',
210 $html
212 $this->assertStringContainsString(
213 'Slave configuration',
214 $html
216 $this->assertStringContainsString(
217 'Change or reconfigure master server',
218 $html
220 $notice = 'Make sure you have a unique server-id '
221 . 'in your configuration file (my.cnf)';
222 $this->assertStringContainsString(
223 $notice,
224 $html