InstallerLanguageDirectionTest.php 1.5 KB

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