Commit e76b29a0 authored by catch's avatar catch
Browse files

Issue #3222783 by longwave, mondrake: Result of method...

Issue #3222783 by longwave, mondrake: Result of method PHPUnit\Framework\Assert::assertEquals() (void) is used
parent 88498c78
......@@ -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)]));
}
/**
......
......@@ -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);
}
/**
......
......@@ -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'] . '"');
}
}
......@@ -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.');
}
/**
......
......@@ -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());
}
/**
......
......@@ -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);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment