TriggerContentTestCase::testActionContentMultiple

7 trigger.test TriggerContentTestCase::testActionContentMultiple()

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.

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);

  for ($index = 0; $index < 3; $index++) {
    $edit = array('title' => $this->randomName());
    $this->drupalPost('node/add/page', $edit, t('Save'));
  }

  $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[1]' => TRUE, 
    'nodes[2]' => TRUE,
  );
  $this->drupalPost('admin/content', $edit, t('Update'));
  $count = variable_get('trigger_test_generic_any_action', 0);
  $this->assertTrue($count == 2, t('Action was triggered 2 times. Actual: %count', array('%count' => $count)));
}
Login or register to post comments