1 | <?php |
||
26 | class ApiContext implements ApiContextInterface |
||
27 | { |
||
28 | /** |
||
29 | * @var HttpClient |
||
30 | */ |
||
31 | private $client; |
||
32 | |||
33 | /** |
||
34 | * @var RequestFactory |
||
35 | */ |
||
36 | private $requestFactory; |
||
37 | |||
38 | /** |
||
39 | * @var string |
||
40 | */ |
||
41 | private $baseUrl; |
||
42 | |||
43 | /** |
||
44 | * @var string[][] |
||
45 | */ |
||
46 | private $headers = []; |
||
47 | |||
48 | /** |
||
49 | * @var RequestInterface|null |
||
50 | */ |
||
51 | private $request; |
||
52 | |||
53 | /** |
||
54 | * @var ResponseInterface|null |
||
55 | */ |
||
56 | private $response; |
||
57 | |||
58 | /** |
||
59 | * @var Matcher |
||
60 | */ |
||
61 | private $matcher; |
||
62 | |||
63 | public function __construct() |
||
67 | |||
68 | /** |
||
69 | * {@inheritdoc} |
||
70 | */ |
||
71 | public function setClient(HttpClient $client) |
||
75 | |||
76 | /** |
||
77 | * {@inheritdoc} |
||
78 | */ |
||
79 | public function setRequestFactory(RequestFactory $requestFactory) |
||
83 | |||
84 | /** |
||
85 | * {@inheritdoc} |
||
86 | */ |
||
87 | public function setBaseUrl($baseUrl) |
||
95 | |||
96 | /** |
||
97 | * @BeforeScenario |
||
98 | */ |
||
99 | public function reset() |
||
105 | |||
106 | /** |
||
107 | * @param string $header |
||
108 | * @param string $value |
||
109 | * |
||
110 | * @Given I set the header ":header" with value ":value" |
||
111 | */ |
||
112 | public function setHeader($header, $value) |
||
116 | |||
117 | /** |
||
118 | * @param string $header |
||
119 | * @param string $value |
||
120 | * |
||
121 | * @Given I add the header ":header" with value ":value" |
||
122 | */ |
||
123 | public function addHeader($header, $value) |
||
127 | |||
128 | /** |
||
129 | * @param string $header |
||
130 | * |
||
131 | * @Given I remove the header ":header" |
||
132 | */ |
||
133 | public function removeHeader($header) |
||
137 | |||
138 | /** |
||
139 | * @param string $method |
||
140 | * @param string $url |
||
141 | * |
||
142 | * @When I send a ":method" request to ":url" |
||
143 | */ |
||
144 | public function send($method, $url) |
||
150 | |||
151 | /** |
||
152 | * @param string $method |
||
153 | * @param string $url |
||
154 | * @param PyStringNode $string |
||
155 | * |
||
156 | * @When I send a ":method" request to ":url" with body: |
||
157 | */ |
||
158 | public function sendWith($method, $url, PyStringNode $string) |
||
169 | |||
170 | /** |
||
171 | * @param string $statusCode |
||
172 | * |
||
173 | * @Then the response status code should be ":statusCode" |
||
174 | */ |
||
175 | public function assertResponseStatusCode($statusCode) |
||
179 | |||
180 | /** |
||
181 | * @param PyStringNode $json |
||
182 | * |
||
183 | * @Then the response should contain: |
||
184 | */ |
||
185 | public function assertResponseContains(PyStringNode $json) |
||
191 | |||
192 | /** |
||
193 | * @Then the response should be empty |
||
194 | */ |
||
195 | public function assertResponseEmpty() |
||
199 | |||
200 | /** |
||
201 | * @Then I print the response |
||
202 | */ |
||
203 | public function printResponse() |
||
213 | |||
214 | /** |
||
215 | * @return RequestInterface |
||
216 | */ |
||
217 | public function getRequest() |
||
225 | |||
226 | /** |
||
227 | * @return ResponseInterface |
||
228 | */ |
||
229 | public function getResponse() |
||
237 | |||
238 | /** |
||
239 | * @param string $url |
||
240 | * |
||
241 | * @return string |
||
242 | */ |
||
243 | private function prepareUrl($url) |
||
247 | |||
248 | private function sendRequest() |
||
260 | } |
||
261 |