Commit e3fc5d91 authored by catch's avatar catch
Browse files

Issue #3031580 by alexpott, Gábor Hojtsy, Lendude, catch, jibran, dawehner,...

Issue #3031580 by alexpott, Gábor Hojtsy, Lendude, catch, jibran, dawehner, Berdir: Undeprecate \Drupal\FunctionalTests\AssertLegacyTrait and \Drupal\KernelTests\AssertLegacyTrait in Drupal 8
parent 6b6b5b08
Loading
Loading
Loading
Loading
+48 −43
Changes for core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php: 48 added lines, 43 removed lines.
Original line number Diff line number Diff line
<?php

// @codingStandardsIgnoreFile
namespace Drupal\FunctionalTests;

use Behat\Mink\Element\NodeElement;
@@ -12,11 +12,16 @@
/**
 * Provides convenience methods for assertions in browser tests.
 *
 * @deprecated Scheduled for removal in Drupal 9.0.0. Use the methods on
 * Deprecated Scheduled for removal in Drupal 10.0.0. Use the methods on
 *   \Drupal\Tests\WebAssert instead, for example
 * @code
 *    $this->assertSession()->statusCodeEquals(200);
 * @endcode
 *
 * @todo https://www.drupal.org/project/drupal/issues/3031580 Note that
 *   deprecations in this file do not use the @ symbol in Drupal 8 because this
 *   will be removed in Drupal 10.0.0. Adding the @ back should re-enable coding
 *   stanadrds checks.
 */
