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);
......
......@@ -64,8 +64,8 @@ public function testDateTime() {
// Verify entity has been created properly.
$id = $entity->id();
$entity = EntityTest::load($id);
$this->assertInstanceOf(FieldItemListInterface::class, $entity->field_timestamp, 'Field implements interface.');
$this->assertInstanceOf(FieldItemInterface::class, $entity->field_timestamp[0], 'Field item implements interface.');
$this->assertInstanceOf(FieldItemListInterface::class, $entity->field_timestamp);
$this->assertInstanceOf(FieldItemInterface::class, $entity->field_timestamp[0]);
$this->assertEquals($entity->field_timestamp->value, $value);
$this->assertEquals($entity->field_timestamp[0]->value, $value);
......
......@@ -608,7 +608,7 @@ public function testHiddenFields() {
->getFormDisplay('node', $this->contentType)
->setComponent($field_name)
->save();
$this->assertInstanceOf(FieldConfig::class, FieldConfig::load('node.' . $this->contentType . '.' . $field_name), new FormattableMarkup('A field of the field storage %field was created programmatically.', ['%field' => $field_name]));
$this->assertInstanceOf(FieldConfig::class, FieldConfig::load('node.' . $this->contentType . '.' . $field_name));
// Check that the newly added field appears on the 'Manage Fields'
// screen.
......
......@@ -102,7 +102,7 @@ public function testNormal() {
$max_fid_after = (int) \Drupal::entityQueryAggregate('file')->aggregate('fid', 'max')->execute()[0]['fid_max'];
$this->assertTrue($max_fid_after > $this->maxFidBefore, 'A new file was created.');
$file1 = File::load($max_fid_after);
$this->assertInstanceOf(File::class, $file1, 'Loaded the file.');
$this->assertInstanceOf(File::class, $file1);
// MIME type of the uploaded image may be either image/jpeg or image/png.
$this->assertEqual(substr($file1->getMimeType(), 0, 5), 'image', 'A MIME type was set.');
......@@ -123,7 +123,7 @@ public function testNormal() {
$this->assertFileHooksCalled(['validate', 'insert']);
$file2 = File::load($max_fid_after);
$this->assertInstanceOf(File::class, $file2, 'Loaded the file');
$this->assertInstanceOf(File::class, $file2);
// MIME type of the uploaded image may be either image/jpeg or image/png.
$this->assertEqual(substr($file2->getMimeType(), 0, 5), 'image', 'A MIME type was set.');
......
......@@ -97,7 +97,7 @@ public function testNormal() {
$max_fid_after = (int) \Drupal::entityQueryAggregate('file')->aggregate('fid', 'max')->execute()[0]['fid_max'];
$this->assertTrue($max_fid_after > $this->maxFidBefore, 'A new file was created.');
$file1 = File::load($max_fid_after);
$this->assertInstanceOf(File::class, $file1, 'Loaded the file.');
$this->assertInstanceOf(File::class, $file1);
// MIME type of the uploaded image may be either image/jpeg or image/png.
$this->assertEqual(substr($file1->getMimeType(), 0, 5), 'image', 'A MIME type was set.');
......@@ -116,7 +116,7 @@ public function testNormal() {
$this->assertFileHooksCalled(['validate', 'insert']);
$file2 = File::load($max_fid_after);
$this->assertInstanceOf(File::class, $file2, 'Loaded the file');
$this->assertInstanceOf(File::class, $file2);
// MIME type of the uploaded image may be either image/jpeg or image/png.
$this->assertEqual(substr($file2->getMimeType(), 0, 5), 'image', 'A MIME type was set.');
......
......@@ -85,7 +85,7 @@ public function testCronDeleteNonExistingTemporary() {
// Delete the file, but leave it in the file_managed table.
\Drupal::service('file_system')->delete($file->getFileUri());
$this->assertFalse(file_exists($file->getFileUri()), 'File is deleted from the filesystem.');
$this->assertInstanceOf(File::class, File::load($file->id()), 'File exist in file_managed table');
$this->assertInstanceOf(File::class, File::load($file->id()));
// Call file_cron() to clean up the file. Make sure the changed timestamp
// of the file is older than the system.file.temporary_maximum_age
......
......@@ -93,8 +93,8 @@ public function testFileItem() {
$entity->save();
$entity = EntityTest::load($entity->id());
$this->assertInstanceOf(FieldItemListInterface::class, $entity->file_test, 'Field implements interface.');
$this->assertInstanceOf(FieldItemInterface::class, $entity->file_test[0], 'Field item implements interface.');
$this->assertInstanceOf(FieldItemListInterface::class, $entity->file_test);
$this->assertInstanceOf(FieldItemInterface::class, $entity->file_test[0]);
$this->assertEqual($entity->file_test->target_id, $this->file->id());
$this->assertEqual($entity->file_test->display, 1);
$this->assertEqual($entity->file_test->description, $description);
......
......@@ -335,7 +335,7 @@ public function testTypedDataAPI() {
$definition = DataDefinition::create('filter_format');
$data = \Drupal::typedDataManager()->create($definition);
$this->assertInstanceOf(OptionsProviderInterface::class, $data, 'Typed data object implements \Drupal\Core\TypedData\OptionsProviderInterface');
$this->assertInstanceOf(OptionsProviderInterface::class, $data);
$filtered_html_user = $this->createUser(['uid' => 2], [
FilterFormat::load('filtered_html')->getPermissionName(),
......
......@@ -89,8 +89,8 @@ public function testImageItem() {
$entity->save();
$entity = EntityTest::load($entity->id());
$this->assertInstanceOf(FieldItemListInterface::class, $entity->image_test, 'Field implements interface.');
$this->assertInstanceOf(FieldItemInterface::class, $entity->image_test[0], 'Field item implements interface.');
$this->assertInstanceOf(FieldItemListInterface::class, $entity->image_test);
$this->assertInstanceOf(FieldItemInterface::class, $entity->image_test[0]);
$this->assertEqual($entity->image_test->target_id, $this->image->id());
$this->assertEqual($entity->image_test->alt, $alt);
$this->assertEqual($entity->image_test->title, $title);
......
......@@ -92,8 +92,8 @@ public function testLinkItem() {
// Verify that the field value is changed.
$id = $entity->id();
$entity = EntityTest::load($id);
$this->assertInstanceOf(FieldItemListInterface::class, $entity->field_test, 'Field implements interface.');
$this->assertInstanceOf(FieldItemInterface::class, $entity->field_test[0], 'Field item implements interface.');
$this->assertInstanceOf(FieldItemListInterface::class, $entity->field_test);
$this->assertInstanceOf(FieldItemInterface::class, $entity->field_test[0]);
$this->assertEqual($entity->field_test->uri, $parsed_url['path']);
$this->assertEqual($entity->field_test[0]->uri, $parsed_url['path']);
$this->assertEqual($entity->field_test->title, $title);
......
......@@ -86,7 +86,7 @@ public function testMediaTypes() {
$source = $media_type->getSource();
/** @var \Drupal\field\FieldConfigInterface $source_field */
$source_field = $source->getSourceFieldDefinition($media_type);
$this->assertInstanceOf(FieldConfigInterface::class, $source_field, 'Source field exists.');
$this->assertInstanceOf(FieldConfigInterface::class, $source_field);
$this->assertFalse($source_field->isNew(), 'Source field was saved.');
/** @var \Drupal\field\FieldStorageConfigInterface $storage */
$storage = $source_field->getFieldStorageDefinition();
......
......@@ -22,12 +22,12 @@ class MediaCreationTest extends MediaKernelTestBase {
public function testMediaTypeCreation() {
$media_type_storage = $this->container->get('entity_type.manager')->getStorage('media_type');
$this->assertInstanceOf(MediaTypeInterface::class, MediaType::load($this->testMediaType->id()), 'The new media type has not been correctly created in the database.');
$this->assertInstanceOf(MediaTypeInterface::class, MediaType::load($this->testMediaType->id()));
// Test a media type created from default configuration.
$this->container->get('module_installer')->install(['media_test_type']);
$test_media_type = $media_type_storage->load('test');
$this->assertInstanceOf(MediaTypeInterface::class, $test_media_type, 'The media type from default configuration has not been created in the database.');
$this->assertInstanceOf(MediaTypeInterface::class, $test_media_type);
$this->assertSame('Test type', $test_media_type->get('label'), 'Could not assure the correct type name.');
$this->assertSame('Test type.', $test_media_type->get('description'), 'Could not assure the correct type description.');
$this->assertSame('test', $test_media_type->get('source'), 'Could not assure the correct media source.');
......@@ -69,9 +69,9 @@ public function testMediaEntityCreation() {
]);
$media->save();
$this->assertNotInstanceOf(MediaInterface::class, Media::load(rand(1000, 9999)), 'Failed asserting a non-existent media.');
$this->assertNotInstanceOf(MediaInterface::class, Media::load(rand(1000, 9999)));
$this->assertInstanceOf(MediaInterface::class, Media::load($media->id()), 'The new media item has not been created in the database.');
$this->assertInstanceOf(MediaInterface::class, Media::load($media->id()));
$this->assertSame($this->testMediaType->id(), $media->bundle(), 'The media item was not created with the correct type.');
$this->assertSame('Unnamed', $media->getName(), 'The media item was not created with the correct name.');
$source_field_name = $media->bundle->entity->getSource()->getSourceFieldDefinition($media->bundle->entity)->getName();
......
......@@ -222,7 +222,7 @@ public function testMenuNodeFormWidget() {
// Assert that the link is still in the Administration menu after save.
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save'));