You are here

public function FormModeManagerUiTest::testFormModeManagerUserOverview 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::testFormModeManagerUserOverview()

Tests Form Mode links provide by module for User entity.

Throws

\Behat\Mink\Exception\ExpectationException

File

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

Class

FormModeManagerUiTest
Tests the Form mode manager user interfaces.

Namespace

Drupal\Tests\form_mode_manager\Functional

Code

public function testFormModeManagerUserOverview() {
  $user_form_mode = $this
    ->drupalCreateFormMode('user');
  Role::load($this->adminUser
    ->getRoles()[1])
    ->grantPermission('administer users')
    ->grantPermission('use ' . $user_form_mode
    ->id() . ' form mode')
    ->save();
  $this
    ->drupalGet("admin/config/people/accounts/form-display");
  $edit = [
    "display_modes_custom[{$this->formModeManager->getFormModeMachineName($user_form_mode->id())}]" => TRUE,
  ];
  $this
    ->drupalPostForm("admin/config/people/accounts/form-display", $edit, t('Save'));
  $this
    ->drupalLogin($this->adminUser);
  $this
    ->drupalGet('admin/people');
  $this
    ->assertSession()
    ->linkExists("Add user as {$user_form_mode->label()}");
  $this
    ->assertSession()
    ->linkExists("Edit as {$user_form_mode->label()}");
}