You are here

protected function RestfulForbiddenItemsTestCase::createEntityWithReferences in RESTful 7.2

Adds some content to be retrieved.

Parameters

int $uid: The owner ID.

Return value

int[] The entity IDs.

1 call to RestfulForbiddenItemsTestCase::createEntityWithReferences()
RestfulForbiddenItemsTestCase::testAccessDenied in tests/RestfulForbiddenItemsTestCase.test
Tests access denied in lists and single elements.

File

tests/RestfulForbiddenItemsTestCase.test, line 130
Contains \RestfulForbiddenItemsTestCase.

Class

RestfulForbiddenItemsTestCase
Class RestfulForbiddenItemsTestCase.

Code

protected function createEntityWithReferences($uid) {
  $node1 = (object) array(
    'title' => t('Node 1'),
    'type' => 'article',
    'uid' => $uid,
  );
  node_object_prepare($node1);
  node_save($node1);
  $node2 = (object) array(
    'title' => t('Node 2'),
    'type' => 'article',
    'uid' => $uid,
  );
  node_object_prepare($node2);
  node_save($node2);
  $node3 = (object) array(
    'title' => t('Node 3'),
    'type' => 'article',
    'uid' => $uid,
  );
  node_object_prepare($node3);
  node_save($node3);

  // Set some references to node1.
  $wrapper = entity_metadata_wrapper('node', $node1);
  $wrapper->entity_reference_single
    ->set($node3);
  $wrapper->entity_reference_multiple[] = $node2;
  $wrapper->entity_reference_multiple[] = $node3;
  $wrapper
    ->save();
  return array(
    $node1->nid,
    $node2->nid,
    $node3->nid,
  );
}