1 | <?php |
||
9 | class RestContext extends BaseContext |
||
10 | { |
||
11 | protected $request; |
||
12 | |||
13 | public function __construct(Request $request) |
||
17 | |||
18 | /** |
||
19 | * Sends a HTTP request |
||
20 | * |
||
21 | * @Given I send a :method request to :url |
||
22 | */ |
||
23 | public function iSendARequestTo($method, $url, PyStringNode $body = null, $files = []) |
||
33 | |||
34 | /** |
||
35 | * Sends a HTTP request with a some parameters |
||
36 | * |
||
37 | * @Given I send a :method request to :url with parameters: |
||
38 | */ |
||
39 | public function iSendARequestToWithParameters($method, $url, TableNode $datas) |
||
66 | |||
67 | /** |
||
68 | * Sends a HTTP request with a body |
||
69 | * |
||
70 | * @Given I send a :method request to :url with body: |
||
71 | */ |
||
72 | public function iSendARequestToWithBody($method, $url, PyStringNode $body) |
||
76 | |||
77 | /** |
||
78 | * Checks, whether the response content is equal to given text |
||
79 | * |
||
80 | * @Then the response should be equal to |
||
81 | */ |
||
82 | public function theResponseShouldBeEqualTo(PyStringNode $expected) |
||
89 | |||
90 | /** |
||
91 | * Checks, whether the response content is null or empty string |
||
92 | * |
||
93 | * @Then the response should be empty |
||
94 | */ |
||
95 | public function theResponseShouldBeEmpty() |
||
101 | |||
102 | /** |
||
103 | * Checks, whether the header name is equal to given text |
||
104 | * |
||
105 | * @Then the header :name should be equal to :value |
||
106 | */ |
||
107 | public function theHeaderShouldBeEqualTo($name, $value) |
||
114 | |||
115 | /** |
||
116 | * Checks, whether the header name is not equal to given text |
||
117 | * |
||
118 | * @Then the header :name should not be equal to :value |
||
119 | */ |
||
120 | public function theHeaderShouldNotBeEqualTo($name, $value) { |
||
129 | |||
130 | /** |
||
131 | * Checks, whether the header name contains the given text |
||
132 | * |
||
133 | * @Then the header :name should contain :value |
||
134 | */ |
||
135 | public function theHeaderShouldBeContains($name, $value) |
||
141 | |||
142 | /** |
||
143 | * Checks, whether the header name doesn't contain the given text |
||
144 | * |
||
145 | * @Then the header :name should not contain :value |
||
146 | */ |
||
147 | public function theHeaderShouldNotContain($name, $value) |
||
153 | |||
154 | /** |
||
155 | * Checks, whether the header not exist |
||
156 | * |
||
157 | * @Then the header :name should not exist |
||
158 | */ |
||
159 | public function theHeaderShouldNotExist($name) |
||
165 | |||
166 | protected function theHeaderShouldExist($name) |
||
170 | |||
171 | /** |
||
172 | * Checks, that the response header expire is in the future |
||
173 | * |
||
174 | * @Then the response should expire in the future |
||
175 | */ |
||
176 | public function theResponseShouldExpireInTheFuture() |
||
185 | |||
186 | /** |
||
187 | * Add an header element in a request |
||
188 | * |
||
189 | * @Then I add :name header equal to :value |
||
190 | */ |
||
191 | public function iAddHeaderEqualTo($name, $value) |
||
195 | |||
196 | /** |
||
197 | * @Then the response should be encoded in :encoding |
||
198 | */ |
||
199 | public function theResponseShouldBeEncodedIn($encoding) |
||
208 | |||
209 | /** |
||
210 | * @Then print last response headers |
||
211 | */ |
||
212 | public function printLastResponseHeaders() |
||
222 | |||
223 | |||
224 | /** |
||
225 | * @Then print the corresponding curl command |
||
226 | */ |
||
227 | public function printTheCorrespondingCurlCommand() |
||
248 | } |
||
249 |
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: