function NodeRevisionsTestCase::setUp

Overrides DrupalWebTestCase::setUp

File

modules/node/node.test, line 179

Class

NodeRevisionsTestCase
Tests the node revision functionality.

Code

function setUp() {
    parent::setUp();
    // Create and login user.
    $web_user = $this->drupalCreateUser(array(
        'view revisions',
        'revert revisions',
        'edit any page content',
        'delete revisions',
        'delete any page content',
    ));
    $this->drupalLogin($web_user);
    // Create initial node.
    $node = $this->drupalCreateNode();
    $settings = get_object_vars($node);
    $settings['revision'] = 1;
    $nodes = array();
    $logs = array();
    // Get original node.
    $nodes[] = $node;
    // Create three revisions.
    $revision_count = 3;
    for ($i = 0; $i < $revision_count; $i++) {
        $logs[] = $settings['log'] = $this->randomName(32);
        // Create revision with random title and body and update variables.
        $this->drupalCreateNode($settings);
        $node = node_load($node->nid);
        // Make sure we get revision information.
        $settings = get_object_vars($node);
        $nodes[] = $node;
    }
    $this->nodes = $nodes;
    $this->logs = $logs;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.