'127.0.0.1', 'port' => 1, 'database' => 'mysql', 'user' => 'nobody', 'password' => 'nopassword', 'socket' => '', ], $settings); $threw = false; try { $mysql->serverVersion(); } catch (Throwable $e) { $threw = true; } assert_true($threw, 'connecting to a closed port must still raise an exception'); $logContents = (string)file_get_contents($logPath); assert_true( str_contains($logContents, 'MYSQL_CONNECT_FAIL'), 'a failed MySQL connection must be logged for diagnosis (expected MYSQL_CONNECT_FAIL marker in error log, got: ' . $logContents . ')' ); assert_true( str_contains($logContents, '127.0.0.1'), 'the connect-failure log line must include the target host for diagnosis' ); unlink($logPath); echo "mysql_connect_failure_test: OK\n";