You are here

protected function FormModeManagerUiTest::setUp in Form mode manager 8.2

Same name and namespace in other branches
  1. 8 tests/src/Functional/FormModeManagerUiTest.php \Drupal\Tests\form_mode_manager\Functional\FormModeManagerUiTest::setUp()

Overrides FormModeManagerBase::setUp

File

tests/src/Functional/FormModeManagerUiTest.php, line 77

Class

FormModeManagerUiTest
Tests the Form mode manager user interfaces.

Namespace

Drupal\Tests\form_mode_manager\Functional

Code

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

  // Hide field for already existing form modes.
  $this
    ->setHiddenFieldFormMode("admin/config/people/accounts/form-display", 'timezone');
  $this
    ->setHiddenFieldFormMode("admin/structure/types/manage/{$this->nodeTypeFmm1->id()}/form-display", 'body');
  $this->vocabulary = $this
    ->createVocabulary();
  $this->blockType = $this
    ->createBlockContentType();

  // Generate contents to this tests.
  for ($i = 0; $i < 3; $i++) {
    $this->terms[] = $this
      ->createTerm($this->vocabulary, [
      'title' => "Term {$i}",
    ]);
    $this->nodes[] = $this
      ->createNode([
      'type' => $this->nodeTypeFmm1
        ->id(),
    ]);
    $this->blocks[] = $this
      ->createBlockContent([
      'type' => $this->blockType
        ->id(),
    ]);
    $this->users[] = $this
      ->createUser([
      'access content',
      'access administration pages',
      'administer site configuration',
      'administer users',
      'administer permissions',
      'administer content types',
      'administer node fields',
      'administer node display',
      'administer node form display',
      'administer nodes',
      'administer display modes',
      'use node.default form mode',
      'use user.default form mode',
      'use ' . $this->nodeFormMode
        ->id() . ' form mode',
      'use ' . $this->userFormMode
        ->id() . ' form mode',
      'edit any ' . $this->nodeTypeFmm1
        ->id() . ' content',
      'create ' . $this->nodeTypeFmm1
        ->id() . ' content',
    ]);
  }
  $this
    ->drupalLogin($this->rootUser);
  $this->blockFormMode = $this
    ->drupalCreateFormMode('block_content');
  $this
    ->setUpFormMode("admin/structure/block/block-content/manage/{$this->blockType->id()}/form-display", $this->blockFormMode
    ->id());
  $this
    ->setHiddenFieldFormMode("admin/structure/block/block-content/manage/{$this->blockType->id()}/form-display", 'info');
  $this->taxonomyFormMode = $this
    ->drupalCreateFormMode('taxonomy_term');
  $this
    ->setUpFormMode("admin/structure/taxonomy/manage/{$this->vocabulary->id()}/overview/form-display", $this->taxonomyFormMode
    ->id());
  $this
    ->setHiddenFieldFormMode("admin/structure/taxonomy/manage/{$this->vocabulary->id()}/overview/form-display", 'description');
  $this->container
    ->get('router.builder')
    ->rebuild();

  // Add additional permissions to users.
  $this
    ->setUsersTestPermissions([
    "use {$this->blockFormMode->id()} form mode",
    "use {$this->taxonomyFormMode->id()} form mode",
    'administer users',
    'administer user form display',
    "edit terms in {$this->vocabulary->id()}",
  ]);
}