Mercurial > hg > cmmr2012-drupal-site
comparison core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | c75dbcec494b |
children |
comparison
equal
deleted
inserted
replaced
4:a9cd425dd02b | 5:12f9dff5fda9 |
---|---|
1 <?php | 1 <?php |
2 | 2 // @codingStandardsIgnoreFile |
3 namespace Drupal\FunctionalTests; | 3 namespace Drupal\FunctionalTests; |
4 | 4 |
5 use Behat\Mink\Element\NodeElement; | 5 use Behat\Mink\Element\NodeElement; |
6 use Behat\Mink\Exception\ExpectationException; | 6 use Behat\Mink\Exception\ExpectationException; |
7 use Behat\Mink\Selector\Xpath\Escaper; | 7 use Behat\Mink\Selector\Xpath\Escaper; |
10 use Drupal\KernelTests\AssertLegacyTrait as BaseAssertLegacyTrait; | 10 use Drupal\KernelTests\AssertLegacyTrait as BaseAssertLegacyTrait; |
11 | 11 |
12 /** | 12 /** |
13 * Provides convenience methods for assertions in browser tests. | 13 * Provides convenience methods for assertions in browser tests. |
14 * | 14 * |
15 * @deprecated Scheduled for removal in Drupal 9.0.0. Use the methods on | 15 * Deprecated Scheduled for removal in Drupal 10.0.0. Use the methods on |
16 * \Drupal\Tests\WebAssert instead, for example | 16 * \Drupal\Tests\WebAssert instead, for example |
17 * @code | 17 * @code |
18 * $this->assertSession()->statusCodeEquals(200); | 18 * $this->assertSession()->statusCodeEquals(200); |
19 * @endcode | 19 * @endcode |
20 * | |
21 * @todo https://www.drupal.org/project/drupal/issues/3031580 Note that | |
22 * deprecations in this file do not use the @ symbol in Drupal 8 because this | |
23 * will be removed in Drupal 10.0.0. Adding the @ back should re-enable coding | |
24 * stanadrds checks. | |
20 */ | 25 */ |
21 trait AssertLegacyTrait { | 26 trait AssertLegacyTrait { |
22 | 27 |
23 use BaseAssertLegacyTrait; | 28 use BaseAssertLegacyTrait; |
24 | 29 |
26 * Asserts that the element with the given CSS selector is present. | 31 * Asserts that the element with the given CSS selector is present. |
27 * | 32 * |
28 * @param string $css_selector | 33 * @param string $css_selector |
29 * The CSS selector identifying the element to check. | 34 * The CSS selector identifying the element to check. |
30 * | 35 * |
31 * @deprecated Scheduled for removal in Drupal 9.0.0. | 36 * Deprecated Scheduled for removal in Drupal 10.0.0. |
32 * Use $this->assertSession()->elementExists() instead. | 37 * Use $this->assertSession()->elementExists() instead. |
33 */ | 38 */ |
34 protected function assertElementPresent($css_selector) { | 39 protected function assertElementPresent($css_selector) { |
35 $this->assertSession()->elementExists('css', $css_selector); | 40 $this->assertSession()->elementExists('css', $css_selector); |
36 } | 41 } |
39 * Asserts that the element with the given CSS selector is not present. | 44 * Asserts that the element with the given CSS selector is not present. |
40 * | 45 * |
41 * @param string $css_selector | 46 * @param string $css_selector |
42 * The CSS selector identifying the element to check. | 47 * The CSS selector identifying the element to check. |
43 * | 48 * |
44 * @deprecated Scheduled for removal in Drupal 9.0.0. | 49 * Deprecated Scheduled for removal in Drupal 10.0.0. |
45 * Use $this->assertSession()->elementNotExists() instead. | 50 * Use $this->assertSession()->elementNotExists() instead. |
46 */ | 51 */ |
47 protected function assertElementNotPresent($css_selector) { | 52 protected function assertElementNotPresent($css_selector) { |
48 $this->assertSession()->elementNotExists('css', $css_selector); | 53 $this->assertSession()->elementNotExists('css', $css_selector); |
49 } | 54 } |
55 * the values of text fields. | 60 * the values of text fields. |
56 * | 61 * |
57 * @param string $text | 62 * @param string $text |
58 * Plain text to look for. | 63 * Plain text to look for. |
59 * | 64 * |
60 * @deprecated Scheduled for removal in Drupal 9.0.0. | 65 * Deprecated Scheduled for removal in Drupal 10.0.0. |
61 * Use instead: | 66 * Use instead: |
62 * - $this->assertSession()->responseContains() for non-HTML responses, | 67 * - $this->assertSession()->responseContains() for non-HTML responses, |
63 * like XML or Json. | 68 * like XML or Json. |
64 * - $this->assertSession()->pageTextContains() for HTML responses. Unlike | 69 * - $this->assertSession()->pageTextContains() for HTML responses. Unlike |
65 * the deprecated assertText(), the passed text should be HTML decoded, | 70 * the deprecated assertText(), the passed text should be HTML decoded, |
87 * the values of text fields. | 92 * the values of text fields. |
88 * | 93 * |
89 * @param string $text | 94 * @param string $text |
90 * Plain text to look for. | 95 * Plain text to look for. |
91 * | 96 * |
92 * @deprecated Scheduled for removal in Drupal 9.0.0. | 97 * Deprecated Scheduled for removal in Drupal 10.0.0. |
93 * Use instead: | 98 * Use instead: |
94 * - $this->assertSession()->responseNotContains() for non-HTML responses, | 99 * - $this->assertSession()->responseNotContains() for non-HTML responses, |
95 * like XML or Json. | 100 * like XML or Json. |
96 * - $this->assertSession()->pageTextNotContains() for HTML responses. | 101 * - $this->assertSession()->pageTextNotContains() for HTML responses. |
97 * Unlike the deprecated assertNoText(), the passed text should be HTML | 102 * Unlike the deprecated assertNoText(), the passed text should be HTML |
153 * Plain text to look for. | 158 * Plain text to look for. |
154 * @param string $message | 159 * @param string $message |
155 * (optional) A message to display with the assertion. Do not translate | 160 * (optional) A message to display with the assertion. Do not translate |
156 * messages with t(). If left blank, a default message will be displayed. | 161 * messages with t(). If left blank, a default message will be displayed. |
157 * | 162 * |
158 * @deprecated Scheduled for removal in Drupal 9.0.0. | 163 * Deprecated Scheduled for removal in Drupal 10.0.0. |
159 * Use $this->getSession()->getPage()->getText() and substr_count() instead. | 164 * Use $this->getSession()->getPage()->getText() and substr_count() instead. |
160 */ | 165 */ |
161 protected function assertUniqueText($text, $message = NULL) { | 166 protected function assertUniqueText($text, $message = NULL) { |
162 // Cast MarkupInterface objects to string. | 167 // Cast MarkupInterface objects to string. |
163 $text = (string) $text; | 168 $text = (string) $text; |
179 * Plain text to look for. | 184 * Plain text to look for. |
180 * @param string $message | 185 * @param string $message |
181 * (optional) A message to display with the assertion. Do not translate | 186 * (optional) A message to display with the assertion. Do not translate |
182 * messages with t(). If left blank, a default message will be displayed. | 187 * messages with t(). If left blank, a default message will be displayed. |
183 * | 188 * |
184 * @deprecated Scheduled for removal in Drupal 9.0.0. | 189 * Deprecated Scheduled for removal in Drupal 10.0.0. |
185 * Use $this->getSession()->getPage()->getText() and substr_count() instead. | 190 * Use $this->getSession()->getPage()->getText() and substr_count() instead. |
186 */ | 191 */ |
187 protected function assertNoUniqueText($text, $message = '') { | 192 protected function assertNoUniqueText($text, $message = '') { |
188 // Cast MarkupInterface objects to string. | 193 // Cast MarkupInterface objects to string. |
189 $text = (string) $text; | 194 $text = (string) $text; |
199 * | 204 * |
200 * @param int $code | 205 * @param int $code |
201 * Response code. For example 200 is a successful page request. For a list | 206 * Response code. For example 200 is a successful page request. For a list |
202 * of all codes see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html. | 207 * of all codes see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html. |
203 * | 208 * |
204 * @deprecated Scheduled for removal in Drupal 9.0.0. | 209 * Deprecated Scheduled for removal in Drupal 10.0.0. |
205 * Use $this->assertSession()->statusCodeEquals() instead. | 210 * Use $this->assertSession()->statusCodeEquals() instead. |
206 */ | 211 */ |
207 protected function assertResponse($code) { | 212 protected function assertResponse($code) { |
208 $this->assertSession()->statusCodeEquals($code); | 213 $this->assertSession()->statusCodeEquals($code); |
209 } | 214 } |
216 * @param string $value | 221 * @param string $value |
217 * (optional) Value of the field to assert. You may pass in NULL (default) | 222 * (optional) Value of the field to assert. You may pass in NULL (default) |
218 * to skip checking the actual value, while still checking that the field | 223 * to skip checking the actual value, while still checking that the field |
219 * exists. | 224 * exists. |
220 * | 225 * |
221 * @deprecated Scheduled for removal in Drupal 9.0.0. | 226 * Deprecated Scheduled for removal in Drupal 10.0.0. |
222 * Use $this->assertSession()->fieldExists() or | 227 * Use $this->assertSession()->fieldExists() or |
223 * $this->assertSession()->buttonExists() or | 228 * $this->assertSession()->buttonExists() or |
224 * $this->assertSession()->fieldValueEquals() instead. | 229 * $this->assertSession()->fieldValueEquals() instead. |
225 */ | 230 */ |
226 protected function assertFieldByName($name, $value = NULL) { | 231 protected function assertFieldByName($name, $value = NULL) { |
236 * (optional) Value for the field, to assert that the field's value on the | 241 * (optional) Value for the field, to assert that the field's value on the |
237 * page does not match it. You may pass in NULL to skip checking the | 242 * page does not match it. You may pass in NULL to skip checking the |
238 * value, while still checking that the field does not exist. However, the | 243 * value, while still checking that the field does not exist. However, the |
239 * default value ('') asserts that the field value is not an empty string. | 244 * default value ('') asserts that the field value is not an empty string. |
240 * | 245 * |
241 * @deprecated Scheduled for removal in Drupal 9.0.0. | 246 * Deprecated Scheduled for removal in Drupal 10.0.0. |
242 * Use $this->assertSession()->fieldNotExists() or | 247 * Use $this->assertSession()->fieldNotExists() or |
243 * $this->assertSession()->buttonNotExists() or | 248 * $this->assertSession()->buttonNotExists() or |
244 * $this->assertSession()->fieldValueNotEquals() instead. | 249 * $this->assertSession()->fieldValueNotEquals() instead. |
245 */ | 250 */ |
246 protected function assertNoFieldByName($name, $value = '') { | 251 protected function assertNoFieldByName($name, $value = '') { |
258 * However, the default value ('') asserts that the field value is an empty | 263 * However, the default value ('') asserts that the field value is an empty |
259 * string. | 264 * string. |
260 * | 265 * |
261 * @throws \Behat\Mink\Exception\ElementNotFoundException | 266 * @throws \Behat\Mink\Exception\ElementNotFoundException |
262 * | 267 * |
263 * @deprecated Scheduled for removal in Drupal 9.0.0. | 268 * Deprecated Scheduled for removal in Drupal 10.0.0. |
264 * Use $this->assertSession()->fieldExists() or | 269 * Use $this->assertSession()->fieldExists() or |
265 * $this->assertSession()->buttonExists() or | 270 * $this->assertSession()->buttonExists() or |
266 * $this->assertSession()->fieldValueEquals() instead. | 271 * $this->assertSession()->fieldValueEquals() instead. |
267 */ | 272 */ |
268 protected function assertFieldById($id, $value = '') { | 273 protected function assertFieldById($id, $value = '') { |
273 * Asserts that a field exists with the given name or ID. | 278 * Asserts that a field exists with the given name or ID. |
274 * | 279 * |
275 * @param string $field | 280 * @param string $field |
276 * Name or ID of field to assert. | 281 * Name or ID of field to assert. |
277 * | 282 * |
278 * @deprecated Scheduled for removal in Drupal 9.0.0. | 283 * Deprecated Scheduled for removal in Drupal 10.0.0. |
279 * Use $this->assertSession()->fieldExists() or | 284 * Use $this->assertSession()->fieldExists() or |
280 * $this->assertSession()->buttonExists() instead. | 285 * $this->assertSession()->buttonExists() instead. |
281 */ | 286 */ |
282 protected function assertField($field) { | 287 protected function assertField($field) { |
283 $this->assertFieldByXPath($this->constructFieldXpath('name', $field) . '|' . $this->constructFieldXpath('id', $field)); | 288 $this->assertFieldByXPath($this->constructFieldXpath('name', $field) . '|' . $this->constructFieldXpath('id', $field)); |
287 * Asserts that a field does NOT exist with the given name or ID. | 292 * Asserts that a field does NOT exist with the given name or ID. |
288 * | 293 * |
289 * @param string $field | 294 * @param string $field |
290 * Name or ID of field to assert. | 295 * Name or ID of field to assert. |
291 * | 296 * |
292 * @deprecated Scheduled for removal in Drupal 9.0.0. | 297 * Deprecated Scheduled for removal in Drupal 10.0.0. |
293 * Use $this->assertSession()->fieldNotExists() or | 298 * Use $this->assertSession()->fieldNotExists() or |
294 * $this->assertSession()->buttonNotExists() instead. | 299 * $this->assertSession()->buttonNotExists() instead. |
295 */ | 300 */ |
296 protected function assertNoField($field) { | 301 protected function assertNoField($field) { |
297 $this->assertNoFieldByXPath($this->constructFieldXpath('name', $field) . '|' . $this->constructFieldXpath('id', $field)); | 302 $this->assertNoFieldByXPath($this->constructFieldXpath('name', $field) . '|' . $this->constructFieldXpath('id', $field)); |
303 * Raw text refers to the raw HTML that the page generated. | 308 * Raw text refers to the raw HTML that the page generated. |
304 * | 309 * |
305 * @param string $raw | 310 * @param string $raw |
306 * Raw (HTML) string to look for. | 311 * Raw (HTML) string to look for. |
307 * | 312 * |
308 * @deprecated Scheduled for removal in Drupal 9.0.0. | 313 * Deprecated Scheduled for removal in Drupal 10.0.0. |
309 * Use $this->assertSession()->responseContains() instead. | 314 * Use $this->assertSession()->responseContains() instead. |
310 */ | 315 */ |
311 protected function assertRaw($raw) { | 316 protected function assertRaw($raw) { |
312 $this->assertSession()->responseContains($raw); | 317 $this->assertSession()->responseContains($raw); |
313 } | 318 } |
318 * Raw text refers to the raw HTML that the page generated. | 323 * Raw text refers to the raw HTML that the page generated. |
319 * | 324 * |
320 * @param string $raw | 325 * @param string $raw |
321 * Raw (HTML) string to look for. | 326 * Raw (HTML) string to look for. |
322 * | 327 * |
323 * @deprecated Scheduled for removal in Drupal 9.0.0. | 328 * Deprecated Scheduled for removal in Drupal 10.0.0. |
324 * Use $this->assertSession()->responseNotContains() instead. | 329 * Use $this->assertSession()->responseNotContains() instead. |
325 */ | 330 */ |
326 protected function assertNoRaw($raw) { | 331 protected function assertNoRaw($raw) { |
327 $this->assertSession()->responseNotContains($raw); | 332 $this->assertSession()->responseNotContains($raw); |
328 } | 333 } |
331 * Pass if the page title is the given string. | 336 * Pass if the page title is the given string. |
332 * | 337 * |
333 * @param string $expected_title | 338 * @param string $expected_title |
334 * The string the page title should be. | 339 * The string the page title should be. |
335 * | 340 * |
336 * @deprecated Scheduled for removal in Drupal 9.0.0. | 341 * Deprecated Scheduled for removal in Drupal 10.0.0. |
337 * Use $this->assertSession()->titleEquals() instead. | 342 * Use $this->assertSession()->titleEquals() instead. |
338 */ | 343 */ |
339 protected function assertTitle($expected_title) { | 344 protected function assertTitle($expected_title) { |
340 // Cast MarkupInterface to string. | 345 // Cast MarkupInterface to string. |
341 $expected_title = (string) $expected_title; | 346 $expected_title = (string) $expected_title; |
350 * @param string|\Drupal\Component\Render\MarkupInterface $label | 355 * @param string|\Drupal\Component\Render\MarkupInterface $label |
351 * Text between the anchor tags. | 356 * Text between the anchor tags. |
352 * @param int $index | 357 * @param int $index |
353 * Link position counting from zero. | 358 * Link position counting from zero. |
354 * | 359 * |
355 * @deprecated Scheduled for removal in Drupal 9.0.0. | 360 * Deprecated Scheduled for removal in Drupal 10.0.0. |
356 * Use $this->assertSession()->linkExists() instead. | 361 * Use $this->assertSession()->linkExists() instead. |
357 */ | 362 */ |
358 protected function assertLink($label, $index = 0) { | 363 protected function assertLink($label, $index = 0) { |
359 return $this->assertSession()->linkExists($label, $index); | 364 return $this->assertSession()->linkExists($label, $index); |
360 } | 365 } |
363 * Passes if a link with the specified label is not found. | 368 * Passes if a link with the specified label is not found. |
364 * | 369 * |
365 * @param string|\Drupal\Component\Render\MarkupInterface $label | 370 * @param string|\Drupal\Component\Render\MarkupInterface $label |
366 * Text between the anchor tags. | 371 * Text between the anchor tags. |
367 * | 372 * |
368 * @deprecated Scheduled for removal in Drupal 9.0.0. | 373 * Deprecated Scheduled for removal in Drupal 10.0.0. |
369 * Use $this->assertSession()->linkNotExists() instead. | 374 * Use $this->assertSession()->linkNotExists() instead. |
370 */ | 375 */ |
371 protected function assertNoLink($label) { | 376 protected function assertNoLink($label) { |
372 return $this->assertSession()->linkNotExists($label); | 377 return $this->assertSession()->linkNotExists($label); |
373 } | 378 } |
378 * @param string $href | 383 * @param string $href |
379 * The full or partial value of the 'href' attribute of the anchor tag. | 384 * The full or partial value of the 'href' attribute of the anchor tag. |
380 * @param int $index | 385 * @param int $index |
381 * Link position counting from zero. | 386 * Link position counting from zero. |
382 * | 387 * |
383 * @deprecated Scheduled for removal in Drupal 9.0.0. | 388 * Deprecated Scheduled for removal in Drupal 10.0.0. |
384 * Use $this->assertSession()->linkByHrefExists() instead. | 389 * Use $this->assertSession()->linkByHrefExists() instead. |
385 */ | 390 */ |
386 protected function assertLinkByHref($href, $index = 0) { | 391 protected function assertLinkByHref($href, $index = 0) { |
387 $this->assertSession()->linkByHrefExists($href, $index); | 392 $this->assertSession()->linkByHrefExists($href, $index); |
388 } | 393 } |
391 * Passes if a link containing a given href (part) is not found. | 396 * Passes if a link containing a given href (part) is not found. |
392 * | 397 * |
393 * @param string $href | 398 * @param string $href |
394 * The full or partial value of the 'href' attribute of the anchor tag. | 399 * The full or partial value of the 'href' attribute of the anchor tag. |
395 * | 400 * |
396 * @deprecated Scheduled for removal in Drupal 9.0.0. | 401 * Deprecated Scheduled for removal in Drupal 10.0.0. |
397 * Use $this->assertSession()->linkByHrefNotExists() instead. | 402 * Use $this->assertSession()->linkByHrefNotExists() instead. |
398 */ | 403 */ |
399 protected function assertNoLinkByHref($href) { | 404 protected function assertNoLinkByHref($href) { |
400 $this->assertSession()->linkByHrefNotExists($href); | 405 $this->assertSession()->linkByHrefNotExists($href); |
401 } | 406 } |
411 * while still checking that the field doesn't exist. However, the default | 416 * while still checking that the field doesn't exist. However, the default |
412 * value ('') asserts that the field value is not an empty string. | 417 * value ('') asserts that the field value is not an empty string. |
413 * | 418 * |
414 * @throws \Behat\Mink\Exception\ExpectationException | 419 * @throws \Behat\Mink\Exception\ExpectationException |
415 * | 420 * |
416 * @deprecated Scheduled for removal in Drupal 9.0.0. | 421 * Deprecated Scheduled for removal in Drupal 10.0.0. |
417 * Use $this->assertSession()->fieldNotExists() or | 422 * Use $this->assertSession()->fieldNotExists() or |
418 * $this->assertSession()->buttonNotExists() or | 423 * $this->assertSession()->buttonNotExists() or |
419 * $this->assertSession()->fieldValueNotEquals() instead. | 424 * $this->assertSession()->fieldValueNotEquals() instead. |
420 */ | 425 */ |
421 protected function assertNoFieldById($id, $value = '') { | 426 protected function assertNoFieldById($id, $value = '') { |
426 * Passes if the internal browser's URL matches the given path. | 431 * Passes if the internal browser's URL matches the given path. |
427 * | 432 * |
428 * @param \Drupal\Core\Url|string $path | 433 * @param \Drupal\Core\Url|string $path |
429 * The expected system path or URL. | 434 * The expected system path or URL. |
430 * | 435 * |
431 * @deprecated Scheduled for removal in Drupal 9.0.0. | 436 * Deprecated Scheduled for removal in Drupal 10.0.0. |
432 * Use $this->assertSession()->addressEquals() instead. | 437 * Use $this->assertSession()->addressEquals() instead. |
433 */ | 438 */ |
434 protected function assertUrl($path) { | 439 protected function assertUrl($path) { |
435 $this->assertSession()->addressEquals($path); | 440 $this->assertSession()->addressEquals($path); |
436 } | 441 } |
441 * @param string $id | 446 * @param string $id |
442 * ID of select field to assert. | 447 * ID of select field to assert. |
443 * @param string $option | 448 * @param string $option |
444 * Option to assert. | 449 * Option to assert. |
445 * | 450 * |
446 * @deprecated Scheduled for removal in Drupal 9.0.0. | 451 * Deprecated Scheduled for removal in Drupal 10.0.0. |
447 * Use $this->assertSession()->optionExists() instead. | 452 * Use $this->assertSession()->optionExists() instead. |
448 */ | 453 */ |
449 protected function assertOption($id, $option) { | 454 protected function assertOption($id, $option) { |
450 return $this->assertSession()->optionExists($id, $option); | 455 return $this->assertSession()->optionExists($id, $option); |
451 } | 456 } |
456 * @param string $id | 461 * @param string $id |
457 * The ID of the select field to assert. | 462 * The ID of the select field to assert. |
458 * @param string $text | 463 * @param string $text |
459 * The text for the option tag to assert. | 464 * The text for the option tag to assert. |
460 * | 465 * |
461 * @deprecated Scheduled for removal in Drupal 9.0.0. | 466 * Deprecated Scheduled for removal in Drupal 10.0.0. |
462 * Use $this->assertSession()->optionExists() instead. | 467 * Use $this->assertSession()->optionExists() instead. |
463 */ | 468 */ |
464 protected function assertOptionByText($id, $text) { | 469 protected function assertOptionByText($id, $text) { |
465 return $this->assertSession()->optionExists($id, $text); | 470 return $this->assertSession()->optionExists($id, $text); |
466 } | 471 } |
471 * @param string $id | 476 * @param string $id |
472 * ID of select field to assert. | 477 * ID of select field to assert. |
473 * @param string $option | 478 * @param string $option |
474 * Option to assert. | 479 * Option to assert. |
475 * | 480 * |
476 * @deprecated Scheduled for removal in Drupal 9.0.0. | 481 * Deprecated Scheduled for removal in Drupal 10.0.0. |
477 * Use $this->assertSession()->optionNotExists() instead. | 482 * Use $this->assertSession()->optionNotExists() instead. |
478 */ | 483 */ |
479 protected function assertNoOption($id, $option) { | 484 protected function assertNoOption($id, $option) { |
480 return $this->assertSession()->optionNotExists($id, $option); | 485 return $this->assertSession()->optionNotExists($id, $option); |
481 } | 486 } |
489 * Option to assert. | 494 * Option to assert. |
490 * @param string $message | 495 * @param string $message |
491 * (optional) A message to display with the assertion. Do not translate | 496 * (optional) A message to display with the assertion. Do not translate |
492 * messages with t(). If left blank, a default message will be displayed. | 497 * messages with t(). If left blank, a default message will be displayed. |
493 * | 498 * |
494 * @deprecated Scheduled for removal in Drupal 9.0.0. | 499 * Deprecated Scheduled for removal in Drupal 10.0.0. |
495 * Use $this->assertSession()->optionExists() instead and check the | 500 * Use $this->assertSession()->optionExists() instead and check the |
496 * "selected" attribute yourself. | 501 * "selected" attribute yourself. |
497 */ | 502 */ |
498 protected function assertOptionSelected($id, $option, $message = NULL) { | 503 protected function assertOptionSelected($id, $option, $message = NULL) { |
499 $option_field = $this->assertSession()->optionExists($id, $option); | 504 $option_field = $this->assertSession()->optionExists($id, $option); |
505 * Asserts that a checkbox field in the current page is checked. | 510 * Asserts that a checkbox field in the current page is checked. |
506 * | 511 * |
507 * @param string $id | 512 * @param string $id |
508 * ID of field to assert. | 513 * ID of field to assert. |
509 * | 514 * |
510 * @deprecated Scheduled for removal in Drupal 9.0.0. | 515 * Deprecated Scheduled for removal in Drupal 10.0.0. |
511 * Use $this->assertSession()->checkboxChecked() instead. | 516 * Use $this->assertSession()->checkboxChecked() instead. |
512 */ | 517 */ |
513 protected function assertFieldChecked($id) { | 518 protected function assertFieldChecked($id) { |
514 $this->assertSession()->checkboxChecked($id); | 519 $this->assertSession()->checkboxChecked($id); |
515 } | 520 } |
518 * Asserts that a checkbox field in the current page is not checked. | 523 * Asserts that a checkbox field in the current page is not checked. |
519 * | 524 * |
520 * @param string $id | 525 * @param string $id |
521 * ID of field to assert. | 526 * ID of field to assert. |
522 * | 527 * |
523 * @deprecated Scheduled for removal in Drupal 9.0.0. | 528 * Deprecated Scheduled for removal in Drupal 10.0.0. |
524 * Use $this->assertSession()->checkboxNotChecked() instead. | 529 * Use $this->assertSession()->checkboxNotChecked() instead. |
525 */ | 530 */ |
526 protected function assertNoFieldChecked($id) { | 531 protected function assertNoFieldChecked($id) { |
527 $this->assertSession()->checkboxNotChecked($id); | 532 $this->assertSession()->checkboxNotChecked($id); |
528 } | 533 } |
538 * exists. | 543 * exists. |
539 * @param string $message | 544 * @param string $message |
540 * (optional) A message to display with the assertion. Do not translate | 545 * (optional) A message to display with the assertion. Do not translate |
541 * messages with t(). | 546 * messages with t(). |
542 * | 547 * |
543 * @deprecated Scheduled for removal in Drupal 9.0.0. | 548 * Deprecated Scheduled for removal in Drupal 10.0.0. |
544 * Use $this->xpath() instead and check the values directly in the test. | 549 * Use $this->xpath() instead and check the values directly in the test. |
545 */ | 550 */ |
546 protected function assertFieldByXPath($xpath, $value = NULL, $message = '') { | 551 protected function assertFieldByXPath($xpath, $value = NULL, $message = '') { |
547 $fields = $this->xpath($xpath); | 552 $fields = $this->xpath($xpath); |
548 | 553 |
561 * (optional) A message to display with the assertion. Do not translate | 566 * (optional) A message to display with the assertion. Do not translate |
562 * messages with t(). | 567 * messages with t(). |
563 * | 568 * |
564 * @throws \Behat\Mink\Exception\ExpectationException | 569 * @throws \Behat\Mink\Exception\ExpectationException |
565 * | 570 * |
566 * @deprecated Scheduled for removal in Drupal 9.0.0. | 571 * Deprecated Scheduled for removal in Drupal 10.0.0. |
567 * Use $this->xpath() instead and assert that the result is empty. | 572 * Use $this->xpath() instead and assert that the result is empty. |
568 */ | 573 */ |
569 protected function assertNoFieldByXPath($xpath, $value = NULL, $message = '') { | 574 protected function assertNoFieldByXPath($xpath, $value = NULL, $message = '') { |
570 $fields = $this->xpath($xpath); | 575 $fields = $this->xpath($xpath); |
571 | 576 |
599 * checking the actual value, while still checking that the field exists. | 604 * checking the actual value, while still checking that the field exists. |
600 * @param string $message | 605 * @param string $message |
601 * (optional) A message to display with the assertion. Do not translate | 606 * (optional) A message to display with the assertion. Do not translate |
602 * messages with t(). | 607 * messages with t(). |
603 * | 608 * |
604 * @deprecated Scheduled for removal in Drupal 9.0.0. | 609 * Deprecated Scheduled for removal in Drupal 10.0.0. |
605 * Iterate over the fields yourself instead and directly check the values in | 610 * Iterate over the fields yourself instead and directly check the values in |
606 * the test. | 611 * the test. |
607 */ | 612 */ |
608 protected function assertFieldsByValue($fields, $value = NULL, $message = '') { | 613 protected function assertFieldsByValue($fields, $value = NULL, $message = '') { |
609 // If value specified then check array for match. | 614 // If value specified then check array for match. |
648 * Raw text refers to the raw HTML that the page generated. | 653 * Raw text refers to the raw HTML that the page generated. |
649 * | 654 * |
650 * @param string $raw | 655 * @param string $raw |
651 * Raw (HTML) string to look for. | 656 * Raw (HTML) string to look for. |
652 * | 657 * |
653 * @deprecated Scheduled for removal in Drupal 9.0.0. | 658 * Deprecated Scheduled for removal in Drupal 10.0.0. |
654 * Use $this->assertSession()->assertEscaped() instead. | 659 * Use $this->assertSession()->assertEscaped() instead. |
655 */ | 660 */ |
656 protected function assertEscaped($raw) { | 661 protected function assertEscaped($raw) { |
657 $this->assertSession()->assertEscaped($raw); | 662 $this->assertSession()->assertEscaped($raw); |
658 } | 663 } |
663 * Raw text refers to the raw HTML that the page generated. | 668 * Raw text refers to the raw HTML that the page generated. |
664 * | 669 * |
665 * @param string $raw | 670 * @param string $raw |
666 * Raw (HTML) string to look for. | 671 * Raw (HTML) string to look for. |
667 * | 672 * |
668 * @deprecated Scheduled for removal in Drupal 9.0.0. | 673 * Deprecated Scheduled for removal in Drupal 10.0.0. |
669 * Use $this->assertSession()->assertNoEscaped() instead. | 674 * Use $this->assertSession()->assertNoEscaped() instead. |
670 */ | 675 */ |
671 protected function assertNoEscaped($raw) { | 676 protected function assertNoEscaped($raw) { |
672 $this->assertSession()->assertNoEscaped($raw); | 677 $this->assertSession()->assertNoEscaped($raw); |
673 } | 678 } |
676 * Triggers a pass if the Perl regex pattern is found in the raw content. | 681 * Triggers a pass if the Perl regex pattern is found in the raw content. |
677 * | 682 * |
678 * @param string $pattern | 683 * @param string $pattern |
679 * Perl regex to look for including the regex delimiters. | 684 * Perl regex to look for including the regex delimiters. |
680 * | 685 * |
681 * @deprecated Scheduled for removal in Drupal 9.0.0. | 686 * Deprecated Scheduled for removal in Drupal 10.0.0. |
682 * Use $this->assertSession()->responseMatches() instead. | 687 * Use $this->assertSession()->responseMatches() instead. |
683 */ | 688 */ |
684 protected function assertPattern($pattern) { | 689 protected function assertPattern($pattern) { |
685 $this->assertSession()->responseMatches($pattern); | 690 $this->assertSession()->responseMatches($pattern); |
686 } | 691 } |
689 * Triggers a pass if the Perl regex pattern is not found in the raw content. | 694 * Triggers a pass if the Perl regex pattern is not found in the raw content. |
690 * | 695 * |
691 * @param string $pattern | 696 * @param string $pattern |
692 * Perl regex to look for including the regex delimiters. | 697 * Perl regex to look for including the regex delimiters. |
693 * | 698 * |
694 * @deprecated Scheduled for removal in Drupal 9.0.0. | 699 * Deprecated Scheduled for removal in Drupal 10.0.0. |
695 * Use $this->assertSession()->responseNotMatches() instead. | 700 * Use $this->assertSession()->responseNotMatches() instead. |
696 * | 701 * |
697 * @see https://www.drupal.org/node/2864262 | 702 * @see https://www.drupal.org/node/2864262 |
698 */ | 703 */ |
699 protected function assertNoPattern($pattern) { | 704 protected function assertNoPattern($pattern) { |
705 * Asserts whether an expected cache tag was present in the last response. | 710 * Asserts whether an expected cache tag was present in the last response. |
706 * | 711 * |
707 * @param string $expected_cache_tag | 712 * @param string $expected_cache_tag |
708 * The expected cache tag. | 713 * The expected cache tag. |
709 * | 714 * |
710 * @deprecated Scheduled for removal in Drupal 9.0.0. | 715 * Deprecated Scheduled for removal in Drupal 10.0.0. |
711 * Use $this->assertSession()->responseHeaderContains() instead. | 716 * Use $this->assertSession()->responseHeaderContains() instead. |
712 */ | 717 */ |
713 protected function assertCacheTag($expected_cache_tag) { | 718 protected function assertCacheTag($expected_cache_tag) { |
714 $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', $expected_cache_tag); | 719 $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', $expected_cache_tag); |
715 } | 720 } |
718 * Asserts whether an expected cache tag was absent in the last response. | 723 * Asserts whether an expected cache tag was absent in the last response. |
719 * | 724 * |
720 * @param string $cache_tag | 725 * @param string $cache_tag |
721 * The cache tag to check. | 726 * The cache tag to check. |
722 * | 727 * |
723 * @deprecated Scheduled for removal in Drupal 9.0.0. | 728 * Deprecated Scheduled for removal in Drupal 10.0.0. |
724 * Use $this->assertSession()->responseHeaderNotContains() instead. | 729 * Use $this->assertSession()->responseHeaderNotContains() instead. |
725 * | 730 * |
726 * @see https://www.drupal.org/node/2864029 | 731 * @see https://www.drupal.org/node/2864029 |
727 */ | 732 */ |
728 protected function assertNoCacheTag($cache_tag) { | 733 protected function assertNoCacheTag($cache_tag) { |
736 * @param string $name | 741 * @param string $name |
737 * Name of header to assert. | 742 * Name of header to assert. |
738 * @param string $value | 743 * @param string $value |
739 * Value of the header to assert | 744 * Value of the header to assert |
740 * | 745 * |
741 * @deprecated Scheduled for removal in Drupal 9.0.0. | 746 * Deprecated Scheduled for removal in Drupal 10.0.0. |
742 * Use $this->assertSession()->responseHeaderEquals() instead. | 747 * Use $this->assertSession()->responseHeaderEquals() instead. |
743 */ | 748 */ |
744 protected function assertHeader($name, $value) { | 749 protected function assertHeader($name, $value) { |
745 $this->assertSession()->responseHeaderEquals($name, $value); | 750 $this->assertSession()->responseHeaderEquals($name, $value); |
746 } | 751 } |
774 * values. | 779 * values. |
775 * | 780 * |
776 * @return string | 781 * @return string |
777 * An XPath query with arguments replaced. | 782 * An XPath query with arguments replaced. |
778 * | 783 * |
779 * @deprecated Scheduled for removal in Drupal 9.0.0. | 784 * Deprecated Scheduled for removal in Drupal 10.0.0. |
780 * Use $this->assertSession()->buildXPathQuery() instead. | 785 * Use $this->assertSession()->buildXPathQuery() instead. |
781 */ | 786 */ |
782 protected function buildXPathQuery($xpath, array $args = []) { | 787 protected function buildXPathQuery($xpath, array $args = []) { |
783 return $this->assertSession()->buildXPathQuery($xpath, $args); | 788 return $this->assertSession()->buildXPathQuery($xpath, $args); |
784 } | 789 } |
792 * Value of field. | 797 * Value of field. |
793 * | 798 * |
794 * @return string | 799 * @return string |
795 * XPath for specified values. | 800 * XPath for specified values. |
796 * | 801 * |
797 * @deprecated Scheduled for removal in Drupal 9.0.0. | 802 * Deprecated Scheduled for removal in Drupal 10.0.0. |
798 * Use $this->getSession()->getPage()->findField() instead. | 803 * Use $this->getSession()->getPage()->findField() instead. |
799 */ | 804 */ |
800 protected function constructFieldXpath($attribute, $value) { | 805 protected function constructFieldXpath($attribute, $value) { |
801 $xpath = '//textarea[@' . $attribute . '=:value]|//input[@' . $attribute . '=:value]|//select[@' . $attribute . '=:value]'; | 806 $xpath = '//textarea[@' . $attribute . '=:value]|//input[@' . $attribute . '=:value]|//select[@' . $attribute . '=:value]'; |
802 return $this->buildXPathQuery($xpath, [':value' => $value]); | 807 return $this->buildXPathQuery($xpath, [':value' => $value]); |
803 } | 808 } |
804 | 809 |
805 /** | 810 /** |
806 * Gets the current raw content. | 811 * Gets the current raw content. |
807 * | 812 * |
808 * @deprecated Scheduled for removal in Drupal 9.0.0. | 813 * Deprecated Scheduled for removal in Drupal 10.0.0. |
809 * Use $this->getSession()->getPage()->getContent() instead. | 814 * Use $this->getSession()->getPage()->getContent() instead. |
810 */ | 815 */ |
811 protected function getRawContent() { | 816 protected function getRawContent() { |
812 @trigger_error('AssertLegacyTrait::getRawContent() is scheduled for removal in Drupal 9.0.0. Use $this->getSession()->getPage()->getContent() instead.', E_USER_DEPRECATED); | 817 @trigger_error('AssertLegacyTrait::getRawContent() is scheduled for removal in Drupal 9.0.0. Use $this->getSession()->getPage()->getContent() instead.', E_USER_DEPRECATED); |
813 return $this->getSession()->getPage()->getContent(); | 818 return $this->getSession()->getPage()->getContent(); |
820 * The element for which to get the options. | 825 * The element for which to get the options. |
821 * | 826 * |
822 * @return \Behat\Mink\Element\NodeElement[] | 827 * @return \Behat\Mink\Element\NodeElement[] |
823 * Option elements in select. | 828 * Option elements in select. |
824 * | 829 * |
825 * @deprecated Scheduled for removal in Drupal 9.0.0. | 830 * Deprecated Scheduled for removal in Drupal 10.0.0. |
826 * Use $element->findAll('xpath', 'option') instead. | 831 * Use $element->findAll('xpath', 'option') instead. |
827 */ | 832 */ |
828 protected function getAllOptions(NodeElement $element) { | 833 protected function getAllOptions(NodeElement $element) { |
829 @trigger_error('AssertLegacyTrait::getAllOptions() is scheduled for removal in Drupal 9.0.0. Use $element->findAll(\'xpath\', \'option\') instead.', E_USER_DEPRECATED); | 834 @trigger_error('AssertLegacyTrait::getAllOptions() is scheduled for removal in Drupal 9.0.0. Use $element->findAll(\'xpath\', \'option\') instead.', E_USER_DEPRECATED); |
830 return $element->findAll('xpath', '//option'); | 835 return $element->findAll('xpath', '//option'); |