protected function LanguageSwitcherExtendedTest::setUp in Language Switcher Extended 8
Overrides BrowserTestBase::setUp
File
- tests/
src/ Functional/ LanguageSwitcherExtendedTest.php, line 44
Class
- LanguageSwitcherExtendedTest
- Functional tests for the language_switcher_extended feature.
Namespace
Drupal\Tests\language_switcher_extended\FunctionalCode
protected function setUp() {
parent::setUp();
// Login as root user.
$this
->drupalLogin($this->rootUser);
// Add another language.
$edit = [
'predefined_langcode' => 'de',
];
$this
->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
// Enable URL language detection and selection.
$edit = [
'language_interface[enabled][language-url]' => '1',
];
$this
->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
// Enable the language switching block.
$block = $this
->drupalPlaceBlock('language_block:' . LanguageInterface::TYPE_INTERFACE, [
'id' => 'test_language_block',
]);
// Create node type, which has english language as default.
$this
->createContentType([
'name' => 'Article',
'type' => 'article',
]);
// Enable content translation.
$this
->drupalGet('admin/config/regional/content-language');
$edit = [
'entity_types[node]' => TRUE,
'settings[node][article][translatable]' => TRUE,
];
$this
->drupalPostForm(NULL, $edit, t('Save configuration'));
// Create a node without a translation.
$this->node = $this
->createNode([
'type' => 'article',
'title' => 'Test article (en)',
'langcode' => 'en',
]);
$this->node
->save();
}