You are here

public function UITest::testAdministrationEckThemeSettings in Entity Construction Kit (ECK) 8

Tests "Use the administration theme when editing or creating ECK entities".

File

tests/src/Functional/UITest.php, line 167

Class

UITest
Tests if eck's UI elements are working properly.

Namespace

Drupal\Tests\eck\Functional

Code

public function testAdministrationEckThemeSettings() {
  $admin_user = $this
    ->drupalCreateUser([
    'administer eck entity types',
    'administer eck entities',
    'administer eck entity bundles',
    'access administration pages',
    'view the administration theme',
    'administer themes',
  ]);
  $this
    ->drupalLogin($admin_user);
  $type = $this
    ->createEntityType();
  $bundle = $this
    ->createEntityBundle($type['id']);
  $this
    ->drupalGet(Url::fromRoute('eck.entity.add', [
    'eck_entity_type' => $type['id'],
    'eck_entity_bundle' => $bundle['type'],
  ]));
  $this
    ->assertSession()
    ->responseContains('core/themes/classy');

  // Install an administration theme and enable "Use the administration theme
  // when editing or creating ECK entities" option.
  $this->container
    ->get('theme_installer')
    ->install([
    'seven',
  ]);
  $edit = [
    'admin_theme' => 'seven',
    'eck_use_admin_theme' => TRUE,
  ];
  $this
    ->drupalGet('admin/appearance');
  $this
    ->submitForm($edit, 'Save configuration');
  $this
    ->drupalGet(Url::fromRoute('eck.entity.add', [
    'eck_entity_type' => $type['id'],
    'eck_entity_bundle' => $bundle['type'],
  ]));
  $this
    ->assertSession()
    ->responseContains('core/themes/seven');
}