1 | <?php |
||
27 | class RestContext extends RawMinkContext |
||
28 | { |
||
29 | use SubContext\EzRest; |
||
30 | use SubContext\Authentication; |
||
31 | use SubContext\ContentTypeGroup; |
||
32 | use SubContext\Exception; |
||
33 | use SubContext\Views; |
||
34 | use SubContext\User; |
||
35 | use KernelDictionary; |
||
36 | |||
37 | const AUTHTYPE_BASICHTTP = 'http_basic'; |
||
38 | const AUTHTYPE_SESSION = 'session'; |
||
39 | |||
40 | const DEFAULT_URL = 'http://localhost/'; |
||
41 | const DEFAULT_DRIVER = 'GuzzleDriver'; |
||
42 | const DEFAULT_BODY_TYPE = 'json'; |
||
43 | |||
44 | const DEFAULT_AUTH_TYPE = self::AUTHTYPE_SESSION; |
||
45 | |||
46 | /** |
||
47 | * Rest driver for all requests and responses. |
||
48 | * |
||
49 | * @var \eZ\Bundle\EzPublishRestBundle\Features\Context\RestClient\DriverInterface |
||
50 | */ |
||
51 | protected $restDriver; |
||
52 | |||
53 | /** |
||
54 | * @var string |
||
55 | */ |
||
56 | private $url; |
||
57 | |||
58 | /** |
||
59 | * @var string |
||
60 | */ |
||
61 | private $driver; |
||
62 | |||
63 | /** |
||
64 | * @var \Behat\Mink\Mink |
||
65 | */ |
||
66 | private $mink; |
||
67 | |||
68 | /** |
||
69 | * @var array |
||
70 | */ |
||
71 | private $minkParameters; |
||
72 | |||
73 | /** |
||
74 | * @var \EzSystems\Behat\API\Facade\UserFacade |
||
75 | */ |
||
76 | private $userFacade; |
||
77 | |||
78 | /** |
||
79 | * @var \eZ\Publish\API\Repository\Repository |
||
80 | */ |
||
81 | private $repository; |
||
82 | |||
83 | /** |
||
84 | * Initialize class. |
||
85 | * |
||
86 | * @param string $url Base URL for REST calls |
||
|
|||
87 | * @param string $driver REST Driver to be used |
||
88 | * @param string $json |
||
89 | */ |
||
90 | public function __construct( |
||
103 | |||
104 | private function setUrl($url) |
||
111 | |||
112 | /** |
||
113 | * Sets Mink instance. |
||
114 | * |
||
115 | * @param Mink $mink Mink session manager |
||
116 | */ |
||
117 | public function setMink(Mink $mink) |
||
121 | |||
122 | /** |
||
123 | * Sets parameters provided for Mink. |
||
124 | * While at it, take the base_url, and use it to build the one for the REST driver. |
||
125 | * |
||
126 | * @param array $parameters |
||
127 | */ |
||
128 | public function setMinkParameters(array $parameters) |
||
133 | |||
134 | /** |
||
135 | * @BeforeScenario |
||
136 | */ |
||
137 | private function resetDriver() |
||
141 | |||
142 | /** |
||
143 | * Create and set the REST driver to be used. |
||
144 | * |
||
145 | * @param string $restDriver REST driver class name |
||
146 | */ |
||
147 | private function setRestDriver($restDriver) |
||
167 | |||
168 | /** |
||
169 | * @When I create a :type request to :resource (url) |
||
170 | */ |
||
171 | public function createRequest($type, $resource) |
||
177 | |||
178 | /** |
||
179 | * @When I send a :type request to :resource (url) |
||
180 | */ |
||
181 | public function createAndSendRequest($type, $resource) |
||
186 | |||
187 | /** |
||
188 | * @When I set :header header with :value (value) |
||
189 | */ |
||
190 | public function setHeader($header, $value) |
||
194 | |||
195 | /** |
||
196 | * @When I send the request |
||
197 | */ |
||
198 | public function sendRequest() |
||
209 | |||
210 | /** |
||
211 | * @Then response status code is :code |
||
212 | */ |
||
213 | public function assertStatusCode($code) |
||
257 | |||
258 | /** |
||
259 | * @Then response status message is :message |
||
260 | */ |
||
261 | public function assertStatusMessage($message) |
||
269 | |||
270 | /** |
||
271 | * @Then response header :header exist |
||
272 | */ |
||
273 | public function existResponseHeader($header) |
||
280 | |||
281 | /** |
||
282 | * @Then response header :header don't exist |
||
283 | */ |
||
284 | public function dontExistResponseHeader($header) |
||
291 | |||
292 | /** |
||
293 | * @Then response header :header have :value (value) |
||
294 | */ |
||
295 | public function assertHeaderHaveValue($header, $value) |
||
303 | |||
304 | /** |
||
305 | * @Then response header :header don't have :value (value) |
||
306 | */ |
||
307 | public function assertHeaderDontHaveValue($header, $value) |
||
315 | |||
316 | /** |
||
317 | * @Then response body has :value (value) |
||
318 | */ |
||
319 | public function responseBodyHasValue($value) |
||
331 | |||
332 | private function getRepository() |
||
340 | } |
||
341 |
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.