function NodeTranslationUITest::testTranslationLinkTheme

Same name and namespace in other branches
  1. 8.9.x core/modules/node/tests/src/Functional/NodeTranslationUITest.php \Drupal\Tests\node\Functional\NodeTranslationUITest::testTranslationLinkTheme()
  2. 10 core/modules/node/tests/src/Functional/NodeTranslationUITest.php \Drupal\Tests\node\Functional\NodeTranslationUITest::testTranslationLinkTheme()
  3. 11.x 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 254

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 the default admin theme and use it for node editing.
    $this->container
        ->get('theme_installer')
        ->install([
        'claro',
    ]);
    $edit = [];
    $edit['admin_theme'] = 'claro';
    $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/claro/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/claro/css/base/elements.css');
    // Assert presence of translation page itself (vs. DisabledBundle below).
    $this->assertSession()
        ->statusCodeEquals(200);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.