function TextWithSummaryFileUsageTest::setUp
Overrides EntityKernelTestBase::setUp
File
-
core/
modules/ editor/ tests/ src/ Kernel/ TextWithSummaryFileUsageTest.php, line 36
Class
- TextWithSummaryFileUsageTest
- Tests tracking of file usage by the Text Editor module.
Namespace
Drupal\Tests\editor\KernelCode
protected function setUp() : void {
parent::setUp();
$this->installEntitySchema('file');
$this->installSchema('node', [
'node_access',
]);
$this->installSchema('file', [
'file_usage',
]);
$this->installConfig([
'node',
]);
// Add text formats.
$filtered_html_format = FilterFormat::create([
'format' => 'filtered_html',
'name' => 'Filtered HTML',
'weight' => 0,
'filters' => [],
]);
$filtered_html_format->save();
// Set up text editor.
$editor = Editor::create([
'format' => 'filtered_html',
'editor' => 'unicorn',
'image_upload' => [
'status' => FALSE,
],
]);
$editor->save();
// Create a node type for testing.
$this->createContentType([
'type' => 'page',
'name' => 'page',
], FALSE);
FieldStorageConfig::create([
'field_name' => 'body',
'type' => 'text_with_summary',
'entity_type' => 'node',
'cardinality' => 1,
])->save();
$fieldStorage = FieldStorageConfig::loadByName('node', 'body');
FieldConfig::create([
'field_storage' => $fieldStorage,
'bundle' => 'page',
'label' => 'Body',
'settings' => [
'display_summary' => TRUE,
'allowed_formats' => [],
],
])->save();
// Set cardinality for body field.
FieldStorageConfig::loadByName('node', 'body')->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED)
->save();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.