You are here

function TextTranslationTestCase::testTextField in Drupal 7

Test that a plaintext textfield widget is correctly populated.

File

modules/field/modules/text/text.test, line 446
Tests for text.module.

Class

TextTranslationTestCase

Code

function testTextField() {

  // Disable text processing for body.
  $edit = array(
    'instance[settings][text_processing]' => 0,
  );
  $this
    ->drupalPost('admin/structure/types/manage/article/fields/body', $edit, t('Save settings'));

  // Login as translator.
  $this
    ->drupalLogin($this->translator);

  // Create content.
  $langcode = LANGUAGE_NONE;
  $body = $this
    ->randomName();
  $edit = array(
    "title" => $this
      ->randomName(),
    "language" => 'en',
    "body[{$langcode}][0][value]" => $body,
  );

  // Translate the article in french.
  $this
    ->drupalPost('node/add/article', $edit, t('Save'));
  $node = $this
    ->drupalGetNodeByTitle($edit['title']);
  $this
    ->drupalGet("node/{$node->nid}/translate");
  $this
    ->clickLink(t('add translation'));
  $this
    ->assertFieldByXPath("//textarea[@name='body[{$langcode}][0][value]']", $body, 'The textfield widget is populated.');
}