protected function EditorLoadingTest::setUp in Drupal 9
Same name and namespace in other branches
- 8 core/modules/editor/tests/src/Functional/EditorLoadingTest.php \Drupal\Tests\editor\Functional\EditorLoadingTest::setUp()
Overrides BrowserTestBase::setUp
File
- core/
modules/ editor/ tests/ src/ Functional/ EditorLoadingTest.php, line 51
Class
- EditorLoadingTest
- Tests loading of text editors.
Namespace
Drupal\Tests\editor\FunctionalCode
protected function setUp() : void {
parent::setUp();
// Let there be T-rex.
\Drupal::state()
->set('editor_test_give_me_a_trex_thanks', TRUE);
\Drupal::service('plugin.manager.editor')
->clearCachedDefinitions();
// Add text formats.
$filtered_html_format = FilterFormat::create([
'format' => 'filtered_html',
'name' => 'Filtered HTML',
'weight' => 0,
'filters' => [],
]);
$filtered_html_format
->save();
$full_html_format = FilterFormat::create([
'format' => 'full_html',
'name' => 'Full HTML',
'weight' => 1,
'filters' => [],
]);
$full_html_format
->save();
// Create article node type.
$this
->drupalCreateContentType([
'type' => 'article',
'name' => 'Article',
]);
// Create page node type, but remove the body.
$this
->drupalCreateContentType([
'type' => 'page',
'name' => 'Page',
]);
$body = FieldConfig::loadByName('node', 'page', 'body');
$body
->delete();
// Create a formatted text field, which uses an <input type="text">.
FieldStorageConfig::create([
'field_name' => 'field_text',
'entity_type' => 'node',
'type' => 'text',
])
->save();
FieldConfig::create([
'field_name' => 'field_text',
'entity_type' => 'node',
'label' => 'Textfield',
'bundle' => 'page',
])
->save();
\Drupal::service('entity_display.repository')
->getFormDisplay('node', 'page')
->setComponent('field_text')
->save();
// Create 3 users, each with access to different text formats.
$this->untrustedUser = $this
->drupalCreateUser([
'create article content',
'edit any article content',
]);
$this->normalUser = $this
->drupalCreateUser([
'create article content',
'edit any article content',
'use text format filtered_html',
]);
$this->privilegedUser = $this
->drupalCreateUser([
'create article content',
'edit any article content',
'create page content',
'edit any page content',
'use text format filtered_html',
'use text format full_html',
]);
}