1 | <?php |
||
29 | class RestContext extends Context implements MinkAwareContext |
||
30 | { |
||
31 | use SubContext\EzRest; |
||
32 | use SubContext\Authentication; |
||
33 | use SubContext\ContentTypeGroup; |
||
34 | use SubContext\Exception; |
||
35 | use SubContext\Views; |
||
36 | use SubContext\User; |
||
37 | |||
38 | const AUTHTYPE_BASICHTTP = 'http_basic'; |
||
39 | const AUTHTYPE_SESSION = 'session'; |
||
40 | |||
41 | const DEFAULT_URL = 'http://localhost/'; |
||
42 | const DEFAULT_DRIVER = 'GuzzleDriver'; |
||
43 | const DEFAULT_BODY_TYPE = 'json'; |
||
44 | |||
45 | const DEFAULT_AUTH_TYPE = self::AUTHTYPE_SESSION; |
||
46 | |||
47 | /** |
||
48 | * Rest driver for all requests and responses. |
||
49 | * |
||
50 | * @var \eZ\Bundle\EzPublishRestBundle\Features\Context\RestClient\DriverInterface |
||
51 | */ |
||
52 | protected $restDriver; |
||
53 | |||
54 | /** |
||
55 | * @var string |
||
56 | */ |
||
57 | private $url; |
||
58 | |||
59 | /** |
||
60 | * @var string |
||
61 | */ |
||
62 | private $driver; |
||
63 | |||
64 | /** |
||
65 | * @var \Behat\Mink\Mink |
||
66 | */ |
||
67 | private $mink; |
||
68 | |||
69 | /** |
||
70 | * @var array |
||
71 | */ |
||
72 | private $minkParameters; |
||
73 | |||
74 | /** |
||
75 | * Initialize class. |
||
76 | * |
||
77 | * @param string $url Base URL for REST calls |
||
|
|||
78 | * @param string $driver REST Driver to be used |
||
79 | * @param string $json |
||
80 | */ |
||
81 | public function __construct( |
||
92 | |||
93 | private function setUrl($url) |
||
100 | |||
101 | /** |
||
102 | * Sets Mink instance. |
||
103 | * |
||
104 | * @param Mink $mink Mink session manager |
||
105 | */ |
||
106 | public function setMink(Mink $mink) |
||
110 | |||
111 | /** |
||
112 | * Sets parameters provided for Mink. |
||
113 | * While at it, take the base_url, and use it to build the one for the REST driver. |
||
114 | * |
||
115 | * @param array $parameters |
||
116 | */ |
||
117 | public function setMinkParameters(array $parameters) |
||
122 | |||
123 | /** |
||
124 | * @BeforeScenario |
||
125 | */ |
||
126 | private function resetDriver() |
||
130 | |||
131 | /** |
||
132 | * Create and set the REST driver to be used. |
||
133 | * |
||
134 | * @param string $restDriver REST driver class name |
||
135 | */ |
||
136 | private function setRestDriver($restDriver) |
||
156 | |||
157 | /** |
||
158 | * @When I create a :type request to :resource (url) |
||
159 | */ |
||
160 | public function createRequest($type, $resource) |
||
168 | |||
169 | /** |
||
170 | * @When I send a :type request to :resource (url) |
||
171 | */ |
||
172 | public function createAndSendRequest($type, $resource) |
||
177 | |||
178 | /** |
||
179 | * @When I set :header header with :value (value) |
||
180 | */ |
||
181 | public function setHeader($header, $value) |
||
185 | |||
186 | /** |
||
187 | * @When I set headers: |
||
188 | */ |
||
189 | public function setHeaders(TableNode $table) |
||
197 | |||
198 | /** |
||
199 | * @When I send the request |
||
200 | */ |
||
201 | public function sendRequest() |
||
212 | |||
213 | /** |
||
214 | * @Then response status code is :code |
||
215 | */ |
||
216 | public function assertStatusCode($code) |
||
260 | |||
261 | /** |
||
262 | * @Then response status message is :message |
||
263 | */ |
||
264 | public function assertStatusMessage($message) |
||
272 | |||
273 | /** |
||
274 | * @Then response header :header exist |
||
275 | */ |
||
276 | public function existResponseHeader($header) |
||
283 | |||
284 | /** |
||
285 | * @Then response header :header don't exist |
||
286 | */ |
||
287 | public function dontExistResponseHeader($header) |
||
294 | |||
295 | /** |
||
296 | * @Then response header :header have :value (value) |
||
297 | */ |
||
298 | public function assertHeaderHaveValue($header, $value) |
||
306 | |||
307 | /** |
||
308 | * @Then response header :header don't have :value (value) |
||
309 | */ |
||
310 | public function assertHeaderDontHaveValue($header, $value) |
||
318 | |||
319 | /** |
||
320 | * @Then response body has :value (value) |
||
321 | */ |
||
322 | public function responseBodyHasValue($value) |
||
334 | } |
||
335 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.