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
......@@ -163,7 +163,7 @@ public function testDenormalize() {
$this->normalizer->setSerializer($serializer_prophecy->reveal());
$denormalized = $this->normalizer->denormalize($timestamp_item_normalization, TimestampItem::class, NULL, $context);
$this->assertTrue($denormalized instanceof TimestampItem);
$this->assertInstanceOf(TimestampItem::class, $denormalized);
}
/**
......
......@@ -59,7 +59,7 @@ public function testShortcutSetMigration() {
*/
protected function assertEntity($id, $label, $expected_size) {
$shortcut_set = ShortcutSet::load($id);
$this->assertTrue($shortcut_set instanceof ShortcutSetInterface);
$this->assertInstanceOf(ShortcutSetInterface::class, $shortcut_set);
/** @var \Drupal\shortcut\ShortcutSetInterface $shortcut_set */
$this->assertIdentical($id, $shortcut_set->id());
$this->assertIdentical($label, $shortcut_set->label());
......
......@@ -53,7 +53,7 @@ protected function setUp() {
*/
protected function assertEntity($id, $title, $weight, $url) {
$shortcut = Shortcut::load($id);
$this->assertTrue($shortcut instanceof ShortcutInterface);
$this->assertInstanceOf(ShortcutInterface::class, $shortcut);
/** @var \Drupal\shortcut\ShortcutInterface $shortcut */
$this->assertIdentical($title, $shortcut->getTitle());
$this->assertIdentical($weight, $shortcut->getWeight());
......
......@@ -678,7 +678,7 @@ protected function createCacheId(array $keys, array $contexts) {
protected function verifyRenderCache($cid, array $tags, $redirected_cid = NULL) {
// Also verify the existence of an entity render cache entry.
$cache_entry = \Drupal::cache('render')->get($cid);
$this->assertInstanceOf(\stdClass::class, $cache_entry, 'A render cache entry exists.');
$this->assertInstanceOf(\stdClass::class, $cache_entry);
sort($cache_entry->tags);
sort($tags);
$this->assertIdentical($cache_entry->tags, $tags);
......
......@@ -100,7 +100,7 @@ public function testEntityFormLanguage() {
// Check to make sure the node was created.
$node = $this->drupalGetNodeByTitle($edit['title[0][value]']);
$this->assertInstanceOf(Node::class, $node, 'Node found in database.');
$this->assertInstanceOf(Node::class, $node);
// Make body translatable.
$field_storage = FieldStorageConfig::loadByName('node', 'body');
......
......@@ -38,8 +38,8 @@ protected function setUp() {
/**
* Checks to see if a value is a Twig template.
*/
public function assertTwigTemplate($value, $message = '', $group = 'Other') {
$this->assertTrue($value instanceof TemplateWrapper, $message, $group);
public function assertTwigTemplate($value, $message = '') {
$this->assertInstanceOf(TemplateWrapper::class, $value, $message);
}
/**
......
......@@ -58,9 +58,9 @@ public function testUpdate() {
// Verify that all the links from system module have a been updated with
// a TranslatableMarkup as title and description due to the rebuild.
if (strpos($link->id, 'system.') === 0) {
$this->assertTrue($title instanceof TranslatableMarkup, get_class($title));
$this->assertInstanceOf(TranslatableMarkup::class, $title);
if ($description) {
$this->assertTrue($description instanceof TranslatableMarkup, get_class($description));
$this->assertInstanceOf(TranslatableMarkup::class, $description);
}
}
}
......
......@@ -54,7 +54,7 @@ public function testOperations() {
// Create an instance of the 'save entity' action.
$action = $this->actionManager->createInstance('action_test_save_entity');
$this->assertTrue($action instanceof ActionInterface, 'The action implements the correct interface.');
$this->assertInstanceOf(ActionInterface::class, $action);
// Create a new unsaved user.
$name = $this->randomMachineName();
......
......@@ -35,7 +35,7 @@ protected function setUp() {
public function testGetNoSettings() {
$php = PhpStorageFactory::get('test');
// This should be the default class used.
$this->assertTrue($php instanceof MTimeProtectedFileStorage, 'An MTimeProtectedFileStorage instance was returned with no settings.');
$this->assertInstanceOf(MTimeProtectedFileStorage::class, $php);
}
/**
......@@ -44,7 +44,7 @@ public function testGetNoSettings() {
public function testGetDefault() {
$this->setSettings();
$php = PhpStorageFactory::get('test');
$this->assertTrue($php instanceof MockPhpStorage, 'A FileReadOnlyStorage instance was returned with default settings.');
$this->assertInstanceOf(MockPhpStorage::class, $php);
}
/**
......@@ -54,24 +54,24 @@ public function testGetOverride() {
$this->setSettings('test');
$php = PhpStorageFactory::get('test');
// The FileReadOnlyStorage should be used from settings.
$this->assertTrue($php instanceof MockPhpStorage, 'A MockPhpStorage instance was returned from overridden settings.');
$this->assertInstanceOf(MockPhpStorage::class, $php);
// Test that the name is used for the bin when it is NULL.
$this->setSettings('test', ['bin' => NULL]);
$php = PhpStorageFactory::get('test');
$this->assertTrue($php instanceof MockPhpStorage, 'An MockPhpStorage instance was returned from overridden settings.');
$this->assertInstanceOf(MockPhpStorage::class, $php);
$this->assertSame('test', $php->getConfigurationValue('bin'), 'Name value was used for bin.');
// Test that a default directory is set if it's empty.
$this->setSettings('test', ['directory' => NULL]);
$php = PhpStorageFactory::get('test');
$this->assertTrue($php instanceof MockPhpStorage, 'An MockPhpStorage instance was returned from overridden settings.');
$this->assertInstanceOf(MockPhpStorage::class, $php);
$this->assertSame(PublicStream::basePath() . '/php', $php->getConfigurationValue('directory'), 'Default file directory was used.');
// Test that a default storage class is set if it's empty.
$this->setSettings('test', ['class' => NULL]);
$php = PhpStorageFactory::get('test');
$this->assertTrue($php instanceof MTimeProtectedFileStorage, 'An MTimeProtectedFileStorage instance was returned from overridden settings with no class.');
$this->assertInstanceOf(MTimeProtectedFileStorage::class, $php);
// Test that a default secret is not returned if it's set in the override.
$this->setSettings('test');
......
......@@ -33,8 +33,8 @@ protected function setUp() {
/**
* Checks to see if a value is a twig template.
*/
public function assertTwigTemplate($value, $message = '', $group = 'Other') {
$this->assertTrue($value instanceof TemplateWrapper, $message, $group);
public function assertTwigTemplate($value, $message = '') {
$this->assertInstanceOf(TemplateWrapper::class, $value, $message);
}
/**
......
......@@ -95,14 +95,14 @@ public function testTaxonomyRelationships() {
// Also check that we have the correct result entity.
$this->assertEqual($row->_entity->id(), $this->terms[$index]->id());
$this->assertTrue($row->_entity instanceof TermInterface);
$this->assertInstanceOf(TermInterface::class, $row->_entity);
if (!$index) {
$this->assertTrue($row->_relationship_entities['parent'] instanceof TermInterface);
$this->assertInstanceOf(TermInterface::class, $row->_relationship_entities['parent']);
$this->assertEqual($row->_relationship_entities['parent']->id(), $this->term2->id());
$this->assertEqual($row->taxonomy_term_field_data_taxonomy_term__parent_tid, $this->term2->id());
}
$this->assertTrue($row->_relationship_entities['nid'] instanceof NodeInterface);
$this->assertInstanceOf(NodeInterface::class, $row->_relationship_entities['nid']);
$this->assertEqual($row->_relationship_entities['nid']->id(), $this->nodes[$index]->id());
}
......
......@@ -41,7 +41,7 @@ protected function setUp() {
*/
public function testMigration() {
$node = Node::load(2);
$this->assertTrue($node instanceof NodeInterface);
$this->assertInstanceOf(NodeInterface::class, $node);
$this->assertEqual(9, $node->field_tags[0]->target_id);
$this->assertEqual(14, $node->field_tags[1]->target_id);
$this->assertEqual(17, $node->field_tags[2]->target_id);
......
......@@ -41,7 +41,7 @@ protected function setUp() {
protected function assertEntity($id, $expected_label, $expected_description, $expected_weight) {
/** @var \Drupal\taxonomy\VocabularyInterface $entity */
$entity = Vocabulary::load($id);
$this->assertTrue($entity instanceof VocabularyInterface);
$this->assertInstanceOf(VocabularyInterface::class, $entity);
$this->assertIdentical($expected_label, $entity->label());
$this->assertIdentical($expected_description, $entity->getDescription());
$this->assertIdentical($expected_weight, $entity->get('weight'));
......
......@@ -54,8 +54,8 @@ public function testTestItem() {
// Verify entity has been created properly.
$id = $entity->id();
$entity = EntityTest::load($id);
$this->assertTrue($entity->field_test instanceof FieldItemListInterface, 'Field implements interface.');
$this->assertTrue($entity->field_test[0] instanceof FieldItemInterface, 'Field item implements interface.');
$this->assertInstanceOf(FieldItemListInterface::class, $entity->field_test);
$this->assertInstanceOf(FieldItemInterface::class, $entity->field_test[0]);
$this->assertEqual($entity->field_test->value, $value);
$this->assertEqual($entity->field_test[0]->value, $value);
......
......@@ -68,8 +68,8 @@ public function testCrudAndUpdate() {
$entity->save();
$entity = $storage->load($entity->id());
$this->assertTrue($entity->summary_field instanceof FieldItemListInterface, 'Field implements interface.');
$this->assertTrue($entity->summary_field[0] instanceof FieldItemInterface, 'Field item implements interface.');
$this->assertInstanceOf(FieldItemListInterface::class, $entity->summary_field);
$this->assertInstanceOf(FieldItemInterface::class, $entity->summary_field[0]);
$this->assertEqual($entity->summary_field->value, $value);
$this->assertEqual($entity->summary_field->summary, $summary);
$this->assertNull($entity->summary_field->format);
......
......@@ -472,7 +472,7 @@ public function testUserDelete() {
$this->assertNull($node_storage->load($node->id()), 'Node of the user has been deleted.');
$this->assertNull(node_revision_load($revision), 'Node revision of the user has been deleted.');
$node_storage->resetCache([$revision_node->id()]);
$this->assertInstanceOf(Node::class, $node_storage->load($revision_node->id()), "Current revision of the user's node was not deleted.");
$this->assertInstanceOf(Node::class, $node_storage->load($revision_node->id()));
\Drupal::entityTypeManager()->getStorage('comment')->resetCache([$comment->id()]);
$this->assertNull(Comment::load($comment->id()), 'Comment of the user has been deleted.');
......
......@@ -52,7 +52,7 @@ public function testAccessRole() {
$executable->setDisplay('page_1');
$access_plugin = $executable->display_handler->getPlugin('access');
$this->assertTrue($access_plugin instanceof Role, 'Make sure the right class got instantiated.');
$this->assertInstanceOf(Role::class, $access_plugin);
// Test the access() method on the access plugin.
$this->assertSame(FALSE, $executable->display_handler->access($this->webUser));
......
......@@ -32,7 +32,7 @@ protected function setUp() {
public function testUserPictureField() {
/** @var \Drupal\field\FieldConfigInterface $field */
$field = FieldConfig::load('user.user.user_picture');
$this->assertTrue($field instanceof FieldConfigInterface);
$this->assertInstanceOf(FieldConfigInterface::class, $field);
$this->assertIdentical('user', $field->getTargetEntityTypeId());
$this->assertIdentical('user', $field->getTargetBundle());
$this->assertIdentical('user_picture', $field->getName());
......
......@@ -29,7 +29,7 @@ protected function setUp() {
public function testUserPictureField() {
/** @var \Drupal\field\FieldStorageConfigInterface $field_storage */
$field_storage = FieldStorageConfig::load('user.user_picture');
$this->assertTrue($field_storage instanceof FieldStorageConfigInterface);
$this->assertInstanceOf(FieldStorageConfigInterface::class, $field_storage);
$this->assertIdentical('user.user_picture', $field_storage->id());
$this->assertIdentical('image', $field_storage->getType());
$this->assertIdentical('user', $field_storage->getTargetEntityTypeId());
......
......@@ -35,7 +35,7 @@ protected function setUp() {
protected function assertEntity($id, $label, $original_rid) {
/** @var \Drupal\user\RoleInterface $entity */
$entity = Role::load($id);
$this->assertTrue($entity instanceof RoleInterface);
$this->assertInstanceOf(RoleInterface::class, $entity);
$this->assertIdentical($label, $entity->label());
if (isset($original_rid)) {
......
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