1 | <?php |
||
10 | class RestContext extends BaseContext |
||
11 | { |
||
12 | /** |
||
13 | * @var Request |
||
14 | */ |
||
15 | protected $request; |
||
16 | |||
17 | public function __construct(Request $request) |
||
21 | |||
22 | /** |
||
23 | * Sends a HTTP request |
||
24 | * |
||
25 | * @Given I send a :method request to :url |
||
26 | */ |
||
27 | public function iSendARequestTo($method, $url, PyStringNode $body = null, $files = []) |
||
37 | |||
38 | /** |
||
39 | * Sends a HTTP request with a some parameters |
||
40 | * |
||
41 | * @Given I send a :method request to :url with parameters: |
||
42 | */ |
||
43 | public function iSendARequestToWithParameters($method, $url, TableNode $data) |
||
70 | |||
71 | /** |
||
72 | * Sends a HTTP request with a body |
||
73 | * |
||
74 | * @Given I send a :method request to :url with body: |
||
75 | */ |
||
76 | public function iSendARequestToWithBody($method, $url, PyStringNode $body) |
||
80 | |||
81 | /** |
||
82 | * Checks, whether the response content is equal to given text |
||
83 | * |
||
84 | * @Then the response should be equal to |
||
85 | */ |
||
86 | public function theResponseShouldBeEqualTo(PyStringNode $expected) |
||
93 | |||
94 | /** |
||
95 | * Checks, whether the response content is null or empty string |
||
96 | * |
||
97 | * @Then the response should be empty |
||
98 | */ |
||
99 | public function theResponseShouldBeEmpty() |
||
105 | |||
106 | /** |
||
107 | * Checks, whether the header name is equal to given text |
||
108 | * |
||
109 | * @Then the header :name should be equal to :value |
||
110 | */ |
||
111 | public function theHeaderShouldBeEqualTo($name, $value) |
||
118 | |||
119 | /** |
||
120 | * Checks, whether the header name is not equal to given text |
||
121 | * |
||
122 | * @Then the header :name should not be equal to :value |
||
123 | */ |
||
124 | public function theHeaderShouldNotBeEqualTo($name, $value) { |
||
133 | |||
134 | public function theHeaderShouldBeContains($name, $value) |
||
142 | |||
143 | /** |
||
144 | * Checks, whether the header name contains the given text |
||
145 | * |
||
146 | * @Then the header :name should contain :value |
||
147 | */ |
||
148 | public function theHeaderShouldContain($name, $value) |
||
155 | |||
156 | /** |
||
157 | * Checks, whether the header name doesn't contain the given text |
||
158 | * |
||
159 | * @Then the header :name should not contain :value |
||
160 | */ |
||
161 | public function theHeaderShouldNotContain($name, $value) |
||
167 | |||
168 | /** |
||
169 | * Checks, whether the header not exist |
||
170 | * |
||
171 | * @Then the header :name should not exist |
||
172 | */ |
||
173 | public function theHeaderShouldNotExist($name) |
||
179 | |||
180 | protected function theHeaderShouldExist($name) |
||
184 | |||
185 | /** |
||
186 | * Checks, that the response header expire is in the future |
||
187 | * |
||
188 | * @Then the response should expire in the future |
||
189 | */ |
||
190 | public function theResponseShouldExpireInTheFuture() |
||
199 | |||
200 | /** |
||
201 | * Add an header element in a request |
||
202 | * |
||
203 | * @Then I add :name header equal to :value |
||
204 | */ |
||
205 | public function iAddHeaderEqualTo($name, $value) |
||
209 | |||
210 | /** |
||
211 | * @Then the response should be encoded in :encoding |
||
212 | */ |
||
213 | public function theResponseShouldBeEncodedIn($encoding) |
||
222 | |||
223 | /** |
||
224 | * @Then print last response headers |
||
225 | */ |
||
226 | public function printLastResponseHeaders() |
||
236 | |||
237 | |||
238 | /** |
||
239 | * @Then print the corresponding curl command |
||
240 | */ |
||
241 | public function printTheCorrespondingCurlCommand() |
||
262 | } |
||
263 |
If you implement
__call
and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__call
is implemented by a parent class and only the child class knows which methods exist: