Commit 27515dc2 authored by catch's avatar catch
Browse files

Issue #3130811 by mondrake, jungle, longwave: Remove redundant $message from...

Issue #3130811 by mondrake, jungle, longwave: Remove redundant $message from assert(Not)InstanceOf calls
parent de052f01
......@@ -42,7 +42,7 @@ protected function setUp(): void {
* Tests CRUD operations.
*/
public function testBlockCRUD() {
$this->assertInstanceOf(ConfigEntityStorage::class, $this->controller, 'The block storage is loaded.');
$this->assertInstanceOf(ConfigEntityStorage::class, $this->controller);
// Run each test method in the same installation.
$this->createTests();
......@@ -73,7 +73,7 @@ protected function createTests() {
]);
$entity->save();
$this->assertInstanceOf(Block::class, $entity, 'The newly created entity is a Block.');
$this->assertInstanceOf(Block::class, $entity);
// Verify all of the block properties.
$actual_properties = $this->config('block.block.test_block')->get();
......@@ -102,7 +102,7 @@ protected function createTests() {
$this->assertIdentical($actual_properties, $expected_properties);
$this->assertInstanceOf(TestHtmlBlock::class, $entity->getPlugin(), 'The entity has an instance of the correct block plugin.');
$this->assertInstanceOf(TestHtmlBlock::class, $entity->getPlugin());
}
/**
......@@ -111,7 +111,7 @@ protected function createTests() {
protected function loadTests() {
$entity = $this->controller->load('test_block');
$this->assertInstanceOf(Block::class, $entity, 'The loaded entity is a Block.');
$this->assertInstanceOf(Block::class, $entity);
// Verify several properties of the block.
$this->assertSame('content', $entity->getRegion());
......
......@@ -80,7 +80,7 @@ public function testRevisions() {
'@revision' => $loaded->getRevisionId(),
]));
if ($delta > 0) {
$this->assertInstanceOf(UserInterface::class, $loaded->getRevisionUser(), 'Revision User found.');
$this->assertInstanceOf(UserInterface::class, $loaded->getRevisionUser());
$this->assertTrue(is_numeric($loaded->getRevisionUserId()), 'Revision User ID found.');
$this->assertTrue(is_numeric($loaded->getRevisionCreationTime()), 'Revision time found.');
}
......
......@@ -71,7 +71,7 @@ public function testBlockContentTypeCreation() {
];
$this->drupalPostForm(NULL, $edit, t('Save'));
$block_type = BlockContentType::load('foo');
$this->assertInstanceOf(BlockContentType::class, $block_type, 'The new block type has been created.');
$this->assertInstanceOf(BlockContentType::class, $block_type);
$field_definitions = \Drupal::service('entity_field.manager')->getFieldDefinitions('block_content', 'foo');
$this->assertTrue(isset($field_definitions['body']), 'Body field created when using the UI to create block content types.');
......@@ -90,7 +90,7 @@ public function testBlockContentTypeCreation() {
$this->assertFalse(isset($field_definitions['body']), "Body field for 'other' block type not created when using the testing API to create block content types.");
$block_type = BlockContentType::load('other');
$this->assertInstanceOf(BlockContentType::class, $block_type, 'The new block type has been created.');
$this->assertInstanceOf(BlockContentType::class, $block_type);
$this->drupalGet('block/add/' . $block_type->id());
$this->assertResponse(200);
......
......@@ -150,7 +150,7 @@ public function testExistingFormat() {
$expected_settings = $expected_default_settings;
$expected_settings['plugins']['stylescombo']['styles'] = '';
$editor = Editor::load('filtered_html');
$this->assertInstanceOf(Editor::class, $editor, 'An Editor config entity exists now.');
$this->assertInstanceOf(Editor::class, $editor);
$this->assertEqual($expected_settings, $editor->getSettings(), 'The Editor config entity has the correct settings.');
// Configure the Styles plugin, and ensure the updated settings are saved.
......@@ -161,7 +161,7 @@ public function testExistingFormat() {
$this->drupalPostForm(NULL, $edit, t('Save configuration'));
$expected_settings['plugins']['stylescombo']['styles'] = "h1.title|Title\np.callout|Callout\n\n";
$editor = Editor::load('filtered_html');
$this->assertInstanceOf(Editor::class, $editor, 'An Editor config entity exists.');
$this->assertInstanceOf(Editor::class, $editor);
$this->assertEqual($expected_settings, $editor->getSettings(), 'The Editor config entity has the correct settings.');
// Change the buttons that appear on the toolbar (in JavaScript, this is
......@@ -177,7 +177,7 @@ public function testExistingFormat() {
];
$this->drupalPostForm(NULL, $edit, t('Save configuration'));
$editor = Editor::load('filtered_html');
$this->assertInstanceOf(Editor::class, $editor, 'An Editor config entity exists.');
$this->assertInstanceOf(Editor::class, $editor);
$this->assertEqual($expected_settings, $editor->getSettings(), 'The Editor config entity has the correct settings.');
// Check that the markup we're setting for the toolbar buttons (actually in
......@@ -205,7 +205,7 @@ public function testExistingFormat() {
$ultra_llama_mode_checkbox = $this->xpath('//input[@type="checkbox" and @name="editor[settings][plugins][llama_contextual_and_button][ultra_llama_mode]" and not(@checked)]');
$this->assertCount(1, $ultra_llama_mode_checkbox, 'The "Ultra llama mode" checkbox exists and is not checked.');
$editor = Editor::load('filtered_html');
$this->assertInstanceOf(Editor::class, $editor, 'An Editor config entity exists.');
$this->assertInstanceOf(Editor::class, $editor);
$this->assertEqual($expected_settings, $editor->getSettings(), 'The Editor config entity has the correct settings.');
// Finally, check the "Ultra llama mode" checkbox.
......@@ -219,7 +219,7 @@ public function testExistingFormat() {
$this->assertCount(1, $ultra_llama_mode_checkbox, 'The "Ultra llama mode" checkbox exists and is checked.');
$expected_settings['plugins']['llama_contextual_and_button']['ultra_llama_mode'] = TRUE;
$editor = Editor::load('filtered_html');
$this->assertInstanceOf(Editor::class, $editor, 'An Editor config entity exists.');
$this->assertInstanceOf(Editor::class, $editor);
$this->assertEqual($expected_settings, $editor->getSettings());
$this->drupalGet('admin/config/content/formats/add');
......@@ -293,13 +293,13 @@ public function testNewFormat() {
// Ensure a FilterFormat object exists now.
$filter_format = FilterFormat::load('amazing_format');
$this->assertInstanceOf(FilterFormatInterface::class, $filter_format, 'A FilterFormat config entity exists now.');
$this->assertInstanceOf(FilterFormatInterface::class, $filter_format);
// Ensure an Editor object exists now, with the proper settings.
$expected_settings = $default_settings;
$expected_settings['plugins']['stylescombo']['styles'] = '';
$editor = Editor::load('amazing_format');
$this->assertInstanceOf(Editor::class, $editor, 'An Editor config entity exists now.');
$this->assertInstanceOf(Editor::class, $editor);
$this->assertEqual($this->castSafeStrings($expected_settings), $this->castSafeStrings($editor->getSettings()), 'The Editor config entity has the correct settings.');
}
......
......@@ -45,7 +45,7 @@ public function testCommentDefaultFields() {
// Check that the 'comment_body' field is not deleted since it is persisted
// even if it has no fields.
$field_storage = FieldStorageConfig::loadByName('comment', 'comment_body');
$this->assertInstanceOf(FieldStorageConfig::class, $field_storage, 'The comment_body field storage was not deleted');
$this->assertInstanceOf(FieldStorageConfig::class, $field_storage);
// Create a new content type.
$type_name = 'test_node_type_2';
......@@ -55,7 +55,7 @@ public function testCommentDefaultFields() {
// Check that the 'comment_body' field exists and has an instance on the
// new comment bundle.
$field_storage = FieldStorageConfig::loadByName('comment', 'comment_body');
$this->assertInstanceOf(FieldStorageConfig::class, $field_storage, 'The comment_body field exists');
$this->assertInstanceOf(FieldStorageConfig::class, $field_storage);
$field = FieldConfig::loadByName('comment', 'comment', 'comment_body');
$this->assertTrue(isset($field), new FormattableMarkup('The comment_body field is present for comments on type @type', ['@type' => $type_name]));
......
......@@ -24,7 +24,7 @@ class CommentNodeChangesTest extends CommentTestBase {
public function testNodeDeletion() {
$this->drupalLogin($this->webUser);
$comment = $this->postComment($this->node, $this->randomMachineName(), $this->randomMachineName());
$this->assertInstanceOf(Comment::class, $comment, 'The comment could be loaded.');
$this->assertInstanceOf(Comment::class, $comment);
$this->node->delete();
$this->assertNull(Comment::load($comment->id()), 'The comment could not be loaded after the node was deleted.');
// Make sure the comment field storage and all its fields are deleted when
......
......@@ -54,7 +54,7 @@ public function testCommentPreview() {
\Drupal::state()->set('user_hooks_test_user_format_name_alter_safe', TRUE);
$this->drupalPostForm('node/' . $this->node->id(), $edit, t('Preview'));
$this->assertInstanceOf(MarkupInterface::class, $this->webUser->getDisplayName(), 'Username is marked safe');
$this->assertInstanceOf(MarkupInterface::class, $this->webUser->getDisplayName());
$this->assertNoEscaped('<em>' . $this->webUser->id() . '</em>');
$this->assertRaw('<em>' . $this->webUser->id() . '</em>');
......
......@@ -59,7 +59,7 @@ public function testCommentTypeCreation() {
$type = $this->createCommentType('other');
$comment_type = CommentType::load('other');
$this->assertInstanceOf(CommentType::class, $comment_type, 'The new comment type has been created.');
$this->assertInstanceOf(CommentType::class, $comment_type);
// Log in a test user.
$this->drupalLogin($this->adminUser);
......@@ -76,7 +76,7 @@ public function testCommentTypeCreation() {
];
$this->drupalPostForm('admin/structure/comment/types/add', $edit, t('Save'));
$comment_type = CommentType::load('foo');
$this->assertInstanceOf(CommentType::class, $comment_type, 'The new comment type has been created.');
$this->assertInstanceOf(CommentType::class, $comment_type);
// Check that the comment type was created in site default language.
$default_langcode = \Drupal::languageManager()->getDefaultLanguage()->getId();
......
......@@ -48,8 +48,8 @@ public function testCommentItem() {
$storage = $this->container->get('entity_type.manager')->getStorage('entity_test');
$storage->resetCache([$id]);
$entity = $storage->load($id);
$this->assertInstanceOf(FieldItemListInterface::class, $entity->comment, 'Field implements interface.');
$this->assertInstanceOf(CommentItemInterface::class, $entity->comment[0], 'Field item implements interface.');
$this->assertInstanceOf(FieldItemListInterface::class, $entity->comment);
$this->assertInstanceOf(CommentItemInterface::class, $entity->comment[0]);
// Test sample item generation.
/** @var \Drupal\entity_test\Entity\EntityTest $entity */
......
......@@ -46,7 +46,7 @@ public function testList() {
$controller = \Drupal::entityTypeManager()->getListBuilder('config_test');
// Test getStorage() method.
$this->assertInstanceOf(EntityStorageInterface::class, $controller->getStorage(), 'EntityStorage instance in storage.');
$this->assertInstanceOf(EntityStorageInterface::class, $controller->getStorage());
// Get a list of ConfigTest entities and confirm that it contains the
// ConfigTest entity provided by the config_test module.
......@@ -54,7 +54,7 @@ public function testList() {
$list = $controller->load();
$this->assertCount(1, $list, '1 ConfigTest entity found.');
$entity = $list['dotted.default'];
$this->assertInstanceOf(ConfigTest::class, $entity, '"Default" ConfigTest entity is an instance of ConfigTest.');
$this->assertInstanceOf(ConfigTest::class, $entity);
// Test getOperations() method.
$expected_operations = [
......
......@@ -198,7 +198,7 @@ public function testUnmetDependenciesInstall() {
$this->drupalPostForm('admin/modules', ['modules[config_other_module_config_test][enable]' => TRUE], t('Install'));
$this->drupalPostForm('admin/modules', ['modules[config_install_dependency_test][enable]' => TRUE], t('Install'));
$this->rebuildContainer();
$this->assertInstanceOf(ConfigTest::class, \Drupal::entityTypeManager()->getStorage('config_test')->load('other_module_test_with_dependency'), 'The config_test.dynamic.other_module_test_with_dependency configuration has been created during install.');
$this->assertInstanceOf(ConfigTest::class, \Drupal::entityTypeManager()->getStorage('config_test')->load('other_module_test_with_dependency'));
}
/**
......
......@@ -1156,9 +1156,7 @@ protected function assertDisabledTextarea($id) {
':id' => $id,
]);
$textarea = reset($textarea);
$this->assertInstanceOf(NodeElement::class, $textarea, new FormattableMarkup('Disabled field @id exists.', [
'@id' => $id,
]));
$this->assertInstanceOf(NodeElement::class, $textarea);
$expected = 'This field has been disabled because you do not have sufficient permissions to edit it.';
$this->assertEqual($textarea->getText(), $expected, new FormattableMarkup('Disabled textarea @id hides text in an inaccessible text format.', [
'@id' => $id,
......
......@@ -78,8 +78,8 @@ public function testDateTime() {
// Verify entity has been created properly.
$id = $entity->id();
$entity = EntityTest::load($id);
$this->assertInstanceOf(FieldItemListInterface::class, $entity->field_datetime, 'Field implements interface.');
$this->assertInstanceOf(FieldItemInterface::class, $entity->field_datetime[0], 'Field item implements interface.');
$this->assertInstanceOf(FieldItemListInterface::class, $entity->field_datetime);
$this->assertInstanceOf(FieldItemInterface::class, $entity->field_datetime[0]);
$this->assertEqual($entity->field_datetime->value, $value);
$this->assertEqual($entity->field_datetime[0]->value, $value);
$this->assertEqual(DateTimeItemInterface::STORAGE_TIMEZONE, $entity->field_datetime[0]->getProperties()['value']->getDateTime()->getTimeZone()->getName());
......@@ -122,8 +122,8 @@ public function testDateOnly() {
// Verify entity has been created properly.
$id = $entity->id();
$entity = EntityTest::load($id);
$this->assertInstanceOf(FieldItemListInterface::class, $entity->field_datetime, 'Field implements interface.');
$this->assertInstanceOf(FieldItemInterface::class, $entity->field_datetime[0], 'Field item implements interface.');
$this->assertInstanceOf(FieldItemListInterface::class, $entity->field_datetime);
$this->assertInstanceOf(FieldItemInterface::class, $entity->field_datetime[0]);
$this->assertEqual($entity->field_datetime->value, $value);
$this->assertEqual($entity->field_datetime[0]->value, $value);
$this->assertEquals(DateTimeItemInterface::STORAGE_TIMEZONE, $entity->field_datetime->date->getTimeZone()->getName());
......
......@@ -57,8 +57,8 @@ public function testBooleanItem() {
// Verify entity has been created properly.
$id = $entity->id();
$entity = EntityTest::load($id);
$this->assertInstanceOf(FieldItemListInterface::class, $entity->field_boolean, 'Field implements interface.');
$this->assertInstanceOf(FieldItemInterface::class, $entity->field_boolean[0], 'Field item implements interface.');
$this->assertInstanceOf(FieldItemListInterface::class, $entity->field_boolean);
$this->assertInstanceOf(FieldItemInterface::class, $entity->field_boolean[0]);
$this->assertEqual($entity->field_boolean->value, $value);
$this->assertEqual($entity->field_boolean[0]->value, $value);
......
......@@ -54,8 +54,8 @@ public function testEmailItem() {
// Verify entity has been created properly.
$id = $entity->id();
$entity = EntityTest::load($id);
$this->assertInstanceOf(FieldItemListInterface::class, $entity->field_email, 'Field implements interface.');
$this->assertInstanceOf(FieldItemInterface::class, $entity->field_email[0], 'Field item implements interface.');
$this->assertInstanceOf(FieldItemListInterface::class, $entity->field_email);
$this->assertInstanceOf(FieldItemInterface::class, $entity->field_email[0]);
$this->assertEqual($entity->field_email->value, $value);
$this->assertEqual($entity->field_email[0]->value, $value);
......
......@@ -128,8 +128,8 @@ public function testContentEntityReferenceItem() {
$entity->save();
$entity = EntityTest::load($entity->id());
$this->assertInstanceOf(FieldItemListInterface::class, $entity->field_test_taxonomy_term, 'Field implements interface.');
$this->assertInstanceOf(FieldItemInterface::class, $entity->field_test_taxonomy_term[0], 'Field item implements interface.');
$this->assertInstanceOf(FieldItemListInterface::class, $entity->field_test_taxonomy_term);
$this->assertInstanceOf(FieldItemInterface::class, $entity->field_test_taxonomy_term[0]);
$this->assertEqual($entity->field_test_taxonomy_term->target_id, $tid);
$this->assertEqual($entity->field_test_taxonomy_term->entity->getName(), $this->term->getName());
$this->assertEqual($entity->field_test_taxonomy_term->entity->id(), $tid);
......@@ -264,8 +264,8 @@ public function testConfigEntityReferenceItem() {
$entity->save();
$entity = EntityTest::load($entity->id());
$this->assertInstanceOf(FieldItemListInterface::class, $entity->field_test_taxonomy_vocabulary, 'Field implements interface.');
$this->assertInstanceOf(FieldItemInterface::class, $entity->field_test_taxonomy_vocabulary[0], 'Field item implements interface.');
$this->assertInstanceOf(FieldItemListInterface::class, $entity->field_test_taxonomy_vocabulary);
$this->assertInstanceOf(FieldItemInterface::class, $entity->field_test_taxonomy_vocabulary[0]);
$this->assertEqual($entity->field_test_taxonomy_vocabulary->target_id, $referenced_entity_id);
$this->assertEqual($entity->field_test_taxonomy_vocabulary->entity->label(), $this->vocabulary->label());
$this->assertEqual($entity->field_test_taxonomy_vocabulary->entity->id(), $referenced_entity_id);
......
......@@ -48,7 +48,7 @@ public function testCreateInstance() {
$instance = $field_type_manager->createInstance($type, $configuration);
$this->assertInstanceOf($class, $instance, new FormattableMarkup('Created a @class instance', ['@class' => $class]));
$this->assertInstanceOf($class, $instance);
$this->assertEqual($field_name, $instance->getName(), new FormattableMarkup('Instance name is @name', ['@name' => $field_name]));
}
}
......@@ -79,7 +79,7 @@ public function testCreateInstanceWithConfig() {
$instance = $field_type_manager->createInstance($type, $configuration);
$this->assertInstanceOf($class, $instance, new FormattableMarkup('Created a @class instance', ['@class' => $class]));
$this->assertInstanceOf($class, $instance);
$this->assertEqual($field_name, $instance->getName(), new FormattableMarkup('Instance name is @name', ['@name' => $field_name]));
$this->assertEqual($instance->getFieldDefinition()->getLabel(), 'Jenny', 'Instance label is Jenny');
$this->assertEqual($instance->getFieldDefinition()->getDefaultValue($entity), [['value' => 8675309]], 'Instance default_value is 8675309');
......
......@@ -62,16 +62,16 @@ public function testNumberItem() {
// Verify entity has been created properly.
$id = $entity->id();
$entity = EntityTest::load($id);
$this->assertInstanceOf(FieldItemListInterface::class, $entity->field_integer, 'Field implements interface.');
$this->assertInstanceOf(FieldItemInterface::class, $entity->field_integer[0], 'Field item implements interface.');
$this->assertInstanceOf(FieldItemListInterface::class, $entity->field_integer);
$this->assertInstanceOf(FieldItemInterface::class, $entity->field_integer[0]);
$this->assertEqual($entity->field_integer->value, $integer);
$this->assertEqual($entity->field_integer[0]->value, $integer);
$this->assertInstanceOf(FieldItemListInterface::class, $entity->field_float, 'Field implements interface.');
$this->assertInstanceOf(FieldItemInterface::class, $entity->field_float[0], 'Field item implements interface.');
$this->assertInstanceOf(FieldItemListInterface::class, $entity->field_float);
$this->assertInstanceOf(FieldItemInterface::class, $entity->field_float[0]);
$this->assertEqual($entity->field_float->value, $float);
$this->assertEqual($entity->field_float[0]->value, $float);
$this->assertInstanceOf(FieldItemListInterface::class, $entity->field_decimal, 'Field implements interface.');
$this->assertInstanceOf(FieldItemInterface::class, $entity->field_decimal[0], 'Field item implements interface.');
$this->assertInstanceOf(FieldItemListInterface::class, $entity->field_decimal);
$this->assertInstanceOf(FieldItemInterface::class, $entity->field_decimal[0]);
$this->assertEqual($entity->field_decimal->value, (float) $decimal);
$this->assertEqual($entity->field_decimal[0]->value, (float) $decimal);
......
......@@ -61,8 +61,8 @@ public function testShapeItem() {
// Verify entity has been created properly.
$id = $entity->id();
$entity = EntityTest::load($id);
$this->assertInstanceOf(FieldItemListInterface::class, $entity->{$this->fieldName}, 'Field implements interface.');
$this->assertInstanceOf(FieldItemInterface::class, $entity->{$this->fieldName}[0], 'Field item implements interface.');
$this->assertInstanceOf(FieldItemListInterface::class, $entity->{$this->fieldName});
$this->assertInstanceOf(FieldItemInterface::class, $entity->{$this->fieldName}[0]);
$this->assertEqual($entity->{$this->fieldName}->shape, $shape);
$this->assertEqual($entity->{$this->fieldName}->color, $color);
$this->assertEqual($entity->{$this->fieldName}[0]->shape, $shape);
......
......@@ -60,8 +60,8 @@ public function testTestItem() {
// Verify entity has been created properly.
$id = $entity->id();
$entity = EntityTest::load($id);
$this->assertInstanceOf(FieldItemListInterface::class, $entity->{$this->fieldName}, 'Field implements interface.');
$this->assertInstanceOf(FieldItemInterface::class, $entity->{$this->fieldName}[0], 'Field item implements interface.');
$this->assertInstanceOf(FieldItemListInterface::class, $entity->{$this->fieldName});
$this->assertInstanceOf(FieldItemInterface::class, $entity->{$this->fieldName}[0]);
$this->assertEqual($entity->{$this->fieldName}->value, $value);
$this->assertEqual($entity->{$this->fieldName}[0]->value, $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