t('Actions content'), 'desc' => t('Perform various tests with content actions.') , 'group' => 'Actions'); } /** * Setup function */ function setup() { global $user; } /** * Various tests, all in one function to assure they happen in the right order. */ function testActionsContent() { $this->setup(); // Test 1: Assign an action to a trigger, then pull the trigger, and make sure the actions fire. (Wow, those metaphors work out nicely). $test_user = $this->drupalCreateUserRolePerm(array('administer actions', 'create page content')); $this->drupalLoginUser($test_user); // Set action id to "publish post". $edit = array('aid' => 'c6d3850086dc3c1bca4bf0625ce78c56'); $this->drupalPostRequest('admin/build/trigger/node', $edit, 'Assign'); // Create an unpublished node. $node->body = $this->randomName(32 + $i); $node->title = $this->randomName(8 + $i); $node->teaser = $node->body; $node->comment = '2'; $node->created = time(); $node->date = format_date($node->created, 'custom', 'Y-m-d H:i:s O'); $node->format = '1'; $node->moderate = 0; $node->name = $test_user->name; $node->uid = $test_user->uid; $node->promote = 0; $node->revision = 0; $node->status = '0'; $node->sticky = 0; $node->type = 'page'; $node->revisions = NULL; $node->changed = $node->created; $node->taxonomy = NULL; node_save($node); // Node should be published automatically. $loaded_node = node_load($node->nid); $this->assertTrue($node->status == '1', t('Check to make sure the node is automatically published')); // Leave action assigned for next test // Test 2: There should be an error when the action is assigned to the trigger twice. $edit = array('aid' => 'c6d3850086dc3c1bca4bf0625ce78c56'); $this->drupalPostRequest('admin/build/trigger/node', $edit, 'Assign'); $this->assertWantedRaw(t('The action you choose is already assigned to that trigger.'), t('Check to make sure an error occurs when assigning an action to a trigger twice.')); // Test 3: The action should be able to be unassigned from a trigger. // This effectively cleans up as well. $this->drupalPostRequest('admin/build/trigger/unassign/nodeapi/presave/c6d3850086dc3c1bca4bf0625ce78c56', array(), 'Unassign'); $this->assertWantedRaw(t('Action %action has been unassigned.', array('%action' => 'Publish post')), t('Check to make sure action can be unassigned from trigger.')); } } ?>