function TriggerOtherTestCase::testActionsTaxonomy in Drupal 7
Tests triggering on taxonomy new term.
File
- modules/
trigger/ trigger.test, line 652 - Tests for trigger.module.
Class
- TriggerOtherTestCase
- Tests other triggers.
Code
function testActionsTaxonomy() {
// Assign an action to the taxonomy term save trigger.
$test_user = $this
->drupalCreateUser(array(
'administer actions',
));
$this
->drupalLogin($test_user);
$action_id = 'trigger_test_generic_action';
$hash = drupal_hash_base64($action_id);
$edit = array(
'aid' => $hash,
);
$this
->drupalPost('admin/structure/trigger/taxonomy', $edit, t('Assign'), array(), array(), 'trigger-taxonomy-term-insert-assign-form');
// Set action variable to FALSE.
variable_set($action_id, FALSE);
// Create a taxonomy vocabulary and add a term to it.
// Create a vocabulary.
$vocabulary = new stdClass();
$vocabulary->name = $this
->randomName();
$vocabulary->description = $this
->randomName();
$vocabulary->machine_name = drupal_strtolower($this
->randomName());
$vocabulary->help = '';
$vocabulary->nodes = array(
'article' => 'article',
);
$vocabulary->weight = mt_rand(0, 10);
taxonomy_vocabulary_save($vocabulary);
$term = new stdClass();
$term->name = $this
->randomName();
$term->vid = $vocabulary->vid;
taxonomy_term_save($term);
// Verify that the action variable has been set.
$this
->assertTrue(variable_get($action_id, FALSE), 'Check that creating a taxonomy term triggered the action.');
}