initial prototype based on nat-as-server
Some checks failed
PHPUnit / test (push) Has been cancelled
Some checks failed
PHPUnit / test (push) Has been cancelled
This commit is contained in:
31
tests/Unit/TextSanitizeTest.php
Normal file
31
tests/Unit/TextSanitizeTest.php
Normal 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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user