You are here

public function ConfigPageTest::setUp in Require on Publish 8

Overrides BrowserTestBase::setUp

File

tests/src/FunctionalJavascript/ConfigPageTest.php, line 41

Class

ConfigPageTest
Tests the 'Require on Publish' functionality on field config pages.

Namespace

Drupal\Tests\require_on_publish\FunctionalJavascript

Code

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

  // Create the 'article' content type.

  /** @var \Drupal\node\NodeTypeInterface $type */
  $type = $this->container
    ->get('entity_type.manager')
    ->getStorage('node_type')
    ->create([
    'type' => 'article',
    'name' => 'Article',
  ]);
  $type
    ->save();
  $this->container
    ->get('router.builder')
    ->rebuild();

  // Create the 'field_tags' field.
  FieldStorageConfig::create([
    'entity_type' => 'node',
    'field_name' => 'field_tags',
    'type' => 'entity_reference',
    'settings' => [
      'target_type' => 'taxonomy_term',
    ],
  ])
    ->save();

  // Add 'field_tags' to the 'article' content type.
  FieldConfig::create([
    'field_name' => 'field_tags',
    'entity_type' => 'node',
    'bundle' => 'article',
  ])
    ->save();

  // Create a user who can administer fields.
  $this->account = $this
    ->drupalCreateUser([
    'administer node fields',
  ]);
}