1 | <?php declare(strict_types=1); |
||
26 | class Context implements BehatContext |
||
27 | { |
||
28 | use Client; |
||
29 | |||
30 | /** @var RequestInterface */ |
||
31 | private $request; |
||
32 | |||
33 | /** @var mixed[] Query args to add */ |
||
34 | private $query; |
||
35 | |||
36 | /** @var EventDispatcherInterface */ |
||
37 | private $dispatcher; |
||
38 | |||
39 | public function __construct(HttpClient $client, StreamFactory $streamFactory, MessageFactory $messageFactory, HttpHistory $history, EventDispatcherInterface $dispatcher) |
||
47 | |||
48 | /** @When /^I create a "(?P<method>GET|POST|PATCH|PUT|DELETE|OPTIONS|HEAD)" request to "(?P<url>.+?)"$/ */ |
||
49 | public function createARequest(string $method, string $url) |
||
59 | |||
60 | /** |
||
61 | * @When /^I send a "(?P<method>GET|POST|PATCH|PUT|DELETE|OPTIONS|HEAD)" request to "(?P<url>.+?)"$/ |
||
62 | * |
||
63 | * ------- |
||
64 | * |
||
65 | * Shortcut for `When I create a X request to Then send the request` |
||
66 | */ |
||
67 | public function sendARequest($method, $url) |
||
72 | |||
73 | /** @When I add/set the value :value to the parameter :parameter */ |
||
74 | public function addAParameter(string $parameter, string $value) |
||
90 | |||
91 | /** @When I set the following query arguments: */ |
||
92 | public function setTheParameters(TableNode $parameters) |
||
100 | |||
101 | /** @When I set the content-type to :type */ |
||
102 | public function setContentType(string $type) |
||
107 | |||
108 | /** @When I set the following body: */ |
||
109 | public function setTheBody(string $body) |
||
116 | |||
117 | /** @When I add/set the value :value to the header :header */ |
||
118 | public function addHeader(string $header, string $value) |
||
123 | |||
124 | /** @When I set the headers: */ |
||
125 | public function setHeaders(TableNode $headers) |
||
135 | |||
136 | /** @When I send the request */ |
||
137 | public function sendRequest() |
||
157 | |||
158 | /** @Then the status code should be :expected */ |
||
159 | public function statusCodeShouldBe(int $expected) |
||
164 | |||
165 | /** @Then the status code should not be :expected */ |
||
166 | public function statusCodeShouldNotBe(int $expected) |
||
171 | |||
172 | /** @Then the content-type should be equal to :expected */ |
||
173 | public function contentTypeShouldBe(string $expected) |
||
178 | |||
179 | /** @Then the response header :header should be equal to :expected */ |
||
180 | public function headerShouldBe(string $header, string $expected) |
||
185 | |||
186 | /** @Then the response header :header should contain :expected */ |
||
187 | public function headerShouldContain(string $header, string $expected) |
||
192 | |||
193 | /** @Then the response should have a header :header */ |
||
194 | public function responseShouldHaveHeader(string $header) |
||
199 | |||
200 | /** @Then the response should have sent some data */ |
||
201 | public function responseShouldHaveSentSomeData() |
||
208 | |||
209 | /** @Then the response should not have sent any data */ |
||
210 | public function responseShouldNotHaveAnyData() |
||
215 | |||
216 | /** @Then the response should contain :data */ |
||
217 | public function responseShouldContain(string $data) |
||
222 | |||
223 | /** @Then the response should not contain :data */ |
||
224 | public function responseShouldNotContain(string $data) |
||
229 | |||
230 | /** @Then the response should be :data */ |
||
231 | public function responseShouldBe(string $data) |
||
236 | |||
237 | /** @Then the response should not be :data */ |
||
238 | public function responseShouldNotBe(string $data) |
||
243 | |||
244 | /** |
||
245 | * @AfterScenario @api |
||
246 | * @AfterScenario @rest |
||
247 | */ |
||
248 | public function clearCache() |
||
254 | |||
255 | /** |
||
256 | * @return RequestInterface |
||
257 | * @throws RuntimeException |
||
258 | */ |
||
259 | public function getRequest(): RequestInterface |
||
267 | |||
268 | /** |
||
269 | * Get the default content type, used when makeRequest is called |
||
270 | * |
||
271 | * @return string |
||
272 | */ |
||
273 | protected function getDefaultContentType(): string |
||
277 | } |
||
278 |