config = [ 'database' => [ 'host' => 'localhost', 'user' => 'test_user', 'pass' => 'test_password', 'db' => 'test_database', 'port' => 3306 ] ]; } public function testConnection() { // Create an instance of Database $db = new Database($this->config); // Check if the connection is successfully established $this->assertInstanceOf(mysqli::class, $db); $this->assertEquals(0, $db->connect_errno, "Database connection error: " . $db->connect_error); } public function testQuery() { // Create an instance of Database $db = new Database($this->config); // Execute a simple query $result = $db->query('SELECT 1 AS value'); $this->assertNotFalse($result, "Query failed: " . $db->error); $row = $result->fetch_assoc(); $this->assertEquals(1, $row['value'], "Query did not return the correct value"); } protected function tearDown(): void { // Close the database connection if it's still open if (isset($db) && $db instanceof mysqli) { $db->close(); } } }