-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathadd-test.php
More file actions
executable file
·30 lines (26 loc) · 1.2 KB
/
add-test.php
File metadata and controls
executable file
·30 lines (26 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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/?username=ODBC&db=adminer_test",
"mariadb" => "/adminer/?server=localhost:3307&username=ODBC&db=adminer_test",
"pgsql" => "/adminer/?pgsql=&username=ODBC&db=adminer_test&ns=public",
"cockroachdb" => "/adminer/?pgsql=localhost:26257&username=ODBC&db=adminer_test&ns=public",
"mssql" => "/adminer/?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";