public function LocaleContentTest::testMachineNameLTR in Drupal 9
Same name and namespace in other branches
- 8 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 32
Class
- LocaleContentTest
- Tests you can enable multilingual support on content types and configure a language for a node.
Namespace
Drupal\Tests\locale\FunctionalCode
public function testMachineNameLTR() {
// 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'));
}