mirror of
https://github.com/mailcow/mailcow-dockerized.git
synced 2026-10-23 11:08:54 +00:00
[Web][Tests] Add PHPUnit setup and imapsync module tests
This commit is contained in:
18 files changed
+3948
-1
No files matched your search
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Mailcow\Tests\Support;
|
||||
|
||||
use Mailcow\Imapsync\Http\OAuthClient;
|
||||
|
||||
/**
|
||||
* OAuthClient without network: resolve() answers from $addresses, send() records the curl options
|
||||
* and returns $response.
|
||||
*/
|
||||
class FakeOAuthClient extends OAuthClient
|
||||
{
|
||||
/** @var array<string, string[]> host => addresses */
|
||||
public array $addresses = [];
|
||||
/** @var array{0: string|false, 1: int} */
|
||||
public array $response = ['{}', 200];
|
||||
/** @var array[] curl options of every send() */
|
||||
public array $sent = [];
|
||||
/** @var string[] hosts passed to resolve() */
|
||||
public array $resolved = [];
|
||||
|
||||
protected function resolve(string $host): array
|
||||
{
|
||||
$this->resolved[] = $host;
|
||||
return $this->addresses[$host] ?? [];
|
||||
}
|
||||
|
||||
protected function send(array $options): array
|
||||
{
|
||||
$this->sent[] = $options;
|
||||
return $this->response;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user