| +-----------------------------------------------------------------------+ */ /** * A helper to mock Roundcube HTTP client */ class HttpClientMock { public static function setResponses(array $responses) { foreach ($responses as $idx => $response) { if ($response instanceof Response) { $responses[$idx] = $response; } elseif (is_array($response)) { $responses[$idx] = new Response( $response[0] ?? 200, $response[1] ?? [], $response[2] ?? '' ); } } $mock = new MockHandler($responses); $handler = HandlerStack::create($mock); $rcube = \rcube::get_instance(); $rcube->config->set('http_client', ['handler' => $handler]); } }