You are here

private function RelationMigrateTestCase::createNodes in Relation 7

1 call to RelationMigrateTestCase::createNodes()
RelationMigrateTestCase::setUp in relation_migrate/tests/relation.migrate.test
Sets up a Drupal site for running functional and integration tests.

File

relation_migrate/tests/relation.migrate.test, line 48
Test case that tests relation_migrate.module.

Class

RelationMigrateTestCase
Functional tests of Relation's integration with Migrate.

Code

private function createNodes() {
  $this->node1 = $this
    ->drupalCreateNode(array(
    'type' => 'article',
  ));
  $this->node2 = $this
    ->drupalCreateNode(array(
    'type' => 'article',
  ));
  $this->node3 = $this
    ->drupalCreateNode(array(
    'type' => 'article',
  ));
  $this->node4 = $this
    ->drupalCreateNode(array(
    'type' => 'article',
  ));
  $this->node5 = $this
    ->drupalCreateNode(array(
    'type' => 'article',
  ));
  $this->tag = (object) array(
    'name' => $this
      ->randomName(8),
    'vid' => 1,
  );
  taxonomy_term_save($this->tag);

  // Node reference.
  $this->node1->field_node[LANGUAGE_NONE][0]['nid'] = $this->node2->nid;
  $this->node2->field_node[LANGUAGE_NONE][0]['nid'] = $this->node3->nid;
  $this->node3->field_node[LANGUAGE_NONE][0]['nid'] = $this->node4->nid;
  $this->node4->field_node[LANGUAGE_NONE][0]['nid'] = $this->node5->nid;
  $this->node5->field_node[LANGUAGE_NONE][0]['nid'] = $this->node1->nid;

  //User reference
  $this->node1->field_user[LANGUAGE_NONE][0]['uid'] = $this->user1->uid;
  $this->node2->field_user[LANGUAGE_NONE][0]['uid'] = $this->user1->uid;
  $this->node3->field_user[LANGUAGE_NONE][0]['uid'] = $this->user1->uid;
  $this->node4->field_user[LANGUAGE_NONE][0]['uid'] = $this->user1->uid;
  $this->node5->field_user[LANGUAGE_NONE][0]['uid'] = $this->user1->uid;

  // Entity reference
  $this->node1->field_entity[LANGUAGE_NONE][0]['target_id'] = $this->node5->nid;
  $this->node2->field_entity[LANGUAGE_NONE][0]['target_id'] = $this->node4->nid;
  $this->node3->field_entity[LANGUAGE_NONE][0]['target_id'] = $this->node3->nid;
  $this->node4->field_entity[LANGUAGE_NONE][0]['target_id'] = $this->node2->nid;
  $this->node5->field_entity[LANGUAGE_NONE][0]['target_id'] = $this->node1->nid;

  // Term reference
  $this->node1->field_tags[LANGUAGE_NONE][0]['tid'] = $this->tag->tid;
  $this->node2->field_tags[LANGUAGE_NONE][0]['tid'] = $this->tag->tid;
  $this->node3->field_tags[LANGUAGE_NONE][0]['tid'] = $this->tag->tid;
  $this->node4->field_tags[LANGUAGE_NONE][0]['tid'] = $this->tag->tid;
  $this->node5->field_tags[LANGUAGE_NONE][0]['tid'] = $this->tag->tid;

  // Save nodes again
  node_save($this->node1);
  node_save($this->node2);
  node_save($this->node3);
  node_save($this->node4);
  node_save($this->node5);
}