initial prototype based on nat-as-server
Some checks failed
PHPUnit / test (push) Has been cancelled

This commit is contained in:
tom.hempel
2026-06-29 12:39:55 +02:00
commit f1caa9e681
148 changed files with 34905 additions and 0 deletions

View File

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace Tests\Unit;
use PHPUnit\Framework\TestCase;
final class TextSanitizeTest extends TestCase
{
public function testStripsSqlLikePatterns(): void
{
require_once dirname(__DIR__, 2) . '/lib/text_sanitize.php';
$out = sanitize_free_text("hello'; DROP TABLE users;--");
$this->assertStringNotContainsString('DROP TABLE', $out);
$this->assertStringNotContainsString('--', $out);
}
public function testPreservesNewlines(): void
{
require_once dirname(__DIR__, 2) . '/lib/text_sanitize.php';
$out = sanitize_free_text("line1\nline2");
$this->assertStringContainsString("\n", $out);
}
public function testNonStringReturnsEmpty(): void
{
require_once dirname(__DIR__, 2) . '/lib/text_sanitize.php';
$this->assertSame('', sanitize_free_text(null));
}
}