Merge pull request #12704 from appwrite/fix/unit-test-warning-deprecations

Fix unit test warnings and deprecations
This commit is contained in:
Chirag Aggarwal authored and GitHub committed 2026-06-28 11:19:05 +05:30
commit cc3a100578
4 files changed
+34 -3

No files matched your search

+7 -3
View File
@@ -50,13 +50,17 @@ class Headers extends Validator
$size = 0;
foreach ($value as $key => $val) {
$length = \strlen($key);
// Reject non-string keys
if (!\is_string($key) || $length === 0) {
if (!\is_string($key)) {
return false;
}
$size += $length + \strlen($val);
$length = \strlen($key);
if ($length === 0) {
return false;
}
$size += $length + \strlen($val ?? '');
if ($size >= $this->maxSize) {
return false;
}
+9
View File
@@ -39,10 +39,19 @@ class Cron extends Validator
}
try {
\set_error_handler(static function (int $severity, string $message): bool {
if (($severity & E_WARNING) === E_WARNING) {
throw new \RuntimeException($message);
}
return false;
});
(new CronExpression($value))->getNextRunDate();
return true;
} catch (\RuntimeException) {
return false;
} finally {
\restore_error_handler();
}
}
@@ -0,0 +1,17 @@
<?php
namespace Appwrite\Tests;
use PHPUnit\Event\TestRunner\ExecutionFinished;
use PHPUnit\Event\TestRunner\ExecutionFinishedSubscriber;
use Swoole\Event;
use Swoole\Timer;
class SwooleCleanupSubscriber implements ExecutionFinishedSubscriber
{
public function notify(ExecutionFinished $event): void
{
Timer::clearAll();
Event::wait();
}
}
+1
View File
@@ -16,5 +16,6 @@ class TestHook implements Extension
$facade->registerSubscriber(new TestPreparationStartedSubscriber());
$facade->registerSubscriber(new TestFinishedSubscriber(self::MAX_SECONDS_ALLOWED));
$facade->registerSubscriber(new RetrySubscriber());
$facade->registerSubscriber(new SwooleCleanupSubscriber());
}
}