InstallerNonEnglishProfileWithoutLocaleModuleTest.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. namespace Drupal\FunctionalTests\Installer;
  3. use Drupal\Core\Serialization\Yaml;
  4. /**
  5. * Tests installing a profile with non-English language and no locale module.
  6. *
  7. * @group Installer
  8. */
  9. class InstallerNonEnglishProfileWithoutLocaleModuleTest extends InstallerTestBase {
  10. /**
  11. * {@inheritdoc}
  12. */
  13. protected $defaultTheme = 'stark';
  14. /**
  15. * The testing profile name.
  16. *
  17. * @var string
  18. */
  19. const PROFILE = 'testing_with_language_without_locale';
  20. /**
  21. * {@inheritdoc}
  22. */
  23. protected $profile = self::PROFILE;
  24. /**
  25. * {@inheritdoc}
  26. */
  27. protected function prepareEnvironment() {
  28. parent::prepareEnvironment();
  29. // Create a self::PROFILE testing profile that depends on the 'language'
  30. // module but not on 'locale' module. We set core_version_requirement to '*'
  31. // for the test so that it does not need to be updated between major
  32. // versions.
  33. $profile_info = [
  34. 'type' => 'profile',
  35. 'core_version_requirement' => '*',
  36. 'name' => 'Test with language but without locale',
  37. 'install' => ['language'],
  38. ];
  39. // File API functions are not available yet.
  40. $profile_dir = "{$this->root}/{$this->siteDirectory}/profiles/" . self::PROFILE;
  41. $profile_config_dir = "$profile_dir/config/install";
  42. mkdir($profile_config_dir, 0777, TRUE);
  43. $profile_info_file = $profile_dir . '/' . static::PROFILE . '.info.yml';
  44. file_put_contents($profile_info_file, Yaml::encode($profile_info));
  45. // Copy a non-English language config YAML to be installed with the profile.
  46. copy($this->root . '/core/profiles/testing_multilingual/config/install/language.entity.de.yml', $profile_config_dir . '/language.entity.de.yml');
  47. }
  48. /**
  49. * Tests installing a profile with non-English language and no locale module.
  50. */
  51. public function testNonEnglishProfileWithoutLocaleModule() {
  52. $this->assertSession()->statusCodeEquals(200);
  53. $this->assertUrl('user/1');
  54. // Confirm that we are logged-in after installation.
  55. $this->assertText($this->rootUser->getAccountName());
  56. // Verify that the confirmation message appears.
  57. require_once $this->root . '/core/includes/install.inc';
  58. $this->assertRaw(t('Congratulations, you installed @drupal!', [
  59. '@drupal' => drupal_install_profile_distribution_name(),
  60. ]));
  61. $this->assertFalse(\Drupal::service('module_handler')->moduleExists('locale'), 'The Locale module is not installed.');
  62. $this->assertTrue(\Drupal::service('module_handler')->moduleExists('language'), 'The Language module is installed.');
  63. $this->assertTrue(\Drupal::languageManager()->isMultilingual(), 'The language manager is multi-lingual.');
  64. }
  65. }