Chris@0: drupalCreateUser(['administer actions']); Chris@0: $this->drupalLogin($user); Chris@0: Chris@0: // Make a POST request to admin/config/system/actions. Chris@0: $edit = []; Chris@14: $edit['action'] = 'node_assign_owner_action'; Chris@0: $this->drupalPostForm('admin/config/system/actions', $edit, t('Create')); Chris@0: $this->assertResponse(200); Chris@0: Chris@0: // Make a POST request to the individual action configuration page. Chris@0: $edit = []; Chris@0: $action_label = $this->randomMachineName(); Chris@0: $edit['label'] = $action_label; Chris@0: $edit['id'] = strtolower($action_label); Chris@0: $edit['owner_uid'] = $user->id(); Chris@14: $this->drupalPostForm('admin/config/system/actions/add/node_assign_owner_action', $edit, t('Save')); Chris@0: $this->assertResponse(200); Chris@0: Chris@14: $action_id = $edit['id']; Chris@14: Chris@0: // Make sure that the new action was saved properly. Chris@0: $this->assertText(t('The action has been successfully saved.'), 'The node_assign_owner_action action has been successfully saved.'); Chris@0: $this->assertText($action_label, 'The label of the node_assign_owner_action action appears on the actions administration page after saving.'); Chris@0: Chris@0: // Make another POST request to the action edit page. Chris@0: $this->clickLink(t('Configure')); Chris@0: $edit = []; Chris@0: $new_action_label = $this->randomMachineName(); Chris@0: $edit['label'] = $new_action_label; Chris@0: $edit['owner_uid'] = $user->id(); Chris@0: $this->drupalPostForm(NULL, $edit, t('Save')); Chris@0: $this->assertResponse(200); Chris@0: Chris@0: // Make sure that the action updated properly. Chris@0: $this->assertText(t('The action has been successfully saved.'), 'The node_assign_owner_action action has been successfully updated.'); Chris@0: $this->assertNoText($action_label, 'The old label for the node_assign_owner_action action does not appear on the actions administration page after updating.'); Chris@0: $this->assertText($new_action_label, 'The new label for the node_assign_owner_action action appears on the actions administration page after updating.'); Chris@0: Chris@0: // Make sure that deletions work properly. Chris@0: $this->drupalGet('admin/config/system/actions'); Chris@0: $this->clickLink(t('Delete')); Chris@0: $this->assertResponse(200); Chris@0: $edit = []; Chris@14: $this->drupalPostForm(NULL, $edit, t('Delete')); Chris@0: $this->assertResponse(200); Chris@0: Chris@0: // Make sure that the action was actually deleted. Chris@0: $this->assertRaw(t('The action %action has been deleted.', ['%action' => $new_action_label]), 'The delete confirmation message appears after deleting the node_assign_owner_action action.'); Chris@0: $this->drupalGet('admin/config/system/actions'); Chris@0: $this->assertResponse(200); Chris@0: $this->assertNoText($new_action_label, 'The label for the node_assign_owner_action action does not appear on the actions administration page after deleting.'); Chris@0: Chris@14: $action = Action::load($action_id); Chris@0: $this->assertFalse($action, 'The node_assign_owner_action action is not available after being deleted.'); Chris@0: } Chris@0: Chris@0: }