From e76b29a0de7800df996ac0ddb1f67274ce2743f6 Mon Sep 17 00:00:00 2001
From: catch <catch@35733.no-reply.drupal.org>
Date: Thu, 8 Jul 2021 15:56:55 +0100
Subject: [PATCH] Issue #3222783 by longwave, mondrake: Result of method
 PHPUnit\Framework\Assert::assertEquals() (void) is used

---
 .../tests/src/Functional/CommentPagerTest.php        |  2 +-
 .../Functional/ContentTranslationSettingsTest.php    |  5 +----
 .../src/Functional/EditorUploadImageScaleTest.php    |  7 ++-----
 core/tests/Drupal/KernelTests/AssertContentTrait.php |  9 ++++-----
 .../Core/Entity/EntityReferenceFieldTest.php         | 10 ++--------
 .../Drupal/KernelTests/Core/Field/FieldItemTest.php  | 12 ++++--------
 6 files changed, 14 insertions(+), 31 deletions(-)

diff --git a/core/modules/comment/tests/src/Functional/CommentPagerTest.php b/core/modules/comment/tests/src/Functional/CommentPagerTest.php
index 51e6ab1d8133..9c11fef7a3eb 100644
--- a/core/modules/comment/tests/src/Functional/CommentPagerTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentPagerTest.php
@@ -224,7 +224,7 @@ public function assertCommentOrder(array $comments, array $expected_order) {
     foreach ($comment_anchors as $anchor) {
       $result_order[] = substr($anchor->getAttribute('id'), 8);
     }
-    return $this->assertEquals($expected_cids, $result_order, new FormattableMarkup('Comment order: expected @expected, returned @returned.', ['@expected' => implode(',', $expected_cids), '@returned' => implode(',', $result_order)]));
+    $this->assertEquals($expected_cids, $result_order, new FormattableMarkup('Comment order: expected @expected, returned @returned.', ['@expected' => implode(',', $expected_cids), '@returned' => implode(',', $result_order)]));
   }
 
   /**
diff --git a/core/modules/content_translation/tests/src/Functional/ContentTranslationSettingsTest.php b/core/modules/content_translation/tests/src/Functional/ContentTranslationSettingsTest.php
index 23bed79b24c9..91ec56987aa6 100644
--- a/core/modules/content_translation/tests/src/Functional/ContentTranslationSettingsTest.php
+++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationSettingsTest.php
@@ -259,16 +259,13 @@ public function testAccountLanguageSettingsUI() {
    *   TRUE if translatability should be enabled, FALSE otherwise.
    * @param array $edit
    *   An array of values to submit to the content translation settings page.
-   *
-   * @return bool
-   *   TRUE if the assertion succeeded, FALSE otherwise.
    */
   protected function assertSettings($entity_type, $bundle, $enabled, $edit) {
     $this->drupalGet('admin/config/regional/content-language');
     $this->submitForm($edit, 'Save configuration');
     $args = ['@entity_type' => $entity_type, '@bundle' => $bundle, '@enabled' => $enabled ? 'enabled' : 'disabled'];
     $message = new FormattableMarkup('Translation for entity @entity_type (@bundle) is @enabled.', $args);
-    return $this->assertEquals($enabled, \Drupal::service('content_translation.manager')->isEnabled($entity_type, $bundle), $message);
+    $this->assertEquals($enabled, \Drupal::service('content_translation.manager')->isEnabled($entity_type, $bundle), $message);
   }
 
   /**
diff --git a/core/modules/editor/tests/src/Functional/EditorUploadImageScaleTest.php b/core/modules/editor/tests/src/Functional/EditorUploadImageScaleTest.php
index 63b08fa1c064..fd347167b8ec 100644
--- a/core/modules/editor/tests/src/Functional/EditorUploadImageScaleTest.php
+++ b/core/modules/editor/tests/src/Functional/EditorUploadImageScaleTest.php
@@ -219,8 +219,6 @@ protected function uploadImage($uri) {
    *   The expected width of the uploaded image.
    * @param string $height
    *   The expected height of the uploaded image.
-   *
-   * @return bool
    */
   protected function assertSavedMaxDimensions($width, $height) {
     $image_upload_settings = Editor::load('basic_html')->getImageUploadSettings();
@@ -228,9 +226,8 @@ protected function assertSavedMaxDimensions($width, $height) {
       'width' => $image_upload_settings['max_dimensions']['width'],
       'height' => $image_upload_settings['max_dimensions']['height'],
     ];
-    $same_width = $this->assertEquals($expected['width'], $width, 'Actual width of "' . $width . '" equals the expected width of "' . $expected['width'] . '"');
-    $same_height = $this->assertEquals($expected['height'], $height, 'Actual height of "' . $height . '" equals the expected width of "' . $expected['height'] . '"');
-    return $same_width && $same_height;
+    $this->assertEquals($expected['width'], $width, 'Actual width of "' . $width . '" equals the expected width of "' . $expected['width'] . '"');
+    $this->assertEquals($expected['height'], $height, 'Actual height of "' . $height . '" equals the expected width of "' . $expected['height'] . '"');
   }
 
 }
