You are here

protected function ServicesEntityNodeResourceTest::createNodeRevisions in Services Entity API 7.2

Create several revisions of a node.

Parameters

int $number: The number of revisions to create.

Return value

An array containing the original node and revisions.

1 call to ServicesEntityNodeResourceTest::createNodeRevisions()
ServicesEntityNodeResourceTest::testCRUD in tests/services_entity.test
Tests basic CRUD and index actions of a node via the entity_node service.

File

tests/services_entity.test, line 948
Services Entity Tests

Class

ServicesEntityNodeResourceTest
Tests entity_node services for both the generic and clean controller.

Code

protected function createNodeRevisions($number = 3) {
  $nodes = array();
  for ($i = 0; $i < $number; $i++) {
    if (empty($nodes)) {
      $nodes[] = $this
        ->drupalCreateNode(array(
        'title' => $this
          ->randomName(),
      ));
    }
    else {
      $node = end($nodes);
      $new_node = (object) array(
        'nid' => $node->nid,
        'vid' => $node->vid,
        'uid' => $node->uid,
        'type' => $node->type,
        'title' => $this
          ->randomName(),
        'revision' => 1,
      );
      node_save($new_node);
      $nodes[] = $new_node;
    }
  }
  return $nodes;
}