trait AssertLegacyTrait {

@@ -28,7 +33,7 @@ trait AssertLegacyTrait {
   * @param string $css_selector
   *   The CSS selector identifying the element to check.
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0.
   * Deprecated Scheduled for removal in Drupal 10.0.0.
   *   Use $this->assertSession()->elementExists() instead.
   */
  protected function assertElementPresent($css_selector) {
@@ -41,7 +46,7 @@ protected function assertElementPresent($css_selector) {
   * @param string $css_selector
   *   The CSS selector identifying the element to check.
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0.
   * Deprecated Scheduled for removal in Drupal 10.0.0.
   *   Use $this->assertSession()->elementNotExists() instead.
   */
  protected function assertElementNotPresent($css_selector) {
@@ -57,7 +62,7 @@ protected function assertElementNotPresent($css_selector) {
   * @param string $text
   *   Plain text to look for.
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0.
   * Deprecated Scheduled for removal in Drupal 10.0.0.
   *   Use instead:
   *     - $this->assertSession()->responseContains() for non-HTML responses,
   *       like XML or Json.
@@ -89,7 +94,7 @@ protected function assertText($text) {
   * @param string $text
   *   Plain text to look for.
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0.
   * Deprecated Scheduled for removal in Drupal 10.0.0.
   *   Use instead:
   *     - $this->assertSession()->responseNotContains() for non-HTML responses,
   *       like XML or Json.
@@ -155,7 +160,7 @@ protected function assertTextHelper($text, $not_exists = TRUE) {
   *   (optional) A message to display with the assertion. Do not translate
   *   messages with t(). If left blank, a default message will be displayed.
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0.
   * Deprecated Scheduled for removal in Drupal 10.0.0.
   *   Use $this->getSession()->getPage()->getText() and substr_count() instead.
   */
  protected function assertUniqueText($text, $message = NULL) {
@@ -181,7 +186,7 @@ protected function assertUniqueText($text, $message = NULL) {
   *   (optional) A message to display with the assertion. Do not translate
   *   messages with t(). If left blank, a default message will be displayed.
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0.
   * Deprecated Scheduled for removal in Drupal 10.0.0.
   *   Use $this->getSession()->getPage()->getText() and substr_count() instead.
   */
  protected function assertNoUniqueText($text, $message = '') {
@@ -201,7 +206,7 @@ protected function assertNoUniqueText($text, $message = '') {
   *   Response code. For example 200 is a successful page request. For a list
   *   of all codes see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html.
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0.
   * Deprecated Scheduled for removal in Drupal 10.0.0.
   *   Use $this->assertSession()->statusCodeEquals() instead.
   */
  protected function assertResponse($code) {
@@ -218,7 +223,7 @@ protected function assertResponse($code) {
   *   to skip checking the actual value, while still checking that the field
   *   exists.
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0.
   * Deprecated Scheduled for removal in Drupal 10.0.0.
   *   Use $this->assertSession()->fieldExists() or
   *   $this->assertSession()->buttonExists() or
   *   $this->assertSession()->fieldValueEquals() instead.
@@ -238,7 +243,7 @@ protected function assertFieldByName($name, $value = NULL) {
   *   value, while still checking that the field does not exist. However, the
   *   default value ('') asserts that the field value is not an empty string.
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0.
   * Deprecated Scheduled for removal in Drupal 10.0.0.
   *   Use $this->assertSession()->fieldNotExists() or
   *   $this->assertSession()->buttonNotExists() or
   *   $this->assertSession()->fieldValueNotEquals() instead.
@@ -260,7 +265,7 @@ protected function assertNoFieldByName($name, $value = '') {
   *
   * @throws \Behat\Mink\Exception\ElementNotFoundException
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0.
   * Deprecated Scheduled for removal in Drupal 10.0.0.
   *   Use $this->assertSession()->fieldExists() or
   *   $this->assertSession()->buttonExists() or
   *   $this->assertSession()->fieldValueEquals() instead.
@@ -275,7 +280,7 @@ protected function assertFieldById($id, $value = '') {
   * @param string $field
   *   Name or ID of field to assert.
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0.
   * Deprecated Scheduled for removal in Drupal 10.0.0.
   *   Use $this->assertSession()->fieldExists() or
   *   $this->assertSession()->buttonExists() instead.
   */
@@ -289,7 +294,7 @@ protected function assertField($field) {
   * @param string $field
   *   Name or ID of field to assert.
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0.
   * Deprecated Scheduled for removal in Drupal 10.0.0.
   *   Use $this->assertSession()->fieldNotExists() or
   *   $this->assertSession()->buttonNotExists() instead.
   */
@@ -305,7 +310,7 @@ protected function assertNoField($field) {
   * @param string $raw
   *   Raw (HTML) string to look for.
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0.
   * Deprecated Scheduled for removal in Drupal 10.0.0.
   *   Use $this->assertSession()->responseContains() instead.
   */
  protected function assertRaw($raw) {
@@ -320,7 +325,7 @@ protected function assertRaw($raw) {
   * @param string $raw
   *   Raw (HTML) string to look for.
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0.
   * Deprecated Scheduled for removal in Drupal 10.0.0.
   *   Use $this->assertSession()->responseNotContains() instead.
   */
  protected function assertNoRaw($raw) {
@@ -333,7 +338,7 @@ protected function assertNoRaw($raw) {
   * @param string $expected_title
   *   The string the page title should be.
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0.
   * Deprecated Scheduled for removal in Drupal 10.0.0.
   *   Use $this->assertSession()->titleEquals() instead.
   */
  protected function assertTitle($expected_title) {
@@ -352,7 +357,7 @@ protected function assertTitle($expected_title) {
   * @param int $index
   *   Link position counting from zero.
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0.
   * Deprecated Scheduled for removal in Drupal 10.0.0.
   *   Use $this->assertSession()->linkExists() instead.
   */
  protected function assertLink($label, $index = 0) {
@@ -365,7 +370,7 @@ protected function assertLink($label, $index = 0) {
   * @param string|\Drupal\Component\Render\MarkupInterface $label
   *   Text between the anchor tags.
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0.
   * Deprecated Scheduled for removal in Drupal 10.0.0.
   *   Use $this->assertSession()->linkNotExists() instead.
   */
  protected function assertNoLink($label) {
@@ -380,7 +385,7 @@ protected function assertNoLink($label) {
   * @param int $index
   *   Link position counting from zero.
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0.
   * Deprecated Scheduled for removal in Drupal 10.0.0.
   *   Use $this->assertSession()->linkByHrefExists() instead.
   */
  protected function assertLinkByHref($href, $index = 0) {
@@ -393,7 +398,7 @@ protected function assertLinkByHref($href, $index = 0) {
   * @param string $href
   *   The full or partial value of the 'href' attribute of the anchor tag.
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0.
   * Deprecated Scheduled for removal in Drupal 10.0.0.
   *   Use $this->assertSession()->linkByHrefNotExists() instead.
   */
  protected function assertNoLinkByHref($href) {
@@ -413,7 +418,7 @@ protected function assertNoLinkByHref($href) {
   *
   * @throws \Behat\Mink\Exception\ExpectationException
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0.
   * Deprecated Scheduled for removal in Drupal 10.0.0.
   *   Use $this->assertSession()->fieldNotExists() or
   *   $this->assertSession()->buttonNotExists() or
   *   $this->assertSession()->fieldValueNotEquals() instead.
@@ -428,7 +433,7 @@ protected function assertNoFieldById($id, $value = '') {
   * @param \Drupal\Core\Url|string $path
   *   The expected system path or URL.
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0.
   * Deprecated Scheduled for removal in Drupal 10.0.0.
   *   Use $this->assertSession()->addressEquals() instead.
   */
  protected function assertUrl($path) {
@@ -443,7 +448,7 @@ protected function assertUrl($path) {
   * @param string $option
   *   Option to assert.
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0.
   * Deprecated Scheduled for removal in Drupal 10.0.0.
   *   Use $this->assertSession()->optionExists() instead.
   */
  protected function assertOption($id, $option) {
@@ -458,7 +463,7 @@ protected function assertOption($id, $option) {
   * @param string $text
   *   The text for the option tag to assert.
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0.
   * Deprecated Scheduled for removal in Drupal 10.0.0.
   *   Use $this->assertSession()->optionExists() instead.
   */
  protected function assertOptionByText($id, $text) {
@@ -473,7 +478,7 @@ protected function assertOptionByText($id, $text) {
   * @param string $option
   *   Option to assert.
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0.
   * Deprecated Scheduled for removal in Drupal 10.0.0.
   *   Use $this->assertSession()->optionNotExists() instead.
   */
  protected function assertNoOption($id, $option) {
@@ -491,7 +496,7 @@ protected function assertNoOption($id, $option) {
   *   (optional) A message to display with the assertion. Do not translate
   *   messages with t(). If left blank, a default message will be displayed.
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0.
   * Deprecated Scheduled for removal in Drupal 10.0.0.
   *   Use $this->assertSession()->optionExists() instead and check the
   *   "selected" attribute yourself.
   */
@@ -507,7 +512,7 @@ protected function assertOptionSelected($id, $option, $message = NULL) {
   * @param string $id
   *   ID of field to assert.
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0.
   * Deprecated Scheduled for removal in Drupal 10.0.0.
   *   Use $this->assertSession()->checkboxChecked() instead.
   */
  protected function assertFieldChecked($id) {
@@ -520,7 +525,7 @@ protected function assertFieldChecked($id) {
   * @param string $id
   *   ID of field to assert.
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0.
   * Deprecated Scheduled for removal in Drupal 10.0.0.
   *   Use $this->assertSession()->checkboxNotChecked() instead.
   */
  protected function assertNoFieldChecked($id) {
@@ -540,7 +545,7 @@ protected function assertNoFieldChecked($id) {
   *   (optional) A message to display with the assertion. Do not translate
   *   messages with t().
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0.
   * Deprecated Scheduled for removal in Drupal 10.0.0.
   *   Use $this->xpath() instead and check the values directly in the test.
   */
  protected function assertFieldByXPath($xpath, $value = NULL, $message = '') {
@@ -563,7 +568,7 @@ protected function assertFieldByXPath($xpath, $value = NULL, $message = '') {
   *
   * @throws \Behat\Mink\Exception\ExpectationException
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0.
   * Deprecated Scheduled for removal in Drupal 10.0.0.
   *   Use $this->xpath() instead and assert that the result is empty.
   */
  protected function assertNoFieldByXPath($xpath, $value = NULL, $message = '') {
@@ -601,7 +606,7 @@ protected function assertNoFieldByXPath($xpath, $value = NULL, $message = '') {
   *   (optional) A message to display with the assertion. Do not translate
   *   messages with t().
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0.
   * Deprecated Scheduled for removal in Drupal 10.0.0.
   *   Iterate over the fields yourself instead and directly check the values in
   *   the test.
   */
@@ -650,7 +655,7 @@ protected function assertFieldsByValue($fields, $value = NULL, $message = '') {
   * @param string $raw
   *   Raw (HTML) string to look for.
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0.
   * Deprecated Scheduled for removal in Drupal 10.0.0.
   *   Use $this->assertSession()->assertEscaped() instead.
   */
  protected function assertEscaped($raw) {
@@ -665,7 +670,7 @@ protected function assertEscaped($raw) {
   * @param string $raw
   *   Raw (HTML) string to look for.
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0.
   * Deprecated Scheduled for removal in Drupal 10.0.0.
   *   Use $this->assertSession()->assertNoEscaped() instead.
   */
  protected function assertNoEscaped($raw) {
@@ -678,7 +683,7 @@ protected function assertNoEscaped($raw) {
   * @param string $pattern
   *   Perl regex to look for including the regex delimiters.
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0.
   * Deprecated Scheduled for removal in Drupal 10.0.0.
   *   Use $this->assertSession()->responseMatches() instead.
   */
  protected function assertPattern($pattern) {
@@ -691,7 +696,7 @@ protected function assertPattern($pattern) {
   * @param string $pattern
   *   Perl regex to look for including the regex delimiters.
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0.
   * Deprecated Scheduled for removal in Drupal 10.0.0.
   *   Use $this->assertSession()->responseNotMatches() instead.
   *
   * @see https://www.drupal.org/node/2864262
@@ -707,7 +712,7 @@ protected function assertNoPattern($pattern) {
   * @param string $expected_cache_tag
   *   The expected cache tag.
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0.
   * Deprecated Scheduled for removal in Drupal 10.0.0.
   *   Use $this->assertSession()->responseHeaderContains() instead.
   */
  protected function assertCacheTag($expected_cache_tag) {
@@ -720,7 +725,7 @@ protected function assertCacheTag($expected_cache_tag) {
   * @param string $cache_tag
   *   The cache tag to check.
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0.
   * Deprecated Scheduled for removal in Drupal 10.0.0.
   *   Use $this->assertSession()->responseHeaderNotContains() instead.
   *
   * @see https://www.drupal.org/node/2864029
@@ -738,7 +743,7 @@ protected function assertNoCacheTag($cache_tag) {
   * @param string $value
   *   Value of the header to assert
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0.
   * Deprecated Scheduled for removal in Drupal 10.0.0.
   *   Use $this->assertSession()->responseHeaderEquals() instead.
   */
  protected function assertHeader($name, $value) {
@@ -776,7 +781,7 @@ abstract public function assertSession($name = NULL);
   * @return string
   *   An XPath query with arguments replaced.
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0.
   * Deprecated Scheduled for removal in Drupal 10.0.0.
   *   Use $this->assertSession()->buildXPathQuery() instead.
   */
  protected function buildXPathQuery($xpath, array $args = []) {
@@ -794,7 +799,7 @@ protected function buildXPathQuery($xpath, array $args = []) {
   * @return string
   *   XPath for specified values.
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0.
   * Deprecated Scheduled for removal in Drupal 10.0.0.
   *   Use $this->getSession()->getPage()->findField() instead.
   */
  protected function constructFieldXpath($attribute, $value) {
@@ -805,7 +810,7 @@ protected function constructFieldXpath($attribute, $value) {
  /**
   * Gets the current raw content.
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0.
   * Deprecated Scheduled for removal in Drupal 10.0.0.
   *   Use $this->getSession()->getPage()->getContent() instead.
   */
  protected function getRawContent() {
@@ -822,7 +827,7 @@ protected function getRawContent() {
   * @return \Behat\Mink\Element\NodeElement[]
   *   Option elements in select.
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0.
   * Deprecated Scheduled for removal in Drupal 10.0.0.
   *   Use $element->findAll('xpath', 'option') instead.
   */
  protected function getAllOptions(NodeElement $element) {
+12 −8
Changes for core/tests/Drupal/KernelTests/AssertLegacyTrait.php: 12 added lines, 8 removed lines.
Original line number Diff line number Diff line
@@ -8,15 +8,19 @@
 * Protected methods are custom. Public static methods override methods of
 * \PHPUnit\Framework\Assert.
 *
 * @deprecated Scheduled for removal in Drupal 9.0.0. Use PHPUnit's native
 * Deprecated Scheduled for removal in Drupal 10.0.0. Use PHPUnit's native
 *   assert methods instead.
 *
 * @todo https://www.drupal.org/project/drupal/issues/3031580 Note that
 *   deprecations in this file do not use the @ symbol in Drupal 8 because this
 *   will be removed in Drupal 10.0.0.
 */
trait AssertLegacyTrait {

  /**
   * @see \Drupal\simpletest\TestBase::assert()
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0. Use self::assertTrue()
   * Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertTrue()
   *   instead.
   */
  protected function assert($actual, $message = '') {
@@ -50,7 +54,7 @@ public static function assertFalse($actual, $message = '') {
  /**
   * @see \Drupal\simpletest\TestBase::assertEqual()
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0. Use self::assertEquals()
   * Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertEquals()
   *   instead.
   */
  protected function assertEqual($actual, $expected, $message = '') {
@@ -60,7 +64,7 @@ protected function assertEqual($actual, $expected, $message = '') {
  /**
   * @see \Drupal\simpletest\TestBase::assertNotEqual()
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0. Use
   * Deprecated Scheduled for removal in Drupal 10.0.0. Use
   *   self::assertNotEquals() instead.
   */
  protected function assertNotEqual($actual, $expected, $message = '') {
@@ -70,7 +74,7 @@ protected function assertNotEqual($actual, $expected, $message = '') {
  /**
   * @see \Drupal\simpletest\TestBase::assertIdentical()
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0. Use self::assertSame()
   * Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertSame()
   *   instead.
   */
  protected function assertIdentical($actual, $expected, $message = '') {
@@ -80,7 +84,7 @@ protected function assertIdentical($actual, $expected, $message = '') {
  /**
   * @see \Drupal\simpletest\TestBase::assertNotIdentical()
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0. Use
   * Deprecated Scheduled for removal in Drupal 10.0.0. Use
   *   self::assertNotSame() instead.
   */
  protected function assertNotIdentical($actual, $expected, $message = '') {
@@ -90,7 +94,7 @@ protected function assertNotIdentical($actual, $expected, $message = '') {
  /**
   * @see \Drupal\simpletest\TestBase::assertIdenticalObject()
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0. Use self::assertEquals()
   * Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertEquals()
   *   instead.
   */
  protected function assertIdenticalObject($actual, $expected, $message = '') {
@@ -103,7 +107,7 @@ protected function assertIdenticalObject($actual, $expected, $message = '') {
  /**
   * @see \Drupal\simpletest\TestBase::pass()
   *
   * @deprecated Scheduled for removal in Drupal 9.0.0. Use self::assertTrue()
   * Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertTrue()
   *   instead.
   */
  protected function pass($message) {