[Web][Tests] Add archive module tests

This commit is contained in:
FreddleSpl0it committed 2026-11-07 00:18:58 +01:00
1 parent 2ac2edf0ad
commit fc56d53029
14 files changed
+1403

No files matched your search

+46
View File
@@ -0,0 +1,46 @@
<?php
declare(strict_types=1);
namespace Mailcow\Tests\Support;
use Mailcow\Archive\Smtp\SmtpClient;
use Mailcow\Archive\Smtp\SmtpException;
/**
* SmtpClient without network: records submit() and probe() calls, answers with the configured results.
*/
class FakeSmtpClient extends SmtpClient
{
/** @var array[] submit() calls: host, port, from, rcpt, data */
public array $submitted = [];
/** @var array[] probe() calls */
public array $probed = [];
public ?SmtpException $error = null;
/** @var string[] extensions probe() reports */
public array $extensions = ['PIPELINING', 'SIZE', 'STARTTLS', '8BITMIME', 'SMTPUTF8'];
public array $mx = [];
public function submit(string $host, int $port, string $from, string $rcpt, string $data): string
{
if ($this->error !== null) {
throw $this->error;
}
$this->submitted[] = compact('host', 'port', 'from', 'rcpt', 'data');
return 'Q' . count($this->submitted);
}
public function probe(string $host, int $port, string $tls, string $username, string $password, string $from, string $rcpt): array
{
$this->probed[] = compact('host', 'port', 'tls', 'username', 'password', 'from', 'rcpt');
if ($this->error !== null) {
throw $this->error;
}
return $this->extensions;
}
public function mailHost(string $domain): string
{
return $this->mx[$domain] ?? $domain;
}
}