dummyDbi = $this->createDbiDummy(); $this->dbi = $this->createDatabaseInterface($this->dummyDbi); DatabaseInterface::$instance = $this->dbi; Current::$database = 'db'; Current::$table = 'table'; $config = Config::getInstance(); $config->selectedServer['DisableIS'] = false; $config->selectedServer['host'] = 'localhost'; } public function testIndex(): void { $data = new Data(DatabaseInterface::getInstance(), Config::getInstance()); $bytesReceived = 100; $bytesSent = 200; $maxUsedConnections = 500; $abortedConnections = 200; $connections = 1000; $data->status['Uptime'] = 36000; $data->status['Bytes_received'] = $bytesReceived; $data->status['Bytes_sent'] = $bytesSent; $data->status['Max_used_connections'] = $maxUsedConnections; $data->status['Aborted_connects'] = $abortedConnections; $data->status['Connections'] = $connections; $response = new ResponseRenderer(); $template = new Template(); $controller = new StatusController( $response, $template, $data, new ReplicationGui(new Replication(DatabaseInterface::getInstance()), $template), DatabaseInterface::getInstance(), ); $replicationInfo = $data->getReplicationInfo(); $replicationInfo->primaryVariables = []; $replicationInfo->replicaVariables = []; $this->dummyDbi->addSelectDb('mysql'); $controller(self::createStub(ServerRequest::class)); $this->dummyDbi->assertAllSelectsConsumed(); $html = $response->getHTMLResult(); $traffic = $bytesReceived + $bytesSent; $trafficHtml = 'Network traffic since startup: ' . $traffic . ' B'; self::assertStringContainsString($trafficHtml, $html); //updatetime $upTimeHtml = 'This MySQL server has been running for 0 days, 10 hours, 0 minutes and 0 seconds'; self::assertStringContainsString($upTimeHtml, $html); //primary state $primaryHtml = 'This MySQL server works as primary'; self::assertStringContainsString($primaryHtml, $html); //validate 2: Status::getHtmlForServerStateTraffic $trafficHtml = ''; self::assertStringContainsString($trafficHtml, $html); //traffic hint $trafficHtml = 'On a busy server, the byte counters may overrun'; self::assertStringContainsString($trafficHtml, $html); //$bytes_received self::assertStringContainsString('', $html); self::assertStringContainsString('', $html); self::assertStringContainsString( '
' . $bytesReceived . ' B', $html); //$bytes_sent self::assertStringContainsString('' . $bytesSent . ' B', $html); //validate 3: Status::getHtmlForServerStateConnections self::assertStringContainsString('ConnectionsΓΈ per hour
', $html, ); self::assertStringContainsString('', $html); //Max_used_connections self::assertStringContainsString('', $html); //Aborted_connects self::assertStringContainsString('', $html); } }
Max. concurrent connections' . $maxUsedConnections, $html); self::assertStringContainsString('Failed attempts' . $abortedConnections, $html); self::assertStringContainsString('Aborted