You are here

public function EntityViewModeConfigurationFormTest::testEntityViewModeConfigurationForm in Acquia Lift Connector 8.4

Tests EntityViewModeConfigurationForm.

Throws

\Behat\Mink\Exception\ElementNotFoundException

\Behat\Mink\Exception\ExpectationException

File

modules/acquia_lift_publisher/tests/src/Functional/Form/EntityViewModeConfigurationFormTest.php, line 67

Class

EntityViewModeConfigurationFormTest
Class EntityViewModeConfigurationFormTest.

Namespace

Drupal\Tests\acquia_lift_publisher\Functional\Form

Code

public function testEntityViewModeConfigurationForm() {
  $formUrl = Url::fromRoute('acquia_lift_publisher.entity_config_form');
  $this
    ->drupalLogin($this->notAdminUser);
  $this
    ->drupalGet($formUrl);
  $this
    ->assertSession()
    ->statusCodeEquals(403);
  $this
    ->drupalLogout();
  $this
    ->drupalLogin($this->adminUser);
  $this
    ->drupalGet($formUrl);
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $page = $this
    ->getSession()
    ->getPage();
  $this
    ->assertTrue($page
    ->hasUncheckedField('options[user][user][default]'));
  $bundles = [
    'page',
    'article',
  ];
  $view_modes = [
    'default',
    'full',
    'teaser',
  ];
  foreach ($bundles as $bundle) {
    foreach ($view_modes as $view_mode) {
      $locator = sprintf("options[node][%s][%s]", $bundle, $view_mode);
      $this
        ->assertTrue($page
        ->hasUncheckedField($locator));
      $page
        ->checkField($locator);
    }
  }
  $page
    ->pressButton('edit-submit');
  foreach ($bundles as $bundle) {
    foreach ($view_modes as $view_mode) {
      $locator = sprintf("options[node][%s][%s]", $bundle, $view_mode);
      $this
        ->assertTrue($page
        ->hasCheckedField($locator));
    }
  }
}