diff --git a/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php b/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php index 5785a7d..f0ee8e7 100644 --- a/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php +++ b/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php @@ -94,7 +94,7 @@ protected function assertNoText($text) { } /** - * Passes if the text is found ONLY ONCE on the text version of the page. + * Passes if the text is found only once on the text version of the page. * * The text version is the equivalent of what a user would see when viewing * through a web browser. In other words the HTML has been filtered out of @@ -115,12 +115,12 @@ protected function assertUniqueText($text, $message = NULL) { $message = $message ?: "'$text' found only once on the page"; $page_text = $this->getSession()->getPage()->getText(); - $nr_found = substr_count($page_text, $text); - $this->assertSame(1, $nr_found, $message); + $occurrences = substr_count($page_text, $text); + $this->assertSame(1, $occurrences, $message); } /** - * Passes if the text is found MORE THAN ONCE on the text version of the page. + * Passes if the text is found more tjan once on the text version of the page. * * The text version is the equivalent of what a user would see when viewing * through a web browser. In other words the HTML has been filtered out of @@ -141,8 +141,8 @@ protected function assertNoUniqueText($text, $message = '') { $message = $message ?: "'$text' found more than once on the page"; $page_text = $this->getSession()->getPage()->getText(); - $nr_found = substr_count($page_text, $text); - $this->assertGreaterThan(1, $nr_found, $message); + $occurrences = substr_count($page_text, $text); + $this->assertGreaterThan(1, $occurrences, $message); } /** @@ -189,12 +189,17 @@ protected function assertFieldByName($name, $value = NULL) { * (optional) Value of the field to assert. You may pass in NULL (default) * to skip checking the actual value, while still checking that the field * exists. + * @param string $message + * (optional) A message to display with the assertion. Do not translate + * messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed + * variables in the message text, not t(). If left blank, a default message + * will be displayed. * * @deprecated Scheduled for removal in Drupal 9.0.0. * Use $this->assertSession()->fieldNotExists() or * $this->assertSession()->fieldValueNotEquals() instead. */ - protected function assertNoFieldByName($name, $value = NULL) { + protected function assertNoFieldByName($name, $value = NULL, $message = '') { $this->assertSession()->fieldNotExists($name); if ($value !== NULL) { $this->assertSession()->fieldValueNotEquals($name, (string) $value); @@ -442,11 +447,16 @@ protected function assertOptionSelected($id, $option, $message = NULL) { * * @param string $id * ID of field to assert. + * @param string $message + * (optional) A message to display with the assertion. Do not translate + * messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed + * variables in the message text, not t(). If left blank, a default message + * will be displayed. * * @deprecated Scheduled for removal in Drupal 9.0.0. * Use $this->assertSession()->checkboxChecked() instead. */ - protected function assertFieldChecked($id) { + protected function assertFieldChecked($id, $message = '') { $this->assertSession()->checkboxChecked($id); } @@ -455,11 +465,16 @@ protected function assertFieldChecked($id) { * * @param string $id * ID of field to assert. + * @param string $message + * (optional) A message to display with the assertion. Do not translate + * messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed + * variables in the message text, not t(). If left blank, a default message + * will be displayed. * * @deprecated Scheduled for removal in Drupal 9.0.0. * Use $this->assertSession()->checkboxNotChecked() instead. */ - protected function assertNoFieldChecked($id) { + protected function assertNoFieldChecked($id, $message = '') { $this->assertSession()->checkboxNotChecked($id); } @@ -498,11 +513,16 @@ protected function assertNoEscaped($raw) { * * @param string $pattern * Perl regex to look for including the regex delimiters. + * @param string $message + * (optional) A message to display with the assertion. Do not translate + * messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed + * variables in the message text, not t(). If left blank, a default message + * will be displayed. * * @deprecated Scheduled for removal in Drupal 9.0.0. * Use $this->assertSession()->responseMatches() instead. */ - protected function assertPattern($pattern) { + protected function assertPattern($pattern, $message = '') { $this->assertSession()->responseMatches($pattern); }