diff --git a/core/tests/Drupal/KernelTests/AssertContentTrait.php b/core/tests/Drupal/KernelTests/AssertContentTrait.php
index ea06d26f..893fed72 100644
--- a/core/tests/Drupal/KernelTests/AssertContentTrait.php
+++ b/core/tests/Drupal/KernelTests/AssertContentTrait.php
@@ -293,16 +293,13 @@ protected function getAllOptions(\SimpleXMLElement $element) {
* in test output. Use 'Debug' to indicate this is debugging output. Do not
* translate this string. Defaults to 'Other'; most tests do not override
* this default.
- *
- * @return bool
- * TRUE if the assertion succeeded, FALSE otherwise.
*/
- protected function assertLink($label, $index = 0, $message = '', $group = 'Other') {
+ protected function assertLink($label, $index = 0, $message = '', $group = 'Other'): void {
// Cast MarkupInterface objects to string.
$label = (string) $label;
$links = $this->xpath('//a[normalize-space(text())=:label]', [':label' => $label]);
$message = ($message ? $message : strtr('Link with label %label found.', ['%label' => $label]));
- return $this->assert(isset($links[$index]), $message, $group);
+ $this->assert(isset($links[$index]), $message, $group);
}
/**
@@ -320,16 +317,13 @@ protected function assertLink($label, $index = 0, $message = '', $group = 'Other
* in test output. Use 'Debug' to indicate this is debugging output. Do not
* translate this string. Defaults to 'Other'; most tests do not override
* this default.
- *
- * @return bool
- * TRUE if the assertion succeeded, FALSE otherwise.
*/
- protected function assertNoLink($label, $message = '', $group = 'Other') {
+ protected function assertNoLink($label, $message = '', $group = 'Other'): void {
// Cast MarkupInterface objects to string.
$label = (string) $label;
$links = $this->xpath('//a[normalize-space(text())=:label]', [':label' => $label]);
$message = ($message ? $message : new FormattableMarkup('Link with label %label not found.', ['%label' => $label]));
- return $this->assert(empty($links), $message, $group);
+ $this->assert(empty($links), $message, $group);
}
/**
@@ -349,14 +343,11 @@ protected function assertNoLink($label, $message = '', $group = 'Other') {
* in test output. Use 'Debug' to indicate this is debugging output. Do not
* translate this string. Defaults to 'Other'; most tests do not override
* this default.
- *
- * @return bool
- * TRUE if the assertion succeeded, FALSE otherwise.
*/
- protected function assertLinkByHref($href, $index = 0, $message = '', $group = 'Other') {
+ protected function assertLinkByHref($href, $index = 0, $message = '', $group = 'Other'): void {
$links = $this->xpath('//a[contains(@href, :href)]', [':href' => $href]);
$message = ($message ? $message : new FormattableMarkup('Link containing href %href found.', ['%href' => $href]));
- return $this->assert(isset($links[$index]), $message, $group);
+ $this->assert(isset($links[$index]), $message, $group);
}
/**
@@ -374,14 +365,11 @@ protected function assertLinkByHref($href, $index = 0, $message = '', $group = '
* in test output. Use 'Debug' to indicate this is debugging output. Do not
* translate this string. Defaults to 'Other'; most tests do not override
* this default.
- *
- * @return bool
- * TRUE if the assertion succeeded, FALSE otherwise.
*/
- protected function assertNoLinkByHref($href, $message = '', $group = 'Other') {
+ protected function assertNoLinkByHref($href, $message = '', $group = 'Other'): void {
$links = $this->xpath('//a[contains(@href, :href)]', [':href' => $href]);
$message = ($message ? $message : new FormattableMarkup('No link containing href %href found.', ['%href' => $href]));
- return $this->assert(empty($links), $message, $group);
+ $this->assert(empty($links), $message, $group);
}
/**
@@ -399,14 +387,11 @@ protected function assertNoLinkByHref($href, $message = '', $group = 'Other') {
* in test output. Use 'Debug' to indicate this is debugging output. Do not
* translate this string. Defaults to 'Other'; most tests do not override
* this default.
- *
- * @return bool
- * TRUE if the assertion succeeded, FALSE otherwise.
*/
- protected function assertNoLinkByHrefInMainRegion($href, $message = '', $group = 'Other') {
+ protected function assertNoLinkByHrefInMainRegion($href, $message = '', $group = 'Other'): void {
$links = $this->xpath('//main//a[contains(@href, :href)]', [':href' => $href]);
$message = ($message ? $message : new FormattableMarkup('No link containing href %href found.', ['%href' => $href]));
- return $this->assert(empty($links), $message, $group);
+ $this->assert(empty($links), $message, $group);
}
/**
@@ -426,11 +411,8 @@ protected function assertNoLinkByHrefInMainRegion($href, $message = '', $group =
* in test output. Use 'Debug' to indicate this is debugging output. Do not
* translate this string. Defaults to 'Other'; most tests do not override
* this default.
- *
- * @return bool
- * TRUE on pass, FALSE on fail.
*/
- protected function assertRaw($raw, $message = '', $group = 'Other') {
+ protected function assertRaw($raw, $message = '', $group = 'Other'): void {
if (!$message) {
$message = 'Raw "' . Html::escape($raw) . '" found';
}
@@ -454,11 +436,8 @@ protected function assertRaw($raw, $message = '', $group = 'Other') {
* in test output. Use 'Debug' to indicate this is debugging output. Do not
* translate this string. Defaults to 'Other'; most tests do not override
* this default.
- *
- * @return bool
- * TRUE on pass, FALSE on fail.
*/
- protected function assertNoRaw($raw, $message = '', $group = 'Other') {
+ protected function assertNoRaw($raw, $message = '', $group = 'Other'): void {
if (!$message) {
$message = 'Raw "' . Html::escape($raw) . '" not found';
}
@@ -482,11 +461,8 @@ protected function assertNoRaw($raw, $message = '', $group = 'Other') {
* in test output. Use 'Debug' to indicate this is debugging output. Do not
* translate this string. Defaults to 'Other'; most tests do not override
* this default.
- *
- * @return bool
- * TRUE on pass, FALSE on fail.
*/
- protected function assertEscaped($raw, $message = '', $group = 'Other') {
+ protected function assertEscaped($raw, $message = '', $group = 'Other'): void {
if (!$message) {
$message = 'Escaped "' . Html::escape($raw) . '" found';
}
@@ -511,11 +487,8 @@ protected function assertEscaped($raw, $message = '', $group = 'Other') {
* in test output. Use 'Debug' to indicate this is debugging output. Do not
* translate this string. Defaults to 'Other'; most tests do not override
* this default.
- *
- * @return bool
- * TRUE on pass, FALSE on fail.
*/
- protected function assertNoEscaped($raw, $message = '', $group = 'Other') {
+ protected function assertNoEscaped($raw, $message = '', $group = 'Other'): void {
if (!$message) {
$message = 'Escaped "' . Html::escape($raw) . '" not found';
}
@@ -541,13 +514,10 @@ protected function assertNoEscaped($raw, $message = '', $group = 'Other') {
* translate this string. Defaults to 'Other'; most tests do not override
* this default.
*
- * @return bool
- * TRUE on pass, FALSE on fail.
- *
* @see \Drupal\simpletest\AssertContentTrait::assertRaw()
*/
- protected function assertText($text, $message = '', $group = 'Other') {
- return $this->assertTextHelper($text, $message, $group, FALSE);
+ protected function assertText($text, $message = '', $group = 'Other'): void {
+ $this->assertTextHelper($text, $message, $group, FALSE);
}
/**
@@ -569,13 +539,10 @@ protected function assertText($text, $message = '', $group = 'Other') {
* translate this string. Defaults to 'Other'; most tests do not override
* this default.
*
- * @return bool
- * TRUE on pass, FALSE on fail.
- *
* @see \Drupal\simpletest\AssertContentTrait::assertNoRaw()
*/
- protected function assertNoText($text, $message = '', $group = 'Other') {
- return $this->assertTextHelper($text, $message, $group, TRUE);
+ protected function assertNoText($text, $message = '', $group = 'Other'): void {
+ $this->assertTextHelper($text, $message, $group, TRUE);
}
/**
@@ -598,11 +565,8 @@ protected function assertNoText($text, $message = '', $group = 'Other') {
* @param bool $not_exists
* (optional) TRUE if this text should not exist, FALSE if it should.
* Defaults to TRUE.
- *
- * @return bool
- * TRUE on pass, FALSE on fail.
*/
- protected function assertTextHelper($text, $message = '', $group = 'Other', $not_exists = TRUE) {
+ protected function assertTextHelper($text, $message = '', $group = 'Other', $not_exists = TRUE): void {
if (!$message) {
$message = !$not_exists ? new FormattableMarkup('"@text" found', ['@text' => $text]) : new FormattableMarkup('"@text" not found', ['@text' => $text]);
}
@@ -633,12 +597,9 @@ protected function assertTextHelper($text, $message = '', $group = 'Other', $not
* in test output. Use 'Debug' to indicate this is debugging output. Do not
* translate this string. Defaults to 'Other'; most tests do not override
* this default.
- *
- * @return bool
- * TRUE on pass, FALSE on fail.
*/
- protected function assertUniqueText($text, $message = '', $group = 'Other') {
- return $this->assertUniqueTextHelper($text, $message, $group, TRUE);
+ protected function assertUniqueText($text, $message = '', $group = 'Other'): void {
+ $this->assertUniqueTextHelper($text, $message, $group, TRUE);
}
/**
@@ -660,12 +621,9 @@ protected function assertUniqueText($text, $message = '', $group = 'Other') {
* in test output. Use 'Debug' to indicate this is debugging output. Do not
* translate this string. Defaults to 'Other'; most tests do not override
* this default.
- *
- * @return bool
- * TRUE on pass, FALSE on fail.
*/
- protected function assertNoUniqueText($text, $message = '', $group = 'Other') {
- return $this->assertUniqueTextHelper($text, $message, $group, FALSE);
+ protected function assertNoUniqueText($text, $message = '', $group = 'Other'): void {
+ $this->assertUniqueTextHelper($text, $message, $group, FALSE);
}
/**
@@ -688,11 +646,8 @@ protected function assertNoUniqueText($text, $message = '', $group = 'Other') {
* @param bool $be_unique
* (optional) TRUE if this text should be found only once, FALSE if it
* should be found more than once. Defaults to FALSE.
- *
- * @return bool
- * TRUE on pass, FALSE on fail.
*/
- protected function assertUniqueTextHelper($text, $message = '', $group = 'Other', $be_unique = FALSE) {
+ protected function assertUniqueTextHelper($text, $message = '', $group = 'Other', $be_unique = FALSE): void {
// Cast MarkupInterface objects to string.
$text = (string) $text;
if (!$message) {
@@ -700,11 +655,12 @@ protected function assertUniqueTextHelper($text, $message = '', $group = 'Other'
}
$first_occurrence = strpos($this->getTextContent(), $text);
if ($first_occurrence === FALSE) {
- return $this->assert(FALSE, $message, $group);
+ $this->assert(FALSE, $message, $group);
+ return;
}
$offset = $first_occurrence + strlen($text);
$second_occurrence = strpos($this->getTextContent(), $text, $offset);
- return $this->assert($be_unique == ($second_occurrence === FALSE), $message, $group);
+ $this->assert($be_unique == ($second_occurrence === FALSE), $message, $group);
}
/**
@@ -722,15 +678,12 @@ protected function assertUniqueTextHelper($text, $message = '', $group = 'Other'
* in test output. Use 'Debug' to indicate this is debugging output. Do not
* translate this string. Defaults to 'Other'; most tests do not override
* this default.
- *
- * @return bool
- * TRUE on pass, FALSE on fail.
*/
- protected function assertPattern($pattern, $message = '', $group = 'Other') {
+ protected function assertPattern($pattern, $message = '', $group = 'Other'): void {
if (!$message) {
$message = new FormattableMarkup('Pattern "@pattern" found', ['@pattern' => $pattern]);
}
- return $this->assert((bool) preg_match($pattern, $this->getRawContent()), $message, $group);
+ $this->assert((bool) preg_match($pattern, $this->getRawContent()), $message, $group);
}
/**
@@ -748,15 +701,12 @@ protected function assertPattern($pattern, $message = '', $group = 'Other') {
* in test output. Use 'Debug' to indicate this is debugging output. Do not
* translate this string. Defaults to 'Other'; most tests do not override
* this default.
- *
- * @return bool
- * TRUE on pass, FALSE on fail.
*/
- protected function assertNoPattern($pattern, $message = '', $group = 'Other') {
+ protected function assertNoPattern($pattern, $message = '', $group = 'Other'): void {
if (!$message) {
$message = new FormattableMarkup('Pattern "@pattern" not found', ['@pattern' => $pattern]);
}
- return $this->assert(!preg_match($pattern, $this->getRawContent()), $message, $group);
+ $this->assert(!preg_match($pattern, $this->getRawContent()), $message, $group);
}
/**
@@ -771,15 +721,12 @@ protected function assertNoPattern($pattern, $message = '', $group = 'Other') {
* in test output. Use 'Debug' to indicate this is debugging output. Do not
* translate this string. Defaults to 'Other'; most tests do not override
* this default.
- *
- * @return bool
- * TRUE on pass, FALSE on failure.
*/
- protected function assertTextPattern($pattern, $message = NULL, $group = 'Other') {
+ protected function assertTextPattern($pattern, $message = NULL, $group = 'Other'): void {
if (!isset($message)) {
$message = new FormattableMarkup('Pattern "@pattern" found', ['@pattern' => $pattern]);
}
- return $this->assert((bool) preg_match($pattern, $this->getTextContent()), $message, $group);
+ $this->assert((bool) preg_match($pattern, $this->getTextContent()), $message, $group);
}
/**
@@ -797,11 +744,8 @@ protected function assertTextPattern($pattern, $message = NULL, $group = 'Other'
* in test output. Use 'Debug' to indicate this is debugging output. Do not
* translate this string. Defaults to 'Other'; most tests do not override
* this default.
- *
- * @return bool
- * TRUE on pass, FALSE on fail.
*/
- protected function assertTitle($title, $message = '', $group = 'Other') {
+ protected function assertTitle($title, $message = '', $group = 'Other'): void {
// Don't use xpath as it messes with HTML escaping.
preg_match('@
(.*)@', $this->getRawContent(), $matches);
if (isset($matches[1])) {
@@ -814,9 +758,9 @@ protected function assertTitle($title, $message = '', $group = 'Other') {
'@expected' => var_export($title, TRUE),
]);
}
- return $this->assertEqual($actual, $title, $message, $group);
+ $this->assertEqual($actual, $title, $message, $group);
}
- return $this->fail('No title element found on the page.');
+ $this->fail('No title element found on the page.');
}
/**
@@ -834,11 +778,8 @@ protected function assertTitle($title, $message = '', $group = 'Other') {
* in test output. Use 'Debug' to indicate this is debugging output. Do not
* translate this string. Defaults to 'Other'; most tests do not override
* this default.
- *
- * @return bool
- * TRUE on pass, FALSE on fail.
*/
- protected function assertNoTitle($title, $message = '', $group = 'Other') {
+ protected function assertNoTitle($title, $message = '', $group = 'Other'): void {
$actual = (string) current($this->xpath('//title'));
if (!$message) {
$message = new FormattableMarkup('Page title @actual is not equal to @unexpected.', [
@@ -846,7 +787,7 @@ protected function assertNoTitle($title, $message = '', $group = 'Other') {
'@unexpected' => var_export($title, TRUE),
]);
}
- return $this->assertNotEqual($actual, $title, $message, $group);
+ $this->assertNotEqual($actual, $title, $message, $group);
}
/**
@@ -868,11 +809,8 @@ protected function assertNoTitle($title, $message = '', $group = 'Other') {
* in test output. Use 'Debug' to indicate this is debugging output. Do not
* translate this string. Defaults to 'Other'; most tests do not override
* this default.
- *
- * @return bool
- * TRUE on pass, FALSE on fail.
*/
- protected function assertThemeOutput($callback, array $variables = [], $expected = '', $message = '', $group = 'Other') {
+ protected function assertThemeOutput($callback, array $variables = [], $expected = '', $message = '', $group = 'Other'): void {
/** @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer = \Drupal::service('renderer');
@@ -891,7 +829,7 @@ protected function assertThemeOutput($callback, array $variables = [], $expected
$message = '%callback rendered correctly.';
}
$message = new FormattableMarkup($message, ['%callback' => 'theme_' . $callback . '()']);
- return $this->assertIdentical($output, $expected, $message, $group);
+ $this->assertIdentical($output, $expected, $message, $group);
}
/**
@@ -912,11 +850,8 @@ protected function assertThemeOutput($callback, array $variables = [], $expected
* in test output. Use 'Debug' to indicate this is debugging output. Do not
* translate this string. Defaults to 'Other'; most tests do not override
* this default.
- *
- * @return bool
- * TRUE on pass, FALSE on fail.
*/
- protected function assertFieldsByValue($fields, $value = NULL, $message = '', $group = 'Other') {
+ protected function assertFieldsByValue($fields, $value = NULL, $message = '', $group = 'Other'): void {
// If value specified then check array for match.
$found = TRUE;
if (isset($value)) {
@@ -948,7 +883,7 @@ protected function assertFieldsByValue($fields, $value = NULL, $message = '', $g
}
}
}
- return $this->assertTrue($fields && $found, $message, $group);
+ $this->assertTrue($fields && $found, $message, $group);
}
/**
@@ -970,14 +905,11 @@ protected function assertFieldsByValue($fields, $value = NULL, $message = '', $g
* in test output. Use 'Debug' to indicate this is debugging output. Do not
* translate this string. Defaults to 'Other'; most tests do not override
* this default.
- *
- * @return bool
- * TRUE on pass, FALSE on fail.
*/
- protected function assertFieldByXPath($xpath, $value = NULL, $message = '', $group = 'Other') {
+ protected function assertFieldByXPath($xpath, $value = NULL, $message = '', $group = 'Other'): void {
$fields = $this->xpath($xpath);
- return $this->assertFieldsByValue($fields, $value, $message, $group);
+ $this->assertFieldsByValue($fields, $value, $message, $group);
}
/**
@@ -1021,11 +953,8 @@ protected function getSelectedItem(\SimpleXMLElement $element) {
* in test output. Use 'Debug' to indicate this is debugging output. Do not
* translate this string. Defaults to 'Other'; most tests do not override
* this default.
- *
- * @return bool
- * TRUE on pass, FALSE on fail.
*/
- protected function assertNoFieldByXPath($xpath, $value = NULL, $message = '', $group = 'Other') {
+ protected function assertNoFieldByXPath($xpath, $value = NULL, $message = '', $group = 'Other'): void {
$fields = $this->xpath($xpath);
// If value specified then check array for match.
@@ -1040,7 +969,7 @@ protected function assertNoFieldByXPath($xpath, $value = NULL, $message = '', $g
}
}
}
- return $this->assertFalse($fields && $found, $message, $group);
+ $this->assertFalse($fields && $found, $message, $group);
}
/**
@@ -1062,11 +991,8 @@ protected function assertNoFieldByXPath($xpath, $value = NULL, $message = '', $g
* in test output. Use 'Debug' to indicate this is debugging output. Do not
* translate this string. Defaults to 'Browser'; most tests do not override
* this default.
- *
- * @return bool
- * TRUE on pass, FALSE on fail.
*/
- protected function assertFieldByName($name, $value = NULL, $message = NULL, $group = 'Browser') {
+ protected function assertFieldByName($name, $value = NULL, $message = NULL, $group = 'Browser'): void {
if (!isset($message)) {
if (!isset($value)) {
$message = new FormattableMarkup('Found field with name @name', [
@@ -1080,7 +1006,7 @@ protected function assertFieldByName($name, $value = NULL, $message = NULL, $gro
]);
}
}
- return $this->assertFieldByXPath($this->constructFieldXpath('name', $name), $value, $message, $group);
+ $this->assertFieldByXPath($this->constructFieldXpath('name', $name), $value, $message, $group);
}
/**
@@ -1103,12 +1029,9 @@ protected function assertFieldByName($name, $value = NULL, $message = NULL, $gro
* in test output. Use 'Debug' to indicate this is debugging output. Do not
* translate this string. Defaults to 'Browser'; most tests do not override
* this default.
- *
- * @return bool
- * TRUE on pass, FALSE on fail.
*/
- protected function assertNoFieldByName($name, $value = '', $message = '', $group = 'Browser') {
- return $this->assertNoFieldByXPath($this->constructFieldXpath('name', $name), $value, $message ? $message : new FormattableMarkup('Did not find field by name @name', ['@name' => $name]), $group);
+ protected function assertNoFieldByName($name, $value = '', $message = '', $group = 'Browser'): void {
+ $this->assertNoFieldByXPath($this->constructFieldXpath('name', $name), $value, $message ? $message : new FormattableMarkup('Did not find field by name @name', ['@name' => $name]), $group);
}
/**
@@ -1131,17 +1054,15 @@ protected function assertNoFieldByName($name, $value = '', $message = '', $group
* in test output. Use 'Debug' to indicate this is debugging output. Do not
* translate this string. Defaults to 'Browser'; most tests do not override
* this default.
- *
- * @return bool
- * TRUE on pass, FALSE on fail.
*/
- protected function assertFieldById($id, $value = '', $message = '', $group = 'Browser') {
+ protected function assertFieldById($id, $value = '', $message = '', $group = 'Browser'): void {
// Cast MarkupInterface objects to string.
+ // @todo remove casting
if (isset($value)) {
$value = (string) $value;
}
$message = (string) $message;
- return $this->assertFieldByXPath($this->constructFieldXpath('id', $id), $value, $message ? $message : new FormattableMarkup('Found field by id @id', ['@id' => $id]), $group);
+ $this->assertFieldByXPath($this->constructFieldXpath('id', $id), $value, $message ? $message : new FormattableMarkup('Found field by id @id', ['@id' => $id]), $group);
}
/**
@@ -1164,12 +1085,9 @@ protected function assertFieldById($id, $value = '', $message = '', $group = 'Br
* in test output. Use 'Debug' to indicate this is debugging output. Do not
* translate this string. Defaults to 'Browser'; most tests do not override
* this default.
- *
- * @return bool
- * TRUE on pass, FALSE on fail.
*/
- protected function assertNoFieldById($id, $value = '', $message = '', $group = 'Browser') {
- return $this->assertNoFieldByXPath($this->constructFieldXpath('id', $id), $value, $message ? $message : new FormattableMarkup('Did not find field by id @id', ['@id' => $id]), $group);
+ protected function assertNoFieldById($id, $value = '', $message = '', $group = 'Browser'): void {
+ $this->assertNoFieldByXPath($this->constructFieldXpath('id', $id), $value, $message ? $message : new FormattableMarkup('Did not find field by id @id', ['@id' => $id]), $group);
}
/**
@@ -1187,13 +1105,10 @@ protected function assertNoFieldById($id, $value = '', $message = '', $group = '
* in test output. Use 'Debug' to indicate this is debugging output. Do not
* translate this string. Defaults to 'Browser'; most tests do not override
* this default.
- *
- * @return bool
- * TRUE on pass, FALSE on fail.
*/
- protected function assertFieldChecked($id, $message = '', $group = 'Browser') {
+ protected function assertFieldChecked($id, $message = '', $group = 'Browser'): void {
$elements = $this->xpath('//input[@id=:id]', [':id' => $id]);
- return $this->assertTrue(isset($elements[0]) && !empty($elements[0]['checked']), $message ? $message : new FormattableMarkup('Checkbox field @id is checked.', ['@id' => $id]), $group);
+ $this->assertTrue(isset($elements[0]) && !empty($elements[0]['checked']), $message ? $message : new FormattableMarkup('Checkbox field @id is checked.', ['@id' => $id]), $group);
}
/**
@@ -1211,13 +1126,10 @@ protected function assertFieldChecked($id, $message = '', $group = 'Browser') {
* in test output. Use 'Debug' to indicate this is debugging output. Do not
* translate this string. Defaults to 'Browser'; most tests do not override
* this default.
- *
- * @return bool
- * TRUE on pass, FALSE on fail.
*/
- protected function assertNoFieldChecked($id, $message = '', $group = 'Browser') {
+ protected function assertNoFieldChecked($id, $message = '', $group = 'Browser'): void {
$elements = $this->xpath('//input[@id=:id]', [':id' => $id]);
- return $this->assertTrue(isset($elements[0]) && empty($elements[0]['checked']), $message ? $message : new FormattableMarkup('Checkbox field @id is not checked.', ['@id' => $id]), $group);
+ $this->assertTrue(isset($elements[0]) && empty($elements[0]['checked']), $message ? $message : new FormattableMarkup('Checkbox field @id is not checked.', ['@id' => $id]), $group);
}
/**
@@ -1237,13 +1149,10 @@ protected function assertNoFieldChecked($id, $message = '', $group = 'Browser')
* in test output. Use 'Debug' to indicate this is debugging output. Do not
* translate this string. Defaults to 'Browser'; most tests do not override
* this default.
- *
- * @return bool
- * TRUE on pass, FALSE on fail.
*/
- protected function assertOption($id, $option, $message = '', $group = 'Browser') {
+ protected function assertOption($id, $option, $message = '', $group = 'Browser'): void {
$options = $this->xpath('//select[@id=:id]//option[@value=:option]', [':id' => $id, ':option' => $option]);
- return $this->assertTrue(isset($options[0]), $message ? $message : new FormattableMarkup('Option @option for field @id exists.', ['@option' => $option, '@id' => $id]), $group);
+ $this->assertTrue(isset($options[0]), $message ? $message : new FormattableMarkup('Option @option for field @id exists.', ['@option' => $option, '@id' => $id]), $group);
}
/**
@@ -1255,13 +1164,10 @@ protected function assertOption($id, $option, $message = '', $group = 'Browser')
* The text for the option tag to assert.
* @param string $message
* (optional) A message to display with the assertion.
- *
- * @return bool
- * TRUE on pass, FALSE on fail.
*/
- protected function assertOptionByText($id, $text, $message = '') {
+ protected function assertOptionByText($id, $text, $message = ''): void {
$options = $this->xpath('//select[@id=:id]//option[normalize-space(text())=:text]', [':id' => $id, ':text' => $text]);
- return $this->assertTrue(isset($options[0]), $message ?: 'Option with text label ' . $text . ' for select field ' . $id . ' exits.');
+ $this->assertTrue(isset($options[0]), $message ?: 'Option with text label ' . $text . ' for select field ' . $id . ' exits.');
}
/**
@@ -1281,13 +1187,10 @@ protected function assertOptionByText($id, $text, $message = '') {
* in test output. Use 'Debug' to indicate this is debugging output. Do not
* translate this string. Defaults to 'Browser'; most tests do not override
* this default.
- *
- * @return bool
- * TRUE on pass, FALSE on fail.
*/
- protected function assertOptionWithDrupalSelector($drupal_selector, $option, $message = '', $group = 'Browser') {
+ protected function assertOptionWithDrupalSelector($drupal_selector, $option, $message = '', $group = 'Browser'): void {
$options = $this->xpath('//select[@data-drupal-selector=:data_drupal_selector]//option[@value=:option]', [':data_drupal_selector' => $drupal_selector, ':option' => $option]);
- return $this->assertTrue(isset($options[0]), $message ? $message : new FormattableMarkup('Option @option for field @data_drupal_selector exists.', ['@option' => $option, '@data_drupal_selector' => $drupal_selector]), $group);
+ $this->assertTrue(isset($options[0]), $message ? $message : new FormattableMarkup('Option @option for field @data_drupal_selector exists.', ['@option' => $option, '@data_drupal_selector' => $drupal_selector]), $group);
}
/**
@@ -1307,14 +1210,11 @@ protected function assertOptionWithDrupalSelector($drupal_selector, $option, $me
* in test output. Use 'Debug' to indicate this is debugging output. Do not
* translate this string. Defaults to 'Browser'; most tests do not override
* this default.
- *
- * @return bool
- * TRUE on pass, FALSE on fail.
*/
- protected function assertNoOption($id, $option, $message = '', $group = 'Browser') {
+ protected function assertNoOption($id, $option, $message = '', $group = 'Browser'): void {
$selects = $this->xpath('//select[@id=:id]', [':id' => $id]);
$options = $this->xpath('//select[@id=:id]//option[@value=:option]', [':id' => $id, ':option' => $option]);
- return $this->assertTrue(isset($selects[0]) && !isset($options[0]), $message ? $message : new FormattableMarkup('Option @option for field @id does not exist.', ['@option' => $option, '@id' => $id]), $group);
+ $this->assertTrue(isset($selects[0]) && !isset($options[0]), $message ? $message : new FormattableMarkup('Option @option for field @id does not exist.', ['@option' => $option, '@id' => $id]), $group);
}
/**
@@ -1335,14 +1235,11 @@ protected function assertNoOption($id, $option, $message = '', $group = 'Browser
* translate this string. Defaults to 'Browser'; most tests do not override
* this default.
*
- * @return bool
- * TRUE on pass, FALSE on fail.
- *
* @todo $id is unusable. Replace with $name.
*/
- protected function assertOptionSelected($id, $option, $message = '', $group = 'Browser') {
+ protected function assertOptionSelected($id, $option, $message = '', $group = 'Browser'): void {
$elements = $this->xpath('//select[@id=:id]//option[@value=:option]', [':id' => $id, ':option' => $option]);
- return $this->assertTrue(isset($elements[0]) && !empty($elements[0]['selected']), $message ? $message : new FormattableMarkup('Option @option for field @id is selected.', ['@option' => $option, '@id' => $id]), $group);
+ $this->assertTrue(isset($elements[0]) && !empty($elements[0]['selected']), $message ? $message : new FormattableMarkup('Option @option for field @id is selected.', ['@option' => $option, '@id' => $id]), $group);
}
/**
@@ -1363,14 +1260,11 @@ protected function assertOptionSelected($id, $option, $message = '', $group = 'B
* translate this string. Defaults to 'Browser'; most tests do not override
* this default.
*
- * @return bool
- * TRUE on pass, FALSE on fail.
- *
* @todo $id is unusable. Replace with $name.
*/
protected function assertOptionSelectedWithDrupalSelector($drupal_selector, $option, $message = '', $group = 'Browser') {
$elements = $this->xpath('//select[@data-drupal-selector=:data_drupal_selector]//option[@value=:option]', [':data_drupal_selector' => $drupal_selector, ':option' => $option]);
- return $this->assertTrue(isset($elements[0]) && !empty($elements[0]['selected']), $message ? $message : new FormattableMarkup('Option @option for field @data_drupal_selector is selected.', ['@option' => $option, '@data_drupal_selector' => $drupal_selector]), $group);
+ $this->assertTrue(isset($elements[0]) && !empty($elements[0]['selected']), $message ? $message : new FormattableMarkup('Option @option for field @data_drupal_selector is selected.', ['@option' => $option, '@data_drupal_selector' => $drupal_selector]), $group);
}
/**
@@ -1390,13 +1284,10 @@ protected function assertOptionSelectedWithDrupalSelector($drupal_selector, $opt
* in test output. Use 'Debug' to indicate this is debugging output. Do not
* translate this string. Defaults to 'Browser'; most tests do not override
* this default.
- *
- * @return bool
- * TRUE on pass, FALSE on fail.
*/
- protected function assertNoOptionSelected($id, $option, $message = '', $group = 'Browser') {
+ protected function assertNoOptionSelected($id, $option, $message = '', $group = 'Browser'): void {
$elements = $this->xpath('//select[@id=:id]//option[@value=:option]', [':id' => $id, ':option' => $option]);
- return $this->assertTrue(isset($elements[0]) && empty($elements[0]['selected']), $message ? $message : new FormattableMarkup('Option @option for field @id is not selected.', ['@option' => $option, '@id' => $id]), $group);
+ $this->assertTrue(isset($elements[0]) && empty($elements[0]['selected']), $message ? $message : new FormattableMarkup('Option @option for field @id is not selected.', ['@option' => $option, '@id' => $id]), $group);
}
/**
@@ -1414,12 +1305,9 @@ protected function assertNoOptionSelected($id, $option, $message = '', $group =
* in test output. Use 'Debug' to indicate this is debugging output. Do not
* translate this string. Defaults to 'Other'; most tests do not override
* this default.
- *
- * @return bool
- * TRUE on pass, FALSE on fail.
*/
- protected function assertField($field, $message = '', $group = 'Other') {
- return $this->assertFieldByXPath($this->constructFieldXpath('name', $field) . '|' . $this->constructFieldXpath('id', $field), NULL, $message, $group);
+ protected function assertField($field, $message = '', $group = 'Other'): void {
+ $this->assertFieldByXPath($this->constructFieldXpath('name', $field) . '|' . $this->constructFieldXpath('id', $field), NULL, $message, $group);
}
/**
@@ -1437,12 +1325,9 @@ protected function assertField($field, $message = '', $group = 'Other') {
* in test output. Use 'Debug' to indicate this is debugging output. Do not
* translate this string. Defaults to 'Other'; most tests do not override
* this default.
- *
- * @return bool
- * TRUE on pass, FALSE on fail.
*/
- protected function assertNoField($field, $message = '', $group = 'Other') {
- return $this->assertNoFieldByXPath($this->constructFieldXpath('name', $field) . '|' . $this->constructFieldXpath('id', $field), NULL, $message, $group);
+ protected function assertNoField($field, $message = '', $group = 'Other'): void {
+ $this->assertNoFieldByXPath($this->constructFieldXpath('name', $field) . '|' . $this->constructFieldXpath('id', $field), NULL, $message, $group);
}
/**
@@ -1465,11 +1350,8 @@ protected function assertNoField($field, $message = '', $group = 'Other') {
* it should add a "todo" comment above the call to this function explaining
* the legacy bug that the test wishes to ignore and including a link to an
* issue that is working to fix that legacy bug.
- *
- * @return bool
- * TRUE on pass, FALSE on fail.
*/
- protected function assertNoDuplicateIds($message = '', $group = 'Other', $ids_to_skip = []) {
+ protected function assertNoDuplicateIds($message = '', $group = 'Other', $ids_to_skip = []): void {
$status = TRUE;
foreach ($this->xpath('//*[@id]') as $element) {
$id = (string) $element['id'];
@@ -1479,7 +1361,7 @@ protected function assertNoDuplicateIds($message = '', $group = 'Other', $ids_to
}
$seen_ids[$id] = TRUE;
}
- return $this->assert($status, $message, $group);
+ $this->assert($status, $message, $group);
}
/**
diff --git a/core/tests/Drupal/KernelTests/Core/Ajax/CommandsTest.php b/core/tests/Drupal/KernelTests/Core/Ajax/CommandsTest.php
index faf8cadb..b4cb7ce0 100644
--- a/core/tests/Drupal/KernelTests/Core/Ajax/CommandsTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Ajax/CommandsTest.php
@@ -95,7 +95,7 @@ public function testEmptyInsertCommand() {
* @param $message
* An assertion message.
*/
- protected function assertCommand($haystack, $needle, $message) {
+ protected function assertCommand($haystack, $needle, $message): void {
$found = FALSE;
foreach ($haystack as $command) {
// If the command has additional settings that we're not testing for, do
diff --git a/core/tests/Drupal/KernelTests/Core/Asset/LibraryDiscoveryIntegrationTest.php b/core/tests/Drupal/KernelTests/Core/Asset/LibraryDiscoveryIntegrationTest.php
index fc059732..754e2925 100644
--- a/core/tests/Drupal/KernelTests/Core/Asset/LibraryDiscoveryIntegrationTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Asset/LibraryDiscoveryIntegrationTest.php
@@ -246,21 +246,19 @@ protected function activateTheme($theme_name) {
* The library sub key where the given asset is defined.
* @param string $message
* (optional) A message to display with the assertion.
- *
- * @return bool
- * TRUE if the specified asset is found in the library.
*/
- protected function assertAssetInLibrary($asset, $extension, $library_name, $sub_key, $message = NULL) {
+ protected function assertAssetInLibrary($asset, $extension, $library_name, $sub_key, $message = NULL): void {
if (!isset($message)) {
$message = sprintf('Asset %s found in library "%s/%s"', $asset, $extension, $library_name);
}
$library = $this->libraryDiscovery->getLibraryByName($extension, $library_name);
+ // @todo refactor here to remove use of pass()
foreach ($library[$sub_key] as $definition) {
if ($asset == $definition['data']) {
- return $this->pass($message);
+ $this->pass($message);
}
}
- return $this->fail($message);
+ $this->fail($message);
}
/**
@@ -276,21 +274,18 @@ protected function assertAssetInLibrary($asset, $extension, $library_name, $sub_
* The library sub key where the given asset is defined.
* @param string $message
* (optional) A message to display with the assertion.
- *
- * @return bool
- * TRUE if the specified asset is not found in the library.
*/
- protected function assertNoAssetInLibrary($asset, $extension, $library_name, $sub_key, $message = NULL) {
+ protected function assertNoAssetInLibrary($asset, $extension, $library_name, $sub_key, $message = NULL): void {
if (!isset($message)) {
$message = sprintf('Asset %s not found in library "%s/%s"', $asset, $extension, $library_name);
}
$library = $this->libraryDiscovery->getLibraryByName($extension, $library_name);
foreach ($library[$sub_key] as $definition) {
if ($asset == $definition['data']) {
- return $this->fail($message);
+ $this->fail($message);
+ return;
}
}
- return $this->pass($message);
}
}
diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigDiffTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigDiffTest.php
index 0ad2e2c8..5b09267e 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/ConfigDiffTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigDiffTest.php
@@ -152,7 +152,7 @@ public function testCollectionDiff() {
* (optional) The closing value of the edit. If not supplied, assertion
* is skipped.
*/
- protected function assertYamlEdit(array $edits, $field, $type, $orig = NULL, $closing = NULL) {
+ protected function assertYamlEdit(array $edits, $field, $type, $orig = NULL, $closing = NULL): void {
$match = FALSE;
foreach ($edits as $edit) {
// Choose which section to search for the field.
diff --git a/core/tests/Drupal/KernelTests/Core/Database/ConnectionUnitTest.php b/core/tests/Drupal/KernelTests/Core/Database/ConnectionUnitTest.php
index 6380d716..37e64d64 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/ConnectionUnitTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/ConnectionUnitTest.php
@@ -76,9 +76,9 @@ protected function getConnectionId() {
* @param int $id
* The connection ID to verify.
*/
- protected function assertConnection($id) {
+ protected function assertConnection($id): void {
$list = $this->monitor->query('SHOW PROCESSLIST')->fetchAllKeyed(0, 0);
- return $this->assertTrue(isset($list[$id]), new FormattableMarkup('Connection ID @id found.', ['@id' => $id]));
+ $this->assertTrue(isset($list[$id]), new FormattableMarkup('Connection ID @id found.', ['@id' => $id]));
}
/**
@@ -87,9 +87,9 @@ protected function assertConnection($id) {
* @param int $id
* The connection ID to verify.
*/
- protected function assertNoConnection($id) {
+ protected function assertNoConnection($id): void {
$list = $this->monitor->query('SHOW PROCESSLIST')->fetchAllKeyed(0, 0);
- return $this->assertFalse(isset($list[$id]), new FormattableMarkup('Connection ID @id not found.', ['@id' => $id]));
+ $this->assertFalse(isset($list[$id]), new FormattableMarkup('Connection ID @id not found.', ['@id' => $id]));
}
/**
diff --git a/core/tests/Drupal/KernelTests/Core/Database/SchemaTest.php b/core/tests/Drupal/KernelTests/Core/Database/SchemaTest.php
index aef1c741..f72145d3 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/SchemaTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/SchemaTest.php
@@ -675,7 +675,7 @@ public function testSchemaAddFieldDefaultInitial() {
* @param $field_spec
* The schema specification of the field.
*/
- protected function assertFieldAdditionRemoval($field_spec) {
+ protected function assertFieldAdditionRemoval($field_spec): void {
// Try creating the field on a new table.
$table_name = 'test_table_' . ($this->counter++);
$table_spec = [
@@ -741,7 +741,7 @@ protected function assertFieldAdditionRemoval($field_spec) {
/**
* Asserts that a newly added field has the correct characteristics.
*/
- protected function assertFieldCharacteristics($table_name, $field_name, $field_spec) {
+ protected function assertFieldCharacteristics($table_name, $field_name, $field_spec): void {
// Check that the initial value has been registered.
if (isset($field_spec['initial'])) {
// There should be no row with a value different then $field_spec['initial'].
@@ -1015,7 +1015,7 @@ public function testSchemaChangeFieldDefaultInitial() {
* @param $new_spec
* The ending field specification.
*/
- protected function assertFieldChange($old_spec, $new_spec, $test_data = NULL) {
+ protected function assertFieldChange($old_spec, $new_spec, $test_data = NULL): void {
$table_name = 'test_table_' . ($this->counter++);
$table_spec = [
'fields' => [
diff --git a/core/tests/Drupal/KernelTests/Core/Database/TransactionTest.php b/core/tests/Drupal/KernelTests/Core/Database/TransactionTest.php
index 02981160..dbcbd79e 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/TransactionTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/TransactionTest.php
@@ -319,12 +319,12 @@ protected function cleanUp() {
* @param $message
* The message to log for the assertion.
*/
- public function assertRowPresent($name, $message = NULL) {
+ public function assertRowPresent($name, $message = NULL): void {
if (!isset($message)) {
$message = new FormattableMarkup('Row %name is present.', ['%name' => $name]);
}
$present = (boolean) $this->connection->query('SELECT 1 FROM {test} WHERE name = :name', [':name' => $name])->fetchField();
- return $this->assertTrue($present, $message);
+ $this->assertTrue($present, $message);
}
/**
@@ -335,12 +335,12 @@ public function assertRowPresent($name, $message = NULL) {
* @param $message
* The message to log for the assertion.
*/
- public function assertRowAbsent($name, $message = NULL) {
+ public function assertRowAbsent($name, $message = NULL): void {
if (!isset($message)) {
$message = new FormattableMarkup('Row %name is absent.', ['%name' => $name]);
}
$present = (boolean) $this->connection->query('SELECT 1 FROM {test} WHERE name = :name', [':name' => $name])->fetchField();
- return $this->assertFalse($present, $message);
+ $this->assertFalse($present, $message);
}
/**
diff --git a/core/tests/Drupal/KernelTests/Core/Datetime/Element/TimezoneTest.php b/core/tests/Drupal/KernelTests/Core/Datetime/Element/TimezoneTest.php
index 0e790af4..836f7d07 100644
--- a/core/tests/Drupal/KernelTests/Core/Datetime/Element/TimezoneTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Datetime/Element/TimezoneTest.php
@@ -253,7 +253,7 @@ public function testDatelistTimezonePropertyProcessed() {
*
* @throws \Exception
*/
- protected function assertTimesUnderstoodCorrectly($elementType, array $inputs) {
+ protected function assertTimesUnderstoodCorrectly($elementType, array $inputs): void {
$this->elementType = $elementType;
// Simulate the form being saved, with the user adding the date for any
@@ -327,7 +327,7 @@ protected function assertTimesUnderstoodCorrectly($elementType, array $inputs) {
*
* @throws \Exception
*/
- public function assertDateTimezonePropertyProcessed($elementType) {
+ public function assertDateTimezonePropertyProcessed($elementType): void {
$this->elementType = $elementType;
// Simulate form being loaded and default values displayed to user.
$form_state = new FormState();
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/BundleConstraintValidatorTest.php b/core/tests/Drupal/KernelTests/Core/Entity/BundleConstraintValidatorTest.php
index f2421d99..6c21556a 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/BundleConstraintValidatorTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/BundleConstraintValidatorTest.php
@@ -43,7 +43,7 @@ public function testValidation() {
* @param string|array $bundle
* Bundle/bundles to use as constraint option.
*/
- protected function assertValidation($bundle) {
+ protected function assertValidation($bundle): void {
// Create a typed data definition with a Bundle constraint.
$definition = DataDefinition::create('entity_reference')
->addConstraint('Bundle', $bundle);
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityQueryTest.php b/core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityQueryTest.php
index 53a80abc..7aba40e3 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityQueryTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityQueryTest.php
@@ -688,7 +688,7 @@ public function testLookupKeys() {
* @param array $expected
* Array of expected entity IDs.
*/
- protected function assertResults($expected) {
+ protected function assertResults($expected): void {
$this->assertIdentical(count($this->queryResults), count($expected));
foreach ($expected as $value) {
// This also tests whether $this->queryResults[$value] is even set at all.
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityAccessControlHandlerTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityAccessControlHandlerTest.php
index c6b7ae33..df534560 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityAccessControlHandlerTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityAccessControlHandlerTest.php
@@ -39,7 +39,7 @@ public function setUp(): void {
/**
* Asserts entity access correctly grants or denies access.
*/
- public function assertEntityAccess($ops, AccessibleInterface $object, AccountInterface $account = NULL) {
+ public function assertEntityAccess($ops, AccessibleInterface $object, AccountInterface $account = NULL): void {
foreach ($ops as $op => $result) {
$message = new FormattableMarkup("Entity access returns @result with operation '@op'.", [
'@result' => !isset($result) ? 'null' : ($result ? 'true' : 'false'),
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityApiTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityApiTest.php
index 3bebe79b..2142f51d 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityApiTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityApiTest.php
@@ -47,7 +47,7 @@ public function testCRUD() {
* @param \Drupal\user\UserInterface $user1
* The user to run the tests with.
*/
- protected function assertCRUD($entity_type, UserInterface $user1) {
+ protected function assertCRUD($entity_type, UserInterface $user1): void {
// Create some test entities.
$entity = $this->container->get('entity_type.manager')
->getStorage($entity_type)
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityCrudHookTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityCrudHookTest.php
index 5c4fd427..14ddec53 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityCrudHookTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityCrudHookTest.php
@@ -71,7 +71,7 @@ protected function setUp(): void {
* @param $messages
* An array of plain-text messages in the order they should appear.
*/
- protected function assertHookMessageOrder($messages) {
+ protected function assertHookMessageOrder($messages): void {
$positions = [];
foreach ($messages as $message) {
// Verify that each message is found and record its position.
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldDefaultValueTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldDefaultValueTest.php
index c8ddc84c..b9b7542b 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldDefaultValueTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldDefaultValueTest.php
@@ -41,7 +41,7 @@ public function testDefaultValues() {
* @param string $entity_type_id
* The entity type to run the tests with.
*/
- protected function assertDefaultValues($entity_type_id) {
+ protected function assertDefaultValues($entity_type_id): void {
$entity = $this->container->get('entity_type.manager')
->getStorage($entity_type_id)
->create();
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryAggregateTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryAggregateTest.php
index 6b88d40a..5f9f36c2 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryAggregateTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryAggregateTest.php
@@ -579,7 +579,7 @@ public function testRepeatedExecution() {
* @param array $expected
* An array of the expected results.
*/
- protected function assertResults($expected, $sorted = FALSE) {
+ protected function assertResults($expected, $sorted = FALSE): void {
$found = TRUE;
$expected_keys = array_keys($expected);
foreach ($this->queryResult as $key => $row) {
@@ -593,7 +593,7 @@ protected function assertResults($expected, $sorted = FALSE) {
$found = FALSE;
break;
}
- return $this->assertTrue($found, strtr('!expected expected, !found found', ['!expected' => print_r($expected, TRUE), '!found' => print_r($this->queryResult, TRUE)]));
+ $this->assertTrue($found, strtr('!expected expected, !found found', ['!expected' => print_r($expected, TRUE), '!found' => print_r($this->queryResult, TRUE)]));
}
/**
@@ -602,8 +602,8 @@ protected function assertResults($expected, $sorted = FALSE) {
* @param array $expected
* An array of the expected results.
*/
- protected function assertSortedResults($expected) {
- return $this->assertResults($expected, TRUE);
+ protected function assertSortedResults($expected): void {
+ $this->assertResults($expected, TRUE);
}
}
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryRelationshipTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryRelationshipTest.php
index 985d1b8a..1fb0a064 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryRelationshipTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryRelationshipTest.php
@@ -210,7 +210,7 @@ public function testInvalidSpecifier() {
* @param array $expected
* A list of indexes in the $this->entities array.
*/
- protected function assertResults($expected) {
+ protected function assertResults($expected): void {
$this->assertEqual(count($this->queryResults), count($expected));
foreach ($expected as $key) {
$id = $this->entities[$key]->id();
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryTest.php
index 18d62125..7b5c5073 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryTest.php
@@ -677,7 +677,7 @@ public function testDelta() {
}
- protected function assertResult() {
+ protected function assertResult(): void {
$assert = [];
$expected = func_get_args();
if ($expected && is_array($expected[0])) {
@@ -689,16 +689,15 @@ protected function assertResult() {
$this->assertIdentical($this->queryResults, $assert);
}
- protected function assertRevisionResult($keys, $expected) {
+ protected function assertRevisionResult($keys, $expected): void {
$assert = [];
foreach ($expected as $key => $binary) {
$assert[$keys[$key]] = strval($binary);
}
$this->assertIdentical($this->queryResults, $assert);
- return $assert;
}
- protected function assertBundleOrder($order) {
+ protected function assertBundleOrder($order): void {
// This loop is for bundle1 entities.
for ($i = 1; $i <= 15; $i += 2) {
$ok = TRUE;
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityReferenceFieldTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityReferenceFieldTest.php
index 3c7faa51..43ff0831 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityReferenceFieldTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityReferenceFieldTest.php
@@ -333,11 +333,8 @@ public function testAutocreateApi() {
* The referencing entity.
* @param $setter_callback
* A callback setting the target entity on the referencing entity.
- *
- * @return bool
- * TRUE if the user was autocreated, FALSE otherwise.
*/
- protected function assertUserAutocreate(EntityInterface $entity, $setter_callback) {
+ protected function assertUserAutocreate(EntityInterface $entity, $setter_callback): void {
$storage = $this->entityTypeManager->getStorage('user');
$user_id = $this->generateRandomEntityId();
$user = $storage->create(['uid' => $user_id, 'name' => $this->randomString()]);
@@ -345,7 +342,7 @@ protected function assertUserAutocreate(EntityInterface $entity, $setter_callbac
$entity->save();
$storage->resetCache();
$user = User::load($user_id);
- return $this->assertEqual($entity->user_id->target_id, $user->id());
+ $this->assertEqual($entity->user_id->target_id, $user->id());
}
/**
@@ -355,11 +352,8 @@ protected function assertUserAutocreate(EntityInterface $entity, $setter_callbac
* The referencing entity.
* @param $setter_callback
* A callback setting the target entity on the referencing entity.
- *
- * @return bool
- * TRUE if the user was autocreated, FALSE otherwise.
*/
- protected function assertUserRoleAutocreate(EntityInterface $entity, $setter_callback) {
+ protected function assertUserRoleAutocreate(EntityInterface $entity, $setter_callback): void {
$storage = $this->entityTypeManager->getStorage('user_role');
$role_id = $this->generateRandomEntityId(TRUE);
$role = $storage->create(['id' => $role_id, 'label' => $this->randomString()]);
@@ -367,7 +361,7 @@ protected function assertUserRoleAutocreate(EntityInterface $entity, $setter_cal
$entity->save();
$storage->resetCache();
$role = Role::load($role_id);
- return $this->assertEqual($entity->user_role->target_id, $role->id());
+ $this->assertEqual($entity->user_role->target_id, $role->id());
}
/**
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityRepositoryTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityRepositoryTest.php
index 74bc0086..5125370f 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityRepositoryTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityRepositoryTest.php
@@ -301,7 +301,7 @@ protected function doTestLanguageFallback($method_name) {
* @param string $expected_entity_type_id
* The expected entity type ID.
*/
- protected function assertEntityType($entity, $expected_entity_type_id) {
+ protected function assertEntityType($entity, $expected_entity_type_id): void {
$this->assertInstanceOf(EntityTest::class, $entity);
$this->assertEquals($expected_entity_type_id, $entity->getEntityTypeId());
}
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityUUIDTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityUUIDTest.php
index 54fb1c57..760812af 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityUUIDTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityUUIDTest.php
@@ -36,7 +36,7 @@ public function testCRUD() {
* @param string $entity_type
* The entity type to run the tests with.
*/
- protected function assertCRUD($entity_type) {
+ protected function assertCRUD($entity_type): void {
// Verify that no UUID is auto-generated when passing one for creation.
$uuid_service = $this->container->get('uuid');
$uuid = $uuid_service->generate();
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/FieldTranslationSqlStorageTest.php b/core/tests/Drupal/KernelTests/Core/Entity/FieldTranslationSqlStorageTest.php
index c1900c52..a7803064 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/FieldTranslationSqlStorageTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/FieldTranslationSqlStorageTest.php
@@ -71,7 +71,7 @@ public function testFieldSqlStorage() {
* @param string $message
* (optional) A message to display with the assertion.
*/
- protected function assertFieldStorageLangcode(FieldableEntityInterface $entity, $message = '') {
+ protected function assertFieldStorageLangcode(FieldableEntityInterface $entity, $message = ''): void {
$status = TRUE;
$entity_type = $entity->getEntityTypeId();
$id = $entity->id();
@@ -98,7 +98,7 @@ protected function assertFieldStorageLangcode(FieldableEntityInterface $entity,
}
}
- return $this->assertTrue($status, $message);
+ $this->assertTrue($status, $message);
}
}
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/FieldableEntityDefinitionUpdateTest.php b/core/tests/Drupal/KernelTests/Core/Entity/FieldableEntityDefinitionUpdateTest.php
index a4c49794..cbfca7b0 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/FieldableEntityDefinitionUpdateTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/FieldableEntityDefinitionUpdateTest.php
@@ -382,7 +382,7 @@ protected function insertData($revisionable, $translatable) {
* @param bool $translatable
* Whether the entity type was translatable prior to the update.
*/
- protected function assertEntityData($revisionable, $translatable) {
+ protected function assertEntityData($revisionable, $translatable): void {
$entities = $this->entityTypeManager->getStorage($this->entityTypeId)->loadMultiple();
$this->assertCount(3, $entities);
foreach ($entities as $entity_id => $entity) {
@@ -452,7 +452,7 @@ protected function assertEntityData($revisionable, $translatable) {
* (optional) Whether a new base field was added as part of the update.
* Defaults to FALSE.
*/
- protected function assertEntityTypeSchema($revisionable, $translatable, $new_base_field = FALSE) {
+ protected function assertEntityTypeSchema($revisionable, $translatable, $new_base_field = FALSE): void {
// Check whether the 'new_base_field' field has been installed correctly.
$field_storage_definition = $this->entityDefinitionUpdateManager->getFieldStorageDefinition('new_base_field', $this->entityTypeId);
if ($new_base_field) {
@@ -481,7 +481,7 @@ protected function assertEntityTypeSchema($revisionable, $translatable, $new_bas
/**
* Asserts the revisionable characteristics of an entity type.
*/
- protected function assertRevisionable() {
+ protected function assertRevisionable(): void {
/** @var \Drupal\Core\Entity\ContentEntityTypeInterface $entity_type */
$entity_type = $this->entityDefinitionUpdateManager->getEntityType($this->entityTypeId);
$this->assertTrue($entity_type->isRevisionable());
@@ -520,7 +520,7 @@ protected function assertRevisionable() {
/**
* Asserts the translatable characteristics of an entity type.
*/
- protected function assertTranslatable() {
+ protected function assertTranslatable(): void {
/** @var \Drupal\Core\Entity\ContentEntityTypeInterface $entity_type */
$entity_type = $this->entityDefinitionUpdateManager->getEntityType($this->entityTypeId);
$this->assertTrue($entity_type->isTranslatable());
@@ -549,7 +549,7 @@ protected function assertTranslatable() {
/**
* Asserts the revisionable / translatable characteristics of an entity type.
*/
- protected function assertRevisionableAndTranslatable() {
+ protected function assertRevisionableAndTranslatable(): void {
$this->assertRevisionable();
$this->assertTranslatable();
@@ -595,7 +595,7 @@ protected function assertRevisionableAndTranslatable() {
/**
* Asserts that an entity type is neither revisionable nor translatable.
*/
- protected function assertNonRevisionableAndNonTranslatable() {
+ protected function assertNonRevisionableAndNonTranslatable(): void {
/** @var \Drupal\Core\Entity\ContentEntityTypeInterface $entity_type */
$entity_type = $this->entityDefinitionUpdateManager->getEntityType($this->entityTypeId);
$this->assertFalse($entity_type->isRevisionable());
@@ -614,7 +614,7 @@ protected function assertNonRevisionableAndNonTranslatable() {
* @param bool $revisionable
* Whether the entity type is revisionable or not.
*/
- protected function assertBundleFieldSchema($revisionable) {
+ protected function assertBundleFieldSchema($revisionable): void {
$entity_type_id = 'entity_test_update';
$field_storage_definition = $this->entityFieldManager->getFieldStorageDefinitions($entity_type_id)['new_bundle_field'];
$database_schema = $this->database->schema();
@@ -631,7 +631,7 @@ protected function assertBundleFieldSchema($revisionable) {
/**
* Asserts that the backup tables have been kept after a successful update.
*/
- protected function assertBackupTables() {
+ protected function assertBackupTables(): void {
$backups = \Drupal::keyValue('entity.update_backup')->getAll();
$backup = reset($backups);
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/RevisionableContentEntityBaseTest.php b/core/tests/Drupal/KernelTests/Core/Entity/RevisionableContentEntityBaseTest.php
index c83a6bde..7aa3caee 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/RevisionableContentEntityBaseTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/RevisionableContentEntityBaseTest.php
@@ -167,7 +167,7 @@ public function testWasDefaultRevision() {
* @param \Drupal\Core\Entity\EntityTypeInterface $definition
* The definition and metadata of the entity being tested.
*/
- protected function assertItemsTableCount($count, EntityTypeInterface $definition) {
+ protected function assertItemsTableCount($count, EntityTypeInterface $definition): void {
$connection = Database::getConnection();
$this->assertEqual(1, $connection->query('SELECT COUNT(*) FROM {' . $definition->getBaseTable() . '}')->fetchField());
$this->assertEqual(1, $connection->query('SELECT COUNT(*) FROM {' . $definition->getDataTable() . '}')->fetchField());
diff --git a/core/tests/Drupal/KernelTests/Core/Field/FieldItemTest.php b/core/tests/Drupal/KernelTests/Core/Field/FieldItemTest.php
index fbce513e..7c0f8984 100644
--- a/core/tests/Drupal/KernelTests/Core/Field/FieldItemTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Field/FieldItemTest.php
@@ -85,11 +85,8 @@ public function testSaveWorkflow() {
* The test entity.
* @param $expected_value
* The expected field item value.
- *
- * @return bool
- * TRUE if the item value matches expectations, FALSE otherwise.
*/
- protected function assertSavedFieldItemValue(EntityTest $entity, $expected_value) {
+ protected function assertSavedFieldItemValue(EntityTest $entity, $expected_value): void {
$entity->setNewRevision(TRUE);
$entity->save();
$base_field_expected_value = str_replace($this->fieldName, 'field_test_item', $expected_value);
@@ -98,7 +95,6 @@ protected function assertSavedFieldItemValue(EntityTest $entity, $expected_value
$entity = $this->reloadEntity($entity);
$result = $result && $this->assertEqual($entity->field_test_item->value, $base_field_expected_value);
$result = $result && $this->assertEqual($entity->{$this->fieldName}->value, $expected_value);
- return $result;
}
}
diff --git a/core/tests/Drupal/KernelTests/Core/File/FileTestBase.php b/core/tests/Drupal/KernelTests/Core/File/FileTestBase.php
index 574041e0..f0ec6649 100644
--- a/core/tests/Drupal/KernelTests/Core/File/FileTestBase.php
+++ b/core/tests/Drupal/KernelTests/Core/File/FileTestBase.php
@@ -86,7 +86,7 @@ protected function setUpFilesystem() {
* @param $message
* Optional message.
*/
- public function assertFilePermissions($filepath, $expected_mode, $message = NULL) {
+ public function assertFilePermissions($filepath, $expected_mode, $message = NULL): void {
// Clear out PHP's file stat cache to be sure we see the current value.
clearstatcache(TRUE, $filepath);
@@ -121,7 +121,7 @@ public function assertFilePermissions($filepath, $expected_mode, $message = NULL
* @param $message
* Optional message.
*/
- public function assertDirectoryPermissions($directory, $expected_mode, $message = NULL) {
+ public function assertDirectoryPermissions($directory, $expected_mode, $message = NULL): void {
// Clear out PHP's file stat cache to be sure we see the current value.
clearstatcache(TRUE, $directory);
diff --git a/core/tests/Drupal/KernelTests/Core/File/HtaccessTest.php b/core/tests/Drupal/KernelTests/Core/File/HtaccessTest.php
index b9f59efb..14c6ce35 100644
--- a/core/tests/Drupal/KernelTests/Core/File/HtaccessTest.php
+++ b/core/tests/Drupal/KernelTests/Core/File/HtaccessTest.php
@@ -98,7 +98,7 @@ public function testHtaccessSave() {
* @param int $expected
* The expected file permissions; e.g., 0444.
*/
- protected function assertFilePermissions($uri, $expected) {
+ protected function assertFilePermissions($uri, $expected): void {
$actual = fileperms($uri) & 0777;
$this->assertSame($actual, $expected, new FormattableMarkup('@uri file permissions @actual are identical to @expected.', [
'@uri' => $uri,
diff --git a/core/tests/Drupal/KernelTests/Core/Menu/MenuTreeStorageTest.php b/core/tests/Drupal/KernelTests/Core/Menu/MenuTreeStorageTest.php
index 14e6171a..0970e0fb 100644
--- a/core/tests/Drupal/KernelTests/Core/Menu/MenuTreeStorageTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Menu/MenuTreeStorageTest.php
@@ -407,7 +407,7 @@ protected function moveMenuLink($id, $new_parent) {
* @param array $children
* Array of child IDs that are visible (enabled == 1).
*/
- protected function assertMenuLink($id, array $expected_properties, array $parents = [], array $children = []) {
+ protected function assertMenuLink($id, array $expected_properties, array $parents = [], array $children = []): void {
$query = $this->connection->select('menu_tree');
$query->fields('menu_tree');
$query->condition('id', $id);
diff --git a/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/DiscoveryTestBase.php b/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/DiscoveryTestBase.php
index 4c6e22a8..e58ce8b2 100644
--- a/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/DiscoveryTestBase.php
+++ b/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/DiscoveryTestBase.php
@@ -66,11 +66,9 @@ public function testDiscoveryInterface() {
* The definition to test.
* @param array $expected_definition
* The expected definition to test against.
- *
- * @return bool
- * TRUE if the assertion succeeded, FALSE otherwise.
*/
- protected function assertDefinitionIdentical(array $definition, array $expected_definition) {
+ protected function assertDefinitionIdentical(array $definition, array $expected_definition): void {
+ // @todo remove since we are now using MarkupInterfaceComparator
$func = function (&$item) {
if ($item instanceof TranslatableMarkup) {
$item = (string) $item;
@@ -78,7 +76,7 @@ protected function assertDefinitionIdentical(array $definition, array $expected_
};
array_walk_recursive($definition, $func);
array_walk_recursive($expected_definition, $func);
- return $this->assertIdentical($definition, $expected_definition);
+ $this->assertSame($expected_definition, $definition);
}
}
diff --git a/core/tests/Drupal/KernelTests/Core/Render/Element/RenderElementTypesTest.php b/core/tests/Drupal/KernelTests/Core/Render/Element/RenderElementTypesTest.php
index 8ff094ca..a519291e 100644
--- a/core/tests/Drupal/KernelTests/Core/Render/Element/RenderElementTypesTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Render/Element/RenderElementTypesTest.php
@@ -36,7 +36,7 @@ protected function setUp(): void {
* @param string $message
* Assertion message.
*/
- protected function assertElements(array $elements, $expected_html, $message) {
+ protected function assertElements(array $elements, $expected_html, $message): void {
$actual_html = (string) \Drupal::service('renderer')->renderRoot($elements);
$out = '';
diff --git a/core/tests/Drupal/KernelTests/KernelTestBase.php b/core/tests/Drupal/KernelTests/KernelTestBase.php
index b1ebad5e..5e026711 100644
--- a/core/tests/Drupal/KernelTests/KernelTestBase.php
+++ b/core/tests/Drupal/KernelTests/KernelTestBase.php
@@ -583,7 +583,7 @@ protected function getConfigSchemaExclusions() {
/**
* {@inheritdoc}
*/
- protected function assertPostConditions() {
+ protected function assertPostConditions(): void {
// Execute registered Drupal shutdown functions prior to tearing down.
// @see _drupal_shutdown_function()
$callbacks = &drupal_register_shutdown_function();
diff --git a/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php b/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php
index ca280d58..bba75c5c 100644
--- a/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php
+++ b/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php
@@ -177,7 +177,7 @@ public function testDateTimestamp($input, array $initial, array $transform) {
* @param array $transform
* @see testTimestamp()
*/
- public function assertDateTimestamp($date, $input, $initial, $transform) {
+ public function assertDateTimestamp($date, $input, $initial, $transform): void {
// Check format.
$value = $date->format($initial['format']);
$this->assertEquals($initial['expected_date'], $value, sprintf("Test new DateTimePlus(%s, %s): should be %s, found %s.", $input, $initial['timezone'], $initial['expected_date'], $value));
diff --git a/core/tests/Drupal/Tests/Component/DrupalComponentTest.php b/core/tests/Drupal/Tests/Component/DrupalComponentTest.php
index 6f9d149a..5410dcd5 100644
--- a/core/tests/Drupal/Tests/Component/DrupalComponentTest.php
+++ b/core/tests/Drupal/Tests/Component/DrupalComponentTest.php
@@ -90,7 +90,7 @@ protected function findPhpClasses($dir) {
* @param string $class_path
* The full path to the class that should be checked.
*/
- protected function assertNoCoreUsage($class_path) {
+ protected function assertNoCoreUsage($class_path): void {
$contents = file_get_contents($class_path);
preg_match_all('/^.*Drupal\\\Core.*$/m', $contents, $matches);
$matches = array_filter($matches[0], function ($line) {
diff --git a/core/tests/Drupal/Tests/Component/Graph/GraphTest.php b/core/tests/Drupal/Tests/Component/Graph/GraphTest.php
index eb7d7e3c..5528337b 100644
--- a/core/tests/Drupal/Tests/Component/Graph/GraphTest.php
+++ b/core/tests/Drupal/Tests/Component/Graph/GraphTest.php
@@ -106,7 +106,7 @@ protected function normalizeGraph($graph) {
* @param $expected_paths
* An associative array containing vertices with their expected paths.
*/
- protected function assertPaths($graph, $expected_paths) {
+ protected function assertPaths($graph, $expected_paths): void {
foreach ($expected_paths as $vertex => $paths) {
// Build an array with keys = $paths and values = TRUE.
$expected = array_fill_keys($paths, TRUE);
@@ -124,7 +124,7 @@ protected function assertPaths($graph, $expected_paths) {
* An associative array containing vertices with their expected reverse
* paths.
*/
- protected function assertReversePaths($graph, $expected_reverse_paths) {
+ protected function assertReversePaths($graph, $expected_reverse_paths): void {
foreach ($expected_reverse_paths as $vertex => $paths) {
// Build an array with keys = $paths and values = TRUE.
$expected = array_fill_keys($paths, TRUE);
@@ -141,7 +141,7 @@ protected function assertReversePaths($graph, $expected_reverse_paths) {
* @param $expected_components
* An array containing of components defined as a list of their vertices.
*/
- protected function assertComponents($graph, $expected_components) {
+ protected function assertComponents($graph, $expected_components): void {
$unassigned_vertices = array_fill_keys(array_keys($graph), TRUE);
foreach ($expected_components as $component) {
$result_components = [];
@@ -162,7 +162,7 @@ protected function assertComponents($graph, $expected_components) {
* @param $expected_orders
* An array containing lists of vertices in their expected order.
*/
- protected function assertWeights($graph, $expected_orders) {
+ protected function assertWeights($graph, $expected_orders): void {
foreach ($expected_orders as $order) {
$previous_vertex = array_shift($order);
foreach ($order as $vertex) {
diff --git a/core/tests/Drupal/Tests/Component/PhpStorage/PhpStorageTestBase.php b/core/tests/Drupal/Tests/Component/PhpStorage/PhpStorageTestBase.php
index cc0e79d0..7bfed166 100644
--- a/core/tests/Drupal/Tests/Component/PhpStorage/PhpStorageTestBase.php
+++ b/core/tests/Drupal/Tests/Component/PhpStorage/PhpStorageTestBase.php
@@ -31,7 +31,7 @@ protected function setUp() {
/**
* Assert that a PHP storage's load/save/delete operations work.
*/
- public function assertCRUD($php) {
+ public function assertCRUD($php): void {
// Random generator.
$random_generator = new Random();
diff --git a/core/tests/Drupal/Tests/Component/Utility/SortArrayTest.php b/core/tests/Drupal/Tests/Component/Utility/SortArrayTest.php
index 4c9c41b0..5ca809ce 100644
--- a/core/tests/Drupal/Tests/Component/Utility/SortArrayTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/SortArrayTest.php
@@ -315,7 +315,7 @@ public function providerSortByTitleProperty() {
* @param int $result
* Actual comparison function return value.
*/
- protected function assertBothNegativePositiveOrZero($expected, $result) {
+ protected function assertBothNegativePositiveOrZero($expected, $result): void {
$this->assertIsNumeric($expected);
$this->assertIsNumeric($result);
$this->assertTrue(($expected < 0 && $result < 0) || ($expected > 0 && $result > 0) || ($expected === 0 && $result === 0), 'Numbers are either both negative, both positive or both zero.');
diff --git a/core/tests/Drupal/Tests/Component/Utility/XssTest.php b/core/tests/Drupal/Tests/Component/Utility/XssTest.php
index cccdc6c4..9c1e946b 100644
--- a/core/tests/Drupal/Tests/Component/Utility/XssTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/XssTest.php
@@ -593,7 +593,7 @@ public function providerTestFilterXssAdminNotNormalized() {
* @param string $group
* (optional) The group this message belongs to. Defaults to 'Other'.
*/
- protected function assertNormalized($haystack, $needle, $message = '', $group = 'Other') {
+ protected function assertNormalized($haystack, $needle, $message = '', $group = 'Other'): void {
$this->assertStringContainsString($needle, strtolower(Html::decodeEntities($haystack)), $message);
}
@@ -615,7 +615,7 @@ protected function assertNormalized($haystack, $needle, $message = '', $group =
* @param string $group
* (optional) The group this message belongs to. Defaults to 'Other'.
*/
- protected function assertNotNormalized($haystack, $needle, $message = '', $group = 'Other') {
+ protected function assertNotNormalized($haystack, $needle, $message = '', $group = 'Other'): void {
$this->assertStringNotContainsString($needle, strtolower(Html::decodeEntities($haystack)), $message);
}
diff --git a/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/AssertUtilsTrait.php b/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/AssertUtilsTrait.php
index 96dab849..64c2fe9b 100644
--- a/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/AssertUtilsTrait.php
+++ b/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/AssertUtilsTrait.php
@@ -20,7 +20,7 @@
* @param string $contents_contains
* Regex to check the file contents.
*/
- protected function assertScaffoldedFile($path, $is_link, $contents_contains) {
+ protected function assertScaffoldedFile($path, $is_link, $contents_contains): void {
$this->assertFileExists($path);
$contents = file_get_contents($path);
$this->assertStringContainsString($contents_contains, basename($path) . ': ' . $contents);
@@ -35,7 +35,7 @@ protected function assertScaffoldedFile($path, $is_link, $contents_contains) {
* @param string $contents_not_contains
* A string that is expected should NOT occur in the file contents.
*/
- protected function assertScaffoldedFileDoesNotContain($path, $contents_not_contains) {
+ protected function assertScaffoldedFileDoesNotContain($path, $contents_not_contains): void {
// If the file does not exist at all, we'll count that as a pass.
if (!file_exists($path)) {
return;
diff --git a/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ScaffoldTest.php b/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ScaffoldTest.php
index 086dcef1..7b0da79c 100644
--- a/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ScaffoldTest.php
+++ b/core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ScaffoldTest.php
@@ -358,7 +358,7 @@ public function testDrupalDrupalFileWasAppended($fixture_name, $is_link, $scaffo
* @param bool $is_link
* Whether or not symlinking is used.
*/
- protected function assertDefaultSettingsFromScaffoldOverride($docroot, $is_link) {
+ protected function assertDefaultSettingsFromScaffoldOverride($docroot, $is_link): void {
$this->assertScaffoldedFile($docroot . '/sites/default/default.settings.php', $is_link, 'scaffolded from the scaffold-override-fixture');
}
@@ -368,7 +368,7 @@ protected function assertDefaultSettingsFromScaffoldOverride($docroot, $is_link)
* @param string $docroot
* The path to the System-under-Test's docroot.
*/
- protected function assertHtaccessExcluded($docroot) {
+ protected function assertHtaccessExcluded($docroot): void {
// Ensure that the .htaccess.txt file was not written, as our
// top-level composer.json excludes it from the files to scaffold.
$this->assertFileNotExists($docroot . '/.htaccess');
@@ -386,7 +386,7 @@ protected function assertHtaccessExcluded($docroot) {
* @param bool $is_link
* Whether or not symlinking is used.
*/
- protected function assertCommonDrupalAssetsWereScaffolded($docroot, $is_link) {
+ protected function assertCommonDrupalAssetsWereScaffolded($docroot, $is_link): void {
// Assert scaffold files are written in the correct locations.
$this->assertScaffoldedFile($docroot . '/.csslintrc', $is_link, 'Test version of .csslintrc from drupal/core.');
$this->assertScaffoldedFile($docroot . '/.editorconfig', $is_link, 'Test version of .editorconfig from drupal/core.');
@@ -410,7 +410,7 @@ protected function assertCommonDrupalAssetsWereScaffolded($docroot, $is_link) {
* @param bool $relocated_docroot
* Whether the document root is relocated or now.
*/
- protected function assertAutoloadFileCorrect($docroot, $relocated_docroot = FALSE) {
+ protected function assertAutoloadFileCorrect($docroot, $relocated_docroot = FALSE): void {
$autoload_path = $docroot . '/autoload.php';
// Ensure that the autoload.php file was written.
diff --git a/core/tests/Drupal/Tests/Core/Access/AccessResultTest.php b/core/tests/Drupal/Tests/Core/Access/AccessResultTest.php
index 154e8a60..2f7caa94 100644
--- a/core/tests/Drupal/Tests/Core/Access/AccessResultTest.php
+++ b/core/tests/Drupal/Tests/Core/Access/AccessResultTest.php
@@ -45,7 +45,7 @@ protected function setUp(): void {
\Drupal::setContainer($container);
}
- protected function assertDefaultCacheability(AccessResult $access) {
+ protected function assertDefaultCacheability(AccessResult $access): void {
$this->assertSame([], $access->getCacheContexts());
$this->assertSame([], $access->getCacheTags());
$this->assertSame(Cache::PERMANENT, $access->getCacheMaxAge());
diff --git a/core/tests/Drupal/Tests/Core/Common/TagsTest.php b/core/tests/Drupal/Tests/Core/Common/TagsTest.php
index 3c3058f9..5874b433 100644
--- a/core/tests/Drupal/Tests/Core/Common/TagsTest.php
+++ b/core/tests/Drupal/Tests/Core/Common/TagsTest.php
@@ -44,7 +44,7 @@ public function testImplodeTags() {
/**
* Helper function: asserts that the ending array of tags is what we wanted.
*/
- protected function assertTags($tags) {
+ protected function assertTags($tags): void {
$original = $this->validTags;
foreach ($tags as $tag) {
$key = array_search($tag, $original);
diff --git a/core/tests/Drupal/Tests/Core/Config/ConfigTest.php b/core/tests/Drupal/Tests/Core/Config/ConfigTest.php
index ac09beb7..c6debd4e 100644
--- a/core/tests/Drupal/Tests/Core/Config/ConfigTest.php
+++ b/core/tests/Drupal/Tests/Core/Config/ConfigTest.php
@@ -578,7 +578,7 @@ public function nestedDataProvider() {
* @param array $data
* Config data to be checked.
*/
- public function assertConfigDataEquals($data) {
+ public function assertConfigDataEquals($data): void {
foreach ($data as $key => $value) {
$this->assertEquals($value, $this->config->get($key));
}
@@ -592,7 +592,7 @@ public function assertConfigDataEquals($data) {
* @param bool $apply_overrides
* Apply any overrides to the original data.
*/
- public function assertOriginalConfigDataEquals($data, $apply_overrides) {
+ public function assertOriginalConfigDataEquals($data, $apply_overrides): void {
foreach ($data as $key => $value) {
$config_value = $this->config->getOriginal($key, $apply_overrides);
$this->assertEquals($value, $config_value);
@@ -629,7 +629,7 @@ public function testSafeStringHandling() {
* @param array $overridden_data
* The overridden data.
*/
- protected function assertOverriddenKeys(array $data, array $overridden_data) {
+ protected function assertOverriddenKeys(array $data, array $overridden_data): void {
if (empty($overridden_data)) {
$this->assertFalse($this->config->hasOverrides());
}
diff --git a/core/tests/Drupal/Tests/Core/Controller/ControllerResolverTest.php b/core/tests/Drupal/Tests/Core/Controller/ControllerResolverTest.php
index b9b63e0b..5ef4db80 100644
--- a/core/tests/Drupal/Tests/Core/Controller/ControllerResolverTest.php
+++ b/core/tests/Drupal/Tests/Core/Controller/ControllerResolverTest.php
@@ -183,7 +183,7 @@ public function testGetControllerFromDefinitionNotCallable() {
* @param mixed $output
* The output expected for this controller.
*/
- protected function assertCallableController($controller, $class, $output) {
+ protected function assertCallableController($controller, $class, $output): void {
if ($class) {
$this->assertIsObject($controller[0]);
$this->assertInstanceOf($class, $controller[0]);
diff --git a/core/tests/Drupal/Tests/Core/Database/SchemaIntrospectionTestTrait.php b/core/tests/Drupal/Tests/Core/Database/SchemaIntrospectionTestTrait.php
index 3591adde..95acaa87 100644
--- a/core/tests/Drupal/Tests/Core/Database/SchemaIntrospectionTestTrait.php
+++ b/core/tests/Drupal/Tests/Core/Database/SchemaIntrospectionTestTrait.php
@@ -18,7 +18,7 @@
* (optional) The type of the index. Can be one of 'index', 'unique' or
* 'primary'. Defaults to 'index'.
*/
- protected function assertIndexOnColumns($table_name, array $column_names, $index_type = 'index') {
+ protected function assertIndexOnColumns($table_name, array $column_names, $index_type = 'index': void) {
foreach ($this->getIndexColumnNames($table_name, $index_type) as $index_columns) {
if ($column_names == $index_columns) {
$this->assertTrue(TRUE);
@@ -39,7 +39,7 @@ protected function assertIndexOnColumns($table_name, array $column_names, $index
* (optional) The type of the index. Can be one of 'index', 'unique' or
* 'primary'. Defaults to 'index'.
*/
- protected function assertNoIndexOnColumns($table_name, array $column_names, $index_type = 'index') {
+ protected function assertNoIndexOnColumns($table_name, array $column_names, $index_type = 'index'): void {
foreach ($this->getIndexColumnNames($table_name, $index_type) as $index_columns) {
if ($column_names == $index_columns) {
$this->assertTrue(FALSE);
diff --git a/core/tests/Drupal/Tests/Core/Entity/Access/EntityFormDisplayAccessControlHandlerTest.php b/core/tests/Drupal/Tests/Core/Entity/Access/EntityFormDisplayAccessControlHandlerTest.php
index 38611d70..f1c6b4aa 100644
--- a/core/tests/Drupal/Tests/Core/Entity/Access/EntityFormDisplayAccessControlHandlerTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/Access/EntityFormDisplayAccessControlHandlerTest.php
@@ -203,7 +203,7 @@ protected function setUp(): void {
* @param \Drupal\Core\Session\AccountInterface $user
* The account to use for get access.
*/
- public function assertAllowOperations(array $allow_operations, AccountInterface $user) {
+ public function assertAllowOperations(array $allow_operations, AccountInterface $user): void {
foreach (['view', 'update', 'delete'] as $operation) {
$expected = in_array($operation, $allow_operations);
$actual = $this->accessControlHandler->access($this->entity, $operation, $user);
diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php
index cdfabf06..7d87a20d 100644
--- a/core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php
@@ -477,7 +477,7 @@ public function testConstraintMethods() {
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
*/
- protected function assertNoPublicProperties(EntityTypeInterface $entity_type) {
+ protected function assertNoPublicProperties(EntityTypeInterface $entity_type): void {
$reflection = new \ReflectionObject($entity_type);
$this->assertEmpty($reflection->getProperties(\ReflectionProperty::IS_PUBLIC));
}
diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityUrlTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityUrlTest.php
index 8b49127b..120a54f4 100644
--- a/core/tests/Drupal/Tests/Core/Entity/EntityUrlTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/EntityUrlTest.php
@@ -459,7 +459,7 @@ protected function getEntity($class, array $values, array $methods = []) {
* @param \Drupal\Core\Url $url
* The URL option to make the assertions on.
*/
- protected function assertUrl($expected_route_name, array $expected_route_parameters, $entity, $has_language, Url $url) {
+ protected function assertUrl($expected_route_name, array $expected_route_parameters, $entity, $has_language, Url $url): void {
$this->assertEquals($expected_route_name, $url->getRouteName());
$this->assertEquals($expected_route_parameters, $url->getRouteParameters());
$this->assertEquals($this->entityTypeId, $url->getOption('entity_type'));
diff --git a/core/tests/Drupal/Tests/Core/File/FileSystemTest.php b/core/tests/Drupal/Tests/Core/File/FileSystemTest.php
index a4b2b2aa..cd87cb33 100644
--- a/core/tests/Drupal/Tests/Core/File/FileSystemTest.php
+++ b/core/tests/Drupal/Tests/Core/File/FileSystemTest.php
@@ -136,7 +136,7 @@ public function providerTestBasename() {
* @param string $uri
* @param string $message
*/
- protected function assertFilePermissions($expected_mode, $uri, $message = '') {
+ protected function assertFilePermissions($expected_mode, $uri, $message = ''): void {
// Mask out all but the last three octets.
$actual_mode = fileperms($uri) & 0777;
diff --git a/core/tests/Drupal/Tests/Core/Form/FormTestBase.php b/core/tests/Drupal/Tests/Core/Form/FormTestBase.php
index 5e4b64c4..a35ee542 100644
--- a/core/tests/Drupal/Tests/Core/Form/FormTestBase.php
+++ b/core/tests/Drupal/Tests/Core/Form/FormTestBase.php
@@ -270,7 +270,7 @@ protected function simulateFormSubmission($form_id, FormInterface $form_arg, For
* (optional) The form key to look in. Otherwise the entire form will be
* compared.
*/
- protected function assertFormElement(array $expected_form, array $actual_form, $form_key = NULL) {
+ protected function assertFormElement(array $expected_form, array $actual_form, $form_key = NULL): void {
$expected_element = $form_key ? $expected_form[$form_key] : $expected_form;
$actual_element = $form_key ? $actual_form[$form_key] : $actual_form;
$this->assertSame(array_intersect_key($expected_element, $actual_element), $expected_element);
diff --git a/core/tests/Drupal/Tests/Core/Plugin/Context/EntityContextDefinitionIsSatisfiedTest.php b/core/tests/Drupal/Tests/Core/Plugin/Context/EntityContextDefinitionIsSatisfiedTest.php
index ac52b59a..4ae6d49c 100644
--- a/core/tests/Drupal/Tests/Core/Plugin/Context/EntityContextDefinitionIsSatisfiedTest.php
+++ b/core/tests/Drupal/Tests/Core/Plugin/Context/EntityContextDefinitionIsSatisfiedTest.php
@@ -90,7 +90,7 @@ protected function setUp(): void {
* @param mixed $value
* (optional) The value to set on the context, defaults to NULL.
*/
- protected function assertRequirementIsSatisfied($expected, ContextDefinition $requirement, ContextDefinition $definition, $value = NULL) {
+ protected function assertRequirementIsSatisfied($expected, ContextDefinition $requirement, ContextDefinition $definition, $value = NULL): void {
$context = new EntityContext($definition, $value);
$this->assertSame($expected, $requirement->isSatisfiedBy($context));
}
diff --git a/core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php b/core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php
index c9f35444..bb16520a 100644
--- a/core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php
+++ b/core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php
@@ -554,7 +554,7 @@ protected function generatePlaceholderElement() {
* @param array $expected_data
* A render array with the expected values.
*/
- protected function assertPlaceholderRenderCache($cid_parts, array $bubbled_cache_contexts, array $expected_data) {
+ protected function assertPlaceholderRenderCache($cid_parts, array $bubbled_cache_contexts, array $expected_data): void {
if ($cid_parts !== FALSE) {
if ($bubbled_cache_contexts) {
// Verify render cached placeholder.
diff --git a/core/tests/Drupal/Tests/Core/Render/RendererTest.php b/core/tests/Drupal/Tests/Core/Render/RendererTest.php
index 1d381ca9..c8e04617 100644
--- a/core/tests/Drupal/Tests/Core/Render/RendererTest.php
+++ b/core/tests/Drupal/Tests/Core/Render/RendererTest.php
@@ -719,7 +719,7 @@ public function providerAccessValues() {
* @param bool $access
* Whether the render array is accessible or not.
*/
- protected function assertAccess($build, $access) {
+ protected function assertAccess($build, $access): void {
$sensitive_content = $this->randomContextValue();
$build['#markup'] = $sensitive_content;
if (($access instanceof AccessResultInterface && $access->isAllowed()) || $access === TRUE) {
diff --git a/core/tests/Drupal/Tests/Core/Render/RendererTestBase.php b/core/tests/Drupal/Tests/Core/Render/RendererTestBase.php
index 0a2a74a6..fd271a00 100644
--- a/core/tests/Drupal/Tests/Core/Render/RendererTestBase.php
+++ b/core/tests/Drupal/Tests/Core/Render/RendererTestBase.php
@@ -240,7 +240,7 @@ protected function setUpRequest($method = 'GET') {
* @param string $bin
* The expected cache bin.
*/
- protected function assertRenderCacheItem($cid, $data, $bin = 'render') {
+ protected function assertRenderCacheItem($cid, $data, $bin = 'render'): void {
$cache_backend = $this->cacheFactory->get($bin);
$cached = $cache_backend->get($cid);
$this->assertNotFalse($cached, sprintf('Expected cache item "%s" exists.', $cid));
diff --git a/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php b/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php
index 53d872e7..b8de3a3a 100644
--- a/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php
+++ b/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php
@@ -536,7 +536,7 @@ public function testGenerateWithPathProcessorChangingQueryParameter() {
* @param \Drupal\Core\Render\BubbleableMetadata $expected_bubbleable_metadata
* The expected generated bubbleable metadata.
*/
- protected function assertGenerateFromRoute($route_name, array $route_parameters, array $options, $expected_url, BubbleableMetadata $expected_bubbleable_metadata) {
+ protected function assertGenerateFromRoute($route_name, array $route_parameters, array $options, $expected_url, BubbleableMetadata $expected_bubbleable_metadata): void {
// First, test with $collect_cacheability_metadata set to the default value.
$url = $this->generator->generateFromRoute($route_name, $route_parameters, $options);
$this->assertSame($expected_url, $url);
diff --git a/core/tests/Drupal/Tests/Core/Security/RequestSanitizerTest.php b/core/tests/Drupal/Tests/Core/Security/RequestSanitizerTest.php
index 2301fea2..e2cb19c5 100644
--- a/core/tests/Drupal/Tests/Core/Security/RequestSanitizerTest.php
+++ b/core/tests/Drupal/Tests/Core/Security/RequestSanitizerTest.php
@@ -358,7 +358,7 @@ public function errorHandler($errno, $errstr) {
* @param int $errno
* The severity level of the error.
*/
- protected function assertError($errstr, $errno) {
+ protected function assertError($errstr, $errno): void {
foreach ($this->errors as $error) {
if ($error['errstr'] === $errstr && $error['errno'] === $errno) {
return;
diff --git a/core/tests/Drupal/Tests/Core/Template/AttributeTest.php b/core/tests/Drupal/Tests/Core/Template/AttributeTest.php
index ef3ad8b8..a38b215a 100644
--- a/core/tests/Drupal/Tests/Core/Template/AttributeTest.php
+++ b/core/tests/Drupal/Tests/Core/Template/AttributeTest.php
@@ -381,7 +381,7 @@ public function providerTestAttributeValues() {
* @param string $html
* The HTML snippet to check.
*/
- protected function assertClass($class, $html) {
+ protected function assertClass($class, $html): void {
$xpath = "//*[@class='$class']";
self::assertTrue((bool) $this->getXPathResultCount($xpath, $html));
}
@@ -394,7 +394,7 @@ protected function assertClass($class, $html) {
* @param string $html
* The HTML snippet to check.
*/
- protected function assertNoClass($class, $html) {
+ protected function assertNoClass($class, $html): void {
$xpath = "//*[@class='$class']";
self::assertFalse((bool) $this->getXPathResultCount($xpath, $html));
}
@@ -407,7 +407,7 @@ protected function assertNoClass($class, $html) {
* @param string $html
* The HTML snippet to check.
*/
- protected function assertID($id, $html) {
+ protected function assertID($id, $html): void {
$xpath = "//*[@id='$id']";
self::assertTrue((bool) $this->getXPathResultCount($xpath, $html));
}
@@ -420,7 +420,7 @@ protected function assertID($id, $html) {
* @param string $html
* The HTML snippet to check.
*/
- protected function assertNoID($id, $html) {
+ protected function assertNoID($id, $html): void {
$xpath = "//*[@id='$id']";
self::assertFalse((bool) $this->getXPathResultCount($xpath, $html));
}
diff --git a/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php b/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php
index 20f1291a..90b3e50d 100644
--- a/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php
+++ b/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php
@@ -619,7 +619,7 @@ public function testGenerateTwice() {
* @param int $count
* How many times the link should be present in the HTML. Defaults to 1.
*/
- public static function assertLink(array $properties, MarkupInterface $html, $count = 1) {
+ public static function assertLink(array $properties, MarkupInterface $html, $count = 1): void {
// Provide default values.
$properties += ['attributes' => []];
@@ -657,7 +657,7 @@ public static function assertLink(array $properties, MarkupInterface $html, $cou
* @return int
* The number of results that are found.
*/
- protected function assertNoXPathResults($query, $html) {
+ protected function assertNoXPathResults($query, $html): void {
$document = new \DOMDocument();
$document->loadHTML($html);
$xpath = new \DOMXPath($document);
diff --git a/core/tests/Drupal/Tests/Listeners/DrupalListener.php b/core/tests/Drupal/Tests/Listeners/DrupalListener.php
index e460939c..1259af7e 100644
--- a/core/tests/Drupal/Tests/Listeners/DrupalListener.php
+++ b/core/tests/Drupal/Tests/Listeners/DrupalListener.php
@@ -57,7 +57,7 @@ public function startTest(Test $test): void {
// Check for assert*() methods to ensure they have a void return typehint.
foreach ($class->getMethods() as $method) {
$method_name = $method->getName();
- if (strpos($method_name, 'assert') === 0 && $method_name !== 'assertSession') {
+ if (strpos($method_name, 'assert') === 0 && !in_array($method_name, ['assertSession', 'assert'])) {
if ((!$method->hasReturnType() || $method->getReturnType()->getName() !== 'void') && $method->getDeclaringClass()->getName() !== TestCase::class) {
@trigger_error("Declaring ::$method_name without a void return typehint in " . $method->getDeclaringClass()->getName() . " is deprecated in drupal:9.TODO.0. Typehinting will be required before drupal:10.0.0. See https://www.drupal.org/node/TODO", E_USER_DEPRECATED);
}
diff --git a/core/tests/Drupal/Tests/RequirementsPageTrait.php b/core/tests/Drupal/Tests/RequirementsPageTrait.php
index b71afba0..a072535c 100644
--- a/core/tests/Drupal/Tests/RequirementsPageTrait.php
+++ b/core/tests/Drupal/Tests/RequirementsPageTrait.php
@@ -52,7 +52,7 @@ protected function continueOnExpectedWarnings($expected_warnings = []) {
* A list of warning summaries to expect on the requirements screen (e.g.
* 'PHP', 'PHP OPcode caching', etc.).
*/
- protected function assertWarningSummaries(array $warning_summaries) {
+ protected function assertWarningSummaries(array $warning_summaries): void {
// Allow only details elements that are directly after the warning header
// or each other. There is no guaranteed wrapper we can rely on across
// distributions. When there are multiple warnings, the selectors will be:
diff --git a/core/tests/Drupal/Tests/SchemaCheckTestTrait.php b/core/tests/Drupal/Tests/SchemaCheckTestTrait.php
index 96a0a7f8..96aace39 100644
--- a/core/tests/Drupal/Tests/SchemaCheckTestTrait.php
+++ b/core/tests/Drupal/Tests/SchemaCheckTestTrait.php
@@ -23,13 +23,12 @@
* @param array $config_data
* The configuration data.
*/
- public function assertConfigSchema(TypedConfigManagerInterface $typed_config, $config_name, $config_data) {
+ public function assertConfigSchema(TypedConfigManagerInterface $typed_config, $config_name, $config_data): void {
$errors = $this->checkConfigSchema($typed_config, $config_name, $config_data);
if ($errors === FALSE) {
// @todo Since the use of this trait is under TestBase, it works.
// Can be fixed as part of https://www.drupal.org/node/2260053.
$this->fail(new FormattableMarkup('No schema for @config_name', ['@config_name' => $config_name]));
- return;
}
elseif ($errors === TRUE) {
// @todo Since the use of this trait is under TestBase, it works.
@@ -51,7 +50,7 @@ public function assertConfigSchema(TypedConfigManagerInterface $typed_config, $c
* @param string $config_name
* The configuration name.
*/
- public function assertConfigSchemaByName($config_name) {
+ public function assertConfigSchemaByName($config_name): void {
$config = $this->config($config_name);
$this->assertConfigSchema(\Drupal::service('config.typed'), $config->getName(), $config->get());
}
diff --git a/core/tests/Drupal/Tests/WebAssert.php b/core/tests/Drupal/Tests/WebAssert.php
index 7b296263..b2a0fa46 100644
--- a/core/tests/Drupal/Tests/WebAssert.php
+++ b/core/tests/Drupal/Tests/WebAssert.php
@@ -401,7 +401,7 @@ public function buildXPathQuery($xpath, array $args = []) {
* @param string $raw
* Raw (HTML) string to look for.
*/
- public function assertNoEscaped($raw) {
+ public function assertNoEscaped($raw): void {
$this->responseNotContains(Html::escape($raw));
}
@@ -413,7 +413,7 @@ public function assertNoEscaped($raw) {
* @param string $raw
* Raw (HTML) string to look for.
*/
- public function assertEscaped($raw) {
+ public function assertEscaped($raw): void {
$this->responseContains(Html::escape($raw));
}