function LocaleContentTest::testMachineNameLTR

Verifies that machine name fields are always LTR.

File

drupal/core/modules/locale/lib/Drupal/locale/Tests/LocaleContentTest.php, line 35
Definition of Drupal\locale\Tests\LocaleContentTest.

Class

LocaleContentTest
Functional tests for multilingual support on nodes.

Namespace

Drupal\locale\Tests

Code

function testMachineNameLTR() {

  // User to add and remove language.
  $admin_user = $this
    ->drupalCreateUser(array(
    '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 = array();
  $edit['predefined_langcode'] = 'ar';
  $this
    ->drupalPost('admin/config/regional/language/add', $edit, t('Add language'));
  drupal_static_reset('language_list');
  $edit = array(
    'site_default_language' => 'ar',
  );
  $this
    ->drupalpost('admin/config/regional/settings', $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.');
}