added unit tests

This commit is contained in:
2026-06-04 21:40:59 +02:00
parent d80a8de559
commit 48a619ee4b
64 changed files with 3807 additions and 33 deletions

View File

@ -0,0 +1,48 @@
<?php
declare(strict_types=1);
namespace Tests\Support;
final class TestFilesystem
{
public static function resetUploads(): void
{
if (!defined('QDB_TEST_UPLOADS')) {
return;
}
if (defined('QDB_PATH')) {
if (is_file(QDB_PATH)) {
@unlink(QDB_PATH);
}
if (defined('QDB_LOCK') && is_file(QDB_LOCK)) {
@unlink(QDB_LOCK);
}
}
self::rmTree(QDB_TEST_UPLOADS);
mkdir(QDB_TEST_UPLOADS, 0755, true);
}
private static function rmTree(string $dir): void
{
if (!is_dir($dir)) {
return;
}
$items = scandir($dir);
if ($items === false) {
return;
}
foreach ($items as $item) {
if ($item === '.' || $item === '..') {
continue;
}
$path = $dir . DIRECTORY_SEPARATOR . $item;
if (is_dir($path)) {
self::rmTree($path);
} else {
@unlink($path);
}
}
@rmdir($dir);
}
}