1 | <?php |
||
23 | class Http implements Context |
||
24 | { |
||
25 | use ApiTrait; |
||
26 | use TwigTrait; |
||
27 | |||
28 | /** @var RequestInterface */ |
||
29 | private $request; |
||
30 | |||
31 | /** @var mixed[] Query args to add */ |
||
32 | private $query; |
||
33 | |||
34 | public function __construct(HttpClient $client, StreamFactory $streamFactory, MessageFactory $messageFactory, HttpHistory $history, Twig_Environment $twig = null) |
||
43 | |||
44 | /** @When /^I create a "(?P<method>GET|POST|PATCH|PUT|DELETE|OPTIONS|HEAD)" request to "(?P<url>.+?)"$/ */ |
||
45 | public function createARequest(string $method, string $url) |
||
55 | |||
56 | /** @When I add/set the value :value to the parameter :parameter */ |
||
57 | public function addAParameter(string $parameter, string $value) |
||
73 | |||
74 | /** @When I set the following query arguments: */ |
||
75 | public function setTheParameters(TableNode $parameters) |
||
87 | |||
88 | /** @When I set the content-type to :type */ |
||
89 | public function setContentType(string $type) |
||
94 | |||
95 | /** @When I set the following body: */ |
||
96 | public function setTheBody(string $body) |
||
104 | |||
105 | /** @When I add/set the value :value to the header :header */ |
||
106 | public function addHeader(string $header, string $value) |
||
111 | |||
112 | /** @When I set the headers: */ |
||
113 | public function setHeaders(TableNode $headers) |
||
123 | |||
124 | /** @When I send the request */ |
||
125 | public function sendRequest() |
||
144 | |||
145 | /** @Then the status code should be :expected */ |
||
146 | public function statusCodeShouldBe(int $expected) |
||
151 | |||
152 | /** @Then the status code should not be :expected */ |
||
153 | public function statusCodeShouldNotBe(int $expected) |
||
158 | |||
159 | /** @Then the content-type should be equal to :expected */ |
||
160 | public function contentTypeShouldBe(string $expected) |
||
165 | |||
166 | /** @Then the response header :header should be equal to :expected */ |
||
167 | public function headerShouldBe(string $header, string $expected) |
||
172 | |||
173 | /** @Then the response header :header should contain :expected */ |
||
174 | public function headerShouldContain(string $header, string $expected) |
||
179 | |||
180 | /** @Then the response should have a header :header */ |
||
181 | public function responseShouldHaveHeader(string $header) |
||
186 | |||
187 | /** @Then the response should have sent some data */ |
||
188 | public function responseShouldHaveSentSomeData() |
||
195 | |||
196 | /** @Then the response should not have sent any data */ |
||
197 | public function responseShouldNotHaveAnyData() |
||
202 | |||
203 | /** @Then the response should contain :data */ |
||
204 | public function responseShouldContain(string $data) |
||
209 | |||
210 | /** @Then the response should not contain :data */ |
||
211 | public function responseShouldNotContain(string $data) |
||
216 | |||
217 | /** @Then the response should be :data */ |
||
218 | public function responseShouldBe(string $data) |
||
223 | |||
224 | /** @Then the response should not be :data */ |
||
225 | public function responseShouldNotBe(string $data) |
||
230 | |||
231 | /** |
||
232 | * @AfterScenario @api |
||
233 | * @AfterScenario @rest |
||
234 | */ |
||
235 | public function clearCache() |
||
241 | |||
242 | /** |
||
243 | * @return RequestInterface |
||
244 | * @throws RuntimeException |
||
245 | */ |
||
246 | public function getRequest(): RequestInterface |
||
254 | |||
255 | /** |
||
256 | * Get the default content type, used when makeRequest is called |
||
257 | * |
||
258 | * @return string |
||
259 | */ |
||
260 | protected function getDefaultContentType(): string |
||
264 | } |
||
265 |