protected function PathLanguageTest::setUp in Drupal 9
Same name and namespace in other branches
- 8 core/modules/path/tests/src/Functional/PathLanguageTest.php \Drupal\Tests\path\Functional\PathLanguageTest::setUp()
Overrides PathTestBase::setUp
File
- core/
modules/ path/ tests/ src/ Functional/ PathLanguageTest.php, line 36
Class
- PathLanguageTest
- Confirm that paths work with translated nodes.
Namespace
Drupal\Tests\path\FunctionalCode
protected function setUp() : void {
parent::setUp();
$permissions = [
'access administration pages',
'administer content translation',
'administer content types',
'administer languages',
'administer url aliases',
'create content translations',
'create page content',
'create url aliases',
'edit any page content',
'translate any entity',
];
// Create and log in user.
$this->webUser = $this
->drupalCreateUser($permissions);
$this
->drupalLogin($this->webUser);
// Enable French language.
$edit = [];
$edit['predefined_langcode'] = 'fr';
$this
->drupalGet('admin/config/regional/language/add');
$this
->submitForm($edit, 'Add language');
// Enable URL language detection and selection.
$edit = [
'language_interface[enabled][language-url]' => 1,
];
$this
->drupalGet('admin/config/regional/language/detection');
$this
->submitForm($edit, 'Save settings');
// Enable translation for page node.
$edit = [
'entity_types[node]' => 1,
'settings[node][page][translatable]' => 1,
'settings[node][page][fields][path]' => 1,
'settings[node][page][fields][body]' => 1,
'settings[node][page][settings][language][language_alterable]' => 1,
];
$this
->drupalGet('admin/config/regional/content-language');
$this
->submitForm($edit, 'Save configuration');
$definitions = \Drupal::service('entity_field.manager')
->getFieldDefinitions('node', 'page');
$this
->assertTrue($definitions['path']
->isTranslatable(), 'Node path is translatable.');
$this
->assertTrue($definitions['body']
->isTranslatable(), 'Node body is translatable.');
}