protected function ViewEntityDependenciesTest::setUp in Drupal 10
Same name and namespace in other branches
- 8 core/modules/views/tests/src/Kernel/Entity/ViewEntityDependenciesTest.php \Drupal\Tests\views\Kernel\Entity\ViewEntityDependenciesTest::setUp()
- 9 core/modules/views/tests/src/Kernel/Entity/ViewEntityDependenciesTest.php \Drupal\Tests\views\Kernel\Entity\ViewEntityDependenciesTest::setUp()
Parameters
bool $import_test_views: Should the views specified on the test class be imported. If you need to setup some additional stuff, like fields, you need to call false and then call createTestViews for your own.
Overrides ViewsKernelTestBase::setUp
File
- core/
modules/ views/ tests/ src/ Kernel/ Entity/ ViewEntityDependenciesTest.php, line 44
Class
- ViewEntityDependenciesTest
- Tests the calculation of dependencies for views.
Namespace
Drupal\Tests\views\Kernel\EntityCode
protected function setUp($import_test_views = TRUE) : void {
parent::setUp(FALSE);
// Install the necessary dependencies for node type creation to work.
$this
->installEntitySchema('node');
$this
->installConfig([
'field',
'node',
]);
$comment_type = CommentType::create([
'id' => 'comment',
'label' => 'Comment settings',
'description' => 'Comment settings',
'target_entity_type_id' => 'node',
]);
$comment_type
->save();
$content_type = NodeType::create([
'type' => $this
->randomMachineName(),
'name' => $this
->randomString(),
]);
$content_type
->save();
$field_storage = FieldStorageConfig::create([
'field_name' => mb_strtolower($this
->randomMachineName()),
'entity_type' => 'node',
'type' => 'comment',
]);
$field_storage
->save();
FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => $content_type
->id(),
'label' => $this
->randomMachineName() . '_label',
'description' => $this
->randomMachineName() . '_description',
'settings' => [
'comment_type' => $comment_type
->id(),
],
])
->save();
FieldConfig::create([
'field_storage' => FieldStorageConfig::loadByName('node', 'body'),
'bundle' => $content_type
->id(),
'label' => $this
->randomMachineName() . '_body',
'settings' => [
'display_summary' => TRUE,
],
])
->save();
ViewTestData::createTestViews(static::class, [
'views_test_config',
]);
}