You are here

function TriggerContentTestCase::testActionContentMultiple in Drupal 7

Tests multiple node actions.

Verifies that node actions are fired for each node individually, if acting on multiple nodes.

File

modules/trigger/trigger.test, line 113
Tests for trigger.module.

Class

TriggerContentTestCase
Provides tests for node triggers.

Code

function testActionContentMultiple() {

  // Assign an action to the node save/update trigger.
  $test_user = $this
    ->drupalCreateUser(array(
    'administer actions',
    'administer nodes',
    'create page content',
    'access administration pages',
    'access content overview',
  ));
  $this
    ->drupalLogin($test_user);
  $nodes = array();
  for ($index = 0; $index < 3; $index++) {
    $nodes[] = $this
      ->drupalCreateNode(array(
      'type' => 'page',
    ));
  }
  $action_id = 'trigger_test_generic_any_action';
  $hash = drupal_hash_base64($action_id);
  $edit = array(
    'aid' => $hash,
  );
  $this
    ->drupalPost('admin/structure/trigger/node', $edit, t('Assign'), array(), array(), 'trigger-node-update-assign-form');
  $edit = array(
    'operation' => 'unpublish',
    'nodes[' . $nodes[0]->nid . ']' => TRUE,
    'nodes[' . $nodes[1]->nid . ']' => TRUE,
  );
  $this
    ->drupalPost('admin/content', $edit, t('Update'));
  $count = variable_get('trigger_test_generic_any_action', 0);
  $this
    ->assertTrue($count == 2, format_string('Action was triggered 2 times. Actual: %count', array(
    '%count' => $count,
  )));
}