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
......@@ -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);
}
/**
......
......@@ -52,7 +52,7 @@ protected function setUp() {
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() {
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);
$this->assertInstanceOf(FieldItemInterface::class, $entity->field_integer[0]);
$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);
$this->assertInstanceOf(FieldItemInterface::class, $entity->field_float[0]);
$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);
$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->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});
$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->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});
$this->assertInstanceOf(FieldItemInterface::class, $entity->{$this->fieldName}[0]);
$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);
$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.');
......
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