function LocaleContentTest::testMachineNameLTR
Same name in other branches
- 9 core/modules/locale/tests/src/Functional/LocaleContentTest.php \Drupal\Tests\locale\Functional\LocaleContentTest::testMachineNameLTR()
- 8.9.x core/modules/locale/tests/src/Functional/LocaleContentTest.php \Drupal\Tests\locale\Functional\LocaleContentTest::testMachineNameLTR()
- 11.x core/modules/locale/tests/src/Functional/LocaleContentTest.php \Drupal\Tests\locale\Functional\LocaleContentTest::testMachineNameLTR()
Verifies that machine name fields are always LTR.
File
-
core/
modules/ locale/ tests/ src/ Functional/ LocaleContentTest.php, line 31
Class
- LocaleContentTest
- Tests multilingual support for content types and individual nodes.
Namespace
Drupal\Tests\locale\FunctionalCode
public function testMachineNameLTR() : void {
// User to add and remove language.
$admin_user = $this->drupalCreateUser([
'administer languages',
'administer content types',
'access administration pages',
'administer site configuration',
]);
// Log in as admin.
$this->drupalLogin($admin_user);
// Verify that the machine name field is LTR for a new content type.
$this->drupalGet('admin/structure/types/add');
$type = $this->assertSession()
->fieldExists('type');
$this->assertSame('ltr', $type->getAttribute('dir'));
// Install the Arabic language (which is RTL) and configure as the default.
$edit = [];
$edit['predefined_langcode'] = 'ar';
$this->drupalGet('admin/config/regional/language/add');
$this->submitForm($edit, 'Add language');
$edit = [
'site_default_language' => 'ar',
];
$this->drupalGet('admin/config/regional/language');
$this->submitForm($edit, 'Save configuration');
// Verify that the machine name field is still LTR for a new content type.
$this->drupalGet('admin/structure/types/add');
$type = $this->assertSession()
->fieldExists('type');
$this->assertSame('ltr', $type->getAttribute('dir'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.