You are here

function NodeRevisionsTest::prepareRevisions in SimpleTest 6

Setup function used by tests. Creates a node with three revisions.

If $log is TRUE, then a log message will be recorded.

4 calls to NodeRevisionsTest::prepareRevisions()
NodeRevisionsTest::testLogMessage in tests/node_revisions.test
Simpletest test. Tests to make sure the correct log message appears on "revisions overview" page.
NodeRevisionsTest::testNodeRevisions in tests/node_revisions.test
Simpletest test. Tests to make sure the correct revision text appears on "view revisions" page.
NodeRevisionsTest::testRevisionDelete in tests/node_revisions.test
Simpletest test. Tests to make sure the revision deletes properly.
NodeRevisionsTest::testRevisionRevert in tests/node_revisions.test
Simpletest test. Tests to make sure the that revisions revert properly.

File

tests/node_revisions.test, line 19

Class

NodeRevisionsTest

Code

function prepareRevisions($log = FALSE) {
  $returnarray = array();
  $numtimes = 3;

  // First, middle, last.
  for ($i = 0; $i < $numtimes; $i++) {
    $settings = array(
      'revision' => 1,
    );
    if ($log && $i == 1) {
      $logmessage = $this
        ->randomName(32);
      $settings['log'] = $logmessage;
      $returnarray['log'] = $logmessage;
    }
    if ($i != 0) {
      $settings['nid'] = $node->nid;
    }
    $node = $this
      ->drupalCreateNode($settings);
    if ($i == 1) {
      $returnarray['text'] = $node->body;
      $returnarray['vid'] = $node->vid;
    }

    // Avoid confusion on the revisions overview page which is sorted by r.timestamp.
    sleep(1);
  }
  $returnarray['node'] = $node;
  return $returnarray;
}