protected function LanguageCategoriesTest::setUp in Layout Builder Restrictions 8.2
Overrides LayoutBuilderRestrictionsTestBase::setUp
File
- tests/
src/ FunctionalJavascript/ LanguageCategoriesTest.php, line 30
Class
- LanguageCategoriesTest
- Demonstrate that blocks can be individually restricted.
Namespace
Drupal\Tests\layout_builder_restrictions\FunctionalJavascriptCode
protected function setUp() : void {
parent::setUp();
$this
->drupalLogin($this
->drupalCreateUser([
'administer languages',
'access administration pages',
'administer blocks',
'administer node display',
'administer node fields',
'configure any layout',
'create and edit custom blocks',
]));
// Install Norwegian language.
$edit = [];
$edit['predefined_langcode'] = 'nb';
$this
->drupalGet('admin/config/regional/language/add');
$this
->submitForm($edit, t('Add language'));
$edit = [
'site_default_language' => 'nb',
];
$this
->drupalGet('admin/config/regional/language');
$this
->submitForm($edit, t('Save configuration'));
// Enable URL language detection and selection.
$edit = [
'language_interface[enabled][language-url]' => 1,
];
$this
->drupalGet('admin/config/regional/language/detection');
$this
->submitForm($edit, t('Save settings'));
// Make sure the Norwegian language is prefix free.
$edit = [
'prefix[en]' => 'en',
'prefix[nb]' => '',
];
$this
->drupalGet('admin/config/regional/language/detection/url');
$this
->submitForm($edit, t('Save configuration'));
// Make sure one of the strings we know will be translated.
$locale_storage = $this->container
->get('locale.storage');
$string = NULL;
$strings = $locale_storage
->getStrings([
'source' => '@entity fields',
]);
if (!empty($strings)) {
$string = reset($strings);
}
else {
$string = $locale_storage
->createString([
'source' => '@entity fields',
])
->save();
}
$locale_storage
->createTranslation([
'lid' => $string
->getId(),
'language' => 'nb',
'translation' => '@entity felter',
])
->save();
// Add translation for 'Help'.
$strings = $locale_storage
->getStrings([
'source' => 'Help',
]);
if (!empty($strings)) {
$string = reset($strings);
}
else {
$string = $locale_storage
->createString([
'source' => 'Help',
])
->save();
}
$locale_storage
->createTranslation([
'lid' => $string
->getId(),
'language' => 'nb',
'translation' => 'Hjelp',
])
->save();
}