You are here

function TMGMTEntitySourceTestCase::checkUntranslatedData in Translation Management Tool 7

Checks the fields that should not be translated.

Parameters

$tentity: The translated entity object.

$fields: An array with the field names to check.

$translation: An array with the translated data.

$langcode: The code of the target language.

2 calls to TMGMTEntitySourceTestCase::checkUntranslatedData()
TMGMTEntitySourceTestCase::testEntitySourceNode in sources/entity/tmgmt_entity.source.test
Tests nodes field translation.
TMGMTEntitySourceTestCase::testEntitySourceTerm in sources/entity/tmgmt_entity.source.test
Tests taxonomy terms field translation.

File

sources/entity/tmgmt_entity.source.test, line 198

Class

TMGMTEntitySourceTestCase
Basic Entity Source tests.

Code

function checkUntranslatedData($tentity, $fields, $data, $langcode) {
  foreach ($fields as $field_name) {
    $field_info = field_info_field($field_name);
    if (!$field_info['translatable']) {

      // Avoid some PHP warnings.
      if (isset($data[$field_name])) {
        $this
          ->assertNull($data[$field_name]['#translation']['#text'], 'The not translatable field was not translated.');
      }
      if (isset($tentity->{$field_name}[$langcode])) {
        $this
          ->assertNull($tentity->{$field_name}[$langcode], 'The entity has translated data in a field that is translatable.');
      }
    }
  }
}