You are here

function TMGMTFieldCollectionSourceTestCase::createNode in Translation Management Tool 7

Creates a node of a given bundle.

It uses $this->field_names to populate content of attached fields.

Parameters

string $bundle: Node type name.

string $sourcelang: Source lang of the node to be created.

Return value

object Newly created node object.

Overrides TMGMTEntityTestCaseUtility::createNode

1 call to TMGMTFieldCollectionSourceTestCase::createNode()
TMGMTFieldCollectionSourceTestCase::testFieldCollectionSource in sources/field/tmgmt_field_collection.test
Tests nodes field translation.

File

sources/field/tmgmt_field_collection.test, line 77

Class

TMGMTFieldCollectionSourceTestCase
Basic Field Collection Source tests.

Code

function createNode($bundle, $sourcelang = 'en') {
  $node = parent::createNode($bundle);
  $field_collection = entity_create('field_collection_item', array(
    'bundle' => $this->field_name,
    'field_name' => $this->field_name,
  ));
  $field_collection->field_text[LANGUAGE_NONE][0]['value'] = self::FIELD_COLLECTION_TEXT;
  $field_collection
    ->setHostEntity('node', $node, LANGUAGE_NONE, TRUE);
  entity_save('field_collection_item', $field_collection);
  node_save($node);
  return $node;
}