public function LocaleContentTest::testMachineNameLTR in Drupal 8
Same name and namespace in other branches
- 9 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');
$this
->assertFieldByXpath('//input[@name="type" and @dir="ltr"]', NULL, 'The machine name field is LTR when no additional language is configured.');
// Install the Arabic language (which is RTL) and configure as the default.
$edit = [];
$edit['predefined_langcode'] = 'ar';
$this
->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
$edit = [
'site_default_language' => 'ar',
];
$this
->drupalPostForm('admin/config/regional/language', $edit, t('Save configuration'));
// Verify that the machine name field is still LTR for a new content type.
$this
->drupalGet('admin/structure/types/add');
$this
->assertFieldByXpath('//input[@name="type" and @dir="ltr"]', NULL, 'The machine name field is LTR when the default language is RTL.');
}