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 | * |
||
120 | * @Given I remove the header ":header" |
||
121 | */ |
||
122 | public function removeHeader($header) |
||
126 | |||
127 | /** |
||
128 | * @param string $method |
||
129 | * @param string $url |
||
130 | * |
||
131 | * @When I send a ":method" request to ":url" |
||
132 | */ |
||
133 | public function send($method, $url) |
||
139 | |||
140 | /** |
||
141 | * @param string $method |
||
142 | * @param string $url |
||
143 | * @param PyStringNode $string |
||
144 | * |
||
145 | * @When I send a ":method" request to ":url" with body: |
||
146 | */ |
||
147 | public function sendWith($method, $url, PyStringNode $string) |
||
158 | |||
159 | /** |
||
160 | * @param string $statusCode |
||
161 | * |
||
162 | * @Then the response status code should be ":statusCode" |
||
163 | */ |
||
164 | public function assertResponseStatusCode($statusCode) |
||
168 | |||
169 | /** |
||
170 | * @param PyStringNode $json |
||
171 | * |
||
172 | * @Then the response should contain: |
||
173 | */ |
||
174 | public function assertResponseContains(PyStringNode $json) |
||
180 | |||
181 | /** |
||
182 | * @Then the response should be empty |
||
183 | */ |
||
184 | public function assertResponseEmpty() |
||
188 | |||
189 | /** |
||
190 | * @Then I print the response |
||
191 | */ |
||
192 | public function printResponse() |
||
202 | |||
203 | /** |
||
204 | * @return RequestInterface |
||
205 | */ |
||
206 | public function getRequest() |
||
214 | |||
215 | /** |
||
216 | * @return ResponseInterface |
||
217 | */ |
||
218 | public function getResponse() |
||
226 | |||
227 | /** |
||
228 | * @param string $url |
||
229 | * |
||
230 | * @return string |
||
231 | */ |
||
232 | private function prepareUrl($url) |
||
236 | |||
237 | private function sendRequest() |
||
249 | } |
||
250 |