You are here

class ConfigTranslationUiThemeTest in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/config_translation/tests/src/Functional/ConfigTranslationUiThemeTest.php \Drupal\Tests\config_translation\Functional\ConfigTranslationUiThemeTest
  2. 9 core/modules/config_translation/tests/src/Functional/ConfigTranslationUiThemeTest.php \Drupal\Tests\config_translation\Functional\ConfigTranslationUiThemeTest

Verifies theme configuration translation settings.

@group config_translation

Hierarchy

Expanded class hierarchy of ConfigTranslationUiThemeTest

File

core/modules/config_translation/tests/src/Functional/ConfigTranslationUiThemeTest.php, line 13

Namespace

Drupal\Tests\config_translation\Functional
View source
class ConfigTranslationUiThemeTest extends BrowserTestBase {

  /**
   * Modules to enable.
   *
   * @var array
   */
  protected static $modules = [
    'config_translation',
    'config_translation_test',
  ];

  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'stark';

  /**
   * Languages to enable.
   *
   * @var array
   */
  protected $langcodes = [
    'fr',
    'ta',
  ];

  /**
   * Administrator user for tests.
   *
   * @var \Drupal\user\UserInterface
   */
  protected $adminUser;
  protected function setUp() : void {
    parent::setUp();
    $admin_permissions = [
      'administer themes',
      'administer languages',
      'administer site configuration',
      'translate configuration',
    ];

    // Create and log in user.
    $this->adminUser = $this
      ->drupalCreateUser($admin_permissions);

    // Add languages.
    foreach ($this->langcodes as $langcode) {
      ConfigurableLanguage::createFromLangcode($langcode)
        ->save();
    }
  }

  /**
   * Tests that theme provided *.config_translation.yml files are found.
   */
  public function testThemeDiscovery() {

    // Install the test theme and rebuild routes.
    $theme = 'config_translation_test_theme';
    $this
      ->drupalLogin($this->adminUser);
    $this
      ->drupalGet('admin/appearance');
    $element = $this
      ->assertSession()
      ->elementExists('xpath', "//a[normalize-space()='Install and set as default' and contains(@href, '{$theme}')]");
    $this
      ->drupalGet($GLOBALS['base_root'] . $element
      ->getAttribute('href'), [
      'external' => TRUE,
    ]);
    $translation_base_url = 'admin/config/development/performance/translate';
    $this
      ->drupalGet($translation_base_url);
    $this
      ->assertSession()
      ->statusCodeEquals(200);
    $this
      ->assertSession()
      ->linkByHrefExists("{$translation_base_url}/fr/add");
  }

}

Members