- Mailer::send mit Retry (2 Versuche); SMTP-Test & Templates waren bereits da - admin/vouchers.php: Code per E-Mail (erneut) versenden (ajax_resend) - Tageslimit Voucher pro Nicht-Admin-Benutzer (Setting + Durchsetzung in index) - Docker: HEALTHCHECK (health.php) + curl; GHCR-Publish-Workflow - Setting user_daily_voucher_limit + enforce in integrations.php
42 lines
1.5 KiB
PHP
42 lines
1.5 KiB
PHP
<?php
|
|
namespace Tests;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
require_once __DIR__ . '/../updater/MigrationRunner.php';
|
|
|
|
final class MigrationSplitterTest extends TestCase
|
|
{
|
|
private function split(string $sql): array
|
|
{
|
|
$rc = new \ReflectionClass(\Updater\MigrationRunner::class);
|
|
$inst = $rc->newInstanceWithoutConstructor();
|
|
$m = $rc->getMethod('splitStatements');
|
|
$m->setAccessible(true);
|
|
$parts = $m->invoke($inst, $sql);
|
|
return array_values(array_filter(array_map('trim', $parts), fn($s) => $s !== ''));
|
|
}
|
|
|
|
public function testIgnoresSemicolonsInStringsAndComments(): void
|
|
{
|
|
$sql = "INSERT INTO t (a) VALUES (\";semi;colon\"); -- comment; not split\n"
|
|
. "CREATE TABLE x (id INT); /* block ; comment */ INSERT INTO y VALUES (1);";
|
|
$parts = $this->split($sql);
|
|
$this->assertCount(3, $parts);
|
|
}
|
|
|
|
public function testSingleStatement(): void
|
|
{
|
|
$parts = $this->split("ALTER TABLE users ADD COLUMN foo INT");
|
|
$this->assertCount(1, $parts);
|
|
}
|
|
|
|
public function testIgnorableErrorDetection(): void
|
|
{
|
|
$rc = new \ReflectionClass(\Updater\MigrationRunner::class);
|
|
$inst = $rc->newInstanceWithoutConstructor();
|
|
$this->assertTrue($inst->isIgnorableSqlError('Duplicate column name "x"', 'mysql'));
|
|
$this->assertTrue($inst->isIgnorableSqlError('Table already exists', 'mysql'));
|
|
$this->assertFalse($inst->isIgnorableSqlError('Syntax error near FROM', 'mysql'));
|
|
}
|
|
}
|