InstallerTranslationTest.php 2.09 KB
Newer Older
1 2 3 4 5 6 7 8 9
<?php

/**
 * @file
 * Contains \Drupal\system\Tests\Installer\InstallerTranslationTest.
 */

namespace Drupal\system\Tests\Installer;

10
use Drupal\simpletest\InstallerTestBase;
11 12

/**
13 14 15 16
 * Selects German as the installation language and verifies the following page
 * is not in English.
 *
 * @group Installer
17
 */
18
class InstallerTranslationTest extends InstallerTestBase {
19

20
  /**
21
   * Overrides the language code in which to install Drupal.
22
   *
23
   * @var string
24
   */
25
  protected $langcode = 'de';
26

27 28 29 30
  /**
   * Overrides InstallerTest::setUpLanguage().
   */
  protected function setUpLanguage() {
31 32 33 34
    // Place a custom local translation in the translations directory.
    mkdir(DRUPAL_ROOT . '/' . $this->siteDirectory . '/files/translations', 0777, TRUE);
    file_put_contents(DRUPAL_ROOT . '/' . $this->siteDirectory . '/files/translations/drupal-8.0.0.de.po', "msgid \"\"\nmsgstr \"\"\nmsgid \"Save and continue\"\nmsgstr \"Save and continue German\"");

35 36 37 38
    parent::setUpLanguage();
    // After selecting a different language than English, all following screens
    // should be translated already.
    $elements = $this->xpath('//input[@type="submit"]/@value');
39 40
    $this->assertEqual((string) current($elements), 'Save and continue German');
    $this->translations['Save and continue'] = 'Save and continue German';
41 42 43 44

    // Check the language direction.
    $direction = (string) current($this->xpath('/html/@dir'));
    $this->assertEqual($direction, 'ltr');
45
  }
46

47 48 49 50 51 52
  /**
   * Verifies that installation succeeded.
   */
  public function testInstaller() {
    $this->assertUrl('user/1');
    $this->assertResponse(200);
53 54 55 56

    // Ensure that we can enable basic_auth on a non-english site.
    $this->drupalPostForm('admin/modules', array('modules[Web services][basic_auth][enable]' => TRUE), t('Save configuration'));
    $this->assertResponse(200);
57 58 59 60 61 62

    // Assert that the theme CSS was added to the page.
    $edit = array('preprocess_css' => FALSE);
    $this->drupalPostForm('admin/config/development/performance', $edit, t('Save configuration'));
    $this->drupalGet('<front>');
    $this->assertRaw('stark/css/layout.css');
63 64
  }

65
}