InstallerNonEnglishProfileWithoutLocaleModuleTest.php in Drupal 9
File
core/tests/Drupal/FunctionalTests/Installer/InstallerNonEnglishProfileWithoutLocaleModuleTest.php
View source
<?php
namespace Drupal\FunctionalTests\Installer;
use Drupal\Core\Serialization\Yaml;
class InstallerNonEnglishProfileWithoutLocaleModuleTest extends InstallerTestBase {
protected $defaultTheme = 'stark';
const PROFILE = 'testing_with_language_without_locale';
protected $profile = self::PROFILE;
protected function prepareEnvironment() {
parent::prepareEnvironment();
$profile_info = [
'type' => 'profile',
'core_version_requirement' => '*',
'name' => 'Test with language but without locale',
'install' => [
'language',
],
];
$profile_dir = "{$this->root}/{$this->siteDirectory}/profiles/" . self::PROFILE;
$profile_config_dir = "{$profile_dir}/config/install";
mkdir($profile_config_dir, 0777, TRUE);
$profile_info_file = $profile_dir . '/' . static::PROFILE . '.info.yml';
file_put_contents($profile_info_file, Yaml::encode($profile_info));
copy($this->root . '/core/profiles/testing_multilingual/config/install/language.entity.de.yml', $profile_config_dir . '/language.entity.de.yml');
}
public function testNonEnglishProfileWithoutLocaleModule() {
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->addressEquals('user/1');
$this
->assertSession()
->pageTextContains($this->rootUser
->getAccountName());
require_once $this->root . '/core/includes/install.inc';
$this
->assertSession()
->pageTextContains('Congratulations, you installed Drupal!');
$this
->assertFalse(\Drupal::service('module_handler')
->moduleExists('locale'), 'The Locale module is not installed.');
$this
->assertTrue(\Drupal::service('module_handler')
->moduleExists('language'), 'The Language module is installed.');
$this
->assertTrue(\Drupal::languageManager()
->isMultilingual(), 'The language manager is multi-lingual.');
}
}