Commit 78e14d73 authored by catch's avatar catch

Issue #3128905 by jungle, longwave, Kristen Pol, mondrake: Replace assert*...

Issue #3128905 by jungle, longwave, Kristen Pol, mondrake: Replace assert* involving an instanceof operator with assertInstanceOf()/assertNotInstanceOf()

(cherry picked from commit 4fe0b034)
parent a6e1bd14
......@@ -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(): void {
* Tests CRUD operations.
*/
public function testBlockCRUD() {
$this->assertTrue($this->controller instanceof ConfigEntityStorage, 'The block storage is loaded.');
$this->assertInstanceOf(ConfigEntityStorage::class, $this->controller, 'The block storage is loaded.');
// 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, 'The newly created entity is a Block.');
// 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(), 'The entity has an instance of the correct block plugin.');
}
/**
......@@ -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, 'The loaded entity is a Block.');
// Verify several properties of the block.
$this->assertSame('content', $entity->getRegion());
......
......@@ -78,7 +78,7 @@ protected function setUp(): void {
*/
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(): void {
*/
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());
......
......@@ -80,7 +80,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(), 'Revision User found.');
$this->assertTrue(is_numeric($loaded->getRevisionUserId()), 'Revision User ID found.');
$this->assertTrue(is_numeric($loaded->getRevisionCreationTime()), 'Revision time found.');
}
......
......@@ -36,14 +36,14 @@ protected function setUp(): void {
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(): void {
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(): void {
*/
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, 'An Editor config entity exists now.');
$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, 'An Editor config entity exists.');
$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, 'An Editor config entity exists.');
$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->assertTrue($editor instanceof Editor, 'An Editor config entity exists.');
$this->assertInstanceOf(Editor::class, $editor, 'An Editor config entity exists.');
$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->assertTrue($editor instanceof Editor, 'An Editor config entity exists.');
$this->assertInstanceOf(Editor::class, $editor, 'An Editor config entity exists.');
$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, 'A FilterFormat config entity exists now.');
// 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, 'An Editor config entity exists now.');
$this->assertEqual($this->castSafeStrings($expected_settings), $this->castSafeStrings($editor->getSettings()), 'The Editor config entity has the correct settings.');
}
......
......@@ -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(), 'Username is marked safe');
$this->assertNoEscaped('<em>' . $this->webUser->id() . '</em>');
$this->assertRaw('<em>' . $this->webUser->id() . '</em>');
......
......@@ -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, 'Field implements interface.');
$this->assertInstanceOf(CommentItemInterface::class, $entity->comment[0], 'Field item implements interface.');
// Test sample item generation.
/** @var \Drupal\entity_test\Entity\EntityTest $entity */
......
......@@ -1156,7 +1156,7 @@ protected function assertDisabledTextarea($id) {
':id' => $id,
]);
$textarea = reset($textarea);
$this->assertTrue($textarea instanceof NodeElement, new FormattableMarkup('Disabled field @id exists.', [
$this->assertInstanceOf(NodeElement::class, $textarea, new FormattableMarkup('Disabled field @id exists.', [
'@id' => $id,
]));
$expected = 'This field has been disabled because you do not have sufficient permissions to edit it.';
......
......@@ -45,7 +45,7 @@ protected function setUp(): void {
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, 'Field implements interface.');
$this->assertInstanceOf(FieldItemInterface::class, $entity->field_datetime[0], 'Field item implements interface.');
$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, 'Field implements interface.');
$this->assertInstanceOf(FieldItemInterface::class, $entity->field_datetime[0], 'Field item implements interface.');
$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->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, 'Field implements interface.');
$this->assertInstanceOf(FieldItemInterface::class, $entity->field_boolean[0], 'Field item implements interface.');
$this->assertEqual($entity->field_boolean->value, $value);
$this->assertEqual($entity->field_boolean[0]->value, $value);
......
......@@ -45,7 +45,7 @@ protected function setUp(): void {
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, 'Field implements interface.');
$this->assertInstanceOf(FieldItemInterface::class, $entity->field_email[0], 'Field item implements interface.');
$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, 'Field implements interface.');
$this->assertInstanceOf(FieldItemInterface::class, $entity->field_test_taxonomy_term[0], 'Field item implements interface.');
$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, 'Field implements interface.');
$this->assertInstanceOf(FieldItemInterface::class, $entity->field_test_taxonomy_vocabulary[0], 'Field item implements interface.');
$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->assertTrue($instance instanceof $class, new FormattableMarkup('Created a @class instance', ['@class' => $class]));
$this->assertInstanceOf($class, $instance, new FormattableMarkup('Created a @class instance', ['@class' => $class]));
$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->assertTrue($instance instanceof $class, new FormattableMarkup('Created a @class instance', ['@class' => $class]));
$this->assertInstanceOf($class, $instance, new FormattableMarkup('Created a @class instance', ['@class' => $class]));
$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(): void {
*/
protected function assertEntity($id) {
$display = EntityViewDisplay::load($id);
$this->assertTrue($display instanceof EntityViewDisplayInterface);
$this->assertInstanceOf(EntityViewDisplayInterface::class, $display);
}
/**
......
......@@ -52,7 +52,7 @@ protected function setUp(): void {
protected function assertEntity($id, $expected_entity_type, $expected_bundle) {
/** @var \Drupal\Core\Entity\Display\EntityFormDisplayInterface $entity */
$entity = EntityFormDisplay::load($id);
$this->assertTrue($entity instanceof EntityFormDisplayInterface);
$this->assertInstanceOf(EntityFormDisplayInterface::class, $entity);
$this->assertIdentical($expected_entity_type, $entity->getTargetEntityTypeId());
$this->assertIdentical($expected_bundle, $entity->getTargetBundle());
}
......
......@@ -38,7 +38,7 @@ protected function setUp(): void {
protected function assertEntity($id, $label, $entity_type) {
/** @var \Drupal\Core\Entity\EntityViewModeInterface $view_mode */
$view_mode = EntityViewMode::load($id);
$this->assertTrue($view_mode instanceof EntityViewModeInterface);
$this->assertInstanceOf(EntityViewModeInterface::class, $view_mode);
$this->assertIdentical($label, $view_mode->label());
$this->assertIdentical($entity_type, $view_mode->getTargetType());
}
......
......@@ -62,16 +62,16 @@ public function testNumberItem() {
// Verify entity has been created properly.
$id = $entity->id();
$entity = EntityTest::load($id);
$this->assertTrue($entity->field_integer instanceof FieldItemListInterface, 'Field implements interface.');
$this->assertTrue($entity->field_integer[0] instanceof FieldItemInterface, 'Field item implements interface.');
$this->assertInstanceOf(FieldItemListInterface::class, $entity->field_integer, 'Field implements interface.');
$this->assertInstanceOf(FieldItemInterface::class, $entity->field_integer[0], 'Field item implements interface.');
$this->assertEqual($entity->field_integer->value, $integer);
$this->assertEqual($entity->field_integer[0]->value, $integer);
$this->assertTrue($entity->field_float instanceof FieldItemListInterface, 'Field implements interface.');
$this->assertTrue($entity->field_float[0] instanceof FieldItemInterface, 'Field item implements interface.');
$this->assertInstanceOf(FieldItemListInterface::class, $entity->field_float, 'Field implements interface.');
$this->assertInstanceOf(FieldItemInterface::class, $entity->field_float[0], 'Field item implements interface.');
$this->assertEqual($entity->field_float->value, $float);
$this->assertEqual($entity->field_float[0]->value, $float);
$this->assertTrue($entity->field_decimal instanceof FieldItemListInterface, 'Field implements interface.');
$this->assertTrue($entity->field_decimal[0] instanceof FieldItemInterface, 'Field item implements interface.');
$this->assertInstanceOf(FieldItemListInterface::class, $entity->field_decimal, 'Field implements interface.');
$this->assertInstanceOf(FieldItemInterface::class, $entity->field_decimal[0], 'Field item implements interface.');
$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->assertTrue($entity->{$this->fieldName} instanceof FieldItemListInterface, 'Field implements interface.');
$this->assertTrue($entity->{$this->fieldName}[0] instanceof FieldItemInterface, 'Field item implements interface.');
$this->assertInstanceOf(FieldItemListInterface::class, $entity->{$this->fieldName}, 'Field implements interface.');
$this->assertInstanceOf(FieldItemInterface::class, $entity->{$this->fieldName}[0], 'Field item implements interface.');
$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->assertTrue($entity->{$this->fieldName} instanceof FieldItemListInterface, 'Field implements interface.');
$this->assertTrue($entity->{$this->fieldName}[0] instanceof FieldItemInterface, 'Field item implements interface.');
$this->assertInstanceOf(FieldItemListInterface::class, $entity->{$this->fieldName}, 'Field implements interface.');
$this->assertInstanceOf(FieldItemInterface::class, $entity->{$this->fieldName}[0], 'Field item implements interface.');
$this->assertEqual($entity->{$this->fieldName}->value, $value);
$this->assertEqual($entity->{$this->fieldName}[0]->value, $value);
......
......@@ -52,7 +52,7 @@ public function testTestObjectItem() {
// Verify that the entity has been created properly.
$id = $entity->id();
$entity = EntityTest::load($id);
$this->assertTrue($entity->field_test->value instanceof \stdClass);
$this->assertInstanceOf(\stdClass::class, $entity->field_test->value);
$this->assertEquals($object, $entity->field_test->value);
}
......
......@@ -64,8 +64,8 @@ public function testDateTime() {
// Verify entity has been created properly.
$id = $entity->id();
$entity = EntityTest::load($id);
$this->assertTrue($entity->field_timestamp instanceof FieldItemListInterface, 'Field implements interface.');
$this->assertTrue($entity->field_timestamp[0] instanceof FieldItemInterface, 'Field item implements interface.');
$this->assertInstanceOf(FieldItemListInterface::class, $entity->field_timestamp, 'Field implements interface.');
$this->assertInstanceOf(FieldItemInterface::class, $entity->field_timestamp[0], 'Field item implements interface.');
$this->assertEquals($entity->field_timestamp->value, $value);
$this->assertEquals($entity->field_timestamp[0]->value, $value);
......
......@@ -93,8 +93,8 @@ public function testFileItem() {
$entity->save();
$entity = EntityTest::load($entity->id());
$this->assertTrue($entity->file_test instanceof FieldItemListInterface, 'Field implements interface.');
$this->assertTrue($entity->file_test[0] instanceof FieldItemInterface, 'Field item implements interface.');
$this->assertInstanceOf(FieldItemListInterface::class, $entity->file_test, 'Field implements interface.');
$this->assertInstanceOf(FieldItemInterface::class, $entity->file_test[0], 'Field item implements interface.');
$this->assertEqual($entity->file_test->target_id, $this->file->id());
$this->assertEqual($entity->file_test->display, 1);
$this->assertEqual($entity->file_test->description, $description);
......
......@@ -53,7 +53,7 @@ protected function setUp(): void {
protected function assertEntity($fid, $name, $size, $uri, $type, $uid) {
/** @var \Drupal\file\FileInterface $file */
$file = File::load($fid);
$this->assertTrue($file instanceof FileInterface);
$this->assertInstanceOf(FileInterface::class, $file);
$this->assertIdentical($name, $file->getFilename());
$this->assertIdentical($size, $file->getSize());
$this->assertIdentical($uri, $file->getFileUri());
......
......@@ -335,7 +335,7 @@ public function testTypedDataAPI() {