5e2c15a82d099abd5a103df8401fcb514d8e90f8
[yaffs-website] / web / core / modules / system / src / Tests / Installer / InstallerLanguageDirectionTest.php
1 <?php
2
3 namespace Drupal\system\Tests\Installer;
4
5 use Drupal\simpletest\InstallerTestBase;
6
7 /**
8  * Verifies that the early installer uses the correct language direction.
9  *
10  * @group Installer
11  */
12 class InstallerLanguageDirectionTest extends InstallerTestBase {
13
14   /**
15    * Overrides the language code the installer should use.
16    *
17    * @var string
18    */
19   protected $langcode = 'ar';
20
21   /**
22    * {@inheritdoc}
23    */
24   protected function setUpLanguage() {
25     // Place a custom local translation in the translations directory.
26     mkdir(\Drupal::root() . '/' . $this->siteDirectory . '/files/translations', 0777, TRUE);
27     file_put_contents(\Drupal::root() . '/' . $this->siteDirectory . '/files/translations/drupal-8.0.0.ar.po', "msgid \"\"\nmsgstr \"\"\nmsgid \"Save and continue\"\nmsgstr \"Save and continue Arabic\"");
28
29     parent::setUpLanguage();
30     // After selecting a different language than English, all following screens
31     // should be translated already.
32     $elements = $this->xpath('//input[@type="submit"]/@value');
33     $this->assertEqual((string) current($elements), 'Save and continue Arabic');
34     $this->translations['Save and continue'] = 'Save and continue Arabic';
35
36     // Verify that language direction is right-to-left.
37     $direction = (string) current($this->xpath('/html/@dir'));
38     $this->assertEqual($direction, 'rtl');
39   }
40
41   /**
42    * Confirms that the installation succeeded.
43    */
44   public function testInstalled() {
45     $this->assertUrl('user/1');
46     $this->assertResponse(200);
47   }
48
49 }