You are here

protected function FieldCollectionEntityTranslationTestCase::createRevision in Field collection 7

Creates a new revision of the node and checks the result.

Parameters

mixed $node: The node to remove the translation from.

string $langcode: The language of the translation to remove.

string $source_langcode: The source language of the node.

Return value

mixed The new revision of the node.

1 call to FieldCollectionEntityTranslationTestCase::createRevision()
FieldCollectionEntityTranslationTestCase::testEntityTranslation in ./field_collection.test
Ensures the right behaviour in all Entity Translation use cases.

File

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

Class

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

Code

protected function createRevision($node, $langcode, $source_langcode) {
  $node_original_revision = $node->vid;

  // The original entries of the translated field.
  $original_fc_item_ids = $node->{$this->field_name}[$langcode];

  // Create the revision.
  $node->revision = TRUE;
  node_save($node);

  // The new entries of the translated field.
  $new_fc_item_ids = $node->{$this->field_name}[$langcode];

  // Check that the field collection items are the same and a new revision of
  // each one has been created.
  foreach ($original_fc_item_ids as $delta => $value) {
    $this
      ->assertEqual($value['value'], $new_fc_item_ids[$delta]['value'], t('We have the same field collection item'));
    $this
      ->assertNotEqual($value['revision_id'], $new_fc_item_ids[$delta]['revision_id'], t('We have a new revision of the field collection item'));
  }
  return $node;
}