diff --git a/core/tests/Drupal/KernelTests/AssertContentTrait.php b/core/tests/Drupal/KernelTests/AssertContentTrait.php
index 997d8a959a94..58eabfc38890 100644
--- a/core/tests/Drupal/KernelTests/AssertContentTrait.php
+++ b/core/tests/Drupal/KernelTests/AssertContentTrait.php
@@ -802,9 +802,6 @@ 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') {
     // Don't use xpath as it messes with HTML escaping.
@@ -817,9 +814,11 @@ protected function assertTitle($title, $message = '', $group = 'Other') {
           '@expected' => var_export($title, TRUE),
         ]);
       }
-      return $this->assertEquals($title, $actual, $message);
+      $this->assertEquals($title, $actual, $message);
+    }
+    else {
+      $this->fail('No title element found on the page.');
     }
-    return $this->fail('No title element found on the page.');
   }
 
   /**
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityReferenceFieldTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityReferenceFieldTest.php
index 9c459aa432eb..9258c4acf70e 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityReferenceFieldTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityReferenceFieldTest.php
@@ -333,9 +333,6 @@ 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) {
     $storage = $this->entityTypeManager->getStorage('user');
@@ -345,7 +342,7 @@ protected function assertUserAutocreate(EntityInterface $entity, $setter_callbac
     $entity->save();
     $storage->resetCache();
     $user = User::load($user_id);
-    return $this->assertEquals($entity->user_id->target_id, $user->id());
+    $this->assertEquals($entity->user_id->target_id, $user->id());
   }
 
   /**
@@ -355,9 +352,6 @@ 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) {
     $storage = $this->entityTypeManager->getStorage('user_role');
@@ -367,7 +361,7 @@ protected function assertUserRoleAutocreate(EntityInterface $entity, $setter_cal
     $entity->save();
     $storage->resetCache();
     $role = Role::load($role_id);
-    return $this->assertEquals($entity->user_role->target_id, $role->id());
+    $this->assertEquals($entity->user_role->target_id, $role->id());
   }
 
   /**
diff --git a/core/tests/Drupal/KernelTests/Core/Field/FieldItemTest.php b/core/tests/Drupal/KernelTests/Core/Field/FieldItemTest.php
index 7c011ecff4f1..15ab322db081 100644
--- a/core/tests/Drupal/KernelTests/Core/Field/FieldItemTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Field/FieldItemTest.php
@@ -85,20 +85,16 @@ 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) {
     $entity->setNewRevision(TRUE);
     $entity->save();
     $base_field_expected_value = str_replace($this->fieldName, 'field_test_item', $expected_value);
-    $result = $this->assertEquals($base_field_expected_value, $entity->field_test_item->value);
-    $result = $result && $this->assertEquals($expected_value, $entity->{$this->fieldName}->value);
+    $this->assertEquals($base_field_expected_value, $entity->field_test_item->value);
+    $this->assertEquals($expected_value, $entity->{$this->fieldName}->value);
     $entity = $this->reloadEntity($entity);
-    $result = $result && $this->assertEquals($base_field_expected_value, $entity->field_test_item->value);
-    $result = $result && $this->assertEquals($expected_value, $entity->{$this->fieldName}->value);
-    return $result;
+    $this->assertEquals($base_field_expected_value, $entity->field_test_item->value);
+    $this->assertEquals($expected_value, $entity->{$this->fieldName}->value);
   }
 
 }
-- 
GitLab