-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHttpClientSpy.php
More file actions
61 lines (50 loc) · 1.35 KB
/
HttpClientSpy.php
File metadata and controls
61 lines (50 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
declare(strict_types=1);
namespace BelkaTech\VkTeamsBot\Test\Spy;
use BelkaTech\VkTeamsBot\Http\HttpClient;
final class HttpClientSpy extends HttpClient
{
/**
* @var list<array{
* string,
* string,
* array<string, mixed>,
* }|array{
* string,
* string,
* array<string, mixed>,
* string,
* }>
*/
public array $calls = [];
/** @var array<string, mixed> */
private array $getResponse;
/** @var array<string, mixed> */
private array $postMultipartResponse;
/**
* @param array<string, mixed> $getResponse
* @param array<string, mixed> $postMultipartResponse
*/
public function __construct(
array $getResponse = ['ok' => true],
array $postMultipartResponse = ['ok' => true],
) {
$this->getResponse = $getResponse;
$this->postMultipartResponse = $postMultipartResponse;
}
public function get(
string $path,
array $params = [],
): array {
$this->calls[] = ['get', $path, $params];
return $this->getResponse;
}
public function postMultipart(
string $path,
array $params,
string $filePath,
): array {
$this->calls[] = ['postMultipart', $path, $params, $filePath];
return $this->postMultipartResponse;
}
}