Commit 286c1b57 authored by catch's avatar catch
Browse files

Issue #3130811 by mondrake, jungle, longwave, ravi.shankar: Remove redundant...

Issue #3130811 by mondrake, jungle, longwave, ravi.shankar: Remove redundant $message from assert(Not)InstanceOf calls
parent 8e265e8f
......@@ -61,7 +61,7 @@ public function testActions() {
protected function assertEntity($id, $label, $type, $configuration) {
$action = Action::load($id);
$this->assertTrue($action instanceof Action);
$this->assertInstanceOf(Action::class, $action);
/** @var \Drupal\system\Entity\Action $action */
$this->assertIdentical($id, $action->id());
$this->assertIdentical($label, $action->label());
......
......@@ -61,7 +61,7 @@ public function testActions() {
protected function assertEntity($id, $label, $type, $configuration) {
$action = Action::load($id);
$this->assertTrue($action instanceof Action);
$this->assertInstanceOf(Action::class, $action);
/** @var \Drupal\system\Entity\Action $action */
$this->assertIdentical($id, $action->id());
$this->assertIdentical($label, $action->label());
......
......@@ -42,7 +42,7 @@ protected function setUp() {
* Tests CRUD operations.
*/
public function testBlockCRUD() {
$this->assertTrue($this->controller instanceof ConfigEntityStorage, '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->assertTrue($entity instanceof Block, '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->assertTrue($entity->getPlugin() instanceof TestHtmlBlock, '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->assertTrue($entity instanceof Block, 'The loaded entity is a Block.');
$this->assertInstanceOf(Block::class, $entity);
// Verify several properties of the block.
$this->assertSame('content', $entity->getRegion());
......
......@@ -78,7 +78,7 @@ protected function setUp() {
*/
public function assertEntity($id, $visibility, $region, $theme, $weight, array $settings = NULL, $status = TRUE) {
$block = Block::load($id);
$this->assertTrue($block instanceof Block);
$this->assertInstanceOf(Block::class, $block);
$this->assertSame($visibility, $block->getVisibility());
$this->assertSame($region, $block->getRegion());
$this->assertSame($theme, $block->getTheme());
......@@ -303,7 +303,7 @@ public function testBlockMigration() {
// Custom block with php code is not migrated.
$block = Block::load('block_3');
$this->assertFalse($block instanceof Block);
$this->assertNotInstanceOf(Block::class, $block);
}
}
......@@ -84,7 +84,7 @@ protected function setUp() {
*/
public function assertEntity($id, $plugin_id, array $roles, $pages, $region, $theme, $weight, $label, $label_display, $status = TRUE) {
$block = Block::load($id);
$this->assertTrue($block instanceof Block);
$this->assertInstanceOf(Block::class, $block);
/** @var \Drupal\block\BlockInterface $block */
$this->assertSame($plugin_id, $block->getPluginId());
......
......@@ -84,7 +84,7 @@ public function testRevisions() {
'@revision' => $loaded->getRevisionId(),
]));
if ($delta > 0) {
$this->assertTrue($loaded->getRevisionUser() instanceof UserInterface, '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);
......
......@@ -34,8 +34,8 @@ public function testSimpleUpdates() {
$post_revision_created = $entity_definition_update_manager->getFieldStorageDefinition('revision_created', 'block_content');
$post_revision_user = $entity_definition_update_manager->getFieldStorageDefinition('revision_user', 'block_content');
$this->assertTrue($post_revision_created instanceof BaseFieldDefinition, "Revision created field found");
$this->assertTrue($post_revision_user instanceof BaseFieldDefinition, "Revision user field found");
$this->assertInstanceOf(BaseFieldDefinition::class, $post_revision_created);
$this->assertInstanceOf(BaseFieldDefinition::class, $post_revision_user);
$this->assertEqual('created', $post_revision_created->getType(), "Field is type created");
$this->assertEqual('entity_reference', $post_revision_user->getType(), "Field is type entity_reference");
......
......@@ -36,14 +36,14 @@ protected function setUp() {
public function testBlockContentBodyFieldMigration() {
/** @var \Drupal\field\FieldStorageConfigInterface $storage */
$storage = FieldStorageConfig::load('block_content.body');
$this->assertTrue($storage instanceof FieldStorageConfigInterface);
$this->assertInstanceOf(FieldStorageConfigInterface::class, $storage);
$this->assertIdentical('block_content', $storage->getTargetEntityTypeId());
$this->assertIdentical(['basic'], array_values($storage->getBundles()));
$this->assertIdentical('body', $storage->getName());
/** @var \Drupal\field\FieldConfigInterface $field */
$field = FieldConfig::load('block_content.basic.body');
$this->assertTrue($field instanceof FieldConfigInterface);
$this->assertInstanceOf(FieldConfigInterface::class, $field);
$this->assertIdentical('block_content', $field->getTargetEntityTypeId());
$this->assertIdentical('basic', $field->getTargetBundle());
$this->assertIdentical('body', $field->getName());
......
......@@ -31,7 +31,7 @@ protected function setUp() {
public function testBlockContentTypeMigration() {
/** @var \Drupal\block_content\BlockContentTypeInterface $entity */
$entity = BlockContentType::load('basic');
$this->assertTrue($entity instanceof BlockContentTypeInterface);
$this->assertInstanceOf(BlockContentTypeInterface::class, $entity);
$this->assertIdentical('Basic', $entity->label());
}
......
......@@ -40,7 +40,7 @@ protected function setUp() {
*/
public function testCustomBlockMigration() {
$block = BlockContent::load(1);
$this->assertTrue($block instanceof BlockContentInterface);
$this->assertInstanceOf(BlockContentInterface::class, $block);
/** @var \Drupal\block_content\BlockContentInterface $block */
$this->assertIdentical('Limerick', $block->label());
......
......@@ -64,7 +64,7 @@ public function testSetAccessDependency($use_set_first) {
// Calling setAccessDependency() replaces the existing dependency.
$testRefinable->setAccessDependency($this->neutral);
$dependency = $testRefinable->getAccessDependency();
$this->assertFalse($dependency instanceof AccessGroupAnd);
$this->assertNotInstanceOf(AccessGroupAnd::class, $dependency);
$accessResult = $dependency->access('view', $this->account, TRUE);
$this->assertTrue($accessResult->isNeutral());
$this->assertEquals('I have no opinion', $accessResult->getReason());
......@@ -92,7 +92,7 @@ public function testMergeNonGroup($use_set_first) {
/** @var \Drupal\block_content\Access\AccessGroupAnd $dependency */
$dependency = $testRefinable->getAccessDependency();
// Ensure the new dependency create a new AND group when merged.
$this->assertTrue($dependency instanceof AccessGroupAnd);
$this->assertInstanceOf(AccessGroupAnd::class, $dependency);
$dependencies = $dependency->getDependencies();
$accessResultForbidden = $dependencies[0]->access('view', $this->account, TRUE);
$this->assertTrue($accessResultForbidden->isForbidden());
......@@ -123,7 +123,7 @@ public function testMergeGroup($use_set_first) {
$dependency = $testRefinable->getAccessDependency();
// Ensure the new dependency is merged with the existing group.
$this->assertTrue($dependency instanceof AccessGroupAnd);
$this->assertInstanceOf(AccessGroupAnd::class, $dependency);
$dependencies = $dependency->getDependencies();
$accessResultForbidden = $dependencies[0]->access('view', $this->account, TRUE);
$this->assertTrue($accessResultForbidden->isForbidden());
......
......@@ -150,7 +150,7 @@ public function testExistingFormat() {
$expected_settings = $expected_default_settings;
$expected_settings['plugins']['stylescombo']['styles'] = '';
$editor = Editor::load('filtered_html');
$this->assertTrue($editor instanceof 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->assertTrue($editor instanceof 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->assertTrue($editor instanceof 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->assertTrue(count($ultra_llama_mode_checkbox) === 1, 'The "Ultra llama mode" checkbox exists and is not checked.');
$editor = Editor::load('filtered_html');
$this->assertTrue($editor instanceof 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->assertTrue(count($ultra_llama_mode_checkbox) === 1, '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->assertTrue($editor instanceof 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->assertTrue($filter_format instanceof FilterFormatInterface, '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->assertTrue($editor instanceof 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->assertTrue($this->webUser->getDisplayName() instanceof MarkupInterface, '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->assertTrue($entity->comment instanceof FieldItemListInterface, 'Field implements interface.');
$this->assertTrue($entity->comment[0] instanceof CommentItemInterface, '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->assertTrue($textarea instanceof NodeElement, 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,
......
......@@ -45,7 +45,7 @@ protected function setUp() {
protected function assertEntity($id, $expected_label, array $expected_recipients, $expected_reply, $expected_weight) {
/** @var \Drupal\contact\ContactFormInterface $entity */
$entity = ContactForm::load($id);
$this->assertTrue($entity instanceof ContactFormInterface);
$this->assertInstanceOf(ContactFormInterface::class, $entity);
$this->assertIdentical($expected_label, $entity->label());
$this->assertIdentical($expected_recipients, $entity->getRecipients());
$this->assertIdentical($expected_reply, $entity->getReply());
......
......@@ -78,8 +78,8 @@ public function testDateTime() {
// Verify entity has been created properly.
$id = $entity->id();
$entity = EntityTest::load($id);
$this->assertTrue($entity->field_datetime instanceof FieldItemListInterface, 'Field implements interface.');
$this->assertTrue($entity->field_datetime[0] instanceof FieldItemInterface, '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->assertTrue($entity->field_datetime instanceof FieldItemListInterface, 'Field implements interface.');
$this->assertTrue($entity->field_datetime[0] instanceof FieldItemInterface, '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());
......
......@@ -193,13 +193,13 @@ public function testFieldUpdate8500() {
$this->assertCount(1, $deleted_fields);
$this->assertArrayHasKey($field_uuid, $deleted_fields);
$this->assertTrue($deleted_fields[$field_uuid] instanceof FieldDefinitionInterface);
$this->assertInstanceOf(FieldDefinitionInterface::class, $deleted_fields[$field_uuid]);
$this->assertEquals($field_name, $deleted_fields[$field_uuid]->getName());
$deleted_field_storages = $deleted_fields_repository->getFieldStorageDefinitions();
$this->assertCount(1, $deleted_field_storages);
$this->assertArrayHasKey($field_storage_uuid, $deleted_field_storages);
$this->assertTrue($deleted_field_storages[$field_storage_uuid] instanceof FieldStorageDefinitionInterface);
$this->assertInstanceOf(FieldStorageDefinitionInterface::class, $deleted_field_storages[$field_storage_uuid]);
$this->assertEquals($field_name, $deleted_field_storages[$field_storage_uuid]->getName());
// Check that the installed storage schema still exists.
......
......@@ -57,8 +57,8 @@ public function testBooleanItem() {
// Verify entity has been created properly.
$id = $entity->id();
$entity = EntityTest::load($id);
$this->assertTrue($entity->field_boolean instanceof FieldItemListInterface, 'Field implements interface.');
$this->assertTrue($entity->field_boolean[0] instanceof FieldItemInterface, '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);
......
......@@ -45,7 +45,7 @@ protected function setUp() {
public function testBundleFieldDefinition() {
$definitions = \Drupal::service('entity_field.manager')->getFieldDefinitions($this->entityType, $this->bundle);
$this->assertTrue(isset($definitions[$this->fieldTestData->field->getName()]));
$this->assertTrue($definitions[$this->fieldTestData->field->getName()] instanceof FieldDefinitionInterface);
$this->assertInstanceOf(FieldDefinitionInterface::class, $definitions[$this->fieldTestData->field->getName()]);
// Make sure fields on other entity types are not exposed.
$this->assertFalse(isset($definitions[$this->fieldTestData->field_rev->getName()]));
}
......@@ -56,7 +56,7 @@ public function testBundleFieldDefinition() {
public function testFieldStorageDefinition() {
$field_storage_definitions = \Drupal::service('entity_field.manager')->getFieldStorageDefinitions($this->entityType);
$this->assertTrue(isset($field_storage_definitions[$this->fieldTestData->field->getName()]));
$this->assertTrue($field_storage_definitions[$this->fieldTestData->field->getName()] instanceof FieldStorageDefinitionInterface);
$this->assertInstanceOf(FieldStorageDefinitionInterface::class, $field_storage_definitions[$this->fieldTestData->field->getName()]);
// Make sure storages on other entity types are not exposed.
$this->assertFalse(isset($field_storage_definitions[$this->fieldTestData->field_rev->getName()]));
}
......
......@@ -54,8 +54,8 @@ public function testEmailItem() {
// Verify entity has been created properly.
$id = $entity->id();
$entity = EntityTest::load($id);
$this->assertTrue($entity->field_email instanceof FieldItemListInterface, 'Field implements interface.');
$this->assertTrue($entity->field_email[0] instanceof FieldItemInterface, '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,15 +128,15 @@ public function testContentEntityReferenceItem() {
$entity->save();
$entity = EntityTest::load($entity->id());
$this->assertTrue($entity->field_test_taxonomy_term instanceof FieldItemListInterface, 'Field implements interface.');
$this->assertTrue($entity->field_test_taxonomy_term[0] instanceof FieldItemInterface, '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);
$this->assertEqual($entity->field_test_taxonomy_term->entity->uuid(), $this->term->uuid());
// Verify that the label for the target ID property definition is correct.
$label = $entity->field_test_taxonomy_term->getFieldDefinition()->getFieldStorageDefinition()->getPropertyDefinition('target_id')->getLabel();
$this->assertTrue($label instanceof TranslatableMarkup);
$this->assertInstanceOf(TranslatableMarkup::class, $label);
$this->assertEqual($label->render(), 'Taxonomy term ID');
// Change the name of the term via the reference.
......@@ -247,7 +247,7 @@ public function testContentEntityReferenceItemWithStringId() {
$this->assertEqual($this->entityStringId->id(), $storage->load($entity->id())->field_test_entity_test_string_id->target_id);
// Verify that the label for the target ID property definition is correct.
$label = $entity->field_test_taxonomy_term->getFieldDefinition()->getFieldStorageDefinition()->getPropertyDefinition('target_id')->getLabel();
$this->assertTrue($label instanceof TranslatableMarkup);
$this->assertInstanceOf(TranslatableMarkup::class, $label);
$this->assertEqual($label->render(), 'Taxonomy term ID');
}
......@@ -264,8 +264,8 @@ public function testConfigEntityReferenceItem() {
$entity->save();
$entity = EntityTest::load($entity->id());
$this->assertTrue($entity->field_test_taxonomy_vocabulary instanceof FieldItemListInterface, 'Field implements interface.');
$this->assertTrue($entity->field_test_taxonomy_vocabulary[0] instanceof FieldItemInterface, '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);
......
......@@ -51,7 +51,7 @@ public function testCreateInstance() {
$instance = $field_type_manager->createInstance($type, $configuration);
$this->assertTrue($instance instanceof $class, 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]));
}
}
......@@ -82,7 +82,7 @@ public function testCreateInstanceWithConfig() {
$instance = $field_type_manager->createInstance($type, $configuration);
$this->assertTrue($instance instanceof $class, 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');
......
......@@ -45,7 +45,7 @@ protected function setUp() {
*/
protected function assertEntity($id) {
$display = EntityViewDisplay::load($id);
$this->assertTrue($display instanceof EntityViewDisplayInterface);
$this->assertInstanceOf(EntityViewDisplayInterface::class, $display