Repository navigation
Expand file tree
/
Copy pathTestHttpClient.php
More file actions
65 lines (52 loc) · 1.53 KB
/
Copy pathTestHttpClient.php
File metadata and controls
65 lines (52 loc) · 1.53 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
62
63
64
65
<?php
namespace Github\Tests\Mock;
use Github\HttpClient\HttpClientInterface;
class TestHttpClient implements HttpClientInterface
{
public $authenticated = false;
public $requests = array(
'get' => array(),
'post' => array(),
'patch' => array(),
'put' => array(),
'delete' => array(),
);
public $options = array();
public $headers = array();
public function authenticate()
{
$this->authenticated = true;
}
public function setOption($key, $value)
{
$this->options[$key] = $value;
}
public function setHeaders(array $headers)
{
$this->headers = $headers;
}
public function get($path, array $parameters = array(), array $headers = array())
{
$this->requests['get'][] = $path;
}
public function post($path, array $parameters = array(), array $headers = array())
{
$this->requests['post'][] = $path;
}
public function patch($path, array $parameters = array(), array $headers = array())
{
$this->requests['patch'][] = $path;
}
public function put($path, array $options = array(), array $headers = array())
{
$this->requests['put'][] = $path;
}
public function delete($path, array $parameters = array(), array $headers = array())
{
$this->requests['delete'][] = $path;
}
public function request($path, array $parameters = array(), $httpMethod = 'GET', array $headers = array())
{
$this->requests[$httpMethod][] = $path;
}
}