You are here

public function NodeTranslationUITest::testTranslationLinkTheme in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/node/tests/src/Functional/NodeTranslationUITest.php \Drupal\Tests\node\Functional\NodeTranslationUITest::testTranslationLinkTheme()

Tests that translation page inherits admin status of edit page.

File

core/modules/node/tests/src/Functional/NodeTranslationUITest.php, line 251

Class

NodeTranslationUITest
Tests the Node Translation UI.

Namespace

Drupal\Tests\node\Functional

Code

public function testTranslationLinkTheme() {
  $this
    ->drupalLogin($this->administrator);
  $article = $this
    ->drupalCreateNode([
    'type' => 'article',
    'langcode' => $this->langcodes[0],
  ]);

  // Set up Seven as the admin theme and use it for node editing.
  $this->container
    ->get('theme_installer')
    ->install([
    'seven',
  ]);
  $edit = [];
  $edit['admin_theme'] = 'seven';
  $edit['use_admin_theme'] = TRUE;
  $this
    ->drupalGet('admin/appearance');
  $this
    ->submitForm($edit, 'Save configuration');
  $this
    ->drupalGet('node/' . $article
    ->id() . '/translations');

  // Verify that translation uses the admin theme if edit is admin.
  $this
    ->assertSession()
    ->responseContains('core/themes/seven/css/base/elements.css');

  // Turn off admin theme for editing, assert inheritance to translations.
  $edit['use_admin_theme'] = FALSE;
  $this
    ->drupalGet('admin/appearance');
  $this
    ->submitForm($edit, 'Save configuration');
  $this
    ->drupalGet('node/' . $article
    ->id() . '/translations');

  // Verify that translation uses the frontend theme if edit is frontend.
  $this
    ->assertSession()
    ->responseNotContains('core/themes/seven/css/base/elements.css');

  // Assert presence of translation page itself (vs. DisabledBundle below).
  $this
    ->assertSession()
    ->statusCodeEquals(200);
}