Issue #3222783 by longwave, mondrake: Result of method PHPUnit\Framework\Assert::assertEquals() (void) is used

(cherry picked from commit e76b29a0de)
merge-requests/934/head
catch 2021-07-08 15:56:55 +01:00
parent 344d697fd8
commit 9d892208b8
6 changed files with 14 additions and 31 deletions

View File

@ -224,7 +224,7 @@ class CommentPagerTest extends CommentTestBase {
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)]));
}
/**

View File

@ -259,16 +259,13 @@ class ContentTranslationSettingsTest extends BrowserTestBase {
* 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);
}
/**

View File

@ -219,8 +219,6 @@ class EditorUploadImageScaleTest extends BrowserTestBase {
* 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 @@ class EditorUploadImageScaleTest extends BrowserTestBase {
'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'] . '"');
}
}

View File

@ -802,9 +802,6 @@ trait AssertContentTrait {
* 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 @@ trait AssertContentTrait {
'@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.');
}
/**

View File

@ -333,9 +333,6 @@ class EntityReferenceFieldTest extends EntityKernelTestBase {
* 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 @@ class EntityReferenceFieldTest extends EntityKernelTestBase {
$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 @@ class EntityReferenceFieldTest extends EntityKernelTestBase {
* 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 @@ class EntityReferenceFieldTest extends EntityKernelTestBase {
$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());
}
/**

View File

@ -85,20 +85,16 @@ class FieldItemTest extends EntityKernelTestBase {
* 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);
}
}