ConfigTranslationUiThemeTest.php 1.86 KB
Newer Older
1 2 3 4
<?php

namespace Drupal\config_translation\Tests;

5
use Drupal\language\Entity\ConfigurableLanguage;
6 7 8
use Drupal\simpletest\WebTestBase;

/**
9 10 11
 * Verifies theme configuration translation settings.
 *
 * @group config_translation
12 13 14 15 16 17 18 19
 */
class ConfigTranslationUiThemeTest extends WebTestBase {

  /**
   * Modules to enable.
   *
   * @var array
   */
20
  public static $modules = ['config_translation', 'config_translation_test'];
21 22 23 24 25 26 27 28 29 30 31 32 33

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

  /**
   * Administrator user for tests.
   *
   * @var \Drupal\user\UserInterface
   */
34
  protected $adminUser;
35

36
  protected function setUp() {
37 38
    parent::setUp();

39
    $admin_permissions = [
40 41 42 43
      'administer themes',
      'administer languages',
      'administer site configuration',
      'translate configuration',
44
    ];
45
    // Create and log in user.
46
    $this->adminUser = $this->drupalCreateUser($admin_permissions);
47 48 49

    // Add languages.
    foreach ($this->langcodes as $langcode) {
50
      ConfigurableLanguage::createFromLangcode($langcode)->save();
51 52 53 54 55 56 57
    }
  }

  /**
   * Tests that theme provided *.config_translation.yml files are found.
   */
  public function testThemeDiscovery() {
58
    // Install the test theme and rebuild routes.
59 60
    $theme = 'config_translation_test_theme';

61
    $this->drupalLogin($this->adminUser);
62 63

    $this->drupalGet('admin/appearance');
64
    $elements = $this->xpath('//a[normalize-space()=:label and contains(@href, :theme)]', [
65
      ':label' => 'Install and set as default',
66
      ':theme' => $theme,
67 68
    ]);
    $this->drupalGet($GLOBALS['base_root'] . $elements[0]['href'], ['external' => TRUE]);
69 70 71 72 73 74 75 76

    $translation_base_url = 'admin/config/development/performance/translate';
    $this->drupalGet($translation_base_url);
    $this->assertResponse(200);
    $this->assertLinkByHref("$translation_base_url/fr/add");
  }

}