Issue #3130811 by mondrake, jungle, longwave, ravi.shankar: Remove redundant $message from assert(Not)InstanceOf calls
parent
8e265e8fe0
commit
286c1b57b2
|
@ -61,7 +61,7 @@ class MigrateActionsTest extends MigrateDrupal6TestBase {
|
|||
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 @@ class MigrateActionsTest extends MigrateDrupal7TestBase {
|
|||
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 @@ class BlockStorageUnitTest extends KernelTestBase {
|
|||
* 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 @@ class BlockStorageUnitTest extends KernelTestBase {
|
|||
]);
|
||||
$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 @@ class BlockStorageUnitTest extends KernelTestBase {
|
|||
|
||||
$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 @@ class BlockStorageUnitTest extends KernelTestBase {
|
|||
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 @@ class MigrateBlockTest extends MigrateDrupal6TestBase {
|
|||
*/
|
||||
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 @@ class MigrateBlockTest extends MigrateDrupal6TestBase {
|
|||
|
||||
// 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 @@ class MigrateBlockTest extends MigrateDrupal7TestBase {
|
|||
*/
|
||||
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 @@ class BlockContentRevisionsTest extends BlockContentTestBase {
|
|||
'@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 @@ class BlockContentTypeTest extends BlockContentTestBase {
|
|||
];
|
||||
$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 @@ class BlockContentTypeTest extends BlockContentTestBase {
|
|||
$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 @@ class BlockContentUpdateTest extends UpdatePathTestBase {
|
|||
|
||||
$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 @@ class MigrateBlockContentBodyFieldTest extends MigrateDrupal7TestBase {
|
|||
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 @@ class MigrateBlockContentTypeTest extends MigrateDrupal7TestBase {
|
|||
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 @@ class MigrateCustomBlockTest extends MigrateDrupal7TestBase {
|
|||
*/
|
||||
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 @@ class DependentAccessTest extends UnitTestCase {
|
|||
// 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 @@ class DependentAccessTest extends UnitTestCase {
|
|||
/** @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 @@ class DependentAccessTest extends UnitTestCase {
|
|||
$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 @@ class CKEditorAdminTest extends BrowserTestBase {
|
|||
$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 @@ class CKEditorAdminTest extends BrowserTestBase {
|
|||
$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 @@ class CKEditorAdminTest extends BrowserTestBase {
|
|||
];
|
||||
$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 @@ class CKEditorAdminTest extends BrowserTestBase {
|
|||
$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 @@ class CKEditorAdminTest extends BrowserTestBase {
|
|||
$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 @@ class CKEditorAdminTest extends BrowserTestBase {
|
|||
|
||||
// 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 @@ class CommentFieldsTest extends CommentTestBase {
|
|||
// 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 @@ class CommentFieldsTest extends CommentTestBase {
|
|||
// 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 @@ class CommentPreviewTest extends CommentTestBase {
|
|||
|
||||
\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 @@ class CommentTypeTest extends CommentTestBase {
|
|||
$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 @@ class CommentTypeTest extends CommentTestBase {
|
|||
];
|
||||
$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 @@ class CommentItemTest extends FieldKernelTestBase {
|
|||
$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 @@ class ConfigEntityListTest extends BrowserTestBase {
|
|||
$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 @@ class ConfigEntityListTest extends BrowserTestBase {
|
|||
$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 @@ class ConfigInstallWebTest extends BrowserTestBase {
|
|||
$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 @@ class ConfigTranslationUiTest extends BrowserTestBase {
|
|||
':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 @@ class MigrateContactCategoryTest extends MigrateDrupal6TestBase {
|
|||
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 @@ class DateTimeItemTest extends FieldKernelTestBase {
|
|||
// 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 @@ class DateTimeItemTest extends FieldKernelTestBase {
|
|||
// 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 @@ class FieldUpdateTest extends UpdatePathTestBase {
|
|||
|
||||
$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 @@ class BooleanItemTest extends FieldKernelTestBase {
|
|||
// 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 @@ class ConfigFieldDefinitionTest extends FieldKernelTestBase {
|
|||
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 @@ class ConfigFieldDefinitionTest extends FieldKernelTestBase {
|
|||
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 @@ class EmailItemTest extends FieldKernelTestBase {
|
|||
// 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 @@ class EntityReferenceItemTest extends FieldKernelTestBase {
|
|||
$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 @@ class EntityReferenceItemTest extends FieldKernelTestBase {
|
|||
$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 @@ class EntityReferenceItemTest extends FieldKernelTestBase {
|
|||
$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 @@ class FieldTypePluginManagerTest extends FieldKernelTestBase {
|
|||
|
||||
$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 @@ class FieldTypePluginManagerTest extends FieldKernelTestBase {
|
|||
|
||||
$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 @@ class MigrateFieldFormatterSettingsTest extends MigrateDrupal7TestBase {
|
|||
*/
|
||||
protected function assertEntity($id) {
|
||||
$display = EntityViewDisplay::load($id);
|
||||
$this->assertTrue($display instanceof EntityViewDisplayInterface);
|
||||
$this->assertInstanceOf(EntityViewDisplayInterface::class, $display);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -52,7 +52,7 @@ class MigrateFieldInstanceWidgetSettingsTest extends MigrateDrupal7TestBase {
|
|||
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 @@ class MigrateViewModesTest extends MigrateDrupal7TestBase {
|
|||
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 @@ class NumberItemTest extends FieldKernelTestBase {
|
|||
// 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 @@ class ShapeItemTest extends FieldKernelTestBase {
|
|||
// 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 @@ class TestItemTest extends FieldKernelTestBase {
|
|||
// 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 @@ class TestObjectItemTest extends FieldKernelTestBase {
|
|||
// 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 @@ class TimestampItemTest extends FieldKernelTestBase {
|
|||
// 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 @@ class ManageFieldsFunctionalTest extends BrowserTestBase {
|
|||
->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 @@ class SaveUploadFormTest extends FileManagedTestBase {
|
|||
$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 @@ class SaveUploadFormTest extends FileManagedTestBase {
|
|||
$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 @@ class SaveUploadTest extends FileManagedTestBase {
|
|||
$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 @@ class SaveUploadTest extends FileManagedTestBase {
|
|||
$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 @@ class DeleteTest extends FileManagedUnitTestBase {
|
|||
// 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 @@ class FileItemTest extends FieldKernelTestBase {
|
|||
$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);
|
||||
$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);
|
||||
|
|
|
@ -53,7 +53,7 @@ class MigrateFileTest extends MigrateDrupal6TestBase implements MigrateDumpAlter
|
|||
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 @@ class FilterAPITest extends EntityKernelTestBase {
|
|||
$definition = DataDefinition::create('filter_format');
|
||||
$data = \Drupal::typedDataManager()->create($definition);
|
||||
|
||||
$this->assertTrue($data instanceof OptionsProviderInterface, '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 @@ class ImageItemTest extends FieldKernelTestBase {
|
|||
$entity->save();
|
||||
|
||||
$entity = EntityTest::load($entity->id());
|
||||
$this->assertTrue($entity->image_test instanceof FieldItemListInterface, 'Field implements interface.');
|
||||
$this->assertTrue($entity->image_test[0] instanceof FieldItemInterface, '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);
|
||||
|
|
|
@ -51,7 +51,7 @@ class MigrateImageStylesTest extends MigrateDrupal7TestBase {
|
|||
*/
|
||||
protected function assertEntity($id, $label, array $expected_effect_plugins, array $expected_effect_config) {
|
||||
$style = ImageStyle::load($id);
|
||||
$this->assertTrue($style instanceof ImageStyleInterface);
|
||||
$this->assertInstanceOf(ImageStyleInterface::class, $style);
|
||||
/** @var \Drupal\image\ImageStyleInterface $style */
|
||||
$this->assertIdentical($id, $style->id());
|
||||
$this->assertIdentical($label, $style->label());
|
||||
|
@ -62,7 +62,7 @@ class MigrateImageStylesTest extends MigrateDrupal7TestBase {
|
|||
|
||||
$index = 0;
|
||||
foreach ($effects as $effect) {
|
||||
$this->assertTrue($effect instanceof ImageEffectBase);
|
||||
$this->assertInstanceOf(ImageEffectBase::class, $effect);
|
||||
$this->assertIdentical($expected_effect_plugins[$index], $effect->getPluginId());
|
||||
$config = $effect->getConfiguration();
|
||||
$this->assertIdentical($expected_effect_config[$index], $config['data']);
|
||||
|
|
|
@ -102,7 +102,7 @@ class SerializerTest extends JsonapiKernelTestBase {
|
|||
];
|
||||
|
||||
$value = $this->sut->normalize($this->node->field_text, 'api_json', $context);
|
||||
$this->assertTrue($value instanceof CacheableNormalization);
|
||||
$this->assertInstanceOf(CacheableNormalization::class, $value);
|
||||
|
||||
$nested_field = [
|
||||
$this->node->field_text,
|
||||
|
@ -117,7 +117,7 @@ class SerializerTest extends JsonapiKernelTestBase {
|
|||
// When wrapped in an array, we should still be using the JSON:API
|
||||
// serializer.
|
||||
$value = $this->sut->normalize($nested_field, 'api_json', $context);
|
||||
$this->assertTrue($value[0] instanceof CacheableNormalization);
|
||||
$this->assertInstanceOf(CacheableNormalization::class, $value[0]);
|
||||
|
||||
// Continue to use the fallback normalizer when we need it.
|
||||
$data = Markup::create('<h2>Test Markup</h2>');
|
||||
|
|
|
@ -32,7 +32,7 @@ class MigrateLanguageTest extends MigrateDrupal6TestBase {
|
|||
protected function assertLanguage($id, $label, $direction = ConfigurableLanguageInterface::DIRECTION_LTR, $weight = 0) {
|
||||
/** @var \Drupal\language\ConfigurableLanguageInterface $language */
|
||||
$language = ConfigurableLanguage::load($id);
|
||||
$this->assertTrue($language instanceof ConfigurableLanguageInterface);
|
||||
$this->assertInstanceOf(ConfigurableLanguageInterface::class, $language);
|
||||
$this->assertIdentical($label, $language->label());
|
||||
$this->assertIdentical($direction, $language->getDirection());
|
||||
$this->assertIdentical(0, $language->getWeight());
|
||||
|
|
|
@ -92,8 +92,8 @@ class LinkItemTest extends FieldKernelTestBase {
|
|||
// Verify that the field value is changed.
|
||||
$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->uri, $parsed_url['path']);
|
||||
$this->assertEqual($entity->field_test[0]->uri, $parsed_url['path']);
|
||||
$this->assertEqual($entity->field_test->title, $title);
|
||||
|
|
|
@ -472,11 +472,11 @@ class LocaleConfigSubscriberTest extends KernelTestBase {
|
|||
]);
|
||||
$this->assertIdentical(1, count($strings));
|
||||
$string = reset($strings);
|
||||
$this->assertTrue($string instanceof StringInterface);
|
||||
$this->assertInstanceOf(StringInterface::class, $string);
|
||||
/** @var \Drupal\locale\StringInterface $string */
|
||||
$this->assertIdentical($translation, $string->getString());
|
||||
$this->assertTrue($string->isTranslation());
|
||||
$this->assertTrue($string instanceof TranslationString);
|
||||
$this->assertInstanceOf(TranslationString::class, $string);
|
||||
/** @var \Drupal\locale\TranslationString $string */
|
||||
// Make sure the string is marked as customized so that it does not get
|
||||
// overridden when the string translations are updated.
|
||||
|
|
|
@ -86,7 +86,7 @@ class MediaUiJavascriptTest extends MediaJavascriptTestBase {
|
|||
$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 @@ class MediaCreationTest extends MediaKernelTestBase {
|
|||
]);
|
||||
$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();
|
||||
|
|
|
@ -65,7 +65,7 @@ class MenuLinkContentDeriverTest extends KernelTestBase {
|
|||
$tree_element = reset($menu_tree);
|
||||
$this->assertEqual('route_name_2', $tree_element->link->getRouteName());
|
||||
$title = $tree_element->link->getTitle();
|
||||
$this->assertFalse($title instanceof TranslatableMarkup);
|
||||
$this->assertNotInstanceOf(TranslatableMarkup::class, $title);
|
||||
$this->assertIdentical('<script>alert("Welcome to the discovered jungle!")</script>', $title);
|
||||
|
||||
// Create a hierarchy.
|
||||
|
|
|
@ -222,7 +222,7 @@ class MenuUiNodeTest extends BrowserTestBase {
|
|||
// Assert that the link is still in the Administration menu after save.
|
||||
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save'));
|
||||
$link = MenuLinkContent::load($item->id());
|
||||
$this->assertInstanceOf(MenuLinkContent::class, $link, 'Link in not allowed menu still exists after saving node');
|
||||
$this->assertInstanceOf(MenuLinkContent::class, $link);
|
||||
|
||||
// Move the menu link back to the Tools menu.
|
||||
$item->menu_name->value = 'tools';
|
||||
|
|
|
@ -621,7 +621,7 @@ class MenuUiTest extends BrowserTestBase {
|
|||
$menu_links = \Drupal::entityTypeManager()->getStorage('menu_link_content')->loadByProperties(['title' => $title]);
|
||||
|
||||
$menu_link = reset($menu_links);
|
||||
$this->assertInstanceOf(MenuLinkContent::class, $menu_link, 'Menu link was found in database.');
|
||||
$this->assertInstanceOf(MenuLinkContent::class, $menu_link);
|
||||
$this->assertMenuLink(['menu_name' => $menu_name, 'children' => [], 'parent' => $parent], $menu_link->getPluginId());
|
||||
|
||||
return $menu_link;
|
||||
|
|
|
@ -276,7 +276,7 @@ class MigrateSourceTest extends MigrateTestCase {
|
|||
$source = $this->getSource($configuration, [], MigrateIdMapInterface::STATUS_IMPORTED, $this->row['timestamp'] - 1);
|
||||
|
||||
$source->rewind();
|
||||
$this->assertInstanceOf(Row::class, $source->current(), 'Incoming row timestamp is greater than current highwater mark so we have a row.');
|
||||
$this->assertInstanceOf(Row::class, $source->current());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -33,7 +33,7 @@ class MigrateNodeTitleLabelTest extends MigrateDrupal7TestBase {
|
|||
*/
|
||||
protected function assertEntity($id, $label) {
|
||||
$override = BaseFieldOverride::load($id);
|
||||
$this->assertTrue($override instanceof BaseFieldOverride);
|
||||
$this->assertInstanceOf(BaseFieldOverride::class, $override);
|
||||
/** @var \Drupal\Core\Field\Entity\BaseFieldOverride $override */
|
||||
$this->assertIdentical($label, $override->getLabel());
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ class MigrateNodeTitleLabelTest extends MigrateDrupal7TestBase {
|
|||
];
|
||||
foreach ($no_override_node_type as $type) {
|
||||
$override = BaseFieldOverride::load("node.$type.title");
|
||||
$this->assertFalse($override instanceof BaseFieldOverride);
|
||||
$this->assertNotInstanceOf(BaseFieldOverride::class, $override);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ class MigrateNodeTypeTest extends MigrateDrupal7TestBase {
|
|||
protected function assertEntity($id, $label, $description, $help, $display_submitted, $new_revision, $expected_available_menus, $expected_parent, $body_label = NULL) {
|
||||
/** @var \Drupal\node\NodeTypeInterface $entity */
|
||||
$entity = NodeType::load($id);
|
||||
$this->assertTrue($entity instanceof NodeTypeInterface);
|
||||
$this->assertInstanceOf(NodeTypeInterface::class, $entity);
|
||||
$this->assertIdentical($label, $entity->label());
|
||||
$this->assertIdentical($description, $entity->getDescription());
|
||||
|
||||
|
@ -59,7 +59,7 @@ class MigrateNodeTypeTest extends MigrateDrupal7TestBase {
|
|||
if ($body_label) {
|
||||
/** @var \Drupal\field\FieldConfigInterface $body */
|
||||
$body = FieldConfig::load('node.' . $id . '.body');
|
||||
$this->assertTrue($body instanceof FieldConfigInterface);
|
||||
$this->assertInstanceOf(FieldConfigInterface::class, $body);
|
||||
$this->assertIdentical($body_label, $body->label());
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ class NodeFieldOverridesTest extends EntityKernelTestBase {
|
|||
/** @var \Drupal\node\NodeInterface $node */
|
||||
$node = Node::create(['type' => 'ponies']);
|
||||
$owner = $node->getOwner();
|
||||
$this->assertTrue($owner instanceof UserInterface);
|
||||
$this->assertInstanceOf(UserInterface::class, $owner);
|
||||
$this->assertEqual($owner->id(), $this->user->id());
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
namespace Drupal\Tests\serialization\Kernel;
|
||||
|
||||
use Drupal\Component\Serialization\Json;
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\entity_test\Entity\EntitySerializedField;
|
||||
use Drupal\entity_test\Entity\EntityTestMulRev;
|
||||
use Drupal\filter\Entity\FilterFormat;
|
||||
|
@ -254,7 +253,7 @@ class EntitySerializationTest extends NormalizerTestBase {
|
|||
|
||||
foreach (['json', 'xml'] as $type) {
|
||||
$denormalized = $this->serializer->denormalize($normalized, $this->entityClass, $type, ['entity_type' => 'entity_test_mulrev']);
|
||||
$this->assertTrue($denormalized instanceof $this->entityClass, new FormattableMarkup('Denormalized entity is an instance of @class', ['@class' => $this->entityClass]));
|
||||
$this->assertInstanceOf($this->entityClass, $denormalized);
|
||||
$this->assertIdentical($denormalized->getEntityTypeId(), $this->entity->getEntityTypeId(), 'Expected entity type found.');
|
||||
$this->assertIdentical($denormalized->bundle(), $this->entity->bundle(), 'Expected entity bundle found.');
|
||||
$this->assertIdentical($denormalized->uuid(), $this->entity->uuid(), 'Expected entity UUID found.');
|
||||
|
|
|
@ -163,7 +163,7 @@ class TimestampItemNormalizerTest extends UnitTestCase {
|
|||
$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 @@ class MigrateShortcutSetTest extends MigrateDrupal7TestBase {
|
|||
*/
|
||||
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 @@ class MigrateShortcutTest extends MigrateDrupal7TestBase {
|
|||
*/
|
||||
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 @@ abstract class EntityCacheTagsTestBase extends PageCacheTagsTestBase {
|
|||
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 @@ class EntityTranslationFormTest extends BrowserTestBase {
|
|||
|
||||
// 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 @@ class TwigRegistryLoaderTest extends BrowserTestBase {
|
|||
/**
|
||||
* 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 @@ class MenuTreeSerializationTitleTest extends UpdatePathTestBase {
|
|||
// 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 @@ class ActionTest extends KernelTestBase {
|
|||
|
||||
// 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 @@ class PhpStorageFactoryTest extends KernelTestBase {
|
|||
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 @@ class PhpStorageFactoryTest extends KernelTestBase {
|
|||
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 @@ class PhpStorageFactoryTest extends KernelTestBase {
|
|||
$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 @@ class TwigNamespaceTest extends KernelTestBase {
|
|||
/**
|
||||
* 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 @@ class TaxonomyRelationshipTest extends TaxonomyTestBase {
|
|||
|
||||
// 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 @@ class MigrateNodeTaxonomyTest extends MigrateDrupal7TestBase {
|
|||
*/
|
||||
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 @@ class MigrateTaxonomyVocabularyTest extends MigrateDrupal7TestBase {
|
|||
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 @@ class TelephoneItemTest extends FieldKernelTestBase {
|
|||
// 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 @@ class TextWithSummaryItemTest extends FieldKernelTestBase {
|
|||
$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 @@ class UserCancelTest extends BrowserTestBase {
|
|||
$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 @@ class AccessRoleTest extends AccessTestBase {
|
|||
$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 @@ class MigrateUserPictureFieldInstanceTest extends MigrateDrupal7TestBase {
|
|||
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 @@ class MigrateUserPictureFieldTest extends MigrateDrupal7TestBase {
|
|||
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 @@ class MigrateUserRoleTest extends MigrateDrupal7TestBase {
|
|||
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)) {
|
||||
|
|
|
@ -88,7 +88,7 @@ class MigrateUserTest extends MigrateDrupal7TestBase {
|
|||
protected function assertEntity($id, $label, $mail, $password, $created, $access, $login, $blocked, $entity_langcode, $prefered_langcode, $timezone, $init, $roles, $field_integer, $field_file_target_id = FALSE, $has_picture = FALSE) {
|
||||
/** @var \Drupal\user\UserInterface $user */
|
||||
$user = User::load($id);
|
||||
$this->assertTrue($user instanceof UserInterface);
|
||||
$this->assertInstanceOf(UserInterface::class, $user);
|
||||
$this->assertSame($label, $user->label());
|
||||
$this->assertSame($mail, $user->getEmail());
|
||||
$this->assertSame($password, $user->getPassword());
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\views\Functional\Handler;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\comment\Tests\CommentTestTrait;
|
||||
use Drupal\Tests\views\Functional\ViewTestBase;
|
||||
use Drupal\views\Plugin\views\filter\NumericFilter;
|
||||
|
@ -111,12 +110,7 @@ class HandlerAllTest extends ViewTestBase {
|
|||
foreach ($object_types as $type) {
|
||||
if (isset($view->{$type})) {
|
||||
foreach ($view->{$type} as $handler) {
|
||||
$this->assertTrue($handler instanceof HandlerBase, new FormattableMarkup(
|
||||
'@type handler of class %class is an instance of HandlerBase',
|
||||
[
|
||||
'@type' => $type,
|
||||
'%class' => get_class($handler),
|
||||
]));
|
||||
$this->assertInstanceOf(HandlerBase::class, $handler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -382,7 +382,7 @@ class HandlerTest extends ViewTestBase {
|
|||
|
||||
foreach ($views_data['access_callback'] as $type => $info) {
|
||||
if (!in_array($type, ['title', 'help'])) {
|
||||
$this->assertTrue($view->field['access_callback'] instanceof HandlerBase, 'Make sure the user got access to the access_callback field ');
|
||||
$this->assertInstanceOf(HandlerBase::class, $view->field['access_callback']);
|
||||
$this->assertFalse(isset($view->field['access_callback_arguments']), 'Make sure the user got no access to the access_callback_arguments field ');
|
||||
}
|
||||
}
|
||||
|
@ -397,7 +397,7 @@ class HandlerTest extends ViewTestBase {
|
|||
foreach ($views_data['access_callback'] as $type => $info) {
|
||||
if (!in_array($type, ['title', 'help'])) {
|
||||
$this->assertFalse(isset($view->field['access_callback']), 'Make sure the user got no access to the access_callback field ');
|
||||
$this->assertTrue($view->field['access_callback_arguments'] instanceof HandlerBase, 'Make sure the user got access to the access_callback_arguments field ');
|
||||
$this->assertInstanceOf(HandlerBase::class, $view->field['access_callback_arguments']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ class ArgumentDefaultTest extends ViewTestBase {
|
|||
$id = $view->addHandler('default', 'argument', 'views_test_data', 'name', $options);
|
||||
$view->initHandlers();
|
||||
$plugin = $view->argument[$id]->getPlugin('argument_default');
|
||||
$this->assertTrue($plugin instanceof ArgumentDefaultTestPlugin, 'The correct argument default plugin is used.');
|
||||
$this->assertInstanceOf(ArgumentDefaultTestPlugin::class, $plugin);
|
||||
|
||||
// Check that the value of the default argument is as expected.
|
||||
$this->assertEqual($view->argument[$id]->getDefaultArgument(), 'John', 'The correct argument default value is returned.');
|
||||
|
|
|
@ -86,7 +86,7 @@ class ContextualFiltersBlockContextTest extends ViewTestBase {
|
|||
// Check if context was correctly propagated to the block.
|
||||
$definition = $this->container->get('plugin.manager.block')
|
||||
->getDefinition('views_block:test_view_block_with_context-block_1');
|
||||
$this->assertTrue($definition['context_definitions']['nid'] instanceof ContextDefinitionInterface);
|
||||
$this->assertInstanceOf(ContextDefinitionInterface::class, $definition['context_definitions']['nid']);
|
||||
/** @var \Drupal\Core\Plugin\Context\ContextDefinitionInterface $context */
|
||||
$context = $definition['context_definitions']['nid'];
|
||||
$this->assertEqual($context->getDataType(), 'entity:node', 'Context definition data type is correct.');
|
||||
|
@ -133,21 +133,21 @@ class ContextualFiltersBlockContextTest extends ViewTestBase {
|
|||
// based on the numeric plugin and the other based on numeric validation.
|
||||
$definition = $this->container->get('plugin.manager.block')
|
||||
->getDefinition('views_block:test_view_block_with_context-block_2');
|
||||
$this->assertTrue($definition['context_definitions']['created'] instanceof ContextDefinitionInterface);
|
||||
$this->assertInstanceOf(ContextDefinitionInterface::class, $definition['context_definitions']['created']);
|
||||
/** @var \Drupal\Core\Plugin\Context\ContextDefinitionInterface $context */
|
||||
$context = $definition['context_definitions']['created'];
|
||||
$this->assertEqual($context->getDataType(), 'integer', 'Context definition data type is correct.');
|
||||
$this->assertEqual($context->getLabel(), 'Content: Authored on', 'Context definition label is correct.');
|
||||
$this->assertFalse($context->isRequired(), 'Context is not required.');
|
||||
|
||||
$this->assertTrue($definition['context_definitions']['vid'] instanceof ContextDefinitionInterface);
|
||||
$this->assertInstanceOf(ContextDefinitionInterface::class, $definition['context_definitions']['vid']);
|
||||
/** @var \Drupal\Core\Plugin\Context\ContextDefinitionInterface $context */
|
||||
$context = $definition['context_definitions']['vid'];
|
||||
$this->assertEqual($context->getDataType(), 'integer', 'Context definition data type is correct.');
|
||||
$this->assertEqual($context->getLabel(), 'Content: Revision ID', 'Context definition label is correct.');
|
||||
$this->assertFalse($context->isRequired(), 'Context is not required.');
|
||||
|
||||
$this->assertTrue($definition['context_definitions']['title'] instanceof ContextDefinitionInterface);
|
||||
$this->assertInstanceOf(ContextDefinitionInterface::class, $definition['context_definitions']['title']);
|
||||
/** @var \Drupal\Core\Plugin\Context\ContextDefinitionInterface $context */
|
||||
$context = $definition['context_definitions']['title'];
|
||||
$this->assertEqual($context->getDataType(), 'string', 'Context definition data type is correct.');
|
||||
|
|
|
@ -94,7 +94,7 @@ class DisplayTest extends ViewTestBase {
|
|||
|
||||
$view->setDisplay('display_test_1');
|
||||
|
||||
$this->assertTrue($view->display_handler instanceof DisplayTestPlugin, 'The correct display handler instance is on the view object.');
|
||||
$this->assertInstanceOf(DisplayTestPlugin::class, $view->display_handler);
|
||||
|
||||
// Check the test option.
|
||||
$this->assertIdentical($view->display_handler->getOption('test_option'), '');
|
||||
|
|
|
@ -61,7 +61,7 @@ class FilterTest extends ViewTestBase {
|
|||
public function testFilterQuery() {
|
||||
// Check that we can find the test filter plugin.
|
||||
$plugin = $this->container->get('plugin.manager.views.filter')->createInstance('test_filter');
|
||||
$this->assertTrue($plugin instanceof FilterPlugin, 'Test filter plugin found.');
|
||||
$this->assertInstanceOf(FilterPlugin::class, $plugin);
|
||||
|
||||
$view = Views::getView('test_filter');
|
||||
$view->initDisplay();
|
||||
|
|
|
@ -229,8 +229,8 @@ class FieldFieldTest extends ViewsKernelTestBase {
|
|||
$executable = Views::getView('test_field_field_test');
|
||||
$executable->execute();
|
||||
|
||||
$this->assertTrue($executable->field['id'] instanceof EntityField);
|
||||
$this->assertTrue($executable->field['field_test'] instanceof EntityField);
|
||||
$this->assertInstanceOf(EntityField::class, $executable->field['id']);
|
||||
$this->assertInstanceOf(EntityField::class, $executable->field['field_test']);
|
||||
|
||||
$this->assertIdenticalResultset($executable,
|
||||
[
|
||||
|
@ -299,9 +299,9 @@ class FieldFieldTest extends ViewsKernelTestBase {
|
|||
$executable = Views::getView('test_field_alias_test');
|
||||
$executable->execute();
|
||||
|
||||
$this->assertTrue($executable->field['id'] instanceof EntityField);
|
||||
$this->assertTrue($executable->field['name'] instanceof EntityField);
|
||||
$this->assertTrue($executable->field['name_alias'] instanceof EntityField);
|
||||
$this->assertInstanceOf(EntityField::class, $executable->field['id']);
|
||||
$this->assertInstanceOf(EntityField::class, $executable->field['name']);
|
||||
$this->assertInstanceOf(EntityField::class, $executable->field['name_alias']);
|
||||
|
||||
$this->assertIdenticalResultset($executable,
|
||||
[
|
||||
|
@ -348,10 +348,10 @@ class FieldFieldTest extends ViewsKernelTestBase {
|
|||
$timezones[] = $user->getTimeZone();
|
||||
}
|
||||
|
||||
$this->assertTrue($executable->field['field_test_multiple'] instanceof EntityField);
|
||||
$this->assertTrue($executable->field['field_test_multiple_1'] instanceof EntityField);
|
||||
$this->assertTrue($executable->field['field_test_multiple_2'] instanceof EntityField);
|
||||
$this->assertTrue($executable->field['timezone'] instanceof EntityField);
|
||||
$this->assertInstanceOf(EntityField::class, $executable->field['field_test_multiple']);
|
||||
$this->assertInstanceOf(EntityField::class, $executable->field['field_test_multiple_1']);
|
||||
$this->assertInstanceOf(EntityField::class, $executable->field['field_test_multiple_2']);
|
||||
$this->assertInstanceOf(EntityField::class, $executable->field['timezone']);
|
||||
|
||||
$this->assertIdenticalResultset($executable,
|
||||
[
|
||||
|
@ -421,8 +421,8 @@ class FieldFieldTest extends ViewsKernelTestBase {
|
|||
$executable = Views::getView('test_field_field_revision_test');
|
||||
$executable->execute();
|
||||
|
||||
$this->assertTrue($executable->field['name'] instanceof EntityField);
|
||||
$this->assertTrue($executable->field['field_test'] instanceof EntityField);
|
||||
$this->assertInstanceOf(EntityField::class, $executable->field['name']);
|
||||
$this->assertInstanceOf(EntityField::class, $executable->field['field_test']);
|
||||
|
||||
$this->assertIdenticalResultset($executable,
|
||||
[
|
||||
|
@ -475,12 +475,12 @@ class FieldFieldTest extends ViewsKernelTestBase {
|
|||
$timezones[] = $user->getTimeZone();
|
||||
}
|
||||
|
||||
$this->assertTrue($executable->field['id'] instanceof EntityField);
|
||||
$this->assertTrue($executable->field['revision_id'] instanceof EntityField);
|
||||
$this->assertTrue($executable->field['timezone'] instanceof EntityField);
|
||||
$this->assertTrue($executable->field['field_test_multiple'] instanceof EntityField);
|
||||
$this->assertTrue($executable->field['field_test_multiple_1'] instanceof EntityField);
|
||||
$this->assertTrue($executable->field['field_test_multiple_2'] instanceof EntityField);
|
||||
$this->assertInstanceOf(EntityField::class, $executable->field['id']);
|
||||
$this->assertInstanceOf(EntityField::class, $executable->field['revision_id']);
|
||||
$this->assertInstanceOf(EntityField::class, $executable->field['timezone']);
|
||||
$this->assertInstanceOf(EntityField::class, $executable->field['field_test_multiple']);
|
||||
$this->assertInstanceOf(EntityField::class, $executable->field['field_test_multiple_1']);
|
||||
$this->assertInstanceOf(EntityField::class, $executable->field['field_test_multiple_2']);
|
||||
|
||||
$this->assertIdenticalResultset($executable,
|
||||
[
|
||||
|
|
|
@ -76,7 +76,7 @@ class ModuleTest extends ViewsKernelTestBase {
|
|||
'field' => 'job',
|
||||
];
|
||||
$handler = $this->container->get('plugin.manager.views.filter')->getHandler($item, 'standard');
|
||||
$this->assertTrue($handler instanceof Standard);
|
||||
$this->assertInstanceOf(Standard::class, $handler);
|
||||
|
||||
// @todo Reinstate these tests when the debug() in views_get_handler() is
|
||||
// restored.
|
||||
|
|
|
@ -57,7 +57,7 @@ class ArgumentValidatorTest extends ViewsKernelTestBase {
|
|||
$this->assertTrue($argument->validateArgument($test_value), 'The right argument validates.');
|
||||
|
||||
$plugin = $argument->getPlugin('argument_validator');
|
||||
$this->assertTrue($plugin instanceof ArgumentValidatorTestPlugin, 'The correct argument validator plugin is used.');
|
||||
$this->assertInstanceOf(ArgumentValidatorTestPlugin::class, $plugin);
|
||||
$this->assertFalse($plugin->validateArgument($this->randomMachineName()), 'A random value does not validate.');
|
||||
$this->assertTrue($plugin->validateArgument($test_value), 'The right argument validates.');
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ class CacheTest extends ViewsKernelTestBase {
|
|||
public function testTimeResultCachingWithFilter() {
|
||||
// Check that we can find the test filter plugin.
|
||||
$plugin = $this->container->get('plugin.manager.views.filter')->createInstance('test_filter');
|
||||
$this->assertTrue($plugin instanceof FilterPlugin, 'Test filter plugin found.');
|
||||
$this->assertInstanceOf(FilterPlugin::class, $plugin);
|
||||
|
||||
$view = Views::getView('test_filter');
|
||||
$view->initDisplay();
|
||||
|
|
|
@ -35,7 +35,7 @@ class DisplayExtenderTest extends ViewsKernelTestBase {
|
|||
$this->assertEqual(count($view->display_handler->getExtenders()), 1, 'Make sure that only one extender is initialized.');
|
||||
|
||||
$display_extender = $view->display_handler->getExtenders()['display_extender_test'];
|
||||
$this->assertTrue($display_extender instanceof DisplayExtenderTestData, 'Make sure the right class got initialized.');
|
||||
$this->assertInstanceOf(DisplayExtenderTestData::class, $display_extender);
|
||||
|
||||
$view->preExecute();
|
||||
$this->assertTrue($display_extender->testState['preExecute'], 'Make sure the display extender was able to react on preExecute.');
|
||||
|
|
|
@ -94,13 +94,13 @@ class DisplayKernelTest extends ViewsKernelTestBase {
|
|||
$view->initDisplay();
|
||||
$display_handler = $view->display_handler;
|
||||
|
||||
$this->assertTrue($display_handler->getPlugin('access') instanceof AccessPluginBase, 'An access plugin instance was returned.');
|
||||
$this->assertTrue($display_handler->getPlugin('cache') instanceof CachePluginBase, 'A cache plugin instance was returned.');
|
||||
$this->assertTrue($display_handler->getPlugin('exposed_form') instanceof ExposedFormPluginInterface, 'An exposed_form plugin instance was returned.');
|
||||
$this->assertTrue($display_handler->getPlugin('pager') instanceof PagerPluginBase, 'A pager plugin instance was returned.');
|
||||
$this->assertTrue($display_handler->getPlugin('query') instanceof QueryPluginBase, 'A query plugin instance was returned.');
|
||||
$this->assertTrue($display_handler->getPlugin('row') instanceof RowPluginBase, 'A row plugin instance was returned.');
|
||||
$this->assertTrue($display_handler->getPlugin('style') instanceof StylePluginBase, 'A style plugin instance was returned.');
|
||||
$this->assertInstanceOf(AccessPluginBase::class, $display_handler->getPlugin('access'));
|
||||
$this->assertInstanceOf(CachePluginBase::class, $display_handler->getPlugin('cache'));
|
||||
$this->assertInstanceOf(ExposedFormPluginInterface::class, $display_handler->getPlugin('exposed_form'));
|
||||
$this->assertInstanceOf(PagerPluginBase::class, $display_handler->getPlugin('pager'));
|
||||
$this->assertInstanceOf(QueryPluginBase::class, $display_handler->getPlugin('query'));
|
||||
$this->assertInstanceOf(RowPluginBase::class, $display_handler->getPlugin('row'));
|
||||
$this->assertInstanceOf(StylePluginBase::class, $display_handler->getPlugin('style'));
|
||||
// Test that nothing is returned when an invalid type is requested.
|
||||
$this->assertNull($display_handler->getPlugin('invalid'), 'NULL was returned for an invalid instance');
|
||||
// Test that nothing was returned for an instance with no 'type' in options.
|
||||
|
|
|
@ -63,7 +63,7 @@ class FieldOrLanguageJoinTest extends RelationshipJoinTestBase {
|
|||
'adjusted' => TRUE,
|
||||
];
|
||||
$join = $this->manager->createInstance($this->pluginId, $configuration);
|
||||
$this->assertTrue($join instanceof FieldOrLanguageJoin);
|
||||
$this->assertInstanceOf(FieldOrLanguageJoin::class, $join);
|
||||
$this->assertNull($join->extra);
|
||||
$this->assertTrue($join->adjusted);
|
||||
|
||||
|
@ -196,7 +196,7 @@ class FieldOrLanguageJoinTest extends RelationshipJoinTestBase {
|
|||
$query = \Drupal::database()->select('node');
|
||||
|
||||
$join = $this->manager->createInstance('field_or_language_join', $configuration);
|
||||
$this->assertInstanceOf(FieldOrLanguageJoin::class, $join, 'The correct join class got loaded.');
|
||||
$this->assertInstanceOf(FieldOrLanguageJoin::class, $join);
|
||||
|
||||
$table = ['alias' => $table_alias];
|
||||
$join->buildJoin($query, $table, $view->query);
|
||||
|
|
|
@ -54,7 +54,7 @@ class JoinTest extends RelationshipJoinTestBase {
|
|||
'field' => 'uid',
|
||||
];
|
||||
$join = $this->manager->createInstance('join_test', $configuration);
|
||||
$this->assertTrue($join instanceof JoinTestPlugin, 'The correct join class got loaded.');
|
||||
$this->assertInstanceOf(JoinTestPlugin::class, $join);
|
||||
|
||||
$rand_int = rand(0, 1000);
|
||||
$join->setJoinValue($rand_int);
|
||||
|
@ -88,7 +88,7 @@ class JoinTest extends RelationshipJoinTestBase {
|
|||
'adjusted' => TRUE,
|
||||
];
|
||||
$join = $this->manager->createInstance('standard', $configuration);
|
||||
$this->assertTrue($join instanceof JoinPluginBase, 'The correct join class got loaded.');
|
||||
$this->assertInstanceOf(JoinPluginBase::class, $join);
|
||||
$this->assertNull($join->extra, 'The field extra was not overridden.');
|
||||
$this->assertTrue($join->adjusted, 'The field adjusted was set correctly.');
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ class QueryTest extends ViewsKernelTestBase {
|
|||
$view->setDisplay();
|
||||
|
||||
$view->initQuery();
|
||||
$this->assertInstanceOf(QueryTestPlugin::class, $view->query, 'Make sure the right query plugin got instantiated.');
|
||||
$this->assertInstanceOf(QueryTestPlugin::class, $view->query);
|
||||
}
|
||||
|
||||
public function _testQueryExecute() {
|
||||
|
|
|
@ -100,9 +100,9 @@ class ViewExecutableTest extends ViewsKernelTestBase {
|
|||
*/
|
||||
public function testFactoryService() {
|
||||
$factory = $this->container->get('views.executable');
|
||||
$this->assertTrue($factory instanceof ViewExecutableFactory, 'A ViewExecutableFactory instance was returned from the container.');
|
||||
$this->assertInstanceOf(ViewExecutableFactory::class, $factory);
|
||||
$view = View::load('test_executable_displays');
|
||||
$this->assertTrue($factory->get($view) instanceof ViewExecutable, 'A ViewExecutable instance was returned from the factory.');
|
||||
$this->assertInstanceOf(ViewExecutable::class, $factory->get($view));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -112,8 +112,8 @@ class ViewExecutableTest extends ViewsKernelTestBase {
|
|||
$view = Views::getView('test_destroy');
|
||||
$view->initDisplay();
|
||||
|
||||
$this->assertTrue($view->display_handler instanceof DefaultDisplay, 'Make sure a reference to the current display handler is set.');
|
||||
$this->assertTrue($view->displayHandlers->get('default') instanceof DefaultDisplay, 'Make sure a display handler is created for each display.');
|
||||
$this->assertInstanceOf(DefaultDisplay::class, $view->display_handler);
|
||||
$this->assertInstanceOf(DefaultDisplay::class, $view->displayHandlers->get('default'));
|
||||
|
||||
$view->destroy();
|
||||
$view->initHandlers();
|
||||
|
@ -129,15 +129,15 @@ class ViewExecutableTest extends ViewsKernelTestBase {
|
|||
}
|
||||
|
||||
// initHandlers() should create display handlers automatically as well.
|
||||
$this->assertTrue($view->display_handler instanceof DefaultDisplay, 'Make sure a reference to the current display handler is set.');
|
||||
$this->assertTrue($view->displayHandlers->get('default') instanceof DefaultDisplay, 'Make sure a display handler is created for each display.');
|
||||
$this->assertInstanceOf(DefaultDisplay::class, $view->display_handler);
|
||||
$this->assertInstanceOf(DefaultDisplay::class, $view->displayHandlers->get('default'));
|
||||
|
||||
$view_hash = spl_object_hash($view);
|
||||
$display_hash = spl_object_hash($view->display_handler);
|
||||
|
||||
// Test the initStyle() method.
|
||||
$view->initStyle();
|
||||
$this->assertTrue($view->style_plugin instanceof DefaultStyle, 'Make sure a reference to the style plugin is set.');
|
||||
$this->assertInstanceOf(DefaultStyle::class, $view->style_plugin);
|
||||
// Test the plugin has been invited and view have references to the view and
|
||||
// display handler.
|
||||
$this->assertEqual(spl_object_hash($view->style_plugin->view), $view_hash);
|
||||
|
@ -145,7 +145,7 @@ class ViewExecutableTest extends ViewsKernelTestBase {
|
|||
|
||||
// Test the initQuery method().
|
||||
$view->initQuery();
|
||||
$this->assertTrue($view->query instanceof Sql, 'Make sure a reference to the query is set');
|
||||
$this->assertInstanceOf(Sql::class, $view->query);
|
||||
$this->assertEqual(spl_object_hash($view->query->view), $view_hash);
|
||||
$this->assertEqual(spl_object_hash($view->query->displayHandler), $display_hash);
|
||||
|
||||
|
@ -153,23 +153,23 @@ class ViewExecutableTest extends ViewsKernelTestBase {
|
|||
|
||||
// Test the plugin get methods.
|
||||
$display_plugin = $view->getDisplay();
|
||||
$this->assertTrue($display_plugin instanceof DefaultDisplay, 'An instance of DefaultDisplay was returned.');
|
||||
$this->assertTrue($view->display_handler instanceof DefaultDisplay, 'The display_handler property has been set.');
|
||||
$this->assertInstanceOf(DefaultDisplay::class, $display_plugin);
|
||||
$this->assertInstanceOf(DefaultDisplay::class, $view->display_handler);
|
||||
$this->assertIdentical($display_plugin, $view->getDisplay(), 'The same display plugin instance was returned.');
|
||||
|
||||
$style_plugin = $view->getStyle();
|
||||
$this->assertTrue($style_plugin instanceof DefaultStyle, 'An instance of DefaultStyle was returned.');
|
||||
$this->assertTrue($view->style_plugin instanceof DefaultStyle, 'The style_plugin property has been set.');
|
||||
$this->assertInstanceOf(DefaultStyle::class, $style_plugin);
|
||||
$this->assertInstanceOf(DefaultStyle::class, $view->style_plugin);
|
||||
$this->assertIdentical($style_plugin, $view->getStyle(), 'The same style plugin instance was returned.');
|
||||
|
||||
$pager_plugin = $view->getPager();
|
||||
$this->assertTrue($pager_plugin instanceof PagerPluginBase, 'An instance of PagerPluginBase was returned.');
|
||||
$this->assertTrue($view->pager instanceof PagerPluginBase, 'The pager property has been set.');
|
||||
$this->assertInstanceOf(PagerPluginBase::class, $pager_plugin);
|
||||
$this->assertInstanceOf(PagerPluginBase::class, $view->pager);
|
||||
$this->assertIdentical($pager_plugin, $view->getPager(), 'The same pager plugin instance was returned.');
|
||||
|
||||
$query_plugin = $view->getQuery();
|
||||
$this->assertTrue($query_plugin instanceof QueryPluginBase, 'An instance of QueryPluginBase was returned.');
|
||||
$this->assertTrue($view->query instanceof QueryPluginBase, 'The query property has been set.');
|
||||
$this->assertInstanceOf(QueryPluginBase::class, $query_plugin);
|
||||
$this->assertInstanceOf(QueryPluginBase::class, $view->query);
|
||||
$this->assertIdentical($query_plugin, $view->getQuery(), 'The same query plugin instance was returned.');
|
||||
}
|
||||
|
||||
|
@ -218,11 +218,11 @@ class ViewExecutableTest extends ViewsKernelTestBase {
|
|||
|
||||
// Tests Drupal\views\ViewExecutable::initDisplay().
|
||||
$view->initDisplay();
|
||||
$this->assertTrue($view->displayHandlers instanceof DisplayPluginCollection, 'The displayHandlers property has the right class.');
|
||||
$this->assertInstanceOf(DisplayPluginCollection::class, $view->displayHandlers);
|
||||
// Tests the classes of the instances.
|
||||
$this->assertTrue($view->displayHandlers->get('default') instanceof DefaultDisplay);
|
||||
$this->assertTrue($view->displayHandlers->get('page_1') instanceof Page);
|
||||
$this->assertTrue($view->displayHandlers->get('page_2') instanceof Page);
|
||||
$this->assertInstanceOf(DefaultDisplay::class, $view->displayHandlers->get('default'));
|
||||
$this->assertInstanceOf(Page::class, $view->displayHandlers->get('page_1'));
|
||||
$this->assertInstanceOf(Page::class, $view->displayHandlers->get('page_2'));
|
||||
|
||||
// After initializing the default display is the current used display.
|
||||
$this->assertEqual($view->current_display, 'default');
|
||||
|
@ -253,14 +253,14 @@ class ViewExecutableTest extends ViewsKernelTestBase {
|
|||
// display.
|
||||
$view->setDisplay('page_1');
|
||||
$view->initStyle();
|
||||
$this->assertTrue($view->style_plugin instanceof DefaultStyle);
|
||||
$this->assertTrue($view->rowPlugin instanceof Fields);
|
||||
$this->assertInstanceOf(DefaultStyle::class, $view->style_plugin);
|
||||
$this->assertInstanceOf(Fields::class, $view->rowPlugin);
|
||||
|
||||
$view->setDisplay('page_2');
|
||||
$view->initStyle();
|
||||
$this->assertTrue($view->style_plugin instanceof Grid);
|
||||
$this->assertInstanceOf(Grid::class, $view->style_plugin);
|
||||
// @todo Change this rowPlugin type too.
|
||||
$this->assertTrue($view->rowPlugin instanceof Fields);
|
||||
$this->assertInstanceOf(Fields::class, $view->rowPlugin);
|
||||
|
||||
// Test the newDisplay() method.
|
||||
$view = $this->container->get('entity_type.manager')->getStorage('view')->create(['id' => 'test_executable_displays']);
|
||||
|
@ -270,14 +270,14 @@ class ViewExecutableTest extends ViewsKernelTestBase {
|
|||
$executable->newDisplay('page');
|
||||
$executable->newDisplay('display_test');
|
||||
|
||||
$this->assertTrue($executable->displayHandlers->get('default') instanceof DefaultDisplay);
|
||||
$this->assertInstanceOf(DefaultDisplay::class, $executable->displayHandlers->get('default'));
|
||||
$this->assertFalse(isset($executable->displayHandlers->get('default')->default_display));
|
||||
$this->assertTrue($executable->displayHandlers->get('page_1') instanceof Page);
|
||||
$this->assertTrue($executable->displayHandlers->get('page_1')->default_display instanceof DefaultDisplay);
|
||||
$this->assertTrue($executable->displayHandlers->get('page_2') instanceof Page);
|
||||
$this->assertTrue($executable->displayHandlers->get('page_2')->default_display instanceof DefaultDisplay);
|
||||
$this->assertTrue($executable->displayHandlers->get('display_test_1') instanceof DisplayTest);
|
||||
$this->assertTrue($executable->displayHandlers->get('display_test_1')->default_display instanceof DefaultDisplay);
|
||||
$this->assertInstanceOf(Page::class, $executable->displayHandlers->get('page_1'));
|
||||
$this->assertInstanceOf(DefaultDisplay::class, $executable->displayHandlers->get('page_1')->default_display);
|
||||
$this->assertInstanceOf(Page::class, $executable->displayHandlers->get('page_2'));
|
||||
$this->assertInstanceOf(DefaultDisplay::class, $executable->displayHandlers->get('page_2')->default_display);
|
||||
$this->assertInstanceOf(DisplayTest::class, $executable->displayHandlers->get('display_test_1'));
|
||||
$this->assertInstanceOf(DefaultDisplay::class, $executable->displayHandlers->get('display_test_1')->default_display);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -316,7 +316,7 @@ class ViewExecutableTest extends ViewsKernelTestBase {
|
|||
$this->assertIdentical($view->getBaseTables(), $expected);
|
||||
|
||||
// Test response methods.
|
||||
$this->assertTrue($view->getResponse() instanceof Response, 'New response object returned.');
|
||||
$this->assertInstanceOf(Response::class, $view->getResponse());
|
||||
$new_response = new Response();
|
||||
$view->setResponse($new_response);
|
||||
$this->assertIdentical(spl_object_hash($view->getResponse()), spl_object_hash($new_response), 'New response object correctly set.');
|
||||
|
@ -489,7 +489,7 @@ class ViewExecutableTest extends ViewsKernelTestBase {
|
|||
/** @var \Drupal\views\ViewExecutable $unserialized */
|
||||
$unserialized = unserialize($serialized);
|
||||
|
||||
$this->assertTrue($unserialized instanceof ViewExecutable);
|
||||
$this->assertInstanceOf(ViewExecutable::class, $unserialized);
|
||||
$this->assertIdentical($view->storage->id(), $unserialized->storage->id(), 'The expected storage entity was loaded on the unserialized view.');
|
||||
$this->assertIdentical($unserialized->current_display, 'page_1', 'The expected display was set on the unserialized view.');
|
||||
$this->assertIdentical($unserialized->args, ['test'], 'The expected argument was set on the unserialized view.');
|
||||
|
|
|
@ -63,7 +63,7 @@ class ViewStorageTest extends ViewsKernelTestBase {
|
|||
$this->controller = $this->container->get('entity_type.manager')->getStorage('view');
|
||||
|
||||
// Confirm that an info array has been returned.
|
||||
$this->assertTrue($this->entityType instanceof EntityTypeInterface, 'The View info array is loaded.');
|
||||
$this->assertInstanceOf(EntityTypeInterface::class, $this->entityType);
|
||||
|
||||
// CRUD tests.
|
||||
$this->loadTests();
|
||||
|
@ -83,7 +83,7 @@ class ViewStorageTest extends ViewsKernelTestBase {
|
|||
|
||||
// Confirm that an actual view object is loaded and that it returns all of
|
||||
// expected properties.
|
||||
$this->assertTrue($view instanceof View, 'Single View instance loaded.');
|
||||
$this->assertInstanceOf(View::class, $view);
|
||||
foreach ($this->configProperties as $property) {
|
||||
$this->assertTrue($view->get($property) !== NULL, new FormattableMarkup('Property: @property loaded onto View.', ['@property' => $property]));
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ class ViewStorageTest extends ViewsKernelTestBase {
|
|||
// Create a new View instance with empty values.
|
||||
$created = $this->controller->create([]);
|
||||
|
||||
$this->assertTrue($created instanceof View, 'Created object is a View.');
|
||||
$this->assertInstanceOf(View::class, $created);
|
||||
// Check that the View contains all of the properties.
|
||||
foreach ($this->configProperties as $property) {
|
||||
$this->assertTrue(property_exists($created, $property), new FormattableMarkup('Property: @property created on View.', ['@property' => $property]));
|
||||
|
@ -129,7 +129,7 @@ class ViewStorageTest extends ViewsKernelTestBase {
|
|||
unset($values['uuid']);
|
||||
$created = $this->controller->create($values);
|
||||
|
||||
$this->assertTrue($created instanceof View, 'Created object is a View.');
|
||||
$this->assertInstanceOf(View::class, $created);
|
||||
// Check that the View contains all of the properties.
|
||||
$properties = $this->configProperties;
|
||||
// Remove display from list.
|
||||
|
@ -162,7 +162,7 @@ class ViewStorageTest extends ViewsKernelTestBase {
|
|||
|
||||
$executable = $view->getExecutable();
|
||||
$executable->initDisplay();
|
||||
$this->assertTrue($executable->displayHandlers->get($new_id) instanceof Page, 'New page display "test" uses the right display plugin.');
|
||||
$this->assertInstanceOf(Page::class, $executable->displayHandlers->get($new_id));
|
||||
|
||||
// To save this with a new ID, we should use createDuplicate().
|
||||
$view = $view->createDuplicate();
|
||||
|
@ -316,7 +316,7 @@ class ViewStorageTest extends ViewsKernelTestBase {
|
|||
$view = Views::getView('test_view_storage');
|
||||
$copy = $view->storage->createDuplicate();
|
||||
|
||||
$this->assertTrue($copy instanceof View, 'The copied object is a View.');
|
||||
$this->assertInstanceOf(View::class, $copy);
|
||||
|
||||
// Check that the original view and the copy have different UUIDs.
|
||||
$this->assertNotIdentical($view->storage->uuid(), $copy->uuid(), 'The copied view has a new UUID.');
|
||||
|
|
|
@ -63,7 +63,7 @@ class WizardPluginBaseKernelTest extends ViewsKernelTestBase {
|
|||
|
||||
$this->wizard->validateView($form, $form_state);
|
||||
$view = $this->wizard->createView($form, $form_state);
|
||||
$this->assertTrue($view instanceof ViewUI, 'The created view is a ViewUI object.');
|
||||
$this->assertInstanceOf(ViewUI::class, $view);
|
||||
$this->assertEqual($view->get('id'), $random_id);
|
||||
$this->assertEqual($view->get('label'), $random_label);
|
||||
$this->assertEqual($view->get('description'), $random_description);
|
||||
|
|
|
@ -194,7 +194,7 @@ class ViewAjaxControllerTest extends UnitTestCase {
|
|||
->with('/test-page?type=article');
|
||||
|
||||
$response = $this->viewAjaxController->ajaxView($request);
|
||||
$this->assertTrue($response instanceof ViewAjaxResponse);
|
||||
$this->assertInstanceOf(ViewAjaxResponse::class, $response);
|
||||
|
||||
$this->assertSame($response->getView(), $executable);
|
||||
|
||||
|
@ -234,7 +234,7 @@ class ViewAjaxControllerTest extends UnitTestCase {
|
|||
->with('page_1', ['arg1', 'arg2']);
|
||||
|
||||
$response = $this->viewAjaxController->ajaxView($request);
|
||||
$this->assertTrue($response instanceof ViewAjaxResponse);
|
||||
$this->assertInstanceOf(ViewAjaxResponse::class, $response);
|
||||
|
||||
$this->assertViewResultCommand($response);
|
||||
}
|
||||
|
@ -255,7 +255,7 @@ class ViewAjaxControllerTest extends UnitTestCase {
|
|||
->with('page_1', $this->identicalTo(['arg1', NULL]));
|
||||
|
||||
$response = $this->viewAjaxController->ajaxView($request);
|
||||
$this->assertTrue($response instanceof ViewAjaxResponse);
|
||||
$this->assertInstanceOf(ViewAjaxResponse::class, $response);
|
||||
|
||||
$this->assertViewResultCommand($response);
|
||||
}
|
||||
|
@ -275,7 +275,7 @@ class ViewAjaxControllerTest extends UnitTestCase {
|
|||
->with('page_1', ['arg1 & arg2', 'arg3']);
|
||||
|
||||
$response = $this->viewAjaxController->ajaxView($request);
|
||||
$this->assertTrue($response instanceof ViewAjaxResponse);
|
||||
$this->assertInstanceOf(ViewAjaxResponse::class, $response);
|
||||
|
||||
$this->assertViewResultCommand($response);
|
||||
}
|
||||
|
@ -310,7 +310,7 @@ class ViewAjaxControllerTest extends UnitTestCase {
|
|||
$executable->displayHandlers = $display_collection;
|
||||
|
||||
$response = $this->viewAjaxController->ajaxView($request);
|
||||
$this->assertTrue($response instanceof ViewAjaxResponse);
|
||||
$this->assertInstanceOf(ViewAjaxResponse::class, $response);
|
||||
|
||||
$commands = $this->getCommands($response);
|
||||
$this->assertEquals('viewsScrollTop', $commands[0]['command']);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue