1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-06 14:46:36 +02:00

Tests: Add test adder

This commit is contained in:
Jakub Vrana
2025-03-27 20:20:00 +01:00
parent 104132de36
commit feaed0497a
3 changed files with 31 additions and 0 deletions

30
tests/add-test.php Executable file
View File

@@ -0,0 +1,30 @@
#!/usr/bin/env php
<?php
if ($argc != 2) {
echo "Usage: cat | php add-test.php 'before'\n";
echo "Purpose: Add the same test to all suites. 'before' is a regex for the following full test name (e.g. 'Clone').\n";
exit(1);
}
$before = $argv[1];
echo "Paste test created for MySQL:\n";
$input = stream_get_contents(STDIN);
$urls = array( // this works for tests inside db, not e.g. for server overview
"mysql" => "/adminer.php?username=ODBC&db=adminer_test",
"mariadb" => "/adminer.php?server=localhost:3307&username=ODBC&db=adminer_test",
"pgsql" => "/adminer.php?pgsql=&username=ODBC&db=adminer_test&ns=public",
"cockroachdb" => "/adminer.php?pgsql=localhost:26257&username=ODBC&db=adminer_test&ns=public",
"mssql" => "/adminer.php?mssql=&username=ODBC&db=adminer_test&ns=dbo",
"sqlite" => "/adminer/sqlite.php?sqlite=&username=ODBC&db=adminer_test.sqlite",
);
foreach ($urls as $driver => $url) {
$filename = __DIR__ . "/$driver.html";
$file = file_get_contents($filename);
$test = str_replace(htmlspecialchars($urls['mysql']), htmlspecialchars($urls[$driver]), $input);
$file = preg_replace("(<table.*\n.*>($before)<)", $test . '\0', $file);
file_put_contents($filename, $file);
}
include __DIR__ . "/generate-pdo.php";

View File

@@ -3,6 +3,7 @@
// Katalon Recorder has global variables: https://docs.katalon.com/katalon-platform/plugins-and-add-ons/katalon-recorder-extension/get-your-job-done/automate-scenarios/global-variables-in-katalon-recorder
// It's possible to use them in URL in Katalon Studio but apparently not in Recorder: https://forum.katalon.com/t/45673/2
chdir(__DIR__);
foreach (glob("*.html") as $filename) {
if (!preg_match('~^pdo-~', $filename)) {
$file = file_get_contents($filename);