You are here

protected function FieldCollectionEntityTranslationTestCase::checkFieldCollectionContent in Field collection 7

Check the content of the field collection for a specified language.

Parameters

mixed $node: The node to check.

string $langcode: The language to check.

3 calls to FieldCollectionEntityTranslationTestCase::checkFieldCollectionContent()
FieldCollectionEntityTranslationTestCase::createTranslationForm in ./field_collection.test
Create a translation using the Entity Translation Form.
FieldCollectionEntityTranslationTestCase::removeTranslationForm in ./field_collection.test
Removes a translation using the entity translation form.
FieldCollectionEntityTranslationTestCase::testEntityTranslation in ./field_collection.test
Ensures the right behaviour in all Entity Translation use cases.

File

./field_collection.test, line 1126
Tests for field_collections.

Class

FieldCollectionEntityTranslationTestCase
Test using field collection with content that gets translated with Entity Translation.

Code

protected function checkFieldCollectionContent($node, $langcode) {
  switch ($langcode) {
    case 'en':
      $untrans_field = self::UNTRANS_FIELD_EN;
      $trans_field = self::TRANS_FIELD_EN;
      break;
    case 'de':
      $untrans_field = self::UNTRANS_FIELD_DE;
      $trans_field = self::TRANS_FIELD_DE;
      break;
  }

  // Get the field collection in the specified language.
  $fc_values = $node->{$this->field_name}[$langcode];
  foreach ($fc_values as $delta => $fc_value) {

    // Load the field collection item.
    $fc_item_array = entity_load('field_collection_item', array(
      $fc_value['value'],
    ));
    $fc_item = reset($fc_item_array);
    $fc_untrans_key = "{$this->field_name}[{$langcode}][{$delta}]{$this->field_untrans_base}";
    $fc_trans_key = "{$this->field_name}[{$langcode}][{$delta}]{$this->field_trans_base}";
    $this
      ->assertEqual($untrans_field . '_' . $delta, $fc_item->{$this->field_untrans_name}[LANGUAGE_NONE][0]['value']);
    $this
      ->assertEqual($trans_field . '_' . $delta, $fc_item->{$this->field_trans_name}[$langcode][0]['value']);
  }
}