You are here

vud_node.test in Vote Up/Down 6.2

Same filename and directory in other branches
  1. 6.3 vud_node/vud_node.test
  2. 7 vud_node/vud_node.test

Test file for Vote Up/Down Node.

File

vud_node/vud_node.test
View source
<?php

/**
 * @file
 * Test file for Vote Up/Down Node.
 */
class VudNodeWebTestCase extends DrupalWebTestCase {

  /**
   * Implementation of getInfo().
   */
  public static function getInfo() {
    return array(
      'name' => t('Vote Up/Down Node'),
      'description' => t('Functional tests for Vote Up/Down Node'),
      'group' => t('Vote Up/down'),
    );
  }

  /**
   * Implementation of setUp().
   */
  function setUp() {
    parent::setUp('votingapi', 'ctools', 'vud', 'vud_node');

    // Create a vud admin user
    $this->admin_user = $this
      ->drupalCreateUser(array(
      // vud
      'access vote up/down statistics',
      'administer vote up/down',
      'reset vote up/down votes',
      'use vote up/down',
      // vud_node
      'administer vote up/down on nodes',
      'see vote up/down node stats',
      'use vote up/down on nodes',
      'view vote up/down count on nodes',
    ));

    // Create a vud simple user
    $this->simple_user = $this
      ->drupalCreateUser(array(
      // vud
      'access vote up/down statistics',
      'use vote up/down',
      'reset vote up/down votes',
      // vud_node
      'see vote up/down node stats',
      'use vote up/down on nodes',
      'view vote up/down count on nodes',
    ));

    //TODO more users with less privileges

    // Create a vud restricted user (can not interact with vud)
    $this->restricted_user = $this
      ->drupalCreateUser();
  }

  /**
   * Enable Vote Up/Down for Story node types with updown widget.
   */
  function enableMinimalVoting() {
    $this
      ->drupalLogin($this->admin_user);
    $edit = array(
      'vud_node_types[story]' => TRUE,
      'vud_node_widget' => 'updown',
    );
    $this
      ->drupalPost('admin/settings/voteupdown/node', $edit, t('Save configuration'));
    $this
      ->assertText(t('The configuration options have been saved.'));
  }

  /**
   * Test visibility of the widget.
   */
  function testViewWidget() {
    $this
      ->enableMinimalVoting();
    $this
      ->drupalLogin($this->admin_user);
    $node = $this
      ->drupalCreateNode(array(
      'type' => 'story',
    ));
    $this
      ->drupalLogin($this->simple_user);
    $this
      ->drupalGet("node/{$node->nid}");
    $this
      ->assertRaw('<span class="updown-current-score">0</span>', t('Visible widget for user with permissions.'));
    $this
      ->drupalLogin($this->restricted_user);
    $this
      ->drupalGet("node/{$node->nid}");
    $this
      ->assertNoRaw('<span class="updown-current-score">0</span>', t('Hidden widget for user without permissions'));
  }

  /**
   * Test voting details tab.
   */
  function testVotingDetails() {
    $this
      ->enableMinimalVoting();
    $this
      ->drupalLogin($this->admin_user);
    $node = $this
      ->drupalCreateNode(array(
      'type' => 'story',
    ));
    $this
      ->drupalLogin($this->simple_user);
    $this
      ->drupalGet("node/{$node->nid}");
    $this
      ->clickLink(t('Voting details'));
    $this
      ->assertNoRaw('<td>', t('No voting details records found on the node.'));
  }

}

Classes

Namesort descending Description
VudNodeWebTestCase @file Test file for Vote Up/Down Node.