You are here

function Drafty1992010Test::testFieldTranslation in Drafty 7

Test if field based translation works.

Enable field based translation for basic pages. Add a field with a cardinality higher than 1, to test if field_default_extract_form_values() is invoked. Create a basic page and translate it.

File

modules/drafty_1992010/Drafty1992010Test.test, line 76

Class

Drafty1992010Test
Test draft revisions with entity translation.

Code

function testFieldTranslation() {

  // Create Basic page in English.
  $node_title = $this
    ->randomName();
  $node_body = $this
    ->randomName();
  $node = $this
    ->createPage($node_title, $node_body, 'en');
  $original_version = node_load($node->nid, NULL, TRUE);

  // Submit translation in Spanish.
  $node_translation_title = $this
    ->randomName();
  $node_translation_body = $this
    ->randomName();
  $node_translation = $this
    ->createTranslation($node, $node_translation_title, $node_translation_body, 'es');
  $published_version = node_load($node->nid, NULL, TRUE);

  // At this point there should be three versions of the node:
  //  - the original version with no translation.
  //  - an unpublished version with a translation.
  //  - the published version with no translation, identical to the original.
  $this
    ->assertTrue(!isset($original_version->body['es']), 'No Spanish translation on the original version');

  // This assertion is the reverse of the correct behaviour, so it will fail
  // if http://drupal.org/node/1992010 is fixed. When that happens this entire
  // module can be uninstalled and removed.
  $this
    ->assertFalse(!isset($published_version->body['es']), 'Spanish translation on the published version so http://drupal.org/node/1992010 not fixed yet');
}