You are here

protected function LayoutBuilderIntegrationTest::setUp in Drupal 10

File

core/modules/quickedit/tests/src/FunctionalJavascript/LayoutBuilderIntegrationTest.php, line 49

Class

LayoutBuilderIntegrationTest
@group quickedit

Namespace

Drupal\Tests\quickedit\FunctionalJavascript

Code

protected function setUp() : void {
  parent::setUp();

  // Create text format, associate CKEditor.
  FilterFormat::create([
    'format' => 'some_format',
    'name' => 'Some format',
    'weight' => 0,
    'filters' => [
      'filter_html' => [
        'status' => 1,
        'settings' => [
          'allowed_html' => '<h2 id> <h3> <h4> <h5> <h6> <p> <br> <strong> <a href hreflang>',
        ],
      ],
    ],
  ])
    ->save();
  Editor::create([
    'format' => 'some_format',
    'editor' => 'ckeditor',
  ])
    ->save();

  // Create the Article node type.
  $this
    ->drupalCreateContentType([
    'type' => 'article',
    'name' => 'Article',
  ]);

  // Add "tags" vocabulary + field to the Article node type.
  $vocabulary = Vocabulary::create([
    'name' => 'Tags',
    'vid' => 'tags',
  ]);
  $vocabulary
    ->save();
  $field_name = 'field_' . $vocabulary
    ->id();
  $handler_settings = [
    'target_bundles' => [
      $vocabulary
        ->id() => $vocabulary
        ->id(),
    ],
    'auto_create' => TRUE,
  ];
  $this
    ->createEntityReferenceField('node', 'article', $field_name, 'Tags', 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);

  // Add formatter & widget for "tags" field.
  \Drupal::entityTypeManager()
    ->getStorage('entity_form_display')
    ->load('node.article.default')
    ->setComponent($field_name, [
    'type' => 'entity_reference_autocomplete_tags',
  ])
    ->save();
  \Drupal::entityTypeManager()
    ->getStorage('entity_view_display')
    ->load('node.article.default')
    ->setComponent($field_name, [
    'type' => 'entity_reference_label',
  ])
    ->save();
  $this
    ->drupalPlaceBlock('page_title_block');
  $this
    ->drupalPlaceBlock('system_main_block');

  // Log in as a content author who can use Quick Edit and edit Articles.
  $this->contentAuthorUser = $this
    ->drupalCreateUser([
    'access contextual links',
    'access toolbar',
    'access in-place editing',
    'access content',
    'create article content',
    'edit any article content',
    'use text format some_format',
    'edit terms in tags',
    'administer blocks',
  ]);
  $this
    ->drupalLogin($this->contentAuthorUser);